UNPKG

@naturalcycles/js-lib

Version:

Standard library for universal (browser + Node.js) javascript

19 lines (16 loc) 321 B
/** * Like Set, but serializes to JSON as an array. * * Fixes the "issue" of stock Set being json-serialized as `{}`. * * @experimental */ export class Set2<T = any> extends Set<T> { toArray(): T[] { return [...this] } toJSON(): T[] { return [...this] } // consider more helpful .toString() ? }