Installation
The package has no runtime dependencies and ships its own type definitions.
npm install @ylcnfrht/collectionspnpm add @ylcnfrht/collectionsyarn add @ylcnfrht/collectionsbun add @ylcnfrht/collectionsImporting
Section titled “Importing”The package ships ES module and CommonJS builds; the exports map picks the right one and its type definitions.
Everything is a named export of the package root. There are no deep imports.
import { ArrayList } from '@ylcnfrht/collections';
const names = new ArrayList<string>();names.add('Ada');console.log(names.toString()); // → [Ada]const { ArrayList } = require('@ylcnfrht/collections');Name clashes with built-ins
Section titled “Name clashes with built-ins”The package exports interfaces and factories named List, Set, Map and Iterator. Importing Set or Map
shadows the JS built-in in that module, and the library’s Set and Map are not constructible. Alias them on import,
or reach the built-ins through globalThis.
import { Map as CMap, HashMap } from '@ylcnfrht/collections';
const ours: CMap<string, number> = new HashMap<string, number>();const native = new globalThis.Map<string, number>();console.log(ours.size(), native.size); // → 0 0Browsers and bundlers
Section titled “Browsers and bundlers”- The library is plain ES2020 with no Node-specific APIs. It runs in modern browsers, Deno, Bun, workers and edge runtimes.
- Bundlers select the ESM build through the
exportsmap. The package is a single module, so unused classes are tree-shaken only as far as the bundler can prove them unused. Importing the package registers the stream engine with the collections, which is whylist.stream()works without importingStream. using s = list.stream()works only where the runtime definesSymbol.dispose.- A bundler or minifier may rename classes (
HashMap2). Printing and equality are unaffected; onlyconstructor.nameand class names quoted in some error messages change. Exceptionnames stay the same.
Supported runtimes
Section titled “Supported runtimes”| Runtime | Support |
|---|---|
| Node.js | 18 and newer |
| Browsers | Evergreen browsers (ES2020) |
| TypeScript | 5.x recommended |