id
int64
0
3.78k
code
stringlengths
13
37.9k
declarations
stringlengths
16
64.6k
1,100
(options?: FormatDistanceFnOptions) => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { return 'жарты минут ішінде' } else { return 'жарты минут бұрын' } } return 'жарты минут' }
interface FormatDistanceFnOptions { addSuffix?: boolean comparison?: -1 | 0 | 1 }
1,101
function declension(scheme: Plural, count: number): string { // scheme for count=1 exists if (scheme.one && count === 1) return scheme.one const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominative.replace('{{count}}', Str...
type Plural = { one: string other: string }
1,102
function declension(scheme: Plural, count: number): string { // scheme for count=1 exists if (scheme.one && count === 1) return scheme.one const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominative.replace('{{count}}', Str...
type Plural = { one: Tense other: Tense }
1,103
function declension(scheme: Plural, count: number): string { // scheme for count=1 exists if (scheme.one && count === 1) return scheme.one const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominative.replace('{{count}}', Str...
type Plural = { one?: string singularNominative: string singularGenitive: string pluralGenitive: string }
1,104
function declension(scheme: Plural, count: number): string { // scheme for count=1 exists if (scheme.one && count === 1) return scheme.one const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominative.replace('{{count}}', Str...
type Plural = { one: string two: string few: string other: string }
1,105
function declension(scheme: Plural, count: number): string { // scheme for count=1 exists if (scheme.one && count === 1) return scheme.one const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominative.replace('{{count}}', Str...
type Plural = { one: string other: string }
1,106
function lastWeek(day: Day): string { const weekday = accusativeWeekdays[day] switch (day) { case 0: return "'в прошлое " + weekday + " в' p" case 1: case 2: case 4: return "'в прошлый " + weekday + " в' p" case 3: case 5: case 6: return "'в прошлую " + weekday + " в' ...
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,107
function thisWeek(day: Day) { const weekday = accusativeWeekdays[day] if (day === 2 /* Tue */) { return "'во " + weekday + " в' p" } else { return "'в " + weekday + " в' p" } }
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,108
function nextWeek(day: Day) { const weekday = accusativeWeekdays[day] switch (day) { case 0: return "'в следующее " + weekday + " в' p" case 1: case 2: case 4: return "'в следующий " + weekday + " в' p" case 3: case 5: case 6: return "'в следующую " + weekday + " в' p"...
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,109
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { default: string in: string ago: string }
1,110
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { regular: string past: string future: string }
1,111
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { present: string past: string future: string }
1,112
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { default: string future: string past: string }
1,113
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { regular: DeclensionScheme past?: DeclensionScheme future?: DeclensionScheme }
1,114
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { past: Plural future: Plural present: Plural }
1,115
function buildLocalizeTokenFn(scheme: Tense) { return (count: number, options?: FormatDistanceFnOptions): string => { if (options?.addSuffix) { if (options.comparison && options.comparison > 0) { if (scheme.future) { return declension(scheme.future, count) } else { return...
type Tense = { regular: string past: string future: string }
1,116
function lastWeek(day: Day): string { const weekday = accusativeWeekdays[day] switch (day) { case 0: case 3: case 5: case 6: return "'у минулу " + weekday + " о' p" case 1: case 2: case 4: return "'у минулий " + weekday + " о' p" } }
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,117
function thisWeek(day: Day): string { const weekday = accusativeWeekdays[day] return "'у " + weekday + " о' p" }
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,118
function nextWeek(day: Day): string { const weekday = accusativeWeekdays[day] switch (day) { case 0: case 3: case 5: case 6: return "'у наступну " + weekday + " о' p" case 1: case 2: case 4: return "'у наступний " + weekday + " о' p" } }
type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6
1,119
function declension(scheme: DeclensionScheme, count: number) { // scheme for count=1 exists if (scheme.one !== undefined && count === 1) { return scheme.one } const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominativ...
interface DeclensionScheme { one?: string singularNominative: string singularGenitive: string pluralGenitive: string }
1,120
function declension(scheme: DeclensionScheme, count: number) { // scheme for count=1 exists if (scheme.one !== undefined && count === 1) { return scheme.one } const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominativ...
type DeclensionScheme = { one?: string singularNominative: string singularGenitive: string pluralGenitive: string }
1,121
function declension(scheme: DeclensionScheme, count: number) { // scheme for count=1 exists if (scheme.one !== undefined && count === 1) { return scheme.one } const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominativ...
type DeclensionScheme = { one?: string singularNominative: string singularGenitive: string pluralGenitive: string }
1,122
function declension(scheme: DeclensionScheme, count: number) { // scheme for count=1 exists if (scheme.one !== undefined && count === 1) { return scheme.one } const rem10 = count % 10 const rem100 = count % 100 // 1, 21, 31, ... if (rem10 === 1 && rem100 !== 11) { return scheme.singularNominativ...
interface DeclensionScheme { one?: string singularNominative: string singularGenitive: string pluralGenitive: string }
1,123
function renderChangelog(changelog: ChangelogVersion) { let markdown = `## ${renderVersion(changelog.version)} - ${format( Date.now(), 'yyyy-MM-dd' )} ${sample(thanksOptions)!(renderAuthors(changelog.authors))}` if (changelog.fixed.length) markdown += ` ### Fixed ${changelog.fixed.map(renderItem)....
interface ChangelogVersion { version: Version changed: ChangelogItem[] fixed: ChangelogItem[] added: ChangelogItem[] authors: Author[] }
1,124
function renderVersion({ major, minor, patch }: Version) { return `v${major}.${minor}.${patch}` }
interface Version { major: number minor: number patch: number }
1,125
function renderAuthor(author: Author) { return `@${author.login}` }
interface Author { login: string name: string email: string }
1,126
function renderItem(item: ChangelogItem) { const message = item.pr ? `[${item.message}](https://github.com/date-fns/date-fns/pull/${item.pr})` : item.message const issues = item.issues ? ` (${item.issues .map((i) => `[#${i}](https://github.com/date-fns/date-fns/issues/${i})`) .join(', ')...
interface ChangelogItem { type: ChangelogType author: Author message: string pr?: number issues?: number[] breaking: boolean }
1,127
(doc: DocFn) => doc.kind === 'function' && doc.isFPFn
interface DocFn { kind: string isFPFn: boolean title: string generatedFrom: string args: { length: number } }
1,128
async function buildFPFn({ title, generatedFrom, args: { length }, }: DocFn): Promise<void> { const source = getFPFn(generatedFrom, length) const dir = `./src/fp/${title}` if (!existsSync(dir)) await mkdir(dir) writeFile(`${dir}/index.ts`, source) // remove legacy index.js (if any) const jsPath = `$...
interface DocFn { kind: string isFPFn: boolean title: string generatedFrom: string args: { length: number } }
1,129
constructor(options?: Options)
interface Options extends ReadableOptions { writable?: boolean; readable?: boolean; dataSize?: number; maxDataSize?: number; pauseStreams?: boolean; }
1,130
fn(parser: SaxesParser): void { Object.assign(parser.ENTITIES, ENTITIES); parser.write(`${xmlStart}/>`).close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,131
function test(options: TestOptions): void { const { xml, name, expect: expected, fn, events } = options; it(name, () => { const parser = new SaxesParser(options.opt); let expectedIx = 0; for (const ev of events ?? EVENTS) { // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-loop-fu...
interface TestOptions { xml?: string | readonly string[]; name: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any expect: readonly any[]; // eslint-disable-next-line @typescript-eslint/ban-types fn?: (parser: SaxesParser<{}>) => void; opt?: SaxesOptions; events?: readonly EventName[...
1,132
fn(parser: SaxesParser): void { // This test purposely slices the string into the poop character. parser.write(xml.slice(0, 4)); parser.write(xml.slice(4)); parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,133
fn(parser: SaxesParser): void { parser.write("<unbound:root/>"); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,134
fn(parser: SaxesParser): void { parser.write("<unbound:root xmlns:unbound=\"someuri\"/>"); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,135
fn(parser: SaxesParser): void { parser.write("<root unbound:attr='value'/>"); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,136
(node: SaxesTagPlain) => { expect(node).to.deep.equal({ name: "x", attributes: {}, isSelfClosing: false, }); seen = true; }
type SaxesTagPlain = Pick<SaxesTag, "name" | "attributes" | "isSelfClosing"> & { attributes: Record<string, string>; };
1,137
fn(parser: SaxesParser): void { parser.write("<r><![CDATA[ this is ]") .write("]>") .write("</r>") .close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,138
fn(parser: SaxesParser): void { parser.write("<root length=12").write("345></root>").close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,139
fn(parser: SaxesParser): void { const x = "<r><![CDATA[[[[[[[[[]]]]]]]]]]></r>"; for (let i = 0; i < x.length; i++) { parser.write(x.charAt(i)); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,140
fn(parser: SaxesParser): void { parser.write("<r><![CDATA[ this is ]]>").write("<![CDA") .write("T") .write("A[") .write("character data  ") .write("]]></r>") .close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,141
writeSource(parser: SaxesParser, source: string): void { parser.write(source); parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,142
writeSource(parser: SaxesParser, source: string): void { for (const x of source) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,143
fn(parser: SaxesParser): void { for (const x of xml) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,144
fn(parser: SaxesParser): void { for (const x of nl) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,145
fn(parser: SaxesParser): void { for (const x of cr) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,146
fn(parser: SaxesParser): void { for (const x of crnl) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,147
fn(parser: SaxesParser): void { for (const x of nel) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,148
fn(parser: SaxesParser): void { for (const x of ls) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,149
fn(parser: SaxesParser): void { for (const x of xml) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,150
fn(parser: SaxesParser): void { for (const x of xml) { parser.write(x); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,151
fn(parser: SaxesParser): void { for (let ix = 0; ix < xml.length; ix += 2) { parser.write(xml.slice(ix, ix + 2)); } parser.close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,152
fn(parser: SaxesParser): void { parser.write("<r><![CDATA[ this is ").write("character data  ") .write("]]></r>") .close(); }
class SaxesParser<O extends SaxesOptions = {}> { private readonly fragmentOpt: boolean; private readonly xmlnsOpt: boolean; private readonly trackPosition: boolean; private readonly fileName?: string; private readonly nameStartCheck: (c: number) => boolean; private readonly nameCheck: (c: number) => boolean...
1,153
(decl: XMLDecl) => void
interface XMLDecl { /** The version specified by the XML declaration. */ version?: string; /** The encoding specified by the XML declaration. */ encoding?: string; /** The value of the standalone parameter */ standalone?: string; }
1,154
off(name: EventName): void { // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access (this as any)[EVENT_NAME_TO_HANDLER_NAME[name]] = undefined; }
type EventName = (typeof EVENTS)[number];
1,155
(element: Element) => void
class Element extends NodeWithChildren { /** * @param name Name of the tag, eg. `div`, `span`. * @param attribs Object mapping attribute names to attribute values. * @param children Children of the node. */ constructor( public name: string, public attribs: { [name: string]: s...
1,156
public onparserinit(parser: ParserInterface): void { this.parser = parser; }
interface ParserInterface { startIndex: number | null; endIndex: number | null; }
1,157
protected addNode(node: ChildNode): void { const parent = this.tagStack[this.tagStack.length - 1]; const previousSibling = parent.children[parent.children.length - 1] as | ChildNode | undefined; if (this.options.withStartIndices) { node.startIndex = this.pars...
type ChildNode = | Text | Comment | ProcessingInstruction | Element | CDATA // `Document` is also used for document fragments, and can be a child node. | Document;
1,158
(fork: Fork) => T
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,159
function typesPlugin(_fork: Fork) { const Type = { or(...types: any[]): Type<any> { return new OrType(types.map(type => Type.from(type))); }, from<T>(value: any, name?: string): Type<T> { if ( value instanceof ArrayType || value instanceof IdentityType || value instanc...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,160
function (fork: Fork) { var types = fork.use(typesPlugin); var getFieldNames = types.getFieldNames; var getFieldValue = types.getFieldValue; var isArray = types.builtInTypes.array; var isObject = types.builtInTypes.object; var isDate = types.builtInTypes.Date; var isRegExp = types.builtInTyp...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,161
visit<M = {}>(node: ASTNode, methods?: import("./gen/visitor").Visitor<M>): any
interface ASTNode { type: string; }
1,162
(path: NodePath) => any
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,163
function pathVisitorPlugin(fork: Fork) { var types = fork.use(typesPlugin); var NodePath = fork.use(nodePathPlugin); var isArray = types.builtInTypes.array; var isObject = types.builtInTypes.object; var isFunction = types.builtInTypes.function; var undefined: any; const PathVisitor = function PathVisitor...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,164
function PathVisitor(this: PathVisitor) { if (!(this instanceof PathVisitor)) { throw new Error( "PathVisitor constructor cannot be invoked without 'new'" ); } // Permanent state. this._reusableContextStack = []; this._methodNameTable = computeMethodNameTable(this); this._s...
interface PathVisitor { _reusableContextStack: any; _methodNameTable: any; _shouldVisitComments: any; Context: any; _visiting: any; _changeReported: any; _abortRequested: boolean; visit(...args: any[]): any; reset(...args: any[]): any; visitWithoutReset(path: any): any; AbortRequest: any; abort(...
1,165
function Context(this: Context, path: any) { if (!(this instanceof Context)) { throw new Error(""); } if (!(this instanceof PathVisitor)) { throw new Error(""); } if (!(path instanceof NodePath)) { throw new Error(""); } Object.defineProperty(this, "vis...
interface Context extends Omit<PathVisitor, "visit" | "reset">, SharedContextMethods {}
1,166
replace(replacement?: ASTNode, ...args: ASTNode[]): any
interface ASTNode { type: string; }
1,167
function pathPlugin(fork: Fork): PathConstructor { var types = fork.use(typesPlugin); var isArray = types.builtInTypes.array; var isNumber = types.builtInTypes.number; const Path = function Path(this: Path, value: any, parentPath?: any, name?: any) { if (!(this instanceof Path)) { throw new Error("Pa...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,168
function Path(this: Path, value: any, parentPath?: any, name?: any) { if (!(this instanceof Path)) { throw new Error("Path constructor cannot be invoked without 'new'"); } if (parentPath) { if (!(parentPath instanceof Path)) { throw new Error(""); } } else { parentPath =...
interface Path<V = any> { value: V; parentPath: any; name: any; __childCache: object | null; getValueProperty(name: any): any; get(...names: any[]): any; each(callback: any, context?: any): any; map(callback: any, context?: any): any; filter(callback: any, context?: any): any; shift(): any; unshif...
1,169
new(path: NodePath, parentScope: any): Scope
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,170
function scopePlugin(fork: Fork) { var types = fork.use(typesPlugin); var Type = types.Type; var namedTypes = types.namedTypes; var Node = namedTypes.Node; var Expression = namedTypes.Expression; var isArray = types.builtInTypes.array; var b = types.builders; const Scope = function Scope(this: Scope, p...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,171
function Scope(this: Scope, path: NodePath, parentScope: unknown) { if (!(this instanceof Scope)) { throw new Error("Scope constructor cannot be invoked without 'new'"); } if (!TypeParameterScopeType.check(path.value)) { ScopeType.assert(path.value); } var depth: number; if (parent...
interface Scope { path: NodePath; node: any; isGlobal: boolean; depth: number; parent: any; bindings: any; types: any; didScan: boolean; declares(name: any): any declaresType(name: any): any declareTemporary(prefix?: any): any; injectTemporary(identifier: any, init: any): any; scan(force?: any...
1,172
function Scope(this: Scope, path: NodePath, parentScope: unknown) { if (!(this instanceof Scope)) { throw new Error("Scope constructor cannot be invoked without 'new'"); } if (!TypeParameterScopeType.check(path.value)) { ScopeType.assert(path.value); } var depth: number; if (parent...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,173
function scanScope(path: NodePath, bindings: any, scopeTypes: any) { var node = path.value; if (TypeParameterScopeType.check(node)) { const params = path.get('typeParameters', 'params'); if (isArray.check(params.value)) { params.each((childPath: NodePath) => { addTypeParameter(chil...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,174
(childPath: NodePath) => { addTypeParameter(childPath, scopeTypes); }
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,175
function recursiveScanScope(path: NodePath, bindings: any, scopeTypes: any) { var node = path.value; if (path.parent && namedTypes.FunctionExpression.check(path.parent.node) && path.parent.node.id) { addPattern(path.parent.get("id"), bindings); } if (!node) { // None of the rem...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,176
(childPath: NodePath) => { recursiveScanChild(childPath, bindings, scopeTypes); }
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,177
(paramPath: NodePath) => { addPattern(paramPath, bindings); }
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,178
function pathHasValue(path: NodePath, value: any) { if (path.value === value) { return true; } // Empty arrays are probably produced by defaults.emptyArray, in which // case is makes sense to regard them as equivalent, if not ===. if (Array.isArray(path.value) && path.value.length === 0...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,179
function recursiveScanChild(path: NodePath, bindings: any, scopeTypes: any) { var node = path.value; if (!node || Expression.check(node)) { // Ignore falsy values and Expressions. } else if (namedTypes.FunctionDeclaration.check(node) && node.id !== null) { addPattern(path.get("id"),...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,180
function addPattern(patternPath: NodePath, bindings: any) { var pattern = patternPath.value; namedTypes.Pattern.assert(pattern); if (namedTypes.Identifier.check(pattern)) { if (hasOwn.call(bindings, pattern.name)) { bindings[pattern.name].push(patternPath); } else { bindings[pat...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,181
function addTypePattern(patternPath: NodePath, types: any) { var pattern = patternPath.value; namedTypes.Pattern.assert(pattern); if (namedTypes.Identifier.check(pattern)) { if (hasOwn.call(types, pattern.name)) { types[pattern.name].push(patternPath); } else { types[pattern.nam...
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,182
function addTypeParameter(parameterPath: NodePath, types: any) { var parameter = parameterPath.value; FlowOrTSTypeParameterType.assert(parameter); if (hasOwn.call(types, parameter.name)) { types[parameter.name].push(parameterPath); } else { types[parameter.name] = [parameterPath]; } }
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,183
function nodePathPlugin(fork: Fork): NodePathConstructor { var types = fork.use(typesPlugin); var n = types.namedTypes; var b = types.builders; var isNumber = types.builtInTypes.number; var isArray = types.builtInTypes.array; var Path = fork.use(pathPlugin); var Scope = fork.use(scopePlugin); const Nod...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,184
function NodePath(this: NodePath, value: any, parentPath?: any, name?: any) { if (!(this instanceof NodePath)) { throw new Error("NodePath constructor cannot be invoked without 'new'"); } Path.call(this, value, parentPath, name); }
interface NodePath<N = any, V = any> extends Path<V> { node: N; parent: any; scope: any; replace: Path['replace']; prune(...args: any[]): any; _computeNode(): any; _computeParent(): any; _computeScope(): Scope | null; getValueProperty(name: any): any; needsParens(assumeExpressionContext?: boolean): ...
1,185
function (fork: Fork) { var types = fork.use(typesPlugin); var Type = types.Type; var builtin = types.builtInTypes; var isNumber = builtin.number; // An example of constructing a new type with arbitrary constraints from // an existing type. function geq(than: any) { return Type.from...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,186
function assertVisited(node: ASTNode, visitors: Visitor<any>): any { const visitedSet: Set<string> = new Set(); const wrappedVisitors: Visitor<any> = {} for (const _key of Object.keys(visitors)) { const key = _key as keyof Visitor<any> wrappedVisitors[key] = function (this: Context, path: NodePa...
interface ASTNode { type: string; }
1,187
function (this: Context, path: NodePath<any>) { visitedSet.add(key); (visitors[key] as any)?.call(this, path) }
interface Context extends Omit<PathVisitor, "visit" | "reset">, SharedContextMethods {}
1,188
function assertVisited(node: ASTNode, visitors: Visitor<any>): any { const visitedSet: Set<string> = new Set(); const wrappedVisitors: Visitor<any> = {} for (const _key of Object.keys(visitors)) { const key = _key as keyof Visitor<any> wrappedVisitors[key] = function (this: Context, path: NodePa...
interface ASTNode { type: string; }
1,189
function (fork: Fork) { fork.use(esProposalsDef); var types = fork.use(typesPlugin); var defaults = fork.use(sharedPlugin).defaults; var def = types.Type.def; var or = types.Type.or; def("VariableDeclaration") .field("declarations", [or( def("VariableDeclarator"), def("Identifier") // Espr...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,190
function (fork: Fork) { fork.use(coreDef); const types = fork.use(typesPlugin); const def = types.Type.def; const or = types.Type.or; const defaults = fork.use(sharedPlugin).defaults; def("Function") .field("generator", Boolean, defaults["false"]) .field("expression", Boolean, defaults["false"]) ...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,191
function (fork: Fork) { // The es2016OpsDef plugin comes before es6Def so BinaryOperators and // AssignmentOperators will be appropriately augmented before they are first // used in the core definitions for this fork. fork.use(es2016OpsDef); fork.use(es6Def); }
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,192
function (fork: Fork) { fork.use(esProposalsDef); fork.use(typeAnnotationsDef); const types = fork.use(typesPlugin); const def = types.Type.def; const or = types.Type.or; const defaults = fork.use(sharedPlugin).defaults; // Base types def("Flow").bases("Node"); def("FlowType").bases("Flow"); // ...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,193
function (fork: Fork) { fork.use(es2017Def); const types = fork.use(typesPlugin); const def = types.Type.def; const or = types.Type.or; const defaults = fork.use(sharedPlugin).defaults; def("ForOfStatement") .field("await", Boolean, defaults["false"]); // Legacy def("SpreadProperty") .bases("...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,194
function (fork: Fork) { // The es2020OpsDef plugin comes before es2019Def so LogicalOperators will be // appropriately augmented before first used. fork.use(es2020OpsDef); fork.use(es2019Def); const types = fork.use(typesPlugin); const def = types.Type.def; const or = types.Type.or; const shared = fo...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,195
function (fork: Fork) { // The es2021OpsDef plugin comes before es2020Def so AssignmentOperators will // be appropriately augmented before first used. fork.use(es2021OpsDef); fork.use(es2020Def); }
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,196
function (fork: Fork) { const types = fork.use(typesPlugin); const def = types.Type.def; fork.use(babelCoreDef); fork.use(flowDef); // https://github.com/babel/babel/pull/10148 def("V8IntrinsicIdentifier") .bases("Expression") .build("name") .field("name", String); // https://github.com/bab...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,197
function (fork: Fork) { fork.use(esProposalsDef); const types = fork.use(typesPlugin); const defaults = fork.use(sharedPlugin).defaults; const def = types.Type.def; const or = types.Type.or; const { undefined: isUndefined, } = types.builtInTypes; def("Noop") .bases("Statement") .build(); ...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,198
function (fork: Fork) { fork.use(esProposalsDef); const types = fork.use(typesPlugin); const def = types.Type.def; const or = types.Type.or; const defaults = fork.use(sharedPlugin).defaults; def("JSXAttribute") .bases("Node") .build("name", "value") .field("name", or(def("JSXIdentifier"), def(...
type Fork = { use<T>(plugin: Plugin<T>): T; };
1,199
function (fork: Fork) { // Since TypeScript is parsed by Babylon, include the core Babylon types // but omit the Flow-related types. fork.use(babelCoreDef); fork.use(typeAnnotationsDef); var types = fork.use(typesPlugin); var n = types.namedTypes; var def = types.Type.def; var or = types.Type.or; var...
type Fork = { use<T>(plugin: Plugin<T>): T; };