type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
() => {
testComponent.nzInputNumberComponent.onModelChange('1.');
fixture.detectChanges();
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(-1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
expect(testComponent.nzInputNumberComponent.downStep('abc', 1)).toBe(-1);
testComponent.min = -Infinity;
fixture.detectChanges();
expect(testComponent.nzInputNumberComponent.downStep('abc', 1)).toBe(-1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
expect(testComponent.nzInputNumberComponent.upStep('abc', 1)).toBe(-1);
testComponent.min = -Infinity;
fixture.detectChanges();
expect(testComponent.nzInputNumberComponent.upStep('abc', 1)).toBe(1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
expect(testComponent.nzInputNumberComponent.getValidValue(undefined)).toBe(undefined);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('0');
expect(testComponent.modelChange).toHaveBeenCalledTimes(2);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('-1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(3);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('-1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(3);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.precision = undefined;
fixture.detectChanges();
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('0');
expect(testComponent.modelChange).toHaveBeenCalledTimes(2);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('-1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(3);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputElement.value).toBe('-1');
expect(testComponent.modelChange).toHaveBeenCalledTimes(3);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.nzInputNumberComponent.onModelChange('123');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
testComponent.nzInputNumberComponent.onModelChange('0');
fixture.detectChanges();
expect(testComponent.value).toBe(0);
expect(testComponent.modelChange).toHaveBeenCalledTimes(2);
expect(testComponent.value).toBe(0);
testComponent.nzInputNumberComponent.onModelChange('-4');
fixture.detectChanges();
expect(testComponent.value).toBe(-1);
expect(testComponent.modelChange).toHaveBeenCalledTimes(3);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.precision = undefined;
testComponent.max = 10;
fixture.detectChanges();
testComponent.nzInputNumberComponent.onModelChange('0.999999');
expect(testComponent.value).toBe(0.999999);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(1.999999);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(0.999999);
testComponent.nzInputNumberComponent.onModelChange('1e-10');
fixture.detectChanges();
expect(testComponent.value).toBe(1e-10);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(1.0000000001);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(1e-10);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.nzInputNumberComponent.onModelChange('0.99');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.nzInputNumberComponent.onModelChange('0.993');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.nzInputNumberComponent.onModelChange('0.999');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.nzInputNumberComponent.onModelChange('0.999');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
testComponent.precisionMode = 'toFixed';
testComponent.nzInputNumberComponent.onModelChange('0.991');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.nzInputNumberComponent.onModelChange('0.999');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
testComponent.nzInputNumberComponent.onModelChange('1.0099');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
testComponent.precisionMode = 'cut';
testComponent.nzInputNumberComponent.onModelChange('0.991');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.nzInputNumberComponent.onModelChange('0.998');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.precisionMode = value => +Number(value).toFixed(2);
testComponent.nzInputNumberComponent.onModelChange('0.991');
fixture.detectChanges();
expect(testComponent.value).toBe(0.99);
testComponent.nzInputNumberComponent.onModelChange('0.998');
fixture.detectChanges();
expect(testComponent.value).toBe(1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
value => +Number(value).toFixed(2) | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.step = 2;
testComponent.max = 10;
fixture.detectChanges();
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(2);
expect(testComponent.modelChange).toHaveBeenCalledTimes(1);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(4);
expect(testComponent.modelChange).toHaveBeenCalledTimes(2);
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(testComponent.value).toBe(2);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture.detectChanges();
expect(testComponent.value).toBe(undefined);
dispatchEvent(inputElement, upArrowEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(1);
dispatchEvent(inputElement, downArrowEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0);
dispatchEvent(inputElement, downArrowEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(-1);
dispatchEvent(inputElement, downArrowEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(-1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture.detectChanges();
expect(testComponent.value).toBe(undefined);
dispatchEvent(inputElement, upArrowCtrlEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0.1);
dispatchEvent(inputElement, downArrowCtrlEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0);
dispatchEvent(inputElement, downArrowCtrlEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(-0.1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture.detectChanges();
expect(testComponent.value).toBe(undefined);
dispatchEvent(inputElement, upArrowMetaEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0.1);
dispatchEvent(inputElement, downArrowMetaEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0);
dispatchEvent(inputElement, downArrowMetaEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(-0.1);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
testComponent.max = 100;
testComponent.min = -100;
fixture.detectChanges();
expect(testComponent.value).toBe(undefined);
dispatchEvent(inputElement, upArrowShiftEvent);
dispatchFakeEvent(inputElement, 'keyup');
fixture.detectChanges();
expect(testComponent.value).toBe(10);
dispatchEvent(inputElement, downArrowShiftEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(0);
dispatchEvent(inputElement, downArrowShiftEvent);
fixture.detectChanges();
expect(testComponent.value).toBe(-10);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
const newFormatter = (v: number) => `${v} %`;
const initValue = 1;
const component = testComponent.nzInputNumberComponent;
fixture.detectChanges();
component.onModelChange(`${initValue}`);
fixture.detectChanges();
testComponent.formatter = newFormatter;
fixture.detectChanges();
expect(inputElement.value).toBe(newFormatter(initValue));
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
(v: number) => `${v} %` | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).toContain('ant-input-number-focused');
dispatchFakeEvent(inputElement, 'blur');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).not.toContain('ant-input-number-focused');
dispatchFakeEvent(downHandler, 'mousedown');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).toContain('ant-input-number-focused');
dispatchFakeEvent(inputElement, 'blur');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).not.toContain('ant-input-number-focused');
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
let fixture: ComponentFixture<NzTestInputNumberFormComponent>;
let testComponent: NzTestInputNumberFormComponent;
let inputNumber: DebugElement;
let upHandler: HTMLElement;
beforeEach(fakeAsync(() => {
fixture = TestBed.createComponent(NzTestInputNumberFormComponent);
fixture.detectChanges();
flush();
fixture.detectChanges();
testComponent = fixture.debugElement.componentInstance;
inputNumber = fixture.debugElement.query(By.directive(NzInputNumberComponent));
upHandler = inputNumber.nativeElement.querySelector('.ant-input-number-handler-up');
}));
it('should be in pristine, untouched, and valid states initially', fakeAsync(() => {
flush();
expect(testComponent.formGroup.valid).toBe(true);
expect(testComponent.formGroup.pristine).toBe(true);
expect(testComponent.formGroup.touched).toBe(false);
}));
it('should set disabled work', fakeAsync(() => {
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(1);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(10);
testComponent.disable();
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(10);
}));
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(NzTestInputNumberFormComponent);
fixture.detectChanges();
flush();
fixture.detectChanges();
testComponent = fixture.debugElement.componentInstance;
inputNumber = fixture.debugElement.query(By.directive(NzInputNumberComponent));
upHandler = inputNumber.nativeElement.querySelector('.ant-input-number-handler-up');
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
flush();
expect(testComponent.formGroup.valid).toBe(true);
expect(testComponent.formGroup.pristine).toBe(true);
expect(testComponent.formGroup.touched).toBe(false);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(1);
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(10);
testComponent.disable();
dispatchFakeEvent(upHandler, 'mousedown');
fixture.detectChanges();
flush();
fixture.detectChanges();
expect(testComponent.formGroup.get('inputNumber')!.value).toBe(10);
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
(value: number) => (value !== null ? `${value}` : '') | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
(value: number) => value | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ClassDeclaration |
@Component({
template: `
<nz-input-number
[(ngModel)]="value"
(ngModelChange)="modelChange($event)"
[nzDisabled]="disabled"
[nzAutoFocus]="autofocus"
[nzSize]="size"
[nzMin]="min"
[nzMax]="max"
[nzPlaceHolder]="placeholder"
[nzStep]="step"
[nzFormatter]="formatter"
[nzParser]="parser"
[nzPrecision]="precision"
[nzPrecisionMode]="precisionMode"
>
</nz-input-number>
`
})
export class NzTestInputNumberBasicComponent {
@ViewChild(NzInputNumberComponent, { static: false }) nzInputNumberComponent: NzInputNumberComponent;
value?: number | string;
autofocus = false;
disabled = false;
min = -1;
max = 1;
size = 'default';
placeholder = 'placeholder';
step = 1;
precision?: number = 2;
precisionMode: 'cut' | 'toFixed' | ((value: number | string, precision?: number) => number);
formatter = (value: number) => (value !== null ? `${value}` : '');
parser = (value: number) => value;
modelChange = jasmine.createSpy('change callback');
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ClassDeclaration |
@Component({
template: `
<form [formGroup]="formGroup">
<nz-input-number formControlName="inputNumber" nzMax="10" nzMin="-10"></nz-input-number>
</form>
`
})
export class NzTestInputNumberFormComponent {
formGroup: FormGroup;
constructor(private formBuilder: FormBuilder) {
this.formGroup = this.formBuilder.group({
inputNumber: [1]
});
}
disable(): void {
this.formGroup.disable();
}
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
MethodDeclaration |
disable(): void {
this.formGroup.disable();
} | Anberm/ng-zorro-antd | components/input-number/input-number.spec.ts | TypeScript |
ArrowFunction |
(value: any) => {
if (value == null) {
return value === undefined ? '[object Undefined]' : '[object Null]';
}
return toString.call(value);
} | ourparentcenter/moleculer-decorators-extended | src/util.ts | TypeScript |
ArrowFunction |
(value: any) => {
const type = typeof value;
return value != null && (type == 'object' || type == 'function');
} | ourparentcenter/moleculer-decorators-extended | src/util.ts | TypeScript |
ArrowFunction |
(object: any, remove: string[]) => {
const newObj = { ...object };
for (const n of remove) {
delete newObj[n];
}
return newObj;
} | ourparentcenter/moleculer-decorators-extended | src/util.ts | TypeScript |
ArrowFunction |
(value: any) => {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
const tag = getTag(value);
return ['[object Function]', '[object AsyncFunction]', '[object GeneratorFunction]', '[object Proxy]'].includes(tag);
} | ourparentcenter/moleculer-decorators-extended | src/util.ts | TypeScript |
FunctionDeclaration | // eslint-disable-next-line @typescript-eslint/no-redeclare -- intentional
export function CursorQueryArgsType<DTO>(
DTOClass: Class<DTO>,
opts: QueryArgsTypeOpts<DTO> = { ...DEFAULT_QUERY_OPTS, pagingStrategy: PagingStrategies.CURSOR },
): StaticCursorQueryArgsType<DTO> {
const F = FilterType(DTOClass);
const S = SortType(DTOClass);
const P = CursorPagingType();
@ArgsType()
class QueryArgs implements Query<DTO> {
static SortType = S;
static FilterType = F;
static PageType = P;
@Field(() => P, {
defaultValue: { first: opts.defaultResultSize ?? DEFAULT_QUERY_OPTS.defaultResultSize },
description: 'Limit or page results.',
})
@ValidateNested()
@Validate(PropertyMax, ['first', opts.maxResultsSize ?? DEFAULT_QUERY_OPTS.maxResultsSize])
@Validate(PropertyMax, ['last', opts.maxResultsSize ?? DEFAULT_QUERY_OPTS.maxResultsSize])
@Type(() => P)
paging?: CursorPagingType;
@Field(() => F, {
defaultValue: !F.hasRequiredFilters ? opts.defaultFilter ?? DEFAULT_QUERY_OPTS.defaultFilter : undefined,
description: 'Specify to filter the records returned.',
nullable: false,
})
@ValidateNested()
@Type(() => F)
filter?: Filter<DTO>;
@Field(() => [S], {
defaultValue: opts.defaultSort ?? DEFAULT_QUERY_OPTS.defaultSort,
description: 'Specify to sort results.',
})
@ValidateNested()
@Type(() => S)
sorting?: SortField<DTO>[];
}
return QueryArgs;
} | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ArrowFunction |
() => P | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ArrowFunction |
() => F | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ArrowFunction |
() => [S] | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ArrowFunction |
() => S | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ClassDeclaration |
@ArgsType()
class QueryArgs implements Query<DTO> {
static SortType = S;
static FilterType = F;
static PageType = P;
@Field(() => P, {
defaultValue: { first: opts.defaultResultSize ?? DEFAULT_QUERY_OPTS.defaultResultSize },
description: 'Limit or page results.',
})
@ValidateNested()
@Validate(PropertyMax, ['first', opts.maxResultsSize ?? DEFAULT_QUERY_OPTS.maxResultsSize])
@Validate(PropertyMax, ['last', opts.maxResultsSize ?? DEFAULT_QUERY_OPTS.maxResultsSize])
@Type(() => P)
paging?: CursorPagingType;
@Field(() => F, {
defaultValue: !F.hasRequiredFilters ? opts.defaultFilter ?? DEFAULT_QUERY_OPTS.defaultFilter : undefined,
description: 'Specify to filter the records returned.',
nullable: false,
})
@ValidateNested()
@Type(() => F)
filter?: Filter<DTO>;
@Field(() => [S], {
defaultValue: opts.defaultSort ?? DEFAULT_QUERY_OPTS.defaultSort,
description: 'Specify to sort results.',
})
@ValidateNested()
@Type(() => S)
sorting?: SortField<DTO>[];
} | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
TypeAliasDeclaration |
export type StaticCursorQueryArgsType<DTO> = StaticQueryType<DTO, StaticCursorPagingType>; | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
TypeAliasDeclaration |
export type CursorQueryArgsType<DTO> = QueryType<DTO, CursorPagingType>; | Kol007/nestjs-query | packages/query-graphql/src/types/query/query-args/cursor-query-args.type.ts | TypeScript |
ArrowFunction |
() => {
let component: WorklistComponent;
let fixture: ComponentFixture<WorklistComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WorklistComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WorklistComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
} | pkysetti/Angular | starterRocket/src/app/worklist/worklist.component.spec.ts | TypeScript |
ArrowFunction |
() => {
TestBed.configureTestingModule({
declarations: [ WorklistComponent ]
})
.compileComponents();
} | pkysetti/Angular | starterRocket/src/app/worklist/worklist.component.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(WorklistComponent);
component = fixture.componentInstance;
fixture.detectChanges();
} | pkysetti/Angular | starterRocket/src/app/worklist/worklist.component.spec.ts | TypeScript |
InterfaceDeclaration | /** 热力图的配置类型定义 */
export interface HeatmapOptions extends PlotOptions, HeatmapLayerOptions {
/**
* 具体的数据
*/
source: HeatmapLayerSourceOptions;
} | antvis/L7Plot | packages/l7plot/src/plots/heatmap/types.ts | TypeScript |
ArrowFunction |
() => {
this.gameLaunched = true;
this.apiClient.emit(stateApi.gameLaunched);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
ArrowFunction |
(resolve) => {
emit('sdk:getUserId');
const handler = (id: string) => {
resolve(id);
RemoveEventHandler('sdk:setUserId', handler);
};
on('sdk:setUserId', handler);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
ArrowFunction |
(id: string) => {
resolve(id);
RemoveEventHandler('sdk:setUserId', handler);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
ClassDeclaration |
@injectable()
export class AppStateService implements ApiContribution, AppContribution {
getId() {
return 'AppStateService';
}
public readonly onStateChange = new SingleEventEmitter<AppStates>();
public readonly onServerDataStateChange = new SingleEventEmitter<ServerDataStates>();
@inject(ApiClient)
protected readonly apiClient: ApiClient;
@inject(LogService)
protected readonly logService: LogService;
private userId: string = '';
protected state: AppStates = AppStates.booting;
protected serverDataState: ServerDataStates = ServerDataStates.checking;
protected gameLaunched: boolean = false;
async boot() {
on('sdk:gameLaunched', () => {
this.gameLaunched = true;
this.apiClient.emit(stateApi.gameLaunched);
});
this.userId = await this.fetchUserId();
this.logService.setUserId(this.userId);
}
getUserId(): string {
return this.userId;
}
isGameLaunched() {
return this.gameLaunched;
}
getState() {
return this.state;
}
getServerDataState() {
return this.serverDataState;
}
@handlesClientEvent(stateApi.ackState)
onAckState() {
this.ackState();
this.apiClient.emit(stateApi.setUserId, this.userId);
if (this.gameLaunched) {
this.apiClient.emit(stateApi.gameLaunched);
}
};
ackState() {
this.apiClient.emit(stateApi.state, this.state);
}
ackServerDataState() {
this.apiClient.emit(stateApi.serverDataState, this.serverDataState);
}
toState(newState: AppStates) {
this.state = newState;
this.onStateChange.emit(newState);
this.ackState();
}
toServerDataState(newServerDataState: ServerDataStates) {
this.serverDataState = newServerDataState;
this.onServerDataStateChange.emit(newServerDataState);
this.ackServerDataState();
}
private fetchUserId(): Promise<string> {
return new Promise((resolve) => {
emit('sdk:getUserId');
const handler = (id: string) => {
resolve(id);
RemoveEventHandler('sdk:setUserId', handler);
};
on('sdk:setUserId', handler);
});
}
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
getId() {
return 'AppStateService';
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
async boot() {
on('sdk:gameLaunched', () => {
this.gameLaunched = true;
this.apiClient.emit(stateApi.gameLaunched);
});
this.userId = await this.fetchUserId();
this.logService.setUserId(this.userId);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
getUserId(): string {
return this.userId;
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
isGameLaunched() {
return this.gameLaunched;
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
getState() {
return this.state;
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
getServerDataState() {
return this.serverDataState;
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
@handlesClientEvent(stateApi.ackState)
onAckState() {
this.ackState();
this.apiClient.emit(stateApi.setUserId, this.userId);
if (this.gameLaunched) {
this.apiClient.emit(stateApi.gameLaunched);
}
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
ackState() {
this.apiClient.emit(stateApi.state, this.state);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
ackServerDataState() {
this.apiClient.emit(stateApi.serverDataState, this.serverDataState);
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
toState(newState: AppStates) {
this.state = newState;
this.onStateChange.emit(newState);
this.ackState();
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
toServerDataState(newServerDataState: ServerDataStates) {
this.serverDataState = newServerDataState;
this.onServerDataStateChange.emit(newServerDataState);
this.ackServerDataState();
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
MethodDeclaration |
private fetchUserId(): Promise<string> {
return new Promise((resolve) => {
emit('sdk:getUserId');
const handler = (id: string) => {
resolve(id);
RemoveEventHandler('sdk:setUserId', handler);
};
on('sdk:setUserId', handler);
});
} | 0x965/fivem | ext/sdk/resources/sdk-root/shell/src/backend/app/app-state-service.ts | TypeScript |
ClassDeclaration |
@EntityRepository(Task)
export class TaskRepository extends Repository<Task> {
async getTasks(filterDto: GetTaskFilterDto, user:User ): Promise<Task[]> {
const { status, search } = filterDto;
const query = this.createQueryBuilder('task');
query.where("task.userId = :userId" , { userId : user.id });
if (status) {
query.andWhere("task.status = :status", { status });
}
if (search) {
query.andWhere("(task.title LIKE :search OR task.description LIKE :search) ", { search: `%${search}%` });
}
const tasks = query.getMany();
return tasks;
}
async createTask (createTaskDto: CreateTaskDto, user:User) : Promise<Task>{
// this.create will mapp the dto
let task = await this.create(createTaskDto);
task.status = TaskStatus.OPEN;
task.user = user;
await task.save();
delete task.user;
return task;
}
} | tnramalho/nestjs-task-management | src/tasks/task.repository.ts | TypeScript |
MethodDeclaration |
async getTasks(filterDto: GetTaskFilterDto, user:User ): Promise<Task[]> {
const { status, search } = filterDto;
const query = this.createQueryBuilder('task');
query.where("task.userId = :userId" , { userId : user.id });
if (status) {
query.andWhere("task.status = :status", { status });
}
if (search) {
query.andWhere("(task.title LIKE :search OR task.description LIKE :search) ", { search: `%${search}%` });
}
const tasks = query.getMany();
return tasks;
} | tnramalho/nestjs-task-management | src/tasks/task.repository.ts | TypeScript |
MethodDeclaration |
async createTask (createTaskDto: CreateTaskDto, user:User) : Promise<Task>{
// this.create will mapp the dto
let task = await this.create(createTaskDto);
task.status = TaskStatus.OPEN;
task.user = user;
await task.save();
delete task.user;
return task;
} | tnramalho/nestjs-task-management | src/tasks/task.repository.ts | TypeScript |
ArrowFunction |
() => {
it('converts text decoration to figma compliant string', () => {
expect(convertTextDecorationToFigma('none')).toBe('NONE');
expect(convertTextDecorationToFigma('underline')).toBe('UNDERLINE');
expect(convertTextDecorationToFigma('line-through')).toBe('STRIKETHROUGH');
expect(convertTextDecorationToFigma('strikethrough')).toBe('STRIKETHROUGH');
});
it('converts non-compliant textDecoration to NONE', () => {
expect(convertTextDecorationToFigma('something')).toBe('NONE');
});
} | CachedaCodes/figma-tokens | src/plugin/figmaTransforms/textDecoration.test.ts | TypeScript |
ArrowFunction |
() => {
expect(convertTextDecorationToFigma('none')).toBe('NONE');
expect(convertTextDecorationToFigma('underline')).toBe('UNDERLINE');
expect(convertTextDecorationToFigma('line-through')).toBe('STRIKETHROUGH');
expect(convertTextDecorationToFigma('strikethrough')).toBe('STRIKETHROUGH');
} | CachedaCodes/figma-tokens | src/plugin/figmaTransforms/textDecoration.test.ts | TypeScript |
ArrowFunction |
() => {
expect(convertTextDecorationToFigma('something')).toBe('NONE');
} | CachedaCodes/figma-tokens | src/plugin/figmaTransforms/textDecoration.test.ts | TypeScript |
ArrowFunction |
() => {
it('converts text decoration to figma compliant string', () => {
expect(convertFigmaToTextDecoration('NONE')).toBe('none');
expect(convertFigmaToTextDecoration('UNDERLINE')).toBe('underline');
expect(convertFigmaToTextDecoration('STRIKETHROUGH')).toBe('line-through');
});
} | CachedaCodes/figma-tokens | src/plugin/figmaTransforms/textDecoration.test.ts | TypeScript |
ArrowFunction |
() => {
expect(convertFigmaToTextDecoration('NONE')).toBe('none');
expect(convertFigmaToTextDecoration('UNDERLINE')).toBe('underline');
expect(convertFigmaToTextDecoration('STRIKETHROUGH')).toBe('line-through');
} | CachedaCodes/figma-tokens | src/plugin/figmaTransforms/textDecoration.test.ts | TypeScript |
ArrowFunction |
(currentStep: string) => {
waited++;
switch (currentStep) {
case "firstStep":
return firstStep;
case "createOrder":
return verificationCodesStep;
case "wait":
return waitStep(waited);
case "verify":
return completedStep;
}
} | DevWithReact/widget | iframe/src/mocks/responses/steps/Wyre/index.ts | TypeScript |
ArrowFunction |
(count: number) => ({
type: "wait",
url: `${BASE_API}/transaction/Wyre/${
count > 60 ? "createOrder" : "wait"
}/WyJuUGxEVGF2djFJaXR6MU9jZVNZTHVRLS0iLDEwMCwiRVVSIiwiQlRDIiwiY3JlZGl0Q2FyZCJd`,
}) | DevWithReact/widget | iframe/src/mocks/responses/steps/Wyre/index.ts | TypeScript |
ClassDeclaration |
export declare class VKontakteButton implements IShareButton {
prop: ShareButtonProp;
constructor(prop: ShareButtonProp);
link(url: string, args?: ShareButtonArgs): string;
count(): Observable<{}>;
} | tusharwalzade216/ngx-sharebuttons | classes/vk.class.d.ts | TypeScript |
MethodDeclaration |
link(url: string, args?: ShareButtonArgs): string; | tusharwalzade216/ngx-sharebuttons | classes/vk.class.d.ts | TypeScript |
MethodDeclaration |
count(): Observable<{}>; | tusharwalzade216/ngx-sharebuttons | classes/vk.class.d.ts | TypeScript |
FunctionDeclaration |
function getFragmentHTML(fragment: DocumentFragment): string {
return [...fragment.childNodes]
// @ts-expect-error
.map(n => n.outerHTML || n.textContent)
.join('');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <br />;
t.is(element.outerHTML, '<br>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<div>
<span />
</div>
);
t.is(element.outerHTML, '<div><span></span></div>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<div>
<span />
<br />
</div>
);
t.is(element.outerHTML, '<div><span></span><br></div>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<div>
{[
<span key={0}>0</span>,
<span key={1}>1</span>
]} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <span>7</span>;
t.is(element.outerHTML, '<span>7</span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<span>
{1}
{2}
{3}
</span> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <span>test</span>;
t.is(element.outerHTML, '<span>test</span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<span>
{'hello'} {'world'}
</span> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <div>{document.createTextNode('Hello')}</div>;
t.is(element.outerHTML, '<div>Hello</div>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<span>
{true}
{false}
</span> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <span>{null}</span>;
t.is(element.outerHTML, '<span></span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <span>{undefined}</span>;
t.is(element.outerHTML, '<span></span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<span>
{0}
{Number.NaN}
</span> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const firstElement = <a href="#first">First</a>;
const secondElement = <a href="#second">Second</a>;
const element = (
<div>
{firstElement}
{secondElement}
</div> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const template = document.createElement('template');
template.innerHTML = 'Hello, <strong>World!</strong> ';
const fragment = template.content;
const element = <div>{fragment}</div>;
t.is(element.outerHTML, '<div>Hello, <strong>World!</strong> </div>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const createElementNSSpy = spy(document, 'createElementNS');
const element = (
<svg>
<text x="20" y="20">
Test
</text>
</svg> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const createElementSpy = spy(document, 'createElement');
const createElementNSSpy = spy(document, 'createElementNS');
const element = (
<div>
<h1>Demo</h1>
<svg>
<text>Test</text>
</svg>
</div>
);
t.truthy(element);
t.true(createElementSpy.calledTwice);
t.true(createElementNSSpy.calledTwice);
t.deepEqual(createElementSpy.firstCall.args, ['h1']);
t.deepEqual(createElementSpy.secondCall.args, ['div']);
const xmlns = 'http://www.w3.org/2000/svg';
t.deepEqual(createElementNSSpy.firstCall.args, [xmlns, 'text']);
t.deepEqual(createElementNSSpy.secondCall.args, [xmlns, 'svg']);
createElementSpy.restore();
createElementNSSpy.restore();
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const setAttributeNS = spy(Element.prototype, 'setAttributeNS');
const element = (
<svg>
<text id="text">Test</text>
<use xlinkHref="#text" />
<use xlink-invalid-attribute="#text" />
</svg> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <span className="a b c" />;
t.is(element.outerHTML, '<span class="a b c"></span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
// @ts-expect-error
const element = <span class="a b c" />;
t.is(element.outerHTML, '<span class="a b c"></span>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const style = {
paddingTop: 10,
width: 200,
height: '200px',
fontSize: 12
};
const element = <span {...{style}} />;
t.is(
element.outerHTML,
'<span style="padding-top: 10px; width: 200px; height: 200px; font-size: 12px;"></span>'
);
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const style = {
'padding-top': 10,
'font-size': 12
};
// @ts-expect-error
const element = <span style={style} />;
t.is(
element.outerHTML,
'<span style="padding-top: 10px; font-size: 12px;"></span>'
);
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const style = {
'--padding-top': 10,
'--myCamelCaseVar': 'red'
};
// @ts-expect-error
const element = <span style={style} />;
t.is(
element.outerHTML,
'<span style="--padding-top: 10; --myCamelCaseVar: red;"></span>'
);
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = (
<a href="video.mp4" id="a" referrerPolicy="no-referrer">
Download
</a> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const element = <label htmlFor="name-input">Full name</label>;
t.is(element.outerHTML, '<label for="name-input">Full name</label>');
} | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
ArrowFunction |
t => {
const input = (
<input disabled={false} /> | TheRealSyler/dom-chef | tests/index.tsx | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.