You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
3.5 KiB
1 lines
3.5 KiB
{"version":3,"names":["ParseErrorCode","SyntaxError","SourceTypeModuleError","exports","reflect","keys","last","length","get","reduce","object","key","set","value","item","i","instantiate","constructor","properties","descriptors","Object","map","filter","descriptor","enumerable","assign","split","instance","defineProperty","configurable"],"sources":["../../src/parse-error/credentials.ts"],"sourcesContent":["export const enum ParseErrorCode {\n SyntaxError = \"BABEL_PARSER_SYNTAX_ERROR\",\n SourceTypeModuleError = \"BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED\",\n}\n\nexport type SyntaxPlugin =\n | \"flow\"\n | \"typescript\"\n | \"jsx\"\n | \"pipelineOperator\"\n | \"placeholders\";\n\nexport type ToMessage<ErrorDetails> = (self: ErrorDetails) => string;\n\nexport type ParseErrorCredentials<ErrorDetails> = {\n code: ParseErrorCode;\n reasonCode: string;\n syntaxPlugin?: SyntaxPlugin;\n toMessage: ToMessage<ErrorDetails>;\n};\n\nconst reflect = (keys: string[], last = keys.length - 1) => ({\n get(this: unknown): unknown {\n return keys.reduce(\n (object, key) =>\n // @ts-expect-error key should index object\n object[key],\n this,\n );\n },\n set(this: unknown, value: unknown) {\n keys.reduce(\n // @ts-expect-error key should index item\n (item, key, i) => (i === last ? (item[key] = value) : item[key]),\n this,\n );\n },\n});\n\nconst instantiate = <T>(\n constructor: new () => T,\n properties: any,\n descriptors: any,\n) =>\n Object.keys(descriptors)\n .map(key => [key, descriptors[key]])\n .filter(([, descriptor]) => !!descriptor)\n .map(([key, descriptor]) => [\n key,\n typeof descriptor === \"function\"\n ? { value: descriptor, enumerable: false }\n : typeof descriptor.reflect === \"string\"\n ? { ...descriptor, ...reflect(descriptor.reflect.split(\".\")) }\n : descriptor,\n ])\n .reduce(\n (instance, [key, descriptor]) =>\n Object.defineProperty(instance, key, {\n configurable: true,\n ...descriptor,\n }),\n Object.assign(new constructor(), properties),\n );\n\nexport { instantiate };\n"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