/** * @since 1.0.0 */ import type * as AST from "../AST.js" /** @internal */ export const getKeysForIndexSignature = ( input: { readonly [x: PropertyKey]: unknown }, parameter: AST.Parameter ): ReadonlyArray | ReadonlyArray => { switch (parameter._tag) { case "StringKeyword": case "TemplateLiteral": return Object.keys(input) case "SymbolKeyword": return Object.getOwnPropertySymbols(input) case "Refinement": return getKeysForIndexSignature(input, parameter.from) } } /** @internal */ export const ownKeys = (o: object): Array => (Object.keys(o) as Array).concat(Object.getOwnPropertySymbols(o)) /** @internal */ export const memoizeThunk = (f: () => A): () => A => { let done = false let a: A return () => { if (done) { return a } a = f() done = true return a } }