Download packages/codemode/src/stdlib/collections.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/codemode/src/stdlib/collections.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/codemode/src/stdlib/collections.ts
-
curl -L -o collections.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/codemode/src/stdlib/collections.ts
1.27 kB
| export const arrayMethods = new Set([ | |
| "map", | |
| "filter", | |
| "find", | |
| "findIndex", | |
| "findLast", | |
| "findLastIndex", | |
| "some", | |
| "every", | |
| "includes", | |
| "join", | |
| "reduce", | |
| "reduceRight", | |
| "flatMap", | |
| "forEach", | |
| "sort", | |
| "toSorted", | |
| "slice", | |
| "concat", | |
| "indexOf", | |
| "lastIndexOf", | |
| "at", | |
| "flat", | |
| "reverse", | |
| "toReversed", | |
| "with", | |
| "push", | |
| "pop", | |
| "shift", | |
| "unshift", | |
| "splice", | |
| "fill", | |
| "copyWithin", | |
| "keys", | |
| "values", | |
| "entries", | |
| ]) | |
| export const mapMethods = new Set(["get", "set", "has", "delete", "clear", "forEach", "keys", "values", "entries"]) | |
| export const setMethods = new Set(["add", "has", "delete", "clear", "forEach", "keys", "values", "entries"]) | |
| export const spreadItems = (value: unknown): Array<unknown> | undefined => { | |
| if (Array.isArray(value)) return value | |
| if (typeof value === "string") return Array.from(value) | |
| if (value instanceof SandboxMap) return Array.from(value.map.entries(), ([key, item]) => [key, item]) | |
| if (value instanceof SandboxSet) return Array.from(value.set.values()) | |
| if (value instanceof SandboxURLSearchParams) return Array.from(value.params.entries(), ([key, item]) => [key, item]) | |
| return undefined | |
| } | |
| import { SandboxMap, SandboxSet, SandboxURLSearchParams } from "../values.js" | |