type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
export function unregister() { if ("serviceWorker" in navigator) { navigator.serviceWorker.ready.then(registration => { registration.unregister() }) } }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to t...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { // tslint:disable-next-line console.log( "This web app is being served cache-first by a service " + "worker. To learn more, visit https://bit.ly/CRA-PWA", ) }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
registration => { registration.onupdatefound = () => { const installingWorker = registration.installing if (installingWorker == null) { return } installingWorker.onstatechange = () => { if (installingWorker.state === "installed") { if (navigator.ser...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { const installingWorker = registration.installing if (installingWorker == null) { return } installingWorker.onstatechange = () => { if (installingWorker.state === "installed") { if (navigator.serviceWorker.controller) { // At this poi...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { if (installingWorker.state === "installed") { if (navigator.serviceWorker.controller) { // At this point, the updated precached content has been fetched, // but the previous service worker will still serve the older // content until all client tab...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
error => { // tslint:disable-next-line console.error("Error during service worker registration:", error) }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
response => { // Ensure service worker exists, and that we really are getting a JS file. const contentType = response.headers.get("content-type") if ( response.status === 404 || (contentType != null && contentType.indexOf("javascript") === -1) ) { // No service worker fo...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
registration => { registration.unregister().then(() => { window.location.reload() }) }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { window.location.reload() }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => { // tslint:disable-next-line console.log( "No internet connection found. App is running in offline mode.", ) }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
registration => { registration.unregister() }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
InterfaceDeclaration
interface Config { readonly onSuccess?: (registration: ServiceWorkerRegistration) => void readonly onUpdate?: (registration: ServiceWorkerRegistration) => void }
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
ArrowFunction
() => RequiredValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => CheckboxRequiredValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => EmailValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => MinLengthValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => MaxLengthValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => PatternValidator
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A Directive that adds the `required` validator to any controls marked with the * `required` attribute, via the `NG_VALIDATORS` binding. * * ### Example * * ``` * <input name="fullName" ngModel required> * ``` * * */ @Directive({ selector: ':not([type=checkbox])[required][formControlName],:not([...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A Directive that adds the `required` validator to checkbox controls marked with the * `required` attribute, via the `NG_VALIDATORS` binding. * * ### Example * * ``` * <input type="checkbox" name="active" ngModel required> * ``` * * @experimental */ @Directive({ selector: 'input[type=checkbox][r...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A Directive that adds the `email` validator to controls marked with the * `email` attribute, via the `NG_VALIDATORS` binding. * * ### Example * * ``` * <input type="email" name="email" ngModel email> * <input type="email" name="email" ngModel email="true"> * <input type="email" name="email" ngModel [emai...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A directive which installs the `MinLengthValidator` for any `formControlName`, * `formControl`, or control with `ngModel` that also has a `minlength` attribute. * * */ @Directive({ selector: '[minlength][formControlName],[minlength][formControl],[minlength][ngModel]', providers: [MIN_LENGTH_VALIDATOR], ...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A directive which installs the `MaxLengthValidator` for any `formControlName, * `formControl`, * or control with `ngModel` that also has a `maxlength` attribute. * * */ @Directive({ selector: '[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]', providers: [MAX_LENGTH_VALIDATOR],...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ClassDeclaration
/** * A Directive that adds the `pattern` validator to any controls marked with the * `pattern` attribute, via the `NG_VALIDATORS` binding. Uses attribute value * as the regex to validate Control value against. Follows pattern attribute * semantics; i.e. regex must match entire Control value. * * ### Example * ...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
InterfaceDeclaration
/** * An interface that can be implemented by classes that can act as validators. * * ## Usage * * ```typescript * @Directive({ * selector: '[custom-validator]', * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}] * }) * class CustomValidatorDirective implements Val...
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
InterfaceDeclaration
/** @experimental */ export interface AsyncValidator extends Validator { validate(c: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
InterfaceDeclaration
export interface ValidatorFn { (c: AbstractControl): ValidationErrors|null; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
InterfaceDeclaration
export interface AsyncValidatorFn { (c: AbstractControl): Promise<ValidationErrors|null>|Observable<ValidationErrors|null>; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
TypeAliasDeclaration
/** @experimental */ export type ValidationErrors = { [key: string]: any };
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this.required ? Validators.required(c) : null; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
registerOnValidatorChange(fn: () => void): void { this._onChange = fn; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this.required ? Validators.requiredTrue(c) : null; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this._enabled ? Validators.email(c) : null; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
ngOnChanges(changes: SimpleChanges): void { if ('minlength' in changes) { this._createValidator(); if (this._onChange) this._onChange(); } }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this.minlength == null ? null : this._validator(c); }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
private _createValidator(): void { this._validator = Validators.minLength(parseInt(this.minlength, 10)); }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
ngOnChanges(changes: SimpleChanges): void { if ('maxlength' in changes) { this._createValidator(); if (this._onChange) this._onChange(); } }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this.maxlength != null ? this._validator(c) : null; }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
private _createValidator(): void { this._validator = Validators.maxLength(parseInt(this.maxlength, 10)); }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
ngOnChanges(changes: SimpleChanges): void { if ('pattern' in changes) { this._createValidator(); if (this._onChange) this._onChange(); } }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
validate(c: AbstractControl): ValidationErrors|null { return this._validator(c); }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
MethodDeclaration
private _createValidator(): void { this._validator = Validators.pattern(this.pattern); }
Dok11/angular
packages/forms/src/directives/validators.ts
TypeScript
ArrowFunction
() => { test('Check the INDEX clause of the query builder', async () => { const expr_where: LogicalWhereExpr = { 'travel-sample.callsign': { $like: '%57-59%' } }; const on: IIndexOnParams[] = [{ name: 'travel-sample.callsing' }]; const withExpr: IIndexWithParams = { nodes: ['192.168.1.1:8078', '1...
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
async () => { const expr_where: LogicalWhereExpr = { 'travel-sample.callsign': { $like: '%57-59%' } }; const on: IIndexOnParams[] = [{ name: 'travel-sample.callsing' }]; const withExpr: IIndexWithParams = { nodes: ['192.168.1.1:8078', '192.168.1.1:8079'], defer_build: true, num_replica:...
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => { const run = () => new Query({}, 'travel-sample').index('CREATE', 'travel_index').select('*'); expect(run).toThrow(MultipleQueryTypesException); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => new Query({}, 'travel-sample').index('CREATE', 'travel_index').select('*')
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
async () => { const query = new Query({}, 'travel-sample').index('DROP', 'travel_sample_id_test').usingGSI().build(); expect(query).toStrictEqual('DROP INDEX `travel-sample`.`travel_sample_id_test` USING GSI'); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
async () => { const run = () => new Query({}, 'travel-sample').select().on([{ name: 'test', sort: 'DESC' }]); expect(run).toThrow(IndexParamsOnExceptions); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => new Query({}, 'travel-sample').select().on([{ name: 'test', sort: 'DESC' }])
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
async () => { const run = () => new Query({}, 'travel-sample').index('CREATE', 'index-*&'); expect(run).toThrow( 'Valid GSI index names can contain any of the following characters: A-Z a-z 0-9 # _, and must start with a letter, [A-Z a-z]', ); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => new Query({}, 'travel-sample').index('CREATE', 'index-*&')
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => { const run = () => new Query({}, 'travel-sample').select('*').index('CREATE', 'travel_index'); expect(run).toThrow(MultipleQueryTypesException); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => new Query({}, 'travel-sample').select('*').index('CREATE', 'travel_index')
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => { const run = () => new Query({}, 'travel-sample').select('*').usingGSI(); expect(run).toThrow(IndexParamsUsingGSIExceptions); }
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
ArrowFunction
() => new Query({}, 'travel-sample').select('*').usingGSI()
Cervantes007/test-rel
__test__/query-index.spec.ts
TypeScript
FunctionDeclaration
/** * Create a tagged union from a record mapping tags to value types, along with associated * variant constructors, type predicates and `match` function. * * @param record A record mapping tags to value types. The actual values of the record don't * matter; they're just used in the types of the resulting tagged u...
MainShayne233/unionize
src/index.ts
TypeScript
FunctionDeclaration
export function unionize<Record extends MultiValueRec<TagProp>, TagProp extends string = 'tag'>( record: Record, config?: { tag: TagProp }, ): Unionized<Record, MultiValueVariants<Record, TagProp>, TagProp>;
MainShayne233/unionize
src/index.ts
TypeScript
FunctionDeclaration
export function unionize<Record>(record: Record, config?: { value?: string; tag?: string }) { const { value: valProp = undefined, tag: tagProp = 'tag' } = config || {}; const creators = {} as Creators<Record, any, any>; for (const tag in record) { creators[tag] = ((value: any = {}) => valProp ? { [tag...
MainShayne233/unionize
src/index.ts
TypeScript
FunctionDeclaration
function evalMatch(variant: any, cases: any, defaultCase = cases.default): any { const handler = cases[variant[tagProp]]; return handler ? handler(valProp ? variant[valProp] : variant) : defaultCase(variant); }
MainShayne233/unionize
src/index.ts
TypeScript
FunctionDeclaration
function match<A>(first: any, second?: any): A { return second ? evalMatch(first, second) : (variant: any) => evalMatch(variant, first); }
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(value: any = {}) => valProp ? { [tagProp]: tag, [valProp]: value } : { ...value, [tagProp]: tag }
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(variant: any) => variant[tagProp] === tag
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(variant: any) => evalMatch(variant, first)
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
<A>(x: A) => x
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(first: any, second?: any) => second ? evalMatch(first, second, identity) : (variant: any) => evalMatch(variant, first, identity)
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(variant: any) => evalMatch(variant, first, identity)
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(x: any) => x
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
(val: any) => { throw new Error(`Attempted to cast ${val[tagProp]} as ${expectedTag}`); }
MainShayne233/unionize
src/index.ts
TypeScript
ArrowFunction
<T>() => (undefined as any) as T
MainShayne233/unionize
src/index.ts
TypeScript
InterfaceDeclaration
export interface UnionTypes<Record, TaggedRecord> { _Tags: keyof TaggedRecord; _Record: Record; _Union: TaggedRecord[keyof TaggedRecord]; }
MainShayne233/unionize
src/index.ts
TypeScript
InterfaceDeclaration
export interface UnionExtensions<Record, TaggedRecord> { is: Predicates<TaggedRecord>; as: Casts<Record, TaggedRecord[keyof TaggedRecord]>; match: Match<Record, TaggedRecord[keyof TaggedRecord]>; transform: Transform<Record, TaggedRecord[keyof TaggedRecord]>; }
MainShayne233/unionize
src/index.ts
TypeScript
InterfaceDeclaration
export interface Match<Record, Union> { <A>(cases: MatchCases<Record, Union, A>): (variant: Union) => A; <A>(variant: Union, cases: MatchCases<Record, Union, A>): A; }
MainShayne233/unionize
src/index.ts
TypeScript
InterfaceDeclaration
export interface Transform<Record, Union> { (cases: TransformCases<Record, Union>): (variant: Union) => Union; (variant: Union, cases: TransformCases<Record, Union>): Union; }
MainShayne233/unionize
src/index.ts
TypeScript
InterfaceDeclaration
// Forbid usage of default property; reserved for pattern matching. export interface NoDefaultProp { default?: never; }
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type Unionized<Record, TaggedRecord, TagProp extends string> = UnionTypes< Record, TaggedRecord > & Creators<Record, TaggedRecord, TagProp> & UnionExtensions<Record, TaggedRecord>;
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type TagsOf<U extends UnionTypes<any, any>> = U['_Tags'];
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type RecordOf<U extends UnionTypes<any, any>> = U['_Record'];
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type UnionOf<U extends UnionTypes<any, any>> = U['_Union'];
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type Creators<Record, TaggedRecord, TagProp extends string> = { [T in keyof Record]: {} extends Required<UnTagged<Record[T], TagProp>> ? ((value?: {}) => TaggedRecord[keyof TaggedRecord]) : ((value: UnTagged<Record[T], TagProp>) => TaggedRecord[keyof TaggedRecord]) };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type Predicates<TaggedRecord> = { [T in keyof TaggedRecord]: ( variant: TaggedRecord[keyof TaggedRecord], ) => variant is TaggedRecord[T] };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type Casts<Record, Union> = { [T in keyof Record]: (variant: Union) => Record[T] };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type Cases<Record, A> = { [T in keyof Record]: (value: Record[T]) => A };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type MatchCases<Record, Union, A> = | Cases<Record, A> & NoDefaultProp | Partial<Cases<Record, A>> & { default: (variant: Union) => A };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type TransformCases<Record, Union> = Partial< { [T in keyof Record]: (value: Record[T]) => Union } >;
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type MultiValueVariants<Record extends MultiValueRec<TagProp>, TagProp extends string> = { [T in keyof Record]: Record[T] extends { [_ in TagProp]: T } // does record already has tag with correct value? ? Record[T] // yes: return as is : { [_ in TagProp]: T } & Record[T] // no: decorate with tag };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type UnTagged<Record, TagProp extends string = 'tag'> = Record extends any ? Pick<Record, Exclude<keyof Record, TagProp>> : never;
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type SingleValueVariants< Record extends SingleValueRec, TagProp extends string, ValProp extends string > = { [T in keyof Record]: { [_ in TagProp]: T } & { [_ in ValProp]: Record[T] } };
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type SingleValueRec = NoDefaultRec<{} | null>;
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type MultiValueRec<TagProp extends string> = NoDefaultRec< { [tag: string]: any } & { [tag in TagProp]?: never } >;
MainShayne233/unionize
src/index.ts
TypeScript
TypeAliasDeclaration
export type NoDefaultRec<Val> = { [k: string]: Val; } & NoDefaultProp;
MainShayne233/unionize
src/index.ts
TypeScript
ClassDeclaration
/** * Ellipse constructor * @constructor * @memberof Konva * @augments Konva.Shape * @param {Object} config * @param {Object} config.radius defines x and y radius * @@shapeParams * @@nodeParams * @example * var ellipse = new Konva.Ellipse({ * radius : { * x : 50, * y : 50 * }, * fill: 'red'...
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
InterfaceDeclaration
export interface EllipseConfig extends ShapeConfig { radiusX: number; radiusY: number; }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
MethodDeclaration
_sceneFunc(context) { var rx = this.radiusX(), ry = this.radiusY(); context.beginPath(); context.ellipse(0, 0, rx, ry, 0, 0, Math.PI * 2, false); context.closePath(); context.fillStrokeShape(this); }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
MethodDeclaration
getWidth() { return this.radiusX() * 2; }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
MethodDeclaration
getHeight() { return this.radiusY() * 2; }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
MethodDeclaration
setWidth(width) { this.radiusX(width / 2); }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
MethodDeclaration
setHeight(height) { this.radiusY(height / 2); }
reelevant-tech/konva
src/shapes/Ellipse.ts
TypeScript
ArrowFunction
option => option.type === type
RadheTians/digital-bank-ui
src/app/main/customer/tasks/task.detail.component.ts
TypeScript
ArrowFunction
command => defaultCommandOptions.find(option => option.command === command).label
RadheTians/digital-bank-ui
src/app/main/customer/tasks/task.detail.component.ts
TypeScript