type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ClassDeclaration
/** * Defines a value published from construction code which needs to be accessible * by runtime code. */ export class RuntimeValue extends cdk.Construct { /** * The recommended name of the environment variable to use to set the stack name * from which the runtime value is published. */ public static readonly ENV_NAME = 'RTV_STACK_NAME'; /** * The value to assign to the `RTV_STACK_NAME` environment variable. */ public static readonly ENV_VALUE = new cdk.AwsStackName(); /** * IAM actions needed to read a value from an SSM parameter. */ private static readonly SSM_READ_ACTIONS = [ 'ssm:DescribeParameters', 'ssm:GetParameters', 'ssm:GetParameter' ]; /** * The name of the runtime parameter. */ public readonly parameterName: ParameterName; /** * The ARN fo the SSM parameter used for this runtime value. */ public readonly parameterArn: cdk.Arn; constructor(parent: cdk.Construct, name: string, props: RuntimeValueProps) { super(parent, name); this.parameterName = new cdk.FnConcat('/rtv/', new cdk.AwsStackName(), '/', props.package, '/', name); new ssm.cloudformation.ParameterResource(this, 'Parameter', { parameterName: this.parameterName, type: 'String', value: props.value, }); this.parameterArn = cdk.Arn.fromComponents({ service: 'ssm', resource: 'parameter', resourceName: this.parameterName }); } /** * Grants a principal read permissions on this runtime value. * @param principal The principal (e.g. Role, User, Group) */ public grantRead(principal?: iam.IIdentityResource) { // sometimes "role" is optional, so we want `rtv.grantRead(role)` to be a no-op if (!principal) { return; } principal.addToPolicy(new cdk.PolicyStatement() .addResource(this.parameterArn) .addActions(...RuntimeValue.SSM_READ_ACTIONS)); } }
Mortifera/aws-cdk
packages/@aws-cdk/runtime-values/lib/rtv.ts
TypeScript
ClassDeclaration
/** * The full name of the runtime value's SSM parameter. */ export class ParameterName extends cdk.Token { }
Mortifera/aws-cdk
packages/@aws-cdk/runtime-values/lib/rtv.ts
TypeScript
InterfaceDeclaration
export interface RuntimeValueProps { /** * A namespace for the runtime value. * It is recommended to use the name of the library/package that advertises this value. */ package: string; /** * The value to advertise. Can be either a primitive value or a token. */ value: any; }
Mortifera/aws-cdk
packages/@aws-cdk/runtime-values/lib/rtv.ts
TypeScript
MethodDeclaration
/** * Grants a principal read permissions on this runtime value. * @param principal The principal (e.g. Role, User, Group) */ public grantRead(principal?: iam.IIdentityResource) { // sometimes "role" is optional, so we want `rtv.grantRead(role)` to be a no-op if (!principal) { return; } principal.addToPolicy(new cdk.PolicyStatement() .addResource(this.parameterArn) .addActions(...RuntimeValue.SSM_READ_ACTIONS)); }
Mortifera/aws-cdk
packages/@aws-cdk/runtime-values/lib/rtv.ts
TypeScript
ClassDeclaration
class CreateTagController { async handle(req: Request, res: Response) { const { name } = req.body; const createTagService = new CreateTagService(); const tag = await createTagService.execute(name); return res.json(tag); } }
okalil/nlwvaloriza-node
server/src/controllers/CreateTagController.ts
TypeScript
MethodDeclaration
async handle(req: Request, res: Response) { const { name } = req.body; const createTagService = new CreateTagService(); const tag = await createTagService.execute(name); return res.json(tag); }
okalil/nlwvaloriza-node
server/src/controllers/CreateTagController.ts
TypeScript
ArrowFunction
(props): number => props.width
srg-kostyrko/qspider
libs/aero/src/aero-layout-container.tsx
TypeScript
ArrowFunction
(props): number => props.height
srg-kostyrko/qspider
libs/aero/src/aero-layout-container.tsx
TypeScript
ArrowFunction
({ backgroundImage }): string => (backgroundImage ? `url("${backgroundImage}")` : 'none')
srg-kostyrko/qspider
libs/aero/src/aero-layout-container.tsx
TypeScript
ArrowFunction
({ image }): string => image
srg-kostyrko/qspider
libs/aero/src/aero-layout-container.tsx
TypeScript
ArrowFunction
({ children }) => { const manager = useGameManager(); const layout = useAeroLayout(); const resources = useResources(); const upArrow = layout.scrollUI.upArrowImage ? resources.get(layout.scrollUI.upArrowImage).url : defaultUpArrow; const { width: upArrowWidth, height: upArrowHeight } = hooks.useImageSize(upArrow); const downArrow = layout.scrollUI.downArrowImage ? resources.get(layout.scrollUI.downArrowImage).url : defaultDownArrow; const { width: downArrowWidth, height: downArrowHeight } = hooks.useImageSize(downArrow); const style = { '--up-arrow': layout.scrollUI.hideArrows ? '' : `url("${upArrow}")`, '--up-arrow-width': upArrowWidth + 'px', '--up-arrow-height': upArrowHeight + 'px', '--down-arrow': layout.scrollUI.hideArrows ? '' : `url("${downArrow}")`, '--down-arrow-width': downArrowWidth + 'px', '--down-arrow-height': downArrowHeight + 'px', '--scroll-padding': layout.scrollUI.hideArrows ? '0' : `${Math.max(upArrowWidth, downArrowWidth) + 3}px`, } as React.CSSProperties; return ( <AeroPlayerWrapper> <AeroPlayerBlock width={manager.currentGame?.aero?.width || 800} height={manager.currentGame?.aero?.height || 600} backgroundImage={layout.playerUI?.backImage ? resources.get(layout.playerUI?.backImage).url : defaultBackground} style={style} > <AeroStylesheet /> <AeroStatsPanel /> <AeroMainPanel /> <AeroObjectsPanel /> {layout.playerUI?.intergratedActions ? null : <AeroActionsPanel />} <AeroUserInputPanel /> <AeroViewImagePanel /> {layout.playerUI?.topImage ? ( <AeroPlayerForeground image={resources.get(layout.playerUI?.topImage).url} />
srg-kostyrko/qspider
libs/aero/src/aero-layout-container.tsx
TypeScript
FunctionDeclaration
async function apiDir(dir:string):Promise<void> { const api = fs.readdirSync(`src/${dir}`) for (let i = 0; i < api.length; i++) { if (!api[i].endsWith('map') && !api[i].endsWith('.ts')) { if (fs.lstatSync(`src/${dir}/${api[i]}`).isDirectory()) { await apiDir(`${dir}/${api[i]}`) } else { const path = `./${dir}/${api[i]}` ;(await import(path)).default(app) } } } }
TheUnusAnnusArchive/TUAA-Backend
src/main.ts
TypeScript
ArrowFunction
async() => { app.use('/node_modules', express.static('node_modules')) app.get('/docs/tsconfig.json', handle404) app.use('/docs', express.static('src/docs')) app.all('*', cors()) app.use('/userdata', express.static('src/db/userdata')) await apiDir('api') async function apiDir(dir:string):Promise<void> { const api = fs.readdirSync(`src/${dir}`) for (let i = 0; i < api.length; i++) { if (!api[i].endsWith('map') && !api[i].endsWith('.ts')) { if (fs.lstatSync(`src/${dir}/${api[i]}`).isDirectory()) { await apiDir(`${dir}/${api[i]}`) } else { const path = `./${dir}/${api[i]}` ;(await import(path)).default(app) } } } } app.all('*', handle404) app.all('*', handle500) app.listen(parseInt(process.env.PORT) || 1024, () => { console.log('Server Started') }) }
TheUnusAnnusArchive/TUAA-Backend
src/main.ts
TypeScript
ArrowFunction
() => { console.log('Server Started') }
TheUnusAnnusArchive/TUAA-Backend
src/main.ts
TypeScript
InterfaceDeclaration
export interface TestDescribeInterface<Input = ObjectInterface> { data: Input; templates: { default: PripravaDescriptionInterface; mode: PripravaDescriptionInterface; }; settingModes: GetSettingModesOutputInterface; }
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
InterfaceDeclaration
export interface TestInputInterface<Class, Data> { operator: Class; data: Data; }
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
TypeAliasDeclaration
// COMMON export type TestInterface<Class, Environment> = ( input: TestInputInterface<Class, Environment>, ) => void;
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
TypeAliasDeclaration
export type TestDataInterface = Array<{ title: string; expected: unknown; template: PripravaTemplateInterface; settings?: PripravaInputSettingsInterface; }>;
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
TypeAliasDeclaration
// OPERATORS export type TestOperatorListInterface = typeof TemplateParser | typeof IfOperatorParser | typeof ForOperatorParser;
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
TypeAliasDeclaration
export type TestOperatorInterface = TestInterface< TestOperatorListInterface, { environment: ObjectInterface, tests: { is: TestDataInterface, clear: TestDataInterface, parse: TestDataInterface, }, } >;
said-m/priprava
__tests__/parsers/operators/utils/interfaces.ts
TypeScript
ArrowFunction
({ icon, placeholder, name, value, onChange, onBlur, inputStatus, type, errorMessage, }: InputProps) => { return ( <InputView type={type} icon={icon} name={name} placeholder={placeholder} value={value} onChange={onChange} onBlur={onBlur} inputStatus={inputStatus} errorMessage={errorMessage} />
octo-technology/Tezos-Land-FA2-NFT-Boilerplate
src/frontend/src/app/App.components/Input/Input.controller.tsx
TypeScript
TypeAliasDeclaration
type InputProps = { icon?: string placeholder: string name?: string value?: string | number onChange: any onBlur: any inputStatus?: 'success' | 'error' type: string errorMessage?: string }
octo-technology/Tezos-Land-FA2-NFT-Boilerplate
src/frontend/src/app/App.components/Input/Input.controller.tsx
TypeScript
ArrowFunction
(url: string) => /^[a-z0-9\-]+$/i.test(url)
AbdelzaherMuhammed/baramistan-new
public/admin/tinymce/modules/tinymce/src/core/main/ts/init/ContentCss.ts
TypeScript
ArrowFunction
(editor: Editor): string[] => { const contentCss = Settings.getContentCss(editor); const skinUrl = editor.editorManager.baseURL + '/skins/content'; const suffix = editor.editorManager.suffix; const contentCssFile = `content${suffix}.css`; const inline = editor.inline === true; return Arr.map(contentCss, (url) => { if (isContentCssSkinName(url) && !inline) { return `${skinUrl}/${url}/${contentCssFile}`; } else { return editor.documentBaseURI.toAbsolute(url); } }); }
AbdelzaherMuhammed/baramistan-new
public/admin/tinymce/modules/tinymce/src/core/main/ts/init/ContentCss.ts
TypeScript
ArrowFunction
(url) => { if (isContentCssSkinName(url) && !inline) { return `${skinUrl}/${url}/${contentCssFile}`; } else { return editor.documentBaseURI.toAbsolute(url); } }
AbdelzaherMuhammed/baramistan-new
public/admin/tinymce/modules/tinymce/src/core/main/ts/init/ContentCss.ts
TypeScript
ArrowFunction
(editor: Editor) => { editor.contentCSS = editor.contentCSS.concat(getContentCssUrls(editor)); }
AbdelzaherMuhammed/baramistan-new
public/admin/tinymce/modules/tinymce/src/core/main/ts/init/ContentCss.ts
TypeScript
FunctionDeclaration
export function deserializeMeshErrorOrSignal( value: MeshErrorSerialized ): MeshError { switch (value.type) { case 'MeshError': return new MeshError(); case 'MeshTimeoutError': return new MeshTimeoutError(); case 'MeshRegistrationTimeoutError': return new MeshRegistrationTimeoutError(); case 'MeshDuplicateMessageError': return new MeshDuplicateMessageError( value.header as SubjectMessageHeader ); case 'MeshInvocationError': return new MeshInvocationError(value.cause as Error); case 'MeshVoidResponse': return new MeshVoidResponse(); default: return value.ns === MeshSignal.MESH_ERROR_NAMESPACE ? new MeshError() : new MeshSignal(value.ns, value); } }
github1/meshage
src/mesh.ts
TypeScript
FunctionDeclaration
export function toMeshBackendProvision( provided: MeshBackendProvided ): MeshBackendProvision { let provision: MeshBackendProvision; // tslint:disable-next-line:no-any if ((provided as any).backend) { provision = provided as MeshBackendProvision; } else { provision = { backend: provided as MeshBackend, }; } return provision; }
github1/meshage
src/mesh.ts
TypeScript
FunctionDeclaration
export function mesh(meshBackendProvider: MeshBackendProvider): Mesh { const provision: MeshBackendProvision = toMeshBackendProvision( meshBackendProvider() ); const mesh: Mesh = new MeshBase(provision.backend); if (provision.callback) { provision.callback(mesh); } return mesh; }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(value: any) => { ret = value; // tslint:disable-next-line:no-any }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(value: any) => { ret = value; }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
() => {}
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
( meshSubjectHandlerRegistrations: MeshSubjectHandlerRegistration[], subject: string ) => { return [ ...meshSubjectHandlerRegistrations, ...Object.keys(this.handlers[subject]).map( (messageName: string) => this.handlers[subject][messageName] ), ]; }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(messageName: string) => this.handlers[subject][messageName]
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
() => this.allHandlers .filter( (meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration) => { return meshSubjectHandlerRegistration.subject === subject; } ) .reduce( ( isRegistered: boolean, meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration ) => { return meshSubjectHandlerRegistration.registered && isRegistered; }, true )
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration) => { return meshSubjectHandlerRegistration.subject === subject; }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
( isRegistered: boolean, meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration ) => { return meshSubjectHandlerRegistration.registered && isRegistered; }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(resolve: () => void) => setTimeout(resolve, 100)
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
async (err: Error, envelope: SubjectMessageEnvelope) => { if (err) { throw err; } return handler(envelope.message, envelope.header); }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
async () => this.doRegistrations()
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(subscriptionId: string) => { return ( subscriptionId.indexOf(`${subject}-${messageHeader.name}`) === 0 ); }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
async (resolve, reject) => { let responseTimeout: NodeJS.Timer; if (!broadcast && options.wait && options.timeout > 0) { responseTimeout = setTimeout(() => { reject(new MeshTimeoutError()); }, options.timeout); } responsePromise .then((response: T) => { if (responseTimeout) { clearTimeout(responseTimeout); } if (broadcast) { // tslint:disable-next-line:no-any const multiResponse: T[] = ((Array.isArray(response) ? response : [response]) as any as T[]) || []; // tslint:disable-next-line:no-any resolve( multiResponse .map((item: any) => { return MeshSignal.PROCESS_RESPONSE_SYNC( item, true, options.keepSignals ); }) // tslint:disable-next-line:no-any .filter((item: any) => { return item; // tslint:disable-next-line:no-any }) as any as T ); } else { MeshSignal.PROCESS_RESPONSE( response, false, options.keepSignals, resolve, reject ); } }) .catch((err: Error) => { if (responseTimeout) { clearTimeout(responseTimeout); } reject(err); }); }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
() => { reject(new MeshTimeoutError()); }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(response: T) => { if (responseTimeout) { clearTimeout(responseTimeout); } if (broadcast) { // tslint:disable-next-line:no-any const multiResponse: T[] = ((Array.isArray(response) ? response : [response]) as any as T[]) || []; // tslint:disable-next-line:no-any resolve( multiResponse .map((item: any) => { return MeshSignal.PROCESS_RESPONSE_SYNC( item, true, options.keepSignals ); }) // tslint:disable-next-line:no-any .filter((item: any) => { return item; // tslint:disable-next-line:no-any }) as any as T ); } else { MeshSignal.PROCESS_RESPONSE( response, false, options.keepSignals, resolve, reject ); } }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(item: any) => { return MeshSignal.PROCESS_RESPONSE_SYNC( item, true, options.keepSignals ); }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(item: any) => { return item; // tslint:disable-next-line:no-any }
github1/meshage
src/mesh.ts
TypeScript
ArrowFunction
(err: Error) => { if (responseTimeout) { clearTimeout(responseTimeout); } reject(err); }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshSignal { public static readonly MESH_SIGNAL_NAMESPACE: string = 'meshage.signal'; public static readonly MESH_ERROR_NAMESPACE: string = 'meshage.error'; // tslint:disable-next-line:no-any readonly [key: string]: any; // tslint:disable-next-line:no-any constructor( protected readonly namespace: string = MeshSignal.MESH_SIGNAL_NAMESPACE, details: { [key: string]: any } = {} ) { if (details) { // @ts-ignore this.details = details; } } // tslint:disable-next-line:no-any public static PROCESS_RESPONSE_SYNC( response: any, forBroadcast: boolean, keepSignals: boolean ) { // tslint:disable-next-line:no-unnecessary-initializer let ret = undefined; // tslint:disable-next-line:no-any MeshSignal.PROCESS_RESPONSE( response, forBroadcast, keepSignals, (value: any) => { ret = value; // tslint:disable-next-line:no-any }, (value: any) => { ret = value; } ); return ret; } // tslint:disable-next-line:no-any no-empty public static PROCESS_RESPONSE( response: any, forBroadcast: boolean, keepSignals: boolean, // tslint:disable-next-line:no-any resolve: (value: any) => void, // tslint:disable-next-line:no-any no-empty reject: (value: any) => void = () => {} ) { let meshSymbolOrError = MeshSignal.isSignal(response) || MeshSignal.isSignal(response, MeshSignal.MESH_ERROR_NAMESPACE) ? // tslint:disable-next-line:no-unsafe-any deserializeMeshErrorOrSignal(response) : undefined; if (response instanceof MeshSignal) { meshSymbolOrError = response; } if (meshSymbolOrError) { if ( !keepSignals || MeshSignal.isSignal(meshSymbolOrError, MeshSignal.MESH_ERROR_NAMESPACE) ) { if (forBroadcast) { meshSymbolOrError.processResponseMatchForBroadcast(resolve, reject); } else { meshSymbolOrError.processResponseMatch(resolve, reject); } } else { resolve(meshSymbolOrError); } } else { resolve(response); } } // tslint:disable-next-line:no-any private static isSignal(value: any, namespace?: string): boolean { // tslint:disable-next-line:no-unsafe-any return ( value && value.ns && value.ns.startsWith(namespace || MeshSignal.MESH_SIGNAL_NAMESPACE) ); } public serialize(): MeshErrorSerialized { return { ns: this.namespace, type: this.constructor.name }; } // tslint:disable-next-line:no-any protected processResponseMatch( resolve: (value: any) => void, reject: (value: any) => void ) { reject(this); } // tslint:disable-next-line:no-any protected processResponseMatchForBroadcast( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(this); } }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshError extends MeshSignal { // tslint:disable-next-line:no-any constructor(details: { [key: string]: any } = {}) { super(MeshSignal.MESH_ERROR_NAMESPACE, details); } }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshTimeoutError extends MeshError {}
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshRegistrationTimeoutError extends MeshError {}
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshDuplicateMessageError extends MeshError { constructor(public readonly header: SubjectMessageHeader) { super(); } public serialize(): MeshErrorSerialized { return { ...super.serialize(), header: this.header, }; } }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshInvocationError extends MeshError { constructor(public readonly cause: Error) { super(); } public serialize(): MeshErrorSerialized { return { ...super.serialize(), cause: { message: this.cause.message, stack: this.cause.stack }, }; } }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
// tslint:disable-next-line:no-unnecessary-class export class MeshVoidResponse extends MeshSignal { // tslint:disable-next-line:no-any protected processResponseMatch( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(undefined); } // tslint:disable-next-line:no-any protected processResponseMatchForBroadcast( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(undefined); } }
github1/meshage
src/mesh.ts
TypeScript
ClassDeclaration
export class MeshBase implements Mesh { // tslint:disable-next-line:variable-name protected _status: MeshState = 'running'; constructor(private readonly meshPrivate: MeshBackend) {} public get status(): MeshState { return this._status; } public subject(name: string): Subject { return new SubjectBase(name, this.meshPrivate); } public async shutdown(): Promise<void> { this._status = 'stopping'; await this.meshPrivate.shutdown(); this._status = 'stopped'; } }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface Mesh { readonly status: MeshState; subject(name: string): Subject; shutdown(): Promise<void>; }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface MeshBackend { subscriptionIds: string[]; // tslint:disable-next-line:no-any register( subject: string, name: string | ConstructorOf<any>, handler: SubjectMessageHandler<any> ): void; unregister(subject: string): Promise<void>; isRegistered(subject: string): Promise<void>; shutdown(): Promise<void>; // tslint:disable-next-line:no-any send<T>( subject: string, partitionKey: string, message: SubjectMessage, options: SubjectMessageOptions, broadcast: boolean ): Promise<T>; }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface MeshErrorSerializedCause { message: string; stack: string; }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface MeshErrorSerialized { ns: string; // tslint:disable-next-line:no-reserved-keywords type: string; cause?: MeshErrorSerializedCause; // tslint:disable-next-line:no-any header?: any; }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface MeshSubjectHandlerRegistration { subject: string; messageName: string; // tslint:disable-next-line:no-any handler: MessagePrivateBaseMessageHandler; registered: boolean; }
github1/meshage
src/mesh.ts
TypeScript
InterfaceDeclaration
export interface MeshBackendProvision { backend: MeshBackend; callback?(mesh: Mesh); }
github1/meshage
src/mesh.ts
TypeScript
TypeAliasDeclaration
export type MeshState = 'running' | 'stopping' | 'stopped';
github1/meshage
src/mesh.ts
TypeScript
TypeAliasDeclaration
// tslint:disable-next-line:no-any export type MessagePrivateBaseMessageHandler = ( err: Error, message: SubjectMessageEnvelope ) => Promise<any>;
github1/meshage
src/mesh.ts
TypeScript
TypeAliasDeclaration
// tslint:disable-next-line:no-any export type MeshSubjectHandlers = { [subject: string]: { [name: string]: MeshSubjectHandlerRegistration }; };
github1/meshage
src/mesh.ts
TypeScript
TypeAliasDeclaration
export type MeshBackendProvided = MeshBackend | MeshBackendProvision;
github1/meshage
src/mesh.ts
TypeScript
TypeAliasDeclaration
export type MeshBackendProvider = () => MeshBackendProvided;
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any public static PROCESS_RESPONSE_SYNC( response: any, forBroadcast: boolean, keepSignals: boolean ) { // tslint:disable-next-line:no-unnecessary-initializer let ret = undefined; // tslint:disable-next-line:no-any MeshSignal.PROCESS_RESPONSE( response, forBroadcast, keepSignals, (value: any) => { ret = value; // tslint:disable-next-line:no-any }, (value: any) => { ret = value; } ); return ret; }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any no-empty public static PROCESS_RESPONSE( response: any, forBroadcast: boolean, keepSignals: boolean, // tslint:disable-next-line:no-any resolve: (value: any) => void, // tslint:disable-next-line:no-any no-empty reject: (value: any) => void = () => {} ) { let meshSymbolOrError = MeshSignal.isSignal(response) || MeshSignal.isSignal(response, MeshSignal.MESH_ERROR_NAMESPACE) ? // tslint:disable-next-line:no-unsafe-any deserializeMeshErrorOrSignal(response) : undefined; if (response instanceof MeshSignal) { meshSymbolOrError = response; } if (meshSymbolOrError) { if ( !keepSignals || MeshSignal.isSignal(meshSymbolOrError, MeshSignal.MESH_ERROR_NAMESPACE) ) { if (forBroadcast) { meshSymbolOrError.processResponseMatchForBroadcast(resolve, reject); } else { meshSymbolOrError.processResponseMatch(resolve, reject); } } else { resolve(meshSymbolOrError); } } else { resolve(response); } }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any private static isSignal(value: any, namespace?: string): boolean { // tslint:disable-next-line:no-unsafe-any return ( value && value.ns && value.ns.startsWith(namespace || MeshSignal.MESH_SIGNAL_NAMESPACE) ); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public serialize(): MeshErrorSerialized { return { ns: this.namespace, type: this.constructor.name }; }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any protected processResponseMatch( resolve: (value: any) => void, reject: (value: any) => void ) { reject(this); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any protected processResponseMatchForBroadcast( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(this); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public serialize(): MeshErrorSerialized { return { ...super.serialize(), header: this.header, }; }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public serialize(): MeshErrorSerialized { return { ...super.serialize(), cause: { message: this.cause.message, stack: this.cause.stack }, }; }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any protected processResponseMatch( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(undefined); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any protected processResponseMatchForBroadcast( resolve: (value: any) => void, reject: (value: any) => void ) { resolve(undefined); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public subject(name: string): Subject { return new SubjectBase(name, this.meshPrivate); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public async shutdown(): Promise<void> { this._status = 'stopping'; await this.meshPrivate.shutdown(); this._status = 'stopped'; }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public async isRegistered(subject: string): Promise<void> { let attempts = 300; const hasSubscription = () => this.allHandlers .filter( (meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration) => { return meshSubjectHandlerRegistration.subject === subject; } ) .reduce( ( isRegistered: boolean, meshSubjectHandlerRegistration: MeshSubjectHandlerRegistration ) => { return meshSubjectHandlerRegistration.registered && isRegistered; }, true ); while (attempts > 0 && !hasSubscription()) { if (hasSubscription()) { return; } else { attempts--; if (attempts === 0) { throw new MeshRegistrationTimeoutError(); } else { await new Promise<void>((resolve: () => void) => setTimeout(resolve, 100) ); } } } }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any public register( subject: string, name: string | ConstructorOf<any>, handler: SubjectMessageHandler<any> ): void { this.handlers[subject] = this.handlers[subject] || {}; const strName: string = typeof name === 'string' ? name : name.name; // tslint:disable-next-line:no-any const messagePrivateBaseMessageHandler: MessagePrivateBaseMessageHandler = async (err: Error, envelope: SubjectMessageEnvelope) => { if (err) { throw err; } return handler(envelope.message, envelope.header); }; this.handlers[subject][strName] = { subject, messageName: strName, handler: messagePrivateBaseMessageHandler, registered: false, }; setTimeout(async () => this.doRegistrations(), 1); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any public async send<T>( subject: string, partitionKey: string, message: SubjectMessage, options: SubjectMessageOptions, broadcast: boolean ): Promise<T> { // tslint:disable-next-line:no-parameter-reassignment options = options || {}; options.additionalHeaderData = options.additionalHeaderData || {}; const messageHeader: SubjectMessageHeader = { ...options.additionalHeaderData, uid: v4(), subject, // tslint:disable-next-line:no-unsafe-any name: options.additionalHeaderData.name || message.name || message.constructor.name, partitionKey, }; const messageEnvelope: SubjectMessageEnvelope = { header: messageHeader, message, }; // tslint:disable-next-line:no-parameter-reassignment options = options || {}; if (options.wait === undefined) { options.wait = true; } // tslint:disable-next-line:no-any let responsePromise: Promise<T> = Promise.resolve( MESH_VOID_RESPONSE as any as T ); if (partitionKey && !broadcast) { const candidateSubscriptionIds: string[] = this.subscriptionIds.filter( (subscriptionId: string) => { return ( subscriptionId.indexOf(`${subject}-${messageHeader.name}`) === 0 ); } ); if (candidateSubscriptionIds.length > 0) { const subscriptionId = new HashRing(candidateSubscriptionIds).get( partitionKey ); if (subscriptionId.indexOf(this.instanceId) === -1) { // the subscriptionId here is the backends subscription id, not the logical subject name responsePromise = this.doSend( subscriptionId, messageEnvelope, options, false ); } else { responsePromise = this.invokeHandler(messageEnvelope); } } } else { responsePromise = this.doSend( undefined, messageEnvelope, options, broadcast ); } // tslint:disable-next-line:typedef return new Promise(async (resolve, reject) => { let responseTimeout: NodeJS.Timer; if (!broadcast && options.wait && options.timeout > 0) { responseTimeout = setTimeout(() => { reject(new MeshTimeoutError()); }, options.timeout); } responsePromise .then((response: T) => { if (responseTimeout) { clearTimeout(responseTimeout); } if (broadcast) { // tslint:disable-next-line:no-any const multiResponse: T[] = ((Array.isArray(response) ? response : [response]) as any as T[]) || []; // tslint:disable-next-line:no-any resolve( multiResponse .map((item: any) => { return MeshSignal.PROCESS_RESPONSE_SYNC( item, true, options.keepSignals ); }) // tslint:disable-next-line:no-any .filter((item: any) => { return item; // tslint:disable-next-line:no-any }) as any as T ); } else { MeshSignal.PROCESS_RESPONSE( response, false, options.keepSignals, resolve, reject ); } }) .catch((err: Error) => { if (responseTimeout) { clearTimeout(responseTimeout); } reject(err); }); }); }
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public abstract shutdown(): Promise<void>;
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
public abstract unregister(subject: string): Promise<void>;
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
protected abstract doSend<T>( address: string, envelope: SubjectMessageEnvelope, options: SubjectMessageOptions, // tslint:disable-next-line:no-any broadcast: boolean ): Promise<T>;
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
protected abstract doRegistrations(): Promise<void>;
github1/meshage
src/mesh.ts
TypeScript
MethodDeclaration
// tslint:disable-next-line:no-any protected async invokeHandler<T>( message: SubjectMessageEnvelope, callback?: (err?: MeshError, result?: T) => void ): Promise<T> { const localLog: debug.Debugger = log.extend( `invokeHandler.${message.header.subject}.${message.header.name}` ); if (!this.lruCache) { this.lruCache = new LRUCache({ max: 1000, maxAge: 1000 * 60 * 3, }); } if (this.lruCache.has(message.header.uid)) { localLog('Received duplicate message %o', message.header); if (callback) { callback(new MeshDuplicateMessageError(message.header), undefined); return undefined; } else { throw new MeshDuplicateMessageError(message.header); } } else { this.lruCache.set(message.header.uid, undefined); let response: T; let error: MeshSignal; try { // tslint:disable-next-line:no-any if (this.handlers[message.header.subject][PSEUDO_MESSAGE_BEFORE]) { localLog.extend('debug')('before -> %o', message); // tslint:disable-next-line:no-unsafe-any response = await this.handlers[message.header.subject][ PSEUDO_MESSAGE_BEFORE ].handler(undefined, message); } if ( response === undefined && this.handlers[message.header.subject][message.header.name] ) { localLog.extend('debug')('%o', message); // tslint:disable-next-line:no-unsafe-any response = await this.handlers[message.header.subject][ message.header.name ].handler(undefined, message); } } catch (err) { localLog(`Error invoking handler - %o`, message, err); error = new MeshInvocationError(err as Error); if (!callback) { throw error; } } finally { if ( this.handlers[message.header.subject] && this.handlers[message.header.subject][PSEUDO_MESSAGE_AFTER] ) { localLog.extend('debug')('after -> %o', message); // tslint:disable-next-line:no-unsafe-any await this.handlers[message.header.subject][ PSEUDO_MESSAGE_AFTER ].handler(undefined, message); } } if (!response && !error) { error = MESH_VOID_RESPONSE; } if (callback) { callback(error, response); } return response; } }
github1/meshage
src/mesh.ts
TypeScript
FunctionDeclaration
export function generateDefaultColumns<D extends Record<string, unknown>>( headerItem?: D ): Column<D>[] { if (!headerItem) return []; const filteredHeaderItem = Object.keys(headerItem).filter((key) => { if (Array.isArray(headerItem[key]) || typeof headerItem[key] === 'object') return false; return true; }); return filteredHeaderItem.map((key) => { return { accessor: key as keyof D, Header: key, minWidth: 30, maxWidth: 100, aggregate: 'uniqueCount', Aggregated: (cell) => { return <>{cell.value}</>; }, Footer: (data) => { const total = useMemo( () => data.rows.reduce((sum, row) => row.values[key] + sum, 0), [data.rows] ); if (data.state.groupBy?.includes(key)) { return <div>Total: </div>; } return <div> {total}</div>; }, }; }); }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
(key) => { if (Array.isArray(headerItem[key]) || typeof headerItem[key] === 'object') return false; return true; }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
(key) => { return { accessor: key as keyof D, Header: key, minWidth: 30, maxWidth: 100, aggregate: 'uniqueCount', Aggregated: (cell) => { return <>{cell.value}</>; }, Footer: (data) => { const total = useMemo( () => data.rows.reduce((sum, row) => row.values[key] + sum, 0), [data.rows] ); if (data.state.groupBy?.includes(key)) { return <div>Total: </div>; } return <div> {total}</div>; }, }; }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
(cell) => { return <>{cell.value}</>; }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
(data) => { const total = useMemo( () => data.rows.reduce((sum, row) => row.values[key] + sum, 0), [data.rows] ); if (data.state.groupBy?.includes(key)) { return <div>Total: </div>; } return <div> {total}</div>; }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
() => data.rows.reduce((sum, row) => row.values[key] + sum, 0)
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ArrowFunction
(sum, row) => row.values[key] + sum
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
InterfaceDeclaration
export interface HeaderData { key: string; title: string; }
equinor/lighthouse-client
src/packages/Diagrams/src/Visuals/TableVisual/Utils/generateDefaultColumns.tsx
TypeScript
ClassDeclaration
export class SSOIERProblemParser extends Parser { public getMatchPatterns(): string[] { return ['http://ybt.ssoier.cn/problem_show.php*']; } public async parse(url: string, html: string): Promise<Sendable> { const elem = htmlToElement(html); const task = new TaskBuilder('SSOIER').setUrl(url); const container = elem.querySelector('td.pcontent'); task.setName(container.querySelector('h3').textContent); const limitsStr = container.querySelector('font').textContent; task.setTimeLimit(parseInt(/(\d+) ms/.exec(limitsStr)[1], 10)); task.setMemoryLimit(Math.floor(parseInt(/(\d+) KB/.exec(limitsStr)[1], 10) / 1000)); const codeBlocks = container.querySelectorAll('pre'); for (let i = 0; i < codeBlocks.length; i += 2) { const input = codeBlocks[i].textContent.trim(); const output = codeBlocks[i + 1].textContent.trim(); task.addTest(input, output); } return task.build(); } }
pvimal816/competitive-companion
src/parsers/problem/SSOIERProblemParser.ts
TypeScript
MethodDeclaration
public getMatchPatterns(): string[] { return ['http://ybt.ssoier.cn/problem_show.php*']; }
pvimal816/competitive-companion
src/parsers/problem/SSOIERProblemParser.ts
TypeScript
MethodDeclaration
public async parse(url: string, html: string): Promise<Sendable> { const elem = htmlToElement(html); const task = new TaskBuilder('SSOIER').setUrl(url); const container = elem.querySelector('td.pcontent'); task.setName(container.querySelector('h3').textContent); const limitsStr = container.querySelector('font').textContent; task.setTimeLimit(parseInt(/(\d+) ms/.exec(limitsStr)[1], 10)); task.setMemoryLimit(Math.floor(parseInt(/(\d+) KB/.exec(limitsStr)[1], 10) / 1000)); const codeBlocks = container.querySelectorAll('pre'); for (let i = 0; i < codeBlocks.length; i += 2) { const input = codeBlocks[i].textContent.trim(); const output = codeBlocks[i + 1].textContent.trim(); task.addTest(input, output); } return task.build(); }
pvimal816/competitive-companion
src/parsers/problem/SSOIERProblemParser.ts
TypeScript
ArrowFunction
() => { let component: MapViewComponent; let fixture: ComponentFixture<MapViewComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [MapViewComponent] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(MapViewComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }
DMahanth/cQube_Workflow
development/ui/dashboard_ui/education_usecase/client-side/src/app/reports/student-performance/sem-view/sem-view.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ declarations: [MapViewComponent] }) .compileComponents(); }
DMahanth/cQube_Workflow
development/ui/dashboard_ui/education_usecase/client-side/src/app/reports/student-performance/sem-view/sem-view.component.spec.ts
TypeScript
ArrowFunction
() => { fixture = TestBed.createComponent(MapViewComponent); component = fixture.componentInstance; fixture.detectChanges(); }
DMahanth/cQube_Workflow
development/ui/dashboard_ui/education_usecase/client-side/src/app/reports/student-performance/sem-view/sem-view.component.spec.ts
TypeScript