type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ClassDeclaration
export default class MyDocument extends Document { static async getInitialProps(ctx) { const initialProps = await Document.getInitialProps(ctx); return { ...initialProps }; } render() { return ( <Html lang="en"> <Head> {isProduction && ( <> <script async src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACKING_ID}`}
PedroBoni/nirmalyaghosh.com
pages/_document.tsx
TypeScript
MethodDeclaration
static async getInitialProps(ctx) { const initialProps = await Document.getInitialProps(ctx); return { ...initialProps }; }
PedroBoni/nirmalyaghosh.com
pages/_document.tsx
TypeScript
MethodDeclaration
render() { return ( <Html lang="en"> <Head> {isProduction && ( <> <script async src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACKING_ID}`}
PedroBoni/nirmalyaghosh.com
pages/_document.tsx
TypeScript
ArrowFunction
params => params.has('tabLink')
gaoyuan1223m/E-Business-Pin-DuoDuo
src/app/home/components/home-container/home-container.component.ts
TypeScript
ArrowFunction
params => params.get('tabLink')
gaoyuan1223m/E-Business-Pin-DuoDuo
src/app/home/components/home-container/home-container.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-home-container', templateUrl: './home-container.component.html', styleUrls: ['./home-container.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) export class HomeContainerComponent implements OnInit { topMenus$: Observable<TopMenu[]>; selectedTabLink$: Observable<string>; ngOnInit(): void { this.topMenus$ = this.service.getTabs(); this.selectedTabLink$ = this.activatedRoute.firstChild.paramMap.pipe( filter(params => params.has('tabLink')), map(params => params.get('tabLink')) ); } handleTabSelected(topMenu: TopMenu) { this.router.navigate(['home', topMenu.link]); } constructor( private router: Router, // 路由服务,用于路由跳转 private service: HomeService, private activatedRoute: ActivatedRoute // 当前激活路由,用于路由参数获取 ) { } }
gaoyuan1223m/E-Business-Pin-DuoDuo
src/app/home/components/home-container/home-container.component.ts
TypeScript
MethodDeclaration
ngOnInit(): void { this.topMenus$ = this.service.getTabs(); this.selectedTabLink$ = this.activatedRoute.firstChild.paramMap.pipe( filter(params => params.has('tabLink')), map(params => params.get('tabLink')) ); }
gaoyuan1223m/E-Business-Pin-DuoDuo
src/app/home/components/home-container/home-container.component.ts
TypeScript
MethodDeclaration
handleTabSelected(topMenu: TopMenu) { this.router.navigate(['home', topMenu.link]); }
gaoyuan1223m/E-Business-Pin-DuoDuo
src/app/home/components/home-container/home-container.component.ts
TypeScript
ArrowFunction
() => { beforeEach(() => cy.visit('/')); it('should display welcome message', () => { // Custom command example, see `../support/commands.ts` file cy.login('[email protected]', 'myPassword'); // Function helper example, see `../support/app.po.ts` file getGreeting().contains('Welcome four-fours'); }); }
seadonk/kablamo
apps/four-fours-e2e/src/integration/app.spec.ts
TypeScript
ArrowFunction
() => cy.visit('/')
seadonk/kablamo
apps/four-fours-e2e/src/integration/app.spec.ts
TypeScript
ArrowFunction
() => { // Custom command example, see `../support/commands.ts` file cy.login('[email protected]', 'myPassword'); // Function helper example, see `../support/app.po.ts` file getGreeting().contains('Welcome four-fours'); }
seadonk/kablamo
apps/four-fours-e2e/src/integration/app.spec.ts
TypeScript
ClassDeclaration
@Component({ computed: {...mapState({activeAccount: 'account', app: 'app'})}, components: { LineChart, TransactionList, }, }) export class MonitorDashBoardTs extends Vue { app: AppInfo activeAccount: StoreAccount updateAnimation = '' networkStatusList = networkStatusConfig page = 1 formatNumber = formatNumber get wallet() { return this.activeAccount.wallet } get NetworkProperties() { return this.app.networkProperties } }
Coordinate-Cat/nem2-desktop-wallet
src/views/monitor/monitor-dashboard/MonitorDashBoardTs.ts
TypeScript
ArrowFunction
<T>( promises: Iterable<Promise<T>> ): Subscription<T[], T> => fromPromise(Promise.all(promises)).transform(mapcat((x: T[]) => x))
Bnaya/umbrella
packages/rstream/src/from/promises.ts
TypeScript
ArrowFunction
(x: T[]) => x
Bnaya/umbrella
packages/rstream/src/from/promises.ts
TypeScript
ArrowFunction
() => { let component: TestPage; let fixture: ComponentFixture<TestPage>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [TestPage], imports: [IonicModule.forRoot()] }).compileComponents(); fixture = TestBed.createComponent(TestPage); component = fixture.componentInstance; fixture.detectChanges(); })); it('should create', () => { expect(component).toBeTruthy(); }); }
dehesselle/mycoradar
app/src/app/corona-profile/corona_test/test-page.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ declarations: [TestPage], imports: [IonicModule.forRoot()] }).compileComponents(); fixture = TestBed.createComponent(TestPage); component = fixture.componentInstance; fixture.detectChanges(); }
dehesselle/mycoradar
app/src/app/corona-profile/corona_test/test-page.component.spec.ts
TypeScript
FunctionDeclaration
/* ---------------------------------------------------------------------------- * Helper functions * ------------------------------------------------------------------------- */ /** * Compute whether the header is hidden * * If the user scrolls past a certain threshold, the header can be hidden when * scrolling down, and shown when scrolling up. * * @param options - Options * * @returns Toggle observable */ function isHidden({ viewport$ }: WatchOptions): Observable<boolean> { if (!feature("header.autohide")) return of(false) /* Compute direction and turning point */ const direction$ = viewport$ .pipe( map(({ offset: { y } }) => y), bufferCount(2, 1), map(([a, b]) => [a < b, b] as const), distinctUntilKeyChanged(0) ) /* Compute whether header should be hidden */ const hidden$ = combineLatest([viewport$, direction$]) .pipe( filter(([{ offset }, [, y]]) => Math.abs(y - offset.y) > 100), map(([, [direction]]) => direction), distinctUntilChanged() ) /* Compute threshold for hiding */ const search$ = watchToggle("search") return combineLatest([viewport$, search$]) .pipe( map(([{ offset }, search]) => offset.y > 400 && !search), distinctUntilChanged(), switchMap(active => active ? hidden$ : of(false)), startWith(false) ) }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
FunctionDeclaration
/* ---------------------------------------------------------------------------- * Functions * ------------------------------------------------------------------------- */ /** * Watch header * * @param el - Header element * @param options - Options * * @returns Header observable */ export function watchHeader( el: HTMLElement, options: WatchOptions ): Observable<Header> { return defer(() => { const styles = getComputedStyle(el) return of( styles.position === "sticky" || styles.position === "-webkit-sticky" ) }) .pipe( combineLatestWith(watchElementSize(el), isHidden(options)), map(([sticky, { height }, hidden]) => ({ height: sticky ? height : 0, sticky, hidden })), distinctUntilChanged((a, b) => ( a.sticky === b.sticky && a.height === b.height && a.hidden === b.hidden )), shareReplay(1) ) }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
FunctionDeclaration
/** * Mount header * * This function manages the different states of the header, i.e. whether it's * hidden or rendered with a shadow. This depends heavily on the main area. * * @param el - Header element * @param options - Options * * @returns Header component observable */ export function mountHeader( el: HTMLElement, { header$, main$ }: MountOptions ): Observable<Component<Header>> { return defer(() => { const push$ = new Subject<Main>() push$ .pipe( distinctUntilKeyChanged("active"), combineLatestWith(header$) ) .subscribe(([{ active }, { hidden }]) => { if (active) el.setAttribute("data-md-state", hidden ? "hidden" : "shadow") else el.removeAttribute("data-md-state") }) /* Link to main area */ main$.subscribe(push$) /* Create and return component */ return header$ .pipe( takeUntil(push$.pipe(takeLast(1))), map(state => ({ ref: el, ...state })) ) }) }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
({ offset: { y } }) => y
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([a, b]) => [a < b, b] as const
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([{ offset }, [, y]]) => Math.abs(y - offset.y) > 100
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([, [direction]]) => direction
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([{ offset }, search]) => offset.y > 400 && !search
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
active => active ? hidden$ : of(false)
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
() => { const styles = getComputedStyle(el) return of( styles.position === "sticky" || styles.position === "-webkit-sticky" ) }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([sticky, { height }, hidden]) => ({ height: sticky ? height : 0, sticky, hidden })
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
(a, b) => ( a.sticky === b.sticky && a.height === b.height && a.hidden === b.hidden )
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
() => { const push$ = new Subject<Main>() push$ .pipe( distinctUntilKeyChanged("active"), combineLatestWith(header$) ) .subscribe(([{ active }, { hidden }]) => { if (active) el.setAttribute("data-md-state", hidden ? "hidden" : "shadow") else el.removeAttribute("data-md-state") }) /* Link to main area */ main$.subscribe(push$) /* Create and return component */ return header$ .pipe( takeUntil(push$.pipe(takeLast(1))), map(state => ({ ref: el, ...state })) ) }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
([{ active }, { hidden }]) => { if (active) el.setAttribute("data-md-state", hidden ? "hidden" : "shadow") else el.removeAttribute("data-md-state") }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
ArrowFunction
state => ({ ref: el, ...state })
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
InterfaceDeclaration
/* ---------------------------------------------------------------------------- * Types * ------------------------------------------------------------------------- */ /** * Header */ export interface Header { height: number /* Header visible height */ sticky: boolean /* Header stickyness */ hidden: boolean /* Header is hidden */ }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
InterfaceDeclaration
/* ---------------------------------------------------------------------------- * Helper types * ------------------------------------------------------------------------- */ /** * Watch options */ interface WatchOptions { viewport$: Observable<Viewport> /* Viewport observable */ }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
InterfaceDeclaration
/** * Mount options */ interface MountOptions { viewport$: Observable<Viewport> /* Viewport observable */ header$: Observable<Header> /* Header observable */ main$: Observable<Main> /* Main area observable */ }
109383670/mkdocs-material
src/assets/javascripts/components/header/_/index.ts
TypeScript
MethodDeclaration
async fn() { const res = createMockResponse(); res.body = "hello"; const expected = { status: 200, message: "OK", headers: new Headers({ "cache-control": "max-age=0", "content-type": "text/plain; charset=utf-8", "content-length": "5", }), body: "hello", }; assertEquals(res.inspect(), expected); }
JohannLai/doa
test/response/inspect_test.ts
TypeScript
ArrowFunction
highScores => highScores.map(e => HighscoreDto.fromEntity(e))
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
ArrowFunction
e => HighscoreDto.fromEntity(e)
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
ClassDeclaration
@Injectable() export class HighscoresRepository { private entity: string = "high_scores"; constructor( @InjectRepository(HighScoreEntity) private readonly repo: Repository<HighScoreEntity>, ) {} public async allBySeasonIdRaw( seasonId: string, currentSeasonId: string, limit: number = 0, ) { const take = limit ? limit : seasonId === currentSeasonId ? 50 : 20; // Using joins to fetch logotypeUrl that related to the bots team. const highScores = await this.repo .createQueryBuilder(this.entity) .select(this.entity) .where("highScores.seasonId = :seasonId", { seasonId: seasonId }) .leftJoinAndSelect( BotRegistrationsEntity, "bot", "high_scores.botName = bot.botName", ) .leftJoinAndSelect(TeamsEntity, "teams", "bot.team = teams.id") .orderBy("score", "DESC") .limit(take) .execute(); return highScores; } public getBotScore(botName: string) { return this.repo .find({ where: [{ botName }], }) .then(highScores => highScores.map(e => HighscoreDto.fromEntity(e))); } public async getBestBotScore(botName: string, seasonId: string) { return await this.repo .createQueryBuilder(this.entity) .select(this.entity) .where( "high_scores.botName = :botName AND high_scores.seasonId = :seasonId", { botName, seasonId, }, ) .getOne(); } public async updateBestBotScore( botName: string, seasonId: string, score: number, ) { await this.repo .createQueryBuilder() .update(this.entity) .set({ score }) .where("botName = :botName AND seasonId = :seasonId", { botName, seasonId, }) .execute(); } public async create(dto: HighscoreDto): Promise<HighscoreDto> { return this.repo.save(dto); } public async delete(botName: string) { return await this.repo .createQueryBuilder() .delete() .from(this.entity) .where("botName = :botName", { botName }) .execute(); } }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public async allBySeasonIdRaw( seasonId: string, currentSeasonId: string, limit: number = 0, ) { const take = limit ? limit : seasonId === currentSeasonId ? 50 : 20; // Using joins to fetch logotypeUrl that related to the bots team. const highScores = await this.repo .createQueryBuilder(this.entity) .select(this.entity) .where("highScores.seasonId = :seasonId", { seasonId: seasonId }) .leftJoinAndSelect( BotRegistrationsEntity, "bot", "high_scores.botName = bot.botName", ) .leftJoinAndSelect(TeamsEntity, "teams", "bot.team = teams.id") .orderBy("score", "DESC") .limit(take) .execute(); return highScores; }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public getBotScore(botName: string) { return this.repo .find({ where: [{ botName }], }) .then(highScores => highScores.map(e => HighscoreDto.fromEntity(e))); }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public async getBestBotScore(botName: string, seasonId: string) { return await this.repo .createQueryBuilder(this.entity) .select(this.entity) .where( "high_scores.botName = :botName AND high_scores.seasonId = :seasonId", { botName, seasonId, }, ) .getOne(); }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public async updateBestBotScore( botName: string, seasonId: string, score: number, ) { await this.repo .createQueryBuilder() .update(this.entity) .set({ score }) .where("botName = :botName AND seasonId = :seasonId", { botName, seasonId, }) .execute(); }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public async create(dto: HighscoreDto): Promise<HighscoreDto> { return this.repo.save(dto); }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
MethodDeclaration
public async delete(botName: string) { return await this.repo .createQueryBuilder() .delete() .from(this.entity) .where("botName = :botName", { botName }) .execute(); }
alvalabs/hack-day-team-nice
backend/src/db/repositories/highscores.repository.ts
TypeScript
ArrowFunction
filter => ({ type: SET_PREVIOUS_QUERIES_FILTER, payload: { filter } })
hardforkio/conquery
frontend/src/js/previous-queries/filter/actions.ts
TypeScript
ArrowFunction
(value: any) => isUndefined(value) || isUndefined(value.isValid) ? { isValid: !isUndefined(value), value } : value
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(value, index) => ( <Component defaultValue={value}
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(index: number) => { return (value: RawParam): void => { this.setState( ({ values }: State) => ({ values: values.map((svalue, sindex) => (sindex === index) ? value : svalue )}), () => { const { values } = this.state; const { onChange } = this.props; onChange && onChange({ isValid: values.reduce((result: boolean, { isValid }) => result && isValid, true), value: values.map(({ value }) => value) }); } ); }; }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(value: RawParam): void => { this.setState( ({ values }: State) => ({ values: values.map((svalue, sindex) => (sindex === index) ? value : svalue )}), () => { const { values } = this.state; const { onChange } = this.props; onChange && onChange({ isValid: values.reduce((result: boolean, { isValid }) => result && isValid, true), value: values.map(({ value }) => value) }); } ); }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
({ values }: State) => ({ values: values.map((svalue, sindex) => (sindex === index) ? value : svalue )})
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(svalue, sindex) => (sindex === index) ? value : svalue
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
() => { const { values } = this.state; const { onChange } = this.props; onChange && onChange({ isValid: values.reduce((result: boolean, { isValid }) => result && isValid, true), value: values.map(({ value }) => value) }); }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(): void => { this.setState(({ values }: State, { type: { sub } }: Props) => { const value = getInitValue(sub as TypeDef); return { values: values.concat({ isValid: !isUndefined(value), value }) }; }); }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
({ values }: State, { type: { sub } }: Props) => { const value = getInitValue(sub as TypeDef); return { values: values.concat({ isValid: !isUndefined(value), value }) }; }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
(): void => { this.setState(({ values }: State) => ({ values: values.slice(0, values.length - 1) })); }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ArrowFunction
({ values }: State) => ({ values: values.slice(0, values.length - 1) })
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ClassDeclaration
class Vector extends React.PureComponent<Props, State> { state: State = { Component: null, values: [] }; static getDerivedStateFromProps ({ defaultValue: { value = [] }, isDisabled, type: { sub, type } }: Props, prevState: State): Partial<State> | null { if (type === prevState.type) { return null; } const values: Array<RawParam> = isDisabled || prevState.values.length === 0 ? value.map((value: any) => isUndefined(value) || isUndefined(value.isValid) ? { isValid: !isUndefined(value), value } : value ) : prevState.values; return { Component: findComponent(sub as TypeDef), type, values }; } render () { const { className, isDisabled, onEnter, style, type, withLabel } = this.props; const { Component, values } = this.state; const subType = type.sub as TypeDef; if (!Component) { return null; } return ( <Bare className={className} style={style} > {values.map((value, index) => ( <Component defaultValue={value} isDisabled={isDisabled} key={index} label={`${index}: ${subType.type}`} onChange={this.onChange(index)} onEnter={onEnter} type={subType} withLabel={withLabel} /> ))}
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
TypeAliasDeclaration
type Props = BareProps & WithTranslation;
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
TypeAliasDeclaration
type State = { Component: React.ComponentType<BareProps> | null, type?: string, values: Array<RawParam> };
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
MethodDeclaration
static getDerivedStateFromProps ({ defaultValue: { value = [] }, isDisabled, type: { sub, type } }: Props, prevState: State): Partial<State> | null { if (type === prevState.type) { return null; } const values: Array<RawParam> = isDisabled || prevState.values.length === 0 ? value.map((value: any) => isUndefined(value) || isUndefined(value.isValid) ? { isValid: !isUndefined(value), value } : value ) : prevState.values; return { Component: findComponent(sub as TypeDef), type, values }; }
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
MethodDeclaration
render () { const { className, isDisabled, onEnter, style, type, withLabel } = this.props; const { Component, values } = this.state; const subType = type.sub as TypeDef; if (!Component) { return null; } return ( <Bare className={className} style={style} > {values.map((value, index) => ( <Component defaultValue={value} isDisabled={isDisabled} key={index} label={`${index}: ${subType.type}`} onChange={this.onChange(index)} onEnter={onEnter} type={subType} withLabel={withLabel} /> ))}
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
MethodDeclaration
t('Add item')
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
MethodDeclaration
t('Remove item')
darwinia-network/web-wallet
packages/ui-params/src/Param/Vector.tsx
TypeScript
ClassDeclaration
export declare class HttpRequest { private httpClient; constructor(baseURL: string); get(path: string, params?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>; post(path: string, body?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>; request(method: Method, path: string, params?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>; }
AllanMangeni/Tatum-crypto-exchange
node_modules/@binance-chain/javascript-sdk/lib/utils/request.d.ts
TypeScript
MethodDeclaration
get(path: string, params?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>;
AllanMangeni/Tatum-crypto-exchange
node_modules/@binance-chain/javascript-sdk/lib/utils/request.d.ts
TypeScript
MethodDeclaration
post(path: string, body?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>;
AllanMangeni/Tatum-crypto-exchange
node_modules/@binance-chain/javascript-sdk/lib/utils/request.d.ts
TypeScript
MethodDeclaration
request(method: Method, path: string, params?: any, opts?: AxiosRequestConfig): Promise<{ result: any; status: number; }>;
AllanMangeni/Tatum-crypto-exchange
node_modules/@binance-chain/javascript-sdk/lib/utils/request.d.ts
TypeScript
FunctionDeclaration
function sortNoop (): number { return 0; }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
FunctionDeclaration
function sortLinks (a: SortOption, b: SortOption): number { return !!a.isUnreachable !== !!b.isUnreachable ? a.isUnreachable ? 1 : -1 : 0; }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
FunctionDeclaration
function expandLinked (input: LinkOption[]): LinkOption[] { const valueRelay = input.map(({ value }) => value); return input.reduce((result: LinkOption[], entry): LinkOption[] => { result.push(entry); return entry.linked ? result.concat( expandLinked(entry.linked).map((child): LinkOption => { child.genesisHashRelay = entry.genesisHash; child.isChild = true; child.valueRelay = valueRelay; return child; }) ) : result; }, []); }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
FunctionDeclaration
function expandEndpoint (t: TFunction, { dnslink, genesisHash, homepage, info, isChild, isDisabled, isUnreachable, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly: boolean, withSort: boolean): LinkOption[] { const base = { genesisHash, homepage, info, isChild, isDisabled, isUnreachable, paraId, teleport, text }; const result = Object .entries(providers) .filter((_, index) => !firstOnly || index === 0) .map(([host, value], index): LinkOption => ({ ...base, dnslink: index === 0 ? dnslink : undefined, isLightClient: value.startsWith('light://'), isRelay: false, textBy: value.startsWith('light://') ? t('lightclient.experimental', 'light client (experimental)', { ns: 'apps-config' }) : t('rpc.hosted.via', 'via {{host}}', { ns: 'apps-config', replace: { host } }), value })); if (linked) { const last = result[result.length - 1]; const options: LinkOption[] = []; linked .sort(withSort ? sortLinks : sortNoop) .filter(({ paraId }) => paraId) .forEach((o) => options.push(...expandEndpoint(t, o, firstOnly, withSort)) ); last.isRelay = true; last.linked = options; } return expandLinked(result); }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
FunctionDeclaration
export function expandEndpoints (t: TFunction, input: EndpointOption[], firstOnly: boolean, withSort: boolean): LinkOption[] { return input .sort(withSort ? sortLinks : sortNoop) .reduce((all: LinkOption[], e) => all.concat(expandEndpoint(t, e, firstOnly, withSort)), []); }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(result: LinkOption[], entry): LinkOption[] => { result.push(entry); return entry.linked ? result.concat( expandLinked(entry.linked).map((child): LinkOption => { child.genesisHashRelay = entry.genesisHash; child.isChild = true; child.valueRelay = valueRelay; return child; }) ) : result; }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(child): LinkOption => { child.genesisHashRelay = entry.genesisHash; child.isChild = true; child.valueRelay = valueRelay; return child; }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(_, index) => !firstOnly || index === 0
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
([host, value], index): LinkOption => ({ ...base, dnslink: index === 0 ? dnslink : undefined, isLightClient: value.startsWith('light://'), isRelay: false, textBy: value.startsWith('light://') ? t('lightclient.experimental', 'light client (experimental)', { ns: 'apps-config' }) : t('rpc.hosted.via', 'via {{host}}', { ns: 'apps-config', replace: { host } }), value })
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
({ paraId }) => paraId
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(o) => options.push(...expandEndpoint(t, o, firstOnly, withSort))
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(all: LinkOption[], e) => all.concat(expandEndpoint(t, e, firstOnly, withSort))
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
InterfaceDeclaration
interface SortOption { isUnreachable?: boolean; }
AndreasGassmann/apps
packages/apps-config/src/endpoints/util.ts
TypeScript
ArrowFunction
(t) => { if (t.name === 'rlpx') { t.options.bootnodes = t.options.bootnodes || this.common.bootstrapNodes() return new RlpxServer({ config: this, ...t.options }) } else { return new Libp2pServer({ config: this, ...t.options }) } }
alexfmpe/ethereumjs-vm
packages/client/lib/config.ts
TypeScript
ClassDeclaration
export class Config { // Initialize Common with an explicit 'chainstart' HF set until // hardfork awareness is implemented within the library // Also a fix for https://github.com/ethereumjs/ethereumjs-vm/issues/757 public static readonly COMMON_DEFAULT = new Common({ chain: 'mainnet', hardfork: 'chainstart' }) public static readonly SYNCMODE_DEFAULT = 'full' public static readonly LIGHTSERV_DEFAULT = false public static readonly DATADIR_DEFAULT = `./datadir` public static readonly TRANSPORTS_DEFAULT = ['rlpx:port=30303', 'libp2p'] public static readonly RPC_DEFAULT = false public static readonly RPCPORT_DEFAULT = 8545 public static readonly RPCADDR_DEFAULT = 'localhost' public static readonly LOGLEVEL_DEFAULT = 'info' public static readonly MINPEERS_DEFAULT = 2 public static readonly MAXPEERS_DEFAULT = 25 public readonly common: Common public readonly logger: Logger public readonly syncmode: string public readonly vm?: VM public readonly lightserv: boolean public readonly datadir: string public readonly transports: string[] public readonly rpc: boolean public readonly rpcport: number public readonly rpcaddr: string public readonly loglevel: string public readonly minPeers: number public readonly maxPeers: number public readonly servers: (RlpxServer | Libp2pServer)[] = [] constructor(options: ConfigOptions = {}) { // TODO: map chainParams (and lib/util.parseParams) to new Common format this.common = options.common ?? Config.COMMON_DEFAULT this.syncmode = options.syncmode ?? Config.SYNCMODE_DEFAULT this.vm = options.vm this.lightserv = options.lightserv ?? Config.LIGHTSERV_DEFAULT this.transports = options.transports ?? Config.TRANSPORTS_DEFAULT this.datadir = options.datadir ?? Config.DATADIR_DEFAULT this.rpc = options.rpc ?? Config.RPC_DEFAULT this.rpcport = options.rpcport ?? Config.RPCPORT_DEFAULT this.rpcaddr = options.rpcaddr ?? Config.RPCADDR_DEFAULT this.loglevel = options.loglevel ?? Config.LOGLEVEL_DEFAULT this.minPeers = options.minPeers ?? Config.MINPEERS_DEFAULT this.maxPeers = options.maxPeers ?? Config.MAXPEERS_DEFAULT if (options.logger) { if (options.loglevel) { throw new Error('Config initialization with both logger and loglevel options not allowed') } // Logger option takes precedence this.logger = options.logger } else { this.logger = getLogger({ loglevel: this.loglevel }) } if (options.servers) { if (options.transports) { throw new Error( 'Config initialization with both servers and transports options not allowed' ) } // Servers option takes precedence this.servers = options.servers } else { // Otherwise parse transports from transports option this.servers = parseTransports(this.transports).map((t) => { if (t.name === 'rlpx') { t.options.bootnodes = t.options.bootnodes || this.common.bootstrapNodes() return new RlpxServer({ config: this, ...t.options }) } else { return new Libp2pServer({ config: this, ...t.options }) } }) } } /** * Returns the directory for storing the client chain data * based on syncmode and selected chain (subdirectory of 'datadir') */ getChainDataDirectory(): string { const networkDirName = this.common.chainName() const chainDataDirName = this.syncmode === 'light' ? 'lightchain' : 'chain' const dataDir = `${this.datadir}/${networkDirName}/${chainDataDirName}` return dataDir } /** * Returns the directory for storing the client state data * based selected chain (subdirectory of 'datadir') */ getStateDataDirectory(): string { const networkDirName = this.common.chainName() const dataDir = `${this.datadir}/${networkDirName}/state` return dataDir } }
alexfmpe/ethereumjs-vm
packages/client/lib/config.ts
TypeScript
InterfaceDeclaration
export interface ConfigOptions { /** * Specify the chain and hardfork by passing a Common instance. * * Default: chain 'mainnet' and hardfork 'chainstart' */ common?: Common /** * Synchronization mode ('full' or 'light') * * Default: 'full' */ syncmode?: string /** * Provide a custom VM instance to process blocks * * Default: VM instance created by client */ vm?: VM /** * Serve light peer requests * * Default: `false` */ lightserv?: boolean /** * Root data directory for the blockchain */ datadir?: string /** * Network transports ('rlpx' and/or 'libp2p') * * Default: `['rlpx:port=30303', 'libp2p']` */ transports?: string[] /** * Transport servers (RLPx or Libp2p) * Use `transports` option, only used for testing purposes * * Default: servers created from `transports` option */ servers?: (RlpxServer | Libp2pServer)[] /** * Enable the JSON-RPC server * * Default: false */ rpc?: boolean /** * HTTP-RPC server listening port * * Default: 8545 */ rpcport?: number /** * HTTP-RPC server listening interface */ rpcaddr?: string /** * Logging verbosity * * Choices: ['debug', 'info', 'warn', 'error', 'off'] * Default: 'info' */ loglevel?: string /** * A custom winston logger can be provided * if setting logging verbosity is not sufficient * * Default: Logger with loglevel 'info' */ logger?: Logger /** * Number of peers needed before syncing * * Default: `2` */ minPeers?: number /** * Maximum peers allowed * * Default: `25` */ maxPeers?: number }
alexfmpe/ethereumjs-vm
packages/client/lib/config.ts
TypeScript
MethodDeclaration
/** * Returns the directory for storing the client chain data * based on syncmode and selected chain (subdirectory of 'datadir') */ getChainDataDirectory(): string { const networkDirName = this.common.chainName() const chainDataDirName = this.syncmode === 'light' ? 'lightchain' : 'chain' const dataDir = `${this.datadir}/${networkDirName}/${chainDataDirName}` return dataDir }
alexfmpe/ethereumjs-vm
packages/client/lib/config.ts
TypeScript
MethodDeclaration
/** * Returns the directory for storing the client state data * based selected chain (subdirectory of 'datadir') */ getStateDataDirectory(): string { const networkDirName = this.common.chainName() const dataDir = `${this.datadir}/${networkDirName}/state` return dataDir }
alexfmpe/ethereumjs-vm
packages/client/lib/config.ts
TypeScript
ClassDeclaration
@Component({ selector: 'ng-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'angular'; }
StarApps03/AppsStars
angular/src/app/app.component.ts
TypeScript
FunctionDeclaration
// 时间复杂度:O(n) // 空间复杂度:O(1) export function climbStairs(n: number): number { console.time('爬楼梯'); if(n <= 2) return n; let step0 = 1; let step1 = 1; for(let i = 2; i <= n; i++) { const temp = step0; step0 = step1; step1 = step0 + temp; } console.timeEnd('爬楼梯'); return step1; }
lotosv2010/Learning-algorithm
src/leetcode/70/index.ts
TypeScript
ClassDeclaration
export class Setup { @ApiProperty() game_id: number; @ApiPropertyOptional() variant_id: number; @ApiProperty() selector_value: number; @ApiProperty() name: string; }
GlukKazan/DagazServer
src/interfaces/setup.interface.ts
TypeScript
ArrowFunction
_ => Promise.resolve({ data: {} })
moattarwork/Action.Teams.SendMessage
__mocks__/request-promise.ts
TypeScript
ArrowFunction
t => { const obj: any = {}; const found: any = 1; const wanted: any = 1; const notWanted: any = 1; const fn: (stuff: any) => void = () => {}; const expectedError: Error = new Error(); const eventEmitter: EventEmitter = new EventEmitter(); const pattern: RegExp | string | { [key: string]: RegExp } = 'pattern'; const message = 'message'; const extra = { todo: false, skip: 'skip', diagnostic: true, extra_stuff: false, }; t.ok(obj, message, extra); t.ok(obj, message); t.ok(obj); t.true(obj); t.assert(obj); t.notOk(obj, message, extra); t.notOk(obj, message); t.notOk(obj); t.false(obj); t.assertNot(obj); t.error(expectedError, message, extra); t.error(expectedError, message); t.error(expectedError); t.ifErr(expectedError); t.ifError(expectedError); t.emits(eventEmitter, 'event', message, extra); t.emits(eventEmitter, 'event', message); t.emits(eventEmitter, 'event'); t.matchSnapshot(found, message, extra); t.matchSnapshot(found, message); t.matchSnapshot(found); t.throws(fn, expectedError, message, extra); t.throws(fn, expectedError, message); t.throws(fn, expectedError); t.throws(fn, message); t.throws(fn, expectedError, extra); t.throws(); t.throw(fn, message); t.doesNotThrow(fn, message, extra); t.doesNotThrow(fn, message); t.doesNotThrow(fn); t.doesNotThrow(); t.notThrow(fn, message); t.expectUncaughtException(fn, expectedError, message, extra); t.expectUncaughtException(fn, expectedError, message); t.expectUncaughtException(fn, expectedError); t.expectUncaughtException(fn); t.equal(found, wanted, message, extra); t.equal(found, wanted, message); t.equal(found, wanted); t.equals(found, wanted); t.isEqual(found, wanted); t.is(found, wanted); t.strictEqual(found, wanted); t.strictEquals(found, wanted); t.strictIs(found, wanted); t.isStrict(found, wanted); t.isStrictly(found, wanted); t.notEqual(found, notWanted, message, extra); t.notEqual(found, notWanted, message); t.notEqual(found, notWanted); t.inequal(found, notWanted); t.notEqual(found, notWanted); t.notEquals(found, notWanted); t.notStrictEqual(found, notWanted); t.notStrictEquals(found, notWanted); t.isNotEqual(found, notWanted); t.isNot(found, notWanted); t.doesNotEqual(found, notWanted); t.isInequal(found, notWanted); t.same(found, wanted, message, extra); t.same(found, wanted, message); t.same(found, wanted); t.equivalent(found, wanted); t.looseEqual(found, wanted); t.looseEquals(found, wanted); t.deepEqual(found, wanted); t.deepEquals(found, wanted); t.isLoose(found, wanted); t.looseIs(found, wanted); t.notSame(found, notWanted, message, extra); t.notSame(found, notWanted, message); t.notSame(found, notWanted); t.inequivalent(found, notWanted); t.looseInequal(found, notWanted); t.notDeep(found, notWanted); t.deepInequal(found, notWanted); t.notLoose(found, notWanted); t.looseNot(found, notWanted); t.strictSame(found, wanted, message, extra); t.strictSame(found, wanted, message); t.strictSame(found, wanted); t.strictEquivalent(found, wanted); t.strictDeepEqual(found, wanted); t.sameStrict(found, wanted); t.deepIs(found, wanted); t.isDeeply(found, wanted); t.isDeep(found, wanted); t.strictDeepEquals(found, wanted); t.strictNotSame(found, notWanted, message, extra); t.strictNotSame(found, notWanted, message); t.strictNotSame(found, notWanted); t.strictInequivalent(found, notWanted); t.strictDeepInequal(found, notWanted); t.notSameStrict(found, notWanted); t.deepNot(found, notWanted); t.notDeeply(found, notWanted); t.strictDeepInequals(found, notWanted); t.notStrictSame(found, notWanted); t.hasStrict(found, pattern, message, extra); t.hasStrict(found, pattern, message); t.hasStrict(found, pattern); t.match(found, pattern, message, extra); t.match(found, pattern, message); t.match(found, pattern); t.has(found, pattern); t.hasFields(found, pattern); t.matches(found, pattern); t.similar(found, pattern); t.like(found, pattern); t.isLike(found, pattern); t.includes(found, pattern); t.include(found, pattern); t.contains(found, pattern); t.notMatch(found, pattern, message, extra); t.notMatch(found, pattern, message); t.notMatch(found, pattern); t.dissimilar(found, pattern); t.unsimilar(found, pattern); t.notSimilar(found, pattern); t.unlike(found, pattern); t.isUnlike(found, pattern); t.notLike(found, pattern); t.isNotLike(found, pattern); t.doesNotHave(found, pattern); t.isNotSimilar(found, pattern); t.isDissimilar(found, pattern); t.type(new Date(), 'object', message, extra); t.type(new Date(), 'object', message); t.type(new Date(), 'object'); t.isa(new Date(), 'Date'); t.isA(new Date(), Date); }
AISS-2021-L9-G02/DefinitelyTyped
types/tap/tap-tests.ts
TypeScript
ArrowFunction
async t => { const wanted: any = 1; const expectedError: Error = new Error(); const message = 'message'; const extra = { todo: false, skip: 'skip', diagnostic: true, extra_stuff: false, }; const promise: Promise<any> = Promise.resolve(1); const promiseProvider: () => Promise<void> = () => Promise.resolve(); await t.rejects(promise, expectedError, message, extra); await t.rejects(promise, expectedError, message); await t.rejects(promise, expectedError); await t.rejects(promise, message, extra); await t.rejects(promise, message); await t.rejects(promise); await t.rejects(promiseProvider, expectedError, message, extra); await t.rejects(promiseProvider, expectedError, message); await t.rejects(promiseProvider, expectedError); await t.rejects(promiseProvider, message, extra); await t.rejects(promiseProvider, message); await t.rejects(promiseProvider); await t.resolves(promise, message, extra); await t.resolves(promise, message); await t.resolves(promise); await t.resolves(promiseProvider, message, extra); await t.resolves(promiseProvider, message); await t.resolves(promiseProvider); await t.resolveMatch(promise, wanted, message, extra); await t.resolveMatch(promise, wanted, message); await t.resolveMatch(promise, wanted); await t.resolveMatch(promiseProvider, wanted, message, extra); await t.resolveMatch(promiseProvider, wanted, message); await t.resolveMatch(promiseProvider, wanted); await t.resolveMatchSnapshot(promise, message, extra); await t.resolveMatchSnapshot(promise, message); await t.resolveMatchSnapshot(promise); await t.resolveMatchSnapshot(promiseProvider, message, extra); await t.resolveMatchSnapshot(promiseProvider, message); await t.resolveMatchSnapshot(promiseProvider); }
AISS-2021-L9-G02/DefinitelyTyped
types/tap/tap-tests.ts
TypeScript
ArrowFunction
t => { t.pass(); }
AISS-2021-L9-G02/DefinitelyTyped
types/tap/tap-tests.ts
TypeScript
ArrowFunction
t => { const cwd = t.testdir({ 'demo.jpg': Buffer.from('a jpg'), 'package.json': JSON.stringify({ name: 'pj', }), src: { 'index.js': 'yay', hardlinked: t.fixture('link', '../target'), softlinked: t.fixture('symlink', '../target'), }, target: {}, }); t.notEqual(cwd, topLevelDir); t.equals(cwd, t.testdirName); }
AISS-2021-L9-G02/DefinitelyTyped
types/tap/tap-tests.ts
TypeScript
ArrowFunction
t => { // fairly infrequent vs testdir() sugar t.fixture('dir', {}); t.fixture('file', 'content'); t.fixture('file', Buffer.from('content')); // much more common, as sugar does not exist t.fixture('link', 'target'); t.fixture('symlink', 'target'); }
AISS-2021-L9-G02/DefinitelyTyped
types/tap/tap-tests.ts
TypeScript
ArrowFunction
() => { this.emit(Events.ADBREAK_STATE_PLAYING); }
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript
ArrowFunction
() => { if (this.currentAdBreak) { this.emit(Events.ADBREAK_STATE_TIMEUPDATE, { currentTime: this.currentAdBreak.freewheelSlot.getPlayheadTime(), } as IAdBreakTimeUpdateEventData); } }
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript
ArrowFunction
() => { this.emit(Events.ADBREAK_STATE_BUFFERING); }
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript
ArrowFunction
cuepoint => { if (cuepoint === AdBreakType.PREROLL) { this.adContext.addTemporalSlot('preroll', this.sdk.ADUNIT_PREROLL, 0); } else if (cuepoint === AdBreakType.POSTROLL) { this.adContext.addTemporalSlot( 'postroll', this.sdk.ADUNIT_POSTROLL, freewheel.duration, ); } else { const time = cuepoint as number; this.adContext.addTemporalSlot( `midroll-${time}`, this.sdk.ADUNIT_MIDROLL, time, ); } }
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript
ArrowFunction
(slot, index) => ({ sequenceIndex: index, id: slot.getCustomId(), type: slot.getAdUnit(), startsAt: slot.getTimePosition(), duration: slot.getTotalDuration(), hasBeenWatched: false, maxAds: slot.getAdCount(), freewheelSlot: slot, } as IFWAdBreak)
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript
ArrowFunction
adBreak => adBreak.type === AdBreakType.MIDROLL && adBreak.startsAt <= currentTime && adBreak.startsAt > this.prevCurrentTime && !adBreak.hasBeenWatched
JamoDevNich/indigo-player
src/extensions/FreeWheelExtension/FreeWheelExtension.ts
TypeScript