type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
export function formatTable(table: any[][], options?: { headerSeparator?: boolean, multilineSeparator?: boolean, multilineIndent?: string, }): string { const headerSeparator = options?.headerSeparator ?? false; const multilineSeparator = options?.multilineSeparator ?? false; const multilineIndent = options?.multilineIndent ?? " "; const rows: string[][][] = table.map(row => row.map(cell => toString(cell).split("\n"))); const widths: number[] = []; const isEmpty: boolean[] = []; const updateWidth = (cell: string[], i: number, rowIndex: number) => { while (widths.length <= i) { widths.push(0); isEmpty.push(true); } for (const line of cell) { const width = line.length; widths[i] = Math.max(widths[i], width); const isHeader = headerSeparator && rowIndex === 0; if (!isHeader && (width > 0)) { isEmpty[i] = false; } } }; rows.forEach((row, ri) => row.forEach((cell, vi) => updateWidth(cell, vi, ri))); const formatValue = (value: string, ci: number) => value.padEnd(widths[ci]); const formatRowLine = (rowLine: string[]) => rowLine.map(formatValue).filter((_, i) => !isEmpty[i]).join(" ").trimEnd(); const formatCellLine = (cell: string[], line: number) => { if (line >= cell.length) { return ""; } return `${line > 0 ? multilineIndent : ""}${cell[line]}`; }; const lines: string[] = []; const hasMultilines = rows.find(r => r.find(c => c.length > 0)) !== undefined; const firstDataRowIndex = headerSeparator ? 1 : 0; rows.forEach((row, rowIndex) => { for (let line = 0; row.find(x => line < x.length); line += 1) { if (multilineSeparator && hasMultilines && rowIndex > firstDataRowIndex && line === 0) { lines.push(""); } lines.push(formatRowLine(row.map(x => formatCellLine(x, line)))); } }); if (headerSeparator) { const separator = formatRowLine(widths.map(x => "-".repeat(x))); lines.splice(1, 0, separator); } return lines.join("\n"); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function parseNumber(s: string | undefined | null): number | undefined { if (s === null || s === undefined || s === "") { return undefined; } const n = Number(s); if (Number.isNaN(n)) { throw Error(`Invalid number: ${s}`); } return n; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function parseNanoTokens(s: string | undefined | null): number | undefined { if (s === null || s === undefined || s === "") { return undefined; } const nanos = s.endsWith("T") || s.endsWith("t") ? `${s.slice(0, s.length - 1)}000000000` : s; const nanoTokens = Number(nanos); if (Number.isNaN(nanoTokens)) { throw Error(`Invalid token value: ${s}`); } return nanoTokens; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function reduceBase64String(s: string | undefined): string | undefined { if (s === undefined) { return undefined; } if (s.length < 80) { return s; } const bytes = Buffer.from(s, "base64"); return `${s.slice(0, 30)} ... ${s.slice(-30)} (${bytes.length} bytes)`; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function breakWords(s: string, maxLen: number = 80): string { let result = ""; for (const sourceLine of s.split("\n")) { const words = sourceLine.split(" "); let line = ""; words.forEach((w) => { if (line.length + w.length > maxLen) { if (result !== "") { result += "\n"; } result += line; line = ""; } if (line !== "") { line += " "; } line += w; }); if (line !== "") { if (result !== "") { result += "\n"; } result += line; } } return result; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
function findExisting(paths: string[]): string | undefined { return paths.find(x => fs.existsSync(x)); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function resolveContract(filePath: string): ResolvedContractPackage { filePath = filePath.trim(); const lowered = filePath.toLowerCase(); let basePath; if (lowered.endsWith(".tvc") || lowered.endsWith(".abi") || lowered.endsWith(".sol")) { basePath = filePath.slice(0, -4); } else if (lowered.endsWith(".abi.json")) { basePath = filePath.slice(0, -9); } else { basePath = filePath; } const tvcPath = findExisting([`${basePath}.tvc`]); const abiPath = findExisting([`${basePath}.abi.json`, `${basePath}.abi`]) ?? ""; const tvc = tvcPath ? fs.readFileSync(tvcPath).toString("base64") : undefined; const abi = abiPath !== "" ? JSON.parse(fs.readFileSync(abiPath, "utf8")) : undefined; if (!abi) { throw new Error("ABI file missing."); } return { package: { abi, tvc, }, abiPath, tvcPath, }; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function isHex(s: string): boolean { for (let i = 0; i < s.length; i += 1) { if (!"0123456789ABCDEFabcdef".includes(s[i])) { return false; } } return true; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
export function resolvePath(s: string): string { return s.startsWith("~/") ? `${os.homedir()}${s.substr(1)}` : path.resolve(process.cwd(), s); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(resolve, reject) => { request(url) .on("data", _ => { terminal.write("."); }) .on("error", reject) // http protocol errors .pipe( unzip .Extract({ path: dst }) .on("error", reject) // unzip errors .on("close", resolve), ); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
_ => { terminal.write("."); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(resolve, reject) => { const request = https.get(url, response => { if (response.statusCode !== 200) { reject( new Error( `Download from ${url} failed with ${response.statusCode}: ${response.statusMessage}`, ), ); return; } let file: fs.WriteStream | null = fs.createWriteStream(dest, { flags: "w" }); let opened = false; const failed = (err: Error) => { if (file) { file.close(); file = null; fs.unlink(dest, () => { }); reject(err); } }; const unzip = zlib.createGunzip(); unzip.pipe(file); response.pipe(unzip); response.on("data", _ => { terminal.write("."); }); request.on("error", err => { failed(err); }); file.on("finish", () => { if (opened && file) { resolve(); } }); file.on("open", () => { opened = true; }); file.on("error", err => { if ((err as any).code === "EEXIST" && file) { file.close(); reject("File already exists"); } else { failed(err); } }); }); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
response => { if (response.statusCode !== 200) { reject( new Error( `Download from ${url} failed with ${response.statusCode}: ${response.statusMessage}`, ), ); return; } let file: fs.WriteStream | null = fs.createWriteStream(dest, { flags: "w" }); let opened = false; const failed = (err: Error) => { if (file) { file.close(); file = null; fs.unlink(dest, () => { }); reject(err); } }; const unzip = zlib.createGunzip(); unzip.pipe(file); response.pipe(unzip); response.on("data", _ => { terminal.write("."); }); request.on("error", err => { failed(err); }); file.on("finish", () => { if (opened && file) { resolve(); } }); file.on("open", () => { opened = true; }); file.on("error", err => { if ((err as any).code === "EEXIST" && file) { file.close(); reject("File already exists"); } else { failed(err); } }); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(err: Error) => { if (file) { file.close(); file = null; fs.unlink(dest, () => { }); reject(err); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
() => { }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
err => { failed(err); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
() => { if (opened && file) { resolve(); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
() => { opened = true; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
err => { if ((err as any).code === "EEXIST" && file) { file.close(); reject("File already exists"); } else { failed(err); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
() => { }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
filename => path.resolve(dir, filename)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
filename => !fs.lstatSync(filename).isDirectory()
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
filename => fs.chmodSync(filename, 0o755)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
resolve => setTimeout(resolve, 100)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
err => { fs.unlink(dstPath, () => { }); throw err; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(resolve, reject) => { try { const { cwd } = options; if (cwd && !fs.existsSync(cwd)) { throw Error(`Directory not exists: ${cwd}`); } const isWindows = os.platform() === "win32"; const spawned = isWindows ? spawn("cmd.exe", ["/c", name].concat(args), { env: process.env, ...options, }) : spawn(name, args, { env: process.env, ...options, }); const output: string[] = []; spawned.stdout.on("data", function (data) { const text = data.toString(); output.push(text); terminal.log(text); }); spawned.stderr.on("data", data => { const text = data.toString(); terminal.writeError(text); }); spawned.on("error", err => { reject(err); }); spawned.on("close", code => { if (code === 0) { resolve(output.join("")); } else { reject(`${name} failed`); } }); } catch (error) { reject(error); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
data => { const text = data.toString(); terminal.writeError(text); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
err => { reject(err); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
code => { if (code === 0) { resolve(output.join("")); } else { reject(`${name} failed`); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => `${x}`
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => Number.parseInt(x)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(resolve, reject) => { const tryUrl = (url: string) => { https .get(url, function (res) { let body = ""; res.on("data", function (chunk) { body += chunk; }); res.on("end", function () { if (res.statusCode === 301) { const redirectUrl = res.headers["location"]; if (redirectUrl) { tryUrl(redirectUrl); } else { reject(new Error("Redirect response has no `location` header.")); } return; } const response = JSON.parse(body); resolve(response); }); }) .on("error", error => { reject(error); }); }; tryUrl(url); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(url: string) => { https .get(url, function (res) { let body = ""; res.on("data", function (chunk) { body += chunk; }); res.on("end", function () { if (res.statusCode === 301) { const redirectUrl = res.headers["location"]; if (redirectUrl) { tryUrl(redirectUrl); } else { reject(new Error("Redirect response has no `location` header.")); } return; } const response = JSON.parse(body); resolve(response); }); }) .on("error", error => { reject(error); }); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
error => { reject(error); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
row => row.map(cell => toString(cell).split("\n"))
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
cell => toString(cell).split("\n")
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(cell: string[], i: number, rowIndex: number) => { while (widths.length <= i) { widths.push(0); isEmpty.push(true); } for (const line of cell) { const width = line.length; widths[i] = Math.max(widths[i], width); const isHeader = headerSeparator && rowIndex === 0; if (!isHeader && (width > 0)) { isEmpty[i] = false; } } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(row, ri) => row.forEach((cell, vi) => updateWidth(cell, vi, ri))
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(cell, vi) => updateWidth(cell, vi, ri)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(value: string, ci: number) => value.padEnd(widths[ci])
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(rowLine: string[]) => rowLine.map(formatValue).filter((_, i) => !isEmpty[i]).join(" ").trimEnd()
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(_, i) => !isEmpty[i]
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(cell: string[], line: number) => { if (line >= cell.length) { return ""; } return `${line > 0 ? multilineIndent : ""}${cell[line]}`; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
r => r.find(c => c.length > 0)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
c => c.length > 0
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(row, rowIndex) => { for (let line = 0; row.find(x => line < x.length); line += 1) { if (multilineSeparator && hasMultilines && rowIndex > firstDataRowIndex && line === 0) { lines.push(""); } lines.push(formatRowLine(row.map(x => formatCellLine(x, line)))); } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => line < x.length
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => formatCellLine(x, line)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => "-".repeat(x)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
(w) => { if (line.length + w.length > maxLen) { if (result !== "") { result += "\n"; } result += line; line = ""; } if (line !== "") { line += " "; } line += w; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
ArrowFunction
x => fs.existsSync(x)
INTONNATION/tondev
src/core/utils.ts
TypeScript
ClassDeclaration
export class StringTerminal implements Terminal { stdout: string = ""; stderr: string = ""; log(...args: any[]): void { this.stdout += args.map(x => `${x}`).join(" "); this.stdout += "\r\n"; } write(text: string): void { this.stdout += text; } writeError(text: string): void { this.stderr += text; } }
INTONNATION/tondev
src/core/utils.ts
TypeScript
TypeAliasDeclaration
export type ResolvedContractPackage = { package: ContractPackage, abiPath: string, tvcPath?: string, };
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
write(text: string) { process.stdout.write(text); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
writeError(text: string) { process.stderr.write(text); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
log(...args) { console.log(...args); }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
write(_text: string) { }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
writeError(_text: string) { }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
log(..._args) { }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
log(...args: any[]): void { this.stdout += args.map(x => `${x}`).join(" "); this.stdout += "\r\n"; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
write(text: string): void { this.stdout += text; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
MethodDeclaration
writeError(text: string): void { this.stderr += text; }
INTONNATION/tondev
src/core/utils.ts
TypeScript
FunctionDeclaration
function walk(ctx: Lint.WalkContext<void>): void { collectVariableUsage(ctx.sourceFile).forEach((variable, identifier) => { if (!isParameter(identifier.parent!)) { return; } for (const use of variable.uses) { if (isReassignmentTarget(use.location)) { ctx.addFailureAtNode(use.location, Rule.FAILURE_STRING(identifier.text)); } } }); }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
FunctionDeclaration
function isParameter(node: ts.Node): boolean { switch (node.kind) { case ts.SyntaxKind.Parameter: return true; case ts.SyntaxKind.BindingElement: return getDeclarationOfBindingElement(node as ts.BindingElement).kind === ts.SyntaxKind.Parameter; default: return false; } }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
ArrowFunction
(variable, identifier) => { if (!isParameter(identifier.parent!)) { return; } for (const use of variable.uses) { if (isReassignmentTarget(use.location)) { ctx.addFailureAtNode(use.location, Rule.FAILURE_STRING(identifier.text)); } } }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
ClassDeclaration
export class Rule extends Lint.Rules.AbstractRule { /* tslint:disable:object-literal-sort-keys */ public static metadata: Lint.IRuleMetadata = { ruleName: "no-parameter-reassignment", description: "Disallows reassigning parameters.", optionsDescription: "Not configurable.", options: null, optionExamples: [true], type: "typescript", typescriptOnly: false, }; /* tslint:enable:object-literal-sort-keys */ public static FAILURE_STRING(name: string) { return `Reassigning parameter '${name}' is forbidden.`; } public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { return this.applyWithFunction(sourceFile, walk); } }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
MethodDeclaration
/* tslint:enable:object-literal-sort-keys */ public static FAILURE_STRING(name: string) { return `Reassigning parameter '${name}' is forbidden.`; }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
MethodDeclaration
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { return this.applyWithFunction(sourceFile, walk); }
BridgeAR/tslint
src/rules/noParameterReassignmentRule.ts
TypeScript
ArrowFunction
({ statusCode }) => { const title = 'Error'; return ( <> <PageHead /> <Head> <meta property='og:site_name' content={title} /> <meta property='og:title' content={title} /> <title>{title}</title> </Head> <div className={styles.container}> <main className={styles.main}> <h1>Error Loading Page</h1> {statusCode && <p>Error code: {statusCode}</p>} <img src='/error.png' alt='Error' className={styles.errorImage} /> </main> </div> </>
seong7/nextjs-notion-blog
components/ErrorPage.tsx
TypeScript
ClassDeclaration
/** * ExecutionQueue allows multiple handlers to be processed in real time or deferred. * @internal */ export default class ExecutionQueue { private _shouldExecuteInRealTime; private _handlers; private _executionEntries; /** * Determines if the added execution entries should be processed in real time. * If this is set to true, a stack with entries will not be saved. */ get shouldExecuteInRealTime(): boolean; /** * Sets the behavior for this execution stack. * When set to true, all entries on stack will be processed and future entries * will be executed in real time. * When set to false, future entries will be saved in the execution stack for * later processing. */ set shouldExecuteInRealTime(executeInRealTime: boolean); /** * Registers an external handler to collection for delayed asynchronous processing. * Handlers are registered once. If handler is already registered, it does nothing. */ addHandler(key: string, handler: (...args: unknown[]) => void): void; /** * Execution Entry registration for delayed asynchronous processing. */ addExecutionEntry(key: string, ...args: unknown[]): void; /** * Removes an external executionEntry handler from collection for asynchronous event logging. * Logger is registered once. */ removeHandler(key: string, handler: (...args: unknown[]) => void): void; /** * Reset function clears executionEntry handler collection for asynchronous event logging. * All recorded execution entries and handlers are purged. */ reset(): void; /** * Flushes all the buffered execution entries. * All recorded execution entries are purged. */ flush(): void; private _containsHandler; private _initializeHandlerArrayForKey; private _processAllExecutionEntries; private _processExecutionEntry; }
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
InterfaceDeclaration
/** * @copyright Microsoft Corporation. All rights reserved. */ export interface IExecutionEntry { key: string; args: unknown[]; }
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
MethodDeclaration
/** * Registers an external handler to collection for delayed asynchronous processing. * Handlers are registered once. If handler is already registered, it does nothing. */ addHandler(key: string, handler: (...args: unknown[]) => void): void;
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
MethodDeclaration
/** * Execution Entry registration for delayed asynchronous processing. */ addExecutionEntry(key: string, ...args: unknown[]): void;
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
MethodDeclaration
/** * Removes an external executionEntry handler from collection for asynchronous event logging. * Logger is registered once. */ removeHandler(key: string, handler: (...args: unknown[]) => void): void;
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
MethodDeclaration
/** * Reset function clears executionEntry handler collection for asynchronous event logging. * All recorded execution entries and handlers are purged. */ reset(): void;
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
MethodDeclaration
/** * Flushes all the buffered execution entries. * All recorded execution entries are purged. */ flush(): void;
maximus-uk/SPFX_React_SPA
node_modules/@microsoft/sp-diagnostics/lib/Api/ExecutionQueue.d.ts
TypeScript
ClassDeclaration
/** * PAI configuration to run trials */ export class PAITrialConfig extends TrialConfig { public readonly cpuNum: number; public readonly memoryMB: number; public readonly image: string; public readonly dataDir: string; public readonly outputDir: string; constructor(command : string, codeDir : string, gpuNum : number, cpuNum: number, memoryMB: number, image: string, dataDir: string, outputDir: string) { super(command, codeDir, gpuNum); this.cpuNum = cpuNum; this.memoryMB = memoryMB; this.image = image; this.dataDir = dataDir; this.outputDir = outputDir; } }
3303387067/nni
src/nni_manager/training_service/pai/paiTrialConfig.ts
TypeScript
ClassDeclaration
export class CreateAdressDto { adress_name: string; adress_house_name: string; adress_place: string; adress_city: string; adress_district: string; adress_state: string; adress_zip: string; adress_alternate_phone?: string; }
AnoopNR4136/commonfile
src/user/dto/create-user-adress.dto.ts
TypeScript
FunctionDeclaration
/** * Returns the view state for a given editor. * * @export * @param {EditorId} id * @returns {(editor.ICodeEditorViewState | null)} */ export function getEditorViewState( id: EditorId, ): editor.ICodeEditorViewState | null { const { ElectronFiddle: fiddle } = window; if (!fiddle) { return null; } if (fiddle.editors[id] && fiddle.editors[id]!.saveViewState) { return fiddle.editors[id]!.saveViewState(); } return null; }
BenRussert/fiddle
src/utils/editor-viewstate.ts
TypeScript
ArrowFunction
({ rootStore, children }) => { const providers = [ <StoreContext.Provider value={rootStore} />, <UIStoreContext.Provider value={rootStore.uiStore} />, <ProjectStoreContext.Provider value={rootStore.projectStore} />, <WindowStoreContext.Provider value={rootStore.windowStore} />, <EditorStoreContext.Provider value={rootStore.editorStore} />, <MessageStoreContext.Provider value={rootStore.messageStore} /> ]; let lastEl: JSX.Element | null = null; for (const p of providers.reverse()) { if (lastEl === null) { lastEl = React.cloneElement(p, { children }); } else { lastEl = React.cloneElement(p, { children: lastEl }); } } return ( <React.Fragment> {lastEl} </React.Fragment> ); }
ParadiseEngine/editor
frontend/src/app.tsx
TypeScript
ArrowFunction
(props) => { return ( <StoreProviders rootStore={props.rootStore}> <EngineInit /> {props.rootStore.uiStore.engineLoaded && <React.Fragment> <ProjectHandler /> <MessageDialog /> <div className='root-layout'> <Titlebar /> <Editor className='flexFill' /> </div> </React.Fragment>} </StoreProviders>
ParadiseEngine/editor
frontend/src/app.tsx
TypeScript
InterfaceDeclaration
export interface AppProps { rootStore: RootStore; }
ParadiseEngine/editor
frontend/src/app.tsx
TypeScript
ClassDeclaration
export abstract class SaleInquiriesController< Request extends ISaleInquiry.IRequest, Summary extends ISaleInquiry.ISummary, Content extends ISaleInquiry.IContent> { /** * Get page of summarized inquiries. * * @param section Code of the target section * @param saleId ID of the target sale * @param input Information about pagination and searching * @return Page of the inquiries * * @throw 400 bad request error when type of the input data is not valid * @throw 404 not found error when unable to find the matched record */ @helper.EncryptedRoute.Get() public async index ( @helper.TypedParam("section", "string") section: string, @helper.TypedParam("saleId", "number") saleId: number, @nest.Query() input: Request ): Promise<IPage<Summary>> { section; saleId; input; return null!; } /** * Get detailed record of an inquiry * * @param section Code of the target section * @param saleId ID of the target sale * @param id ID of the Target inquiry * @return Detailed record of the inquiry * * @throw 400 bad request error when type of the input data is not valid * @throw 404 not found error when unable to find the matched record */ @helper.EncryptedRoute.Get(":id") public async at ( @helper.TypedParam("section", "string") section: string, @helper.TypedParam("saleId", "number") saleId: number, @helper.TypedParam("id", "number") id: number ): Promise<ISaleInquiry<Content>> { section; saleId; id; return null!; } }
fossabot/nestia
src/test/controllers/base/SaleInquiriesController.ts
TypeScript
MethodDeclaration
/** * Get page of summarized inquiries. * * @param section Code of the target section * @param saleId ID of the target sale * @param input Information about pagination and searching * @return Page of the inquiries * * @throw 400 bad request error when type of the input data is not valid * @throw 404 not found error when unable to find the matched record */ @helper.EncryptedRoute.Get() public async index ( @helper.TypedParam("section", "string") section: string, @helper.TypedParam("saleId", "number") saleId: number, @nest.Query() input: Request ): Promise<IPage<Summary>> { section; saleId; input; return null!; }
fossabot/nestia
src/test/controllers/base/SaleInquiriesController.ts
TypeScript
MethodDeclaration
/** * Get detailed record of an inquiry * * @param section Code of the target section * @param saleId ID of the target sale * @param id ID of the Target inquiry * @return Detailed record of the inquiry * * @throw 400 bad request error when type of the input data is not valid * @throw 404 not found error when unable to find the matched record */ @helper.EncryptedRoute.Get(":id") public async at ( @helper.TypedParam("section", "string") section: string, @helper.TypedParam("saleId", "number") saleId: number, @helper.TypedParam("id", "number") id: number ): Promise<ISaleInquiry<Content>> { section; saleId; id; return null!; }
fossabot/nestia
src/test/controllers/base/SaleInquiriesController.ts
TypeScript
ArrowFunction
() => { const params = { length: 3 }; // 3 digits only. expect(validate('123', params)).toBe(true); expect(validate('456', params)).toBe(true); expect(validate('789', params)).toBe(true); expect(validate('012', params)).toBe(true); expect(validate('000', params)).toBe(true); expect(validate(['012', '789'], params)).toBe(true); expect(validate(undefined, params)).toBe(true); expect(validate(null, params)).toBe(true); expect(validate('', params)).toBe(true); expect(validate([], params)).toBe(true); // invalid expect(validate(0, params)).toBe(false); expect(validate({}, params)).toBe(false); expect(validate('1234', params)).toBe(false); expect(validate('12', params)).toBe(false); expect(validate('abc', params)).toBe(false); expect(validate('12a', params)).toBe(false); expect(validate(['123', '12a'], params)).toBe(false); }
Andrevwv/vee-validate
packages/rules/tests/digits.spec.ts
TypeScript
ClassDeclaration
/** * <p>Returns a list of Kafka versions.</p> */ export class ListKafkaVersionsCommand extends $Command< ListKafkaVersionsCommandInput, ListKafkaVersionsCommandOutput, KafkaClientResolvedConfig > { // Start section: command_properties // End section: command_properties constructor(readonly input: ListKafkaVersionsCommandInput) { // Start section: command_constructor super(); // End section: command_constructor } /** * @internal */ resolveMiddleware( clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: KafkaClientResolvedConfig, options?: __HttpHandlerOptions ): Handler<ListKafkaVersionsCommandInput, ListKafkaVersionsCommandOutput> { this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); const stack = clientStack.concat(this.middlewareStack); const { logger } = configuration; const clientName = "KafkaClient"; const commandName = "ListKafkaVersionsCommand"; const handlerExecutionContext: HandlerExecutionContext = { logger, clientName, commandName, inputFilterSensitiveLog: ListKafkaVersionsRequest.filterSensitiveLog, outputFilterSensitiveLog: ListKafkaVersionsResponse.filterSensitiveLog, }; const { requestHandler } = configuration; return stack.resolve( (request: FinalizeHandlerArguments<any>) => requestHandler.handle(request.request as __HttpRequest, options || {}), handlerExecutionContext ); } private serialize(input: ListKafkaVersionsCommandInput, context: __SerdeContext): Promise<__HttpRequest> { return serializeAws_restJson1ListKafkaVersionsCommand(input, context); } private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListKafkaVersionsCommandOutput> { return deserializeAws_restJson1ListKafkaVersionsCommand(output, context); } // Start section: command_body_extra // End section: command_body_extra }
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
TypeAliasDeclaration
export type ListKafkaVersionsCommandInput = ListKafkaVersionsRequest;
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
TypeAliasDeclaration
export type ListKafkaVersionsCommandOutput = ListKafkaVersionsResponse & __MetadataBearer;
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
MethodDeclaration
/** * @internal */ resolveMiddleware( clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: KafkaClientResolvedConfig, options?: __HttpHandlerOptions ): Handler<ListKafkaVersionsCommandInput, ListKafkaVersionsCommandOutput> { this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); const stack = clientStack.concat(this.middlewareStack); const { logger } = configuration; const clientName = "KafkaClient"; const commandName = "ListKafkaVersionsCommand"; const handlerExecutionContext: HandlerExecutionContext = { logger, clientName, commandName, inputFilterSensitiveLog: ListKafkaVersionsRequest.filterSensitiveLog, outputFilterSensitiveLog: ListKafkaVersionsResponse.filterSensitiveLog, }; const { requestHandler } = configuration; return stack.resolve( (request: FinalizeHandlerArguments<any>) => requestHandler.handle(request.request as __HttpRequest, options || {}), handlerExecutionContext ); }
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
MethodDeclaration
private serialize(input: ListKafkaVersionsCommandInput, context: __SerdeContext): Promise<__HttpRequest> { return serializeAws_restJson1ListKafkaVersionsCommand(input, context); }
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
MethodDeclaration
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListKafkaVersionsCommandOutput> { return deserializeAws_restJson1ListKafkaVersionsCommand(output, context); }
PaulThompson/aws-sdk-js-v3
clients/client-kafka/commands/ListKafkaVersionsCommand.ts
TypeScript
ArrowFunction
async () => { return fetch( "https://sv443.net/jokeapi/v2/joke/Programming?format=txt&type=single" ).then((response) => response.text()); }
mitom18/jarvis-v2
src/service/jokeService.ts
TypeScript
ArrowFunction
(response) => response.text()
mitom18/jarvis-v2
src/service/jokeService.ts
TypeScript
ClassDeclaration
@Injectable({ providedIn: 'root', }) export class AuthInitResolver implements Resolve<any> { constructor( private svc: ApiService, private accessService: AccessControlService, ) { } resolve(): Observable<any> { return this.svc.get( `${INIT}${this.accessService.orgRootOrgAsQuery}&lang=${this.accessService.locale}`, ) } }
sunbird-cb/sb-cb-ui-components
sb-cb-ui-author/project/ws/author/src/lib/modules/shared/services/auth-init.resolver.service.ts
TypeScript
MethodDeclaration
resolve(): Observable<any> { return this.svc.get( `${INIT}${this.accessService.orgRootOrgAsQuery}&lang=${this.accessService.locale}`, ) }
sunbird-cb/sb-cb-ui-components
sb-cb-ui-author/project/ws/author/src/lib/modules/shared/services/auth-init.resolver.service.ts
TypeScript
ClassDeclaration
/** * An execution context and a data structure to order tasks and schedule their * execution. Provides a notion of (potentially virtual) time, through the * `now()` getter method. * * Each unit of work in a Scheduler is called an `Action`. * * ```ts * class Scheduler { * now(): number; * schedule(work, delay?, state?): Subscription; * } * ``` * * @class Scheduler * @deprecated Scheduler is an internal implementation detail of RxJS, and * should not be used directly. Rather, create your own class and implement * {@link SchedulerLike}. Will be made internal in v8. */ export class Scheduler implements SchedulerLike { public static now: () => number = dateTimestampProvider.now; constructor(private schedulerActionCtor: typeof Action, now: () => number = Scheduler.now) { this.now = now; } /** * A getter method that returns a number representing the current time * (at the time this function was called) according to the scheduler's own * internal clock. * @return {number} A number that represents the current time. May or may not * have a relation to wall-clock time. May or may not refer to a time unit * (e.g. milliseconds). */ public now: () => number; /** * Schedules a function, `work`, for execution. May happen at some point in * the future, according to the `delay` parameter, if specified. May be passed * some context object, `state`, which will be passed to the `work` function. * * The given arguments will be processed an stored as an Action object in a * queue of actions. * * @param {function(state: ?T): ?Subscription} work A function representing a * task, or some unit of work to be executed by the Scheduler. * @param {number} [delay] Time to wait before executing the work, where the * time unit is implicit and defined by the Scheduler itself. * @param {T} [state] Some contextual data that the `work` function uses when * called by the Scheduler. * @return {Subscription} A subscription in order to be able to unsubscribe * the scheduled work. */ public schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay: number = 0, state?: T): Subscription { return new this.schedulerActionCtor<T>(this, work).schedule(state, delay); } }
0xhodl/Module_4
node_modules/rxjs/src/internal/Scheduler.ts
TypeScript
MethodDeclaration
/** * Schedules a function, `work`, for execution. May happen at some point in * the future, according to the `delay` parameter, if specified. May be passed * some context object, `state`, which will be passed to the `work` function. * * The given arguments will be processed an stored as an Action object in a * queue of actions. * * @param {function(state: ?T): ?Subscription} work A function representing a * task, or some unit of work to be executed by the Scheduler. * @param {number} [delay] Time to wait before executing the work, where the * time unit is implicit and defined by the Scheduler itself. * @param {T} [state] Some contextual data that the `work` function uses when * called by the Scheduler. * @return {Subscription} A subscription in order to be able to unsubscribe * the scheduled work. */ public schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay: number = 0, state?: T): Subscription { return new this.schedulerActionCtor<T>(this, work).schedule(state, delay); }
0xhodl/Module_4
node_modules/rxjs/src/internal/Scheduler.ts
TypeScript
InterfaceDeclaration
/** A set of criteria that can be used to filter a list of `MatDrawerHarness` instances. */ export interface DrawerHarnessFilters extends BaseHarnessFilters { /** Only find instances whose side is the given value. */ position?: 'start' | 'end'; }
Ajabhishek/AngularJScomponents
src/material/sidenav/testing/drawer-harness-filters.ts
TypeScript
ArrowFunction
({ isSubmitting }) => { const { state, actions } = useVideoEditorState() const { videoHandler } = state const { updatePinContent, updateTitle, updateDescription } = actions const videoFlow = useRef<VideoSourcesUploadHandlers>(null) const thumbFlow = useRef<ThumbnailUploadHandlers>(null) return ( <> <div className="form-group"> <VideoSourcesUpload ref={videoFlow} disabled={isSubmitting} /> </div> <div className="form-group"> <ThumbnailUpload ref={thumbFlow} disabled={isSubmitting} /> </div> <PinContentField onChange={pin
Etherna/etherna-dapp
src/components/media/VideoEditor/VideoProperties/VideoProperties.tsx
TypeScript