Something went wrong. Try again.
fork of hey-api/openapi-ts because I need some additional things
Something went wrong. Try again.
1.2 kB · 44 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445import { keywords } from './keywords';
type List = ReadonlyArray<string>;
export class ReservedList { private _array: List; private _set: Set<string>;
constructor(values: List) { this._array = values; this._set = new Set(values); }
get '~values'() { return this._set; }
/** * Updates the reserved list with new values. * * @param values New reserved values or a function that receives the previous * reserved values and returns the new ones. */ set(values: List | ((prev: List) => List)): void { const vals = typeof values === 'function' ? values(this._array) : values; this._array = vals; this._set = new Set(vals); }}
const runtimeReserved = new ReservedList([...keywords.pythonKeywords, ...keywords.pythonBuiltins]);
/** * Reserved names for identifiers. These names will not be used * for variables, functions, classes, or other identifiers in generated code. */export const reserved = { /** * Reserved names for runtime identifiers. These names will not be used * for variables, functions, classes, or other runtime identifiers in * generated code. */ runtime: runtimeReserved,};