MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / registrySource

Function registrySource

__tests__/explore-same-basename-pin.test.ts:35–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33const NAMED = ['clampedInt', 'cursorStyleToString', 'cursorStyleFromString'];
34
35function registrySource(): string {
36 const L: string[] = [
37 'export interface IConfigurationPropertySchema {',
38 ' type?: string;',
39 ' default?: unknown;',
40 ' minimum?: number;',
41 ' maximum?: number;',
42 '}',
43 '',
44 'export abstract class BaseEditorOption<K extends number, V> {',
45 ' constructor(public readonly id: K, public readonly name: string, public readonly defaultValue: V) {}',
46 ' public abstract validate(input: unknown): V;',
47 '}',
48 ];
49 const optionClass = (i: number) => {
50 L.push(
51 '',
52 `export class EditorOption${i} extends BaseEditorOption<number, string> {`,
53 ` private readonly allowed${i} = ['alpha${i}', 'beta${i}', 'gamma${i}'];`,
54 '',
55 ` constructor() {`,
56 ` super(${i}, 'option${i}', 'alpha${i}');`,
57 ' }',
58 '',
59 ' public validate(input: unknown): string {',
60 " if (typeof input !== 'string') {",
61 ' return this.defaultValue;',
62 ' }',
63 ` return this.allowed${i}.includes(input) ? input : this.defaultValue;`,
64 ' }',
65 '}',
66 );
67 };
68 for (let i = 0; i < 30; i++) optionClass(i);
69 L.push(
70 '',
71 'export function clampedInt<T>(value: unknown, defaultValue: T, minimum: number, maximum: number): number | T {',
72 " if (typeof value === 'undefined') {",
73 ' return defaultValue;',
74 ' }',
75 ' let r = parseInt(String(value), 10);',
76 ' if (isNaN(r)) {',
77 ' return defaultValue;',
78 ' }',
79 ' r = Math.max(minimum, r);',
80 ' r = Math.min(maximum, r);',
81 ' return r | 0;',
82 '}',
83 '',
84 'export class EditorIntOption<K extends number> extends BaseEditorOption<K, number> {',
85 ' public static clampedInt<T>(value: unknown, defaultValue: T, minimum: number, maximum: number): number | T {',
86 ' return clampedInt(value, defaultValue, minimum, maximum);',
87 ' }',
88 '',
89 ' constructor(id: K, name: string, defaultValue: number, public readonly minimum: number, public readonly maximum: number, schema?: IConfigurationPropertySchema) {',
90 " if (typeof schema !== 'undefined') {",
91 " schema.type = 'integer';",
92 ' schema.default = defaultValue;',

Calls 3

optionClassFunction · 0.85
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected