← All context files

lite/collection-helpers.md

lite – Collection Helpers (the Set / Map replacement)

@kyd/lite 6.11.0 (2026-08-20) adds unique, difference, intersection, groupBy and keyBy.

Use them instead of hand-rolling a dedupe loop when goldfish's asp-compat plugin rejects new Set() / new Map(). Neither can be polyfilled: a faithful Set needs the iterator protocol (Symbol.iterator), which JScript lacks.

import { unique, difference, intersection, groupBy, keyBy } from '@kyd/lite';

Semantics

Why not just seen[value] = true?

Plain-object lookups inherit from Object.prototype, so 'constructor', 'toString' and friends read back as already-seen:

const seen = {};
seen['toString']          // → function, truthy — never added it

lite's internal createLookup prefixes keys (@type:value) to dodge that plus __proto__. If you do roll your own, store true and test === true, since inherited members are never === true.

asp-compat blind spot — lite's own code is never checked

shouldSkipFile in asp-compat-plugin.js skips anything under /node_modules/, so lite's own source is never compat-checked in a consumer build. A JScript-incompatible built-in inside lite will sail through every downstream build and only fail in ASP at runtime.

Anything added to lite has to be hand-verified. To check it properly, run the plugin over lite's dist through babel with a spoofed non-node_modules filename.