type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
logoutFetching ? <Icon type='loading'
Intelligent-Systems-Laboratory/cvat
cvat-ui/src/components/header/header.tsx
TypeScript
ArrowFunction
() => { TestPage.connect(); // description of structure is in TestPage Checkers.checkOpt(Optional.some(TestPage.p1), PredicateFind.first(Checkers.isName('p'))); Checkers.checkOpt(Optional.none<SugarElement<Text>>(), PredicateFind.sibling(TestPage.t5, SugarNode.isText)); Checkers.checkOpt(Optional.some(TestPage.s3), PredicateFind.sibling(TestPage.s4, Checkers.isName('span'))); Checkers.checkOpt(Optional.none<SugarElement<HTMLLIElement>>(), PredicateFind.ancestor(TestPage.t4, Checkers.isName('li'))); Checkers.checkOpt(Optional.some(TestPage.container), PredicateFind.ancestor(TestPage.s4, Checkers.isName('div'))); Checkers.checkOpt(Optional.none<SugarElement<HTMLSpanElement>>(), PredicateFind.ancestor(TestPage.s2, Checkers.isName('span'))); Checkers.checkOpt(Optional.some(TestPage.s2), PredicateFind.closest(TestPage.s2, Checkers.isName('span'))); Checkers.checkOpt(Optional.some(TestPage.s2), PredicateFind.descendant(TestPage.p2, Checkers.isName('span'))); Checkers.checkOpt(Optional.some(TestPage.t4), PredicateFind.descendant(TestPage.p2, SugarNode.isText)); Checkers.checkOpt(Optional.none<SugarElement<Text>>(), PredicateFind.child(TestPage.p2, SugarNode.isText)); Checkers.checkOpt(Optional.some(TestPage.t4), PredicateFind.child(TestPage.s3, SugarNode.isText)); Checkers.checkList([ TestPage.p1, TestPage.p3, TestPage.p2 ], PredicateFilter.all(Checkers.isName('p'))); Checkers.checkList([ TestPage.s3, TestPage.s2 ], PredicateFilter.ancestors(TestPage.t4, Checkers.isName('span'))); Checkers.checkList([ TestPage.d1, TestPage.container ], PredicateFilter.ancestors(TestPage.p3, Checkers.isName('div'))); Checkers.checkList([], PredicateFilter.ancestors(TestPage.t4, SugarNode.isText)); Checkers.checkList([ TestPage.s1, TestPage.t3 ], PredicateFilter.siblings(TestPage.t1, Fun.always)); Checkers.checkList([], PredicateFilter.siblings(TestPage.t5, Fun.always)); Checkers.checkList([ TestPage.t1, TestPage.t3 ], PredicateFilter.children(TestPage.p1, SugarNode.isText)); Checkers.checkList([ TestPage.s1 ], PredicateFilter.children(TestPage.p1, Checkers.isName('span'))); Checkers.checkList([], PredicateFilter.children(TestPage.t2, Fun.always)); Checkers.checkList([ TestPage.s1, TestPage.s2, TestPage.s3, TestPage.s4 ], PredicateFilter.descendants(TestPage.container, Checkers.isName('span'))); Checkers.checkList([], PredicateFilter.descendants(TestPage.container, Checkers.isName('blockquote'))); Assert.eq('', true, PredicateExists.any(Checkers.isName('p'))); Assert.eq('', false, PredicateExists.any(Checkers.isName('table'))); Assert.eq('', true, PredicateExists.ancestor(TestPage.t1, Checkers.isName('p'))); Assert.eq('', false, PredicateExists.ancestor(TestPage.p1, Checkers.isName('p'))); Assert.eq('', false, PredicateExists.ancestor(TestPage.t1, Checkers.isName('span'))); Assert.eq('', true, PredicateExists.closest(TestPage.t1, Checkers.isName('p'))); Assert.eq('', true, PredicateExists.closest(TestPage.p1, Checkers.isName('p'))); Assert.eq('', false, PredicateExists.closest(TestPage.t1, Checkers.isName('span'))); Assert.eq('', true, PredicateExists.sibling(TestPage.p2, Checkers.isName('p'))); Assert.eq('', false, PredicateExists.sibling(TestPage.t1, Checkers.isName('p'))); Assert.eq('', true, PredicateExists.child(TestPage.p1, SugarNode.isText)); Assert.eq('', false, PredicateExists.child(TestPage.p2, SugarNode.isText)); Assert.eq('', true, PredicateExists.descendant(TestPage.p2, SugarNode.isText)); Assert.eq('', false, PredicateExists.descendant(TestPage.s1, Checkers.isName('p'))); Remove.remove(TestPage.container); }
Nelyx/tinymce
modules/sugar/src/test/ts/browser/PredicateTest.ts
TypeScript
ArrowFunction
async () => { let dir = await Directory.at("/GameTypes/").fetch(); console.log(dir); }
Serabass/utd
src/app/core/services/electron/sandbox.ts
TypeScript
InterfaceDeclaration
export interface Update { update_id: number message?: Message edited_message?: Message channel_post?: Message edited_channel_post?: Message inline_query?: InlineQuery chosen_inline_result?: ChosenInlineResult callback_query?: CallbackQuery shipping_query?: ShippingQuery pre_checkout_query?: PreCheckoutQuery }
ChalkPE/ng-telegram-bot
src/app/api/update.ts
TypeScript
ClassDeclaration
@Entity() export class Servidor { @ApiProperty() @PrimaryGeneratedColumn() id: number; @ApiProperty() @Column() @IsDefined({ always: true }) @IsString({ always: true }) @MinLength(2, { always: true }) @MaxLength(50, { always: true }) name: string; @ApiProperty() @Column() @IsDefined({ always: true }) @IsString({ always: true }) @MinLength(3, { always: true }) @MaxLength(50, { always: true }) ip: string; @ApiProperty() @Column() @IsDefined({ always: true }) @IsString({ always: true }) @MinLength(3, { always: true }) @MaxLength(250, { always: true }) descricao: string; }
GTAPlayZ/trabalho_5_web
src/servidor/servidor.entity.ts
TypeScript
ClassDeclaration
export class Profile{ constructor( public accountName: string, public address1: string, public address2: string, public city: string, public state: string, public zipCode: string, public realName: string, public email: string, public phone: number ) {} }
bobbydwise1/site-rebuild-ng
src/app/model/profile.model.ts
TypeScript
FunctionDeclaration
export function checkBlobSupport() { try { return !!new Blob() } catch { throw new ExportErrorBlobApiNotSupported() } }
TakumaKira/covid19_scenarios
src/helpers/saveFile.ts
TypeScript
FunctionDeclaration
export function saveFile(content: string, filename: string) { const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }) saveAs(blob, filename) }
TakumaKira/covid19_scenarios
src/helpers/saveFile.ts
TypeScript
ClassDeclaration
export class ExportErrorBlobApiNotSupported extends Error { constructor() { super('Error: when exporting: `Blob()` API is not supported by this browser') } }
TakumaKira/covid19_scenarios
src/helpers/saveFile.ts
TypeScript
ArrowFunction
( { label, mobileListView, groupSwitch, className, onChange, ...props }, externalRef ) => { const id = useId(props.id); const [checked, setChecked] = useState(props.defaultChecked); const value = props.checked != null ? props.checked : checked; const rootClassName = cn(styles.root, { [styles.mobileList]: mobileListView, [styles.groupSwitch]: groupSwitch, className, }); return ( <label htmlFor={id} className={rootClassName}> <input id={id} {
okalenyk/astro-ui
components/inputs/Toggle/Toggle.tsx
TypeScript
InterfaceDeclaration
interface ToggleProps extends React.HTMLProps<HTMLInputElement> { label?: string | undefined; mobileListView?: boolean; groupSwitch?: boolean; }
okalenyk/astro-ui
components/inputs/Toggle/Toggle.tsx
TypeScript
ArrowFunction
(storyFn) => { return ( <Provider store={store}> <Router>{storyFn()}</Router> </Provider> ); }
Almenon/couchers
app/frontend/src/components/Navigation/Navigation.stories.tsx
TypeScript
ArrowFunction
(args) => <Navigation {...args} />
Almenon/couchers
app/frontend/src/components/Navigation/Navigation.stories.tsx
TypeScript
ArrowFunction
() => { let component: NotifierComponent; let fixture: ComponentFixture<NotifierComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [NotifierComponent], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(NotifierComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }
A-Hilaly/octant
web/src/app/components/notifier/notifier.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ declarations: [NotifierComponent], }).compileComponents(); }
A-Hilaly/octant
web/src/app/components/notifier/notifier.component.spec.ts
TypeScript
ArrowFunction
() => { fixture = TestBed.createComponent(NotifierComponent); component = fixture.componentInstance; fixture.detectChanges(); }
A-Hilaly/octant
web/src/app/components/notifier/notifier.component.spec.ts
TypeScript
FunctionDeclaration
function offlineError(url: string) { let e: any = new Error(Util.lf("Cannot access {0} while offline", url)); e.isOffline = true; return Promise.delay(1000).then(() => Promise.reject(e)) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function hasAccessToken() { return !!accessToken }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function isLocalHost(): boolean { try { return /^http:\/\/(localhost|127\.0\.0\.1):\d+\//.test(window.location.href) && !/nolocalhost=1/.test(window.location.href) && !(pxt.webConfig && pxt.webConfig.isStatic); } catch (e) { return false; } }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function localRequestAsync(path: string, data?: any) { console.log('localRequestAsync', { //// url: "/api/" + path, headers: { "Authorization": Cloud.localToken }, method: data ? "POST" : "GET", data: data || undefined, allowHttpErrors: true }); //// return U.requestAsync({ url: "/api/" + path, headers: { "Authorization": Cloud.localToken }, method: data ? "POST" : "GET", data: data || undefined, allowHttpErrors: true }) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function privateRequestAsync(options: Util.HttpRequestOptions) { options.url = pxt.webConfig && pxt.webConfig.isStatic && !options.forceLiveEndpoint ? pxt.webConfig.relprefix + options.url : apiRoot + options.url; options.allowGzipPost = true if (!Cloud.isOnline()) { return offlineError(options.url); } if (!options.headers) options.headers = {} if (pxt.Cloud.isLocalHost()) { if (Cloud.localToken) options.headers["Authorization"] = Cloud.localToken; } else if (accessToken) { options.headers["x-td-access-token"] = accessToken } return Util.requestAsync(options) .catch(e => { if (e.statusCode == 0) { if (_isOnline) { _isOnline = false; onOffline(); } return offlineError(options.url) } else { return Promise.reject(e) } }) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function privateGetTextAsync(path: string, headers?: pxt.Map<string>): Promise<string> { return privateRequestAsync({ url: path, headers }).then(resp => resp.text) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function privateGetAsync(path: string, forceLiveEndpoint: boolean = false): Promise<any> { return privateRequestAsync({ url: path, forceLiveEndpoint }).then(resp => resp.json) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function downloadTargetConfigAsync(): Promise<pxt.TargetConfig> { if (!Cloud.isOnline()) // offline return Promise.resolve(undefined); const targetVersion = pxt.appTarget.versions && pxt.appTarget.versions.target; const url = pxt.webConfig && pxt.webConfig.isStatic ? `targetconfig.json` : `config/${pxt.appTarget.id}/targetconfig${targetVersion ? `/v${targetVersion}` : ''}`; if (Cloud.isLocalHost()) return localRequestAsync(url).then(r => r ? r.json : undefined) else return Cloud.privateGetAsync(url); }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function downloadScriptFilesAsync(id: string) { return privateRequestAsync({ url: id + "/text", forceLiveEndpoint: true }).then(resp => { return JSON.parse(resp.text) }) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function markdownAsync(docid: string, locale?: string, live?: boolean): Promise<string> { const branch = ""; return pxt.BrowserUtils.translationDbAsync() .then(db => db.getAsync(locale, docid, "") .then(entry => { if (entry && Date.now() - entry.time > MARKDOWN_EXPIRATION) // background update, downloadMarkdownAsync(docid, locale, live, entry.etag) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md || entry.md)) .catch(() => { }) // swallow errors .done(); // return cached entry if (entry && entry.md) return entry.md; // download and cache else return downloadMarkdownAsync(docid, locale, live) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md) .then(() => r.md)) .catch(() => ""); // no translation })) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
function downloadMarkdownAsync(docid: string, locale?: string, live?: boolean, etag?: string): Promise<{ md: string; etag?: string; }> { const packaged = pxt.webConfig && pxt.webConfig.isStatic; const targetVersion = pxt.appTarget.versions && pxt.appTarget.versions.target || '?'; let url: string; if (packaged) { url = docid; const isUnderDocs = /\/?docs\//.test(url); const hasExt = /\.\w+$/.test(url); if (!isUnderDocs) { url = `docs/${url}`; } if (!hasExt) { url = `${url}.md`; } } else { url = `md/${pxt.appTarget.id}/${docid.replace(/^\//, "")}?targetVersion=${encodeURIComponent(targetVersion)}`; } if (!packaged && locale != "en") { url += `&lang=${encodeURIComponent(Util.userLanguage())}` if (live) url += "&live=1" } if (Cloud.isLocalHost() && !live) return localRequestAsync(url).then(resp => { if (resp.statusCode == 404) return privateRequestAsync({ url, method: "GET" }) .then(resp => { return { md: resp.text, etag: resp.headers["etag"] }; }); else return { md: resp.text, etag: undefined }; }); else { const headers: pxt.Map<string> = etag ? { "If-None-Match": etag } : undefined; return privateRequestAsync({ url, method: "GET", headers }) .then(resp => { return { md: resp.text, etag: resp.headers["etag"] }; }); } }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function privateDeleteAsync(path: string) { return privateRequestAsync({ url: path, method: "DELETE" }).then(resp => resp.json) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function privatePostAsync(path: string, data: any, forceLiveEndpoint: boolean = false) { return privateRequestAsync({ url: path, data: data || {}, forceLiveEndpoint }).then(resp => resp.json) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function isLoggedIn() { return !!accessToken }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function isNavigatorOnline() { return navigator && navigator.onLine; }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function isOnline() { if (typeof navigator !== "undefined" && isNavigatorOnline()) { _isOnline = true; } return _isOnline; }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function getServiceUrl() { return apiRoot.replace(/\/api\/$/, "") }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function getUserId() { let m = /^0(\w+)\./.exec(accessToken) if (m) return m[1] return null }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
FunctionDeclaration
export function parseScriptId(uri: string): string { const target = pxt.appTarget; if (!uri || !target.appTheme || !target.cloud || !target.cloud.sharing) return undefined; let domains = ["makecode.com"]; if (target.appTheme.embedUrl) domains.push(target.appTheme.embedUrl); if (target.appTheme.shareUrl) domains.push(target.appTheme.shareUrl); domains = Util.unique(domains, d => d).map(d => Util.escapeForRegex(Util.stripUrlProtocol(d).replace(/\/$/, '')).toLowerCase()); const rx = `^((https:\/\/)?(?:${domains.join('|')})\/)?(api\/oembed\?url=.*%2F([^&]*)&.*?|([a-z0-9\-_]+))$`; const m = new RegExp(rx, 'i').exec(uri.trim()); const scriptid = m && (!m[1] || domains.indexOf(Util.escapeForRegex(m[1].replace(/https:\/\//, '').replace(/\/$/, '')).toLowerCase()) >= 0) && (m[3] || m[4]) ? (m[3] ? m[3] : m[4]) : null if (!scriptid) return undefined; if (scriptid[0] == "_" && scriptid.length == 13) return scriptid; if (scriptid.length == 23 && /^[0-9\-]+$/.test(scriptid)) return scriptid; return undefined; }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
() => Promise.reject(e)
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
e => { if (e.statusCode == 0) { if (_isOnline) { _isOnline = false; onOffline(); } return offlineError(options.url) } else { return Promise.reject(e) } }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
resp => resp.text
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
resp => resp.json
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
r => r ? r.json : undefined
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
resp => { return JSON.parse(resp.text) }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
db => db.getAsync(locale, docid, "") .then(entry => { if (entry && Date.now() - entry.time > MARKDOWN_EXPIRATION) // background update, downloadMarkdownAsync(docid, locale, live, entry.etag) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md || entry.md)) .catch(() => { }) // swallow errors .done(); // return cached entry if (entry && entry.md) return entry.md; // download and cache else return downloadMarkdownAsync(docid, locale, live) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md) .then(() => r.md)) .catch(() => ""); // no translation })
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
entry => { if (entry && Date.now() - entry.time > MARKDOWN_EXPIRATION) // background update, downloadMarkdownAsync(docid, locale, live, entry.etag) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md || entry.md)) .catch(() => { }) // swallow errors .done(); // return cached entry if (entry && entry.md) return entry.md; // download and cache else return downloadMarkdownAsync(docid, locale, live) .then(r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md) .then(() => r.md)) .catch(() => ""); // no translation }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md || entry.md)
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
r => db.setAsync(locale, docid, branch, r.etag, undefined, r.md) .then(() => r.md)
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
() => r.md
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
resp => { if (resp.statusCode == 404) return privateRequestAsync({ url, method: "GET" }) .then(resp => { return { md: resp.text, etag: resp.headers["etag"] }; }); else return { md: resp.text, etag: undefined }; }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
resp => { return { md: resp.text, etag: resp.headers["etag"] }; }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
d => d
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
d => Util.escapeForRegex(Util.stripUrlProtocol(d).replace(/\/$/, '')).toLowerCase()
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
InterfaceDeclaration
// // Interfaces used by the cloud // export interface JsonIdObject { kind: string; id: string; // id }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
InterfaceDeclaration
export interface JsonPublication extends JsonIdObject { time: number; // time when publication was created }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
InterfaceDeclaration
export interface JsonScriptMeta { blocksWidth?: number; blocksHeight?: number; versions?: TargetVersions }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
InterfaceDeclaration
export interface JsonScript extends JsonPublication { shortid?: string; name: string; description: string; editor?: string; // convention where empty means touchdevelop, for backwards compatibility target?: string; targetVersion?: string; meta?: JsonScriptMeta; // only in lite, bag of metadata }
lupyuen/pxt-maker
patches/cloud.ts
TypeScript
ArrowFunction
() => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ AppComponent ], }).compileComponents(); })); it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); }); it(`should have as title 'jyuunikyara'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('jyuunikyara'); }); it('should render title in a h1 tag', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('Welcome to jyuunikyara!'); }); }
hopskipnfall/12cb
jyuunikyara/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app.title).toEqual('jyuunikyara'); }
hopskipnfall/12cb
jyuunikyara/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('h1').textContent).toContain('Welcome to jyuunikyara!'); }
hopskipnfall/12cb
jyuunikyara/src/app/app.component.spec.ts
TypeScript
ArrowFunction
(config) => { const decalParam: string = this.route.snapshot.queryParams.testDecal // "Forgotten" test parameter to play with different stickers on the delivery box image if (config?.application) { if (config.application.name) { this.applicationName = config.application.name } if (config.application.logo) { let logo: string = config.application.logo if (logo.substring(0, 4) === 'http') { logo = decodeURIComponent(logo.substring(logo.lastIndexOf('/') + 1)) } this.logoSrc = `assets/public/images/${decalParam || logo}` } } if (decalParam) { this.ngZone.runOutsideAngular(() => { this.io.socket().emit('verifySvgInjectionChallenge', decalParam) }) } }
007divyachawla/intro-to-semgrep
frontend/src/app/deluxe-user/deluxe-user.component.ts
TypeScript
ArrowFunction
async () => await this.router.navigate(['/payment', 'deluxe'])
007divyachawla/intro-to-semgrep
frontend/src/app/deluxe-user/deluxe-user.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-deluxe-user', templateUrl: './deluxe-user.component.html', styleUrls: ['./deluxe-user.component.scss'] }) export class DeluxeUserComponent implements OnInit { public membershipCost: Number = 0 public error: string = undefined public applicationName = 'OWASP Juice Shop' public logoSrc: string = 'assets/public/images/JuiceShop_Logo.png' constructor (private readonly router: Router, private readonly userService: UserService, private readonly cookieService: CookieService, private readonly configurationService: ConfigurationService, private readonly route: ActivatedRoute, private readonly ngZone: NgZone, private readonly io: SocketIoService) { } ngOnInit () { this.configurationService.getApplicationConfiguration().subscribe((config) => { const decalParam: string = this.route.snapshot.queryParams.testDecal // "Forgotten" test parameter to play with different stickers on the delivery box image if (config?.application) { if (config.application.name) { this.applicationName = config.application.name } if (config.application.logo) { let logo: string = config.application.logo if (logo.substring(0, 4) === 'http') { logo = decodeURIComponent(logo.substring(logo.lastIndexOf('/') + 1)) } this.logoSrc = `assets/public/images/${decalParam || logo}` } } if (decalParam) { this.ngZone.runOutsideAngular(() => { this.io.socket().emit('verifySvgInjectionChallenge', decalParam) }) } }, (err) => console.log(err)) this.userService.deluxeStatus().subscribe((res) => { this.membershipCost = res.membershipCost }, (err) => { this.error = err.error.error }) } upgradeToDeluxe () { this.ngZone.run(async () => await this.router.navigate(['/payment', 'deluxe'])) } }
007divyachawla/intro-to-semgrep
frontend/src/app/deluxe-user/deluxe-user.component.ts
TypeScript
MethodDeclaration
ngOnInit () { this.configurationService.getApplicationConfiguration().subscribe((config) => { const decalParam: string = this.route.snapshot.queryParams.testDecal // "Forgotten" test parameter to play with different stickers on the delivery box image if (config?.application) { if (config.application.name) { this.applicationName = config.application.name } if (config.application.logo) { let logo: string = config.application.logo if (logo.substring(0, 4) === 'http') { logo = decodeURIComponent(logo.substring(logo.lastIndexOf('/') + 1)) } this.logoSrc = `assets/public/images/${decalParam || logo}` } } if (decalParam) { this.ngZone.runOutsideAngular(() => { this.io.socket().emit('verifySvgInjectionChallenge', decalParam) }) } }, (err) => console.log(err)) this.userService.deluxeStatus().subscribe((res) => { this.membershipCost = res.membershipCost }, (err) => { this.error = err.error.error }) }
007divyachawla/intro-to-semgrep
frontend/src/app/deluxe-user/deluxe-user.component.ts
TypeScript
MethodDeclaration
upgradeToDeluxe () { this.ngZone.run(async () => await this.router.navigate(['/payment', 'deluxe'])) }
007divyachawla/intro-to-semgrep
frontend/src/app/deluxe-user/deluxe-user.component.ts
TypeScript
ArrowFunction
(theme: Theme) => ({ root: { backgroundColor: theme.palette.background.paper, }, contentContainer: { flexGrow: 1, padding: '24px 48px', overflowX: 'hidden', overflow: 'scroll', '@media print': { margin: 0, position: 'absolute', left: 0, right: 0, top: '51px', // height of footer }, }, drawer: { display: 'flex', height: '100%', '@media print': { display: 'none', }, }, testSessionContainer: { flexGrow: '1', height: '100%', display: 'flex', flexDirection: 'column', }, testSuiteMain: { display: 'flex', flexGrow: 1, overflow: 'hidden', '@media print': { maxHeight: 'unset', }, }, drawerPaper: { flexShrink: 0, width: '300px', position: 'static', }, hidePrint: { '@media print': { display: 'none', }, }, })
inferno-framework/inferno-core
client/src/components/TestSuite/styles.tsx
TypeScript
ClassDeclaration
@Pipe({ name: 'initial' }) export class InitialPipe implements PipeTransform { transform (input: any): any { if (!isArray(input)) { return input; } return input.slice(0, input.length - 1); } }
baso10/angular-pipes
src/array/initial.pipe.ts
TypeScript
MethodDeclaration
transform (input: any): any { if (!isArray(input)) { return input; } return input.slice(0, input.length - 1); }
baso10/angular-pipes
src/array/initial.pipe.ts
TypeScript
ArrowFunction
async () => { const page = await newE2EPage({ url: '/src/components/header/test/fade?ionic:_testing=true', }); const compare = await page.compareScreenshot(); expect(compare).toMatchScreenshot(); }
10088/ionic-framework
core/src/components/header/test/fade/e2e.ts
TypeScript
ClassDeclaration
export class NotBlankValidator extends ConstraintValidator { /** * @inheritdoc */ validate(value: any, constraint: NotBlank): void; }
fossabot/jymfony
src/Component/Validator/types/Constraints/NotBlankValidator.d.ts
TypeScript
MethodDeclaration
/** * @inheritdoc */ validate(value: any, constraint: NotBlank): void;
fossabot/jymfony
src/Component/Validator/types/Constraints/NotBlankValidator.d.ts
TypeScript
ArrowFunction
() => { beforeEach(() => { TestBed.configureTestingModule({ providers: [TrunkService] }); }); it('should be created', inject([TrunkService], (service: TrunkService) => { expect(service).toBeTruthy(); })); }
darinvivekanandan/pbxnew
src/app/views/trunk/trunk.service.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ providers: [TrunkService] }); }
darinvivekanandan/pbxnew
src/app/views/trunk/trunk.service.spec.ts
TypeScript
ArrowFunction
(service: TrunkService) => { expect(service).toBeTruthy(); }
darinvivekanandan/pbxnew
src/app/views/trunk/trunk.service.spec.ts
TypeScript
FunctionDeclaration
function getType(slice: string, actionKey: string): string { return slice ? `${slice}/${actionKey}` : actionKey }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
FunctionDeclaration
/** * A function that accepts an initial state, an object full of reducer * functions, and optionally a "slice name", and automatically generates * action creators, action types, and selectors that correspond to the * reducers and state. * * The `reducer` argument is passed to `createReducer()`. */ export function createSlice<S, CR extends CaseReducers<S, any>>( options: CreateSliceOptions<S, CR> ): Slice<S, CaseReducerActionPayloads<CR>> { const { slice = '', initialState } = options const reducers = options.reducers || {} const extraReducers = options.extraReducers || {} const actionKeys = Object.keys(reducers) const reducerMap = actionKeys.reduce((map, actionKey) => { map[getType(slice, actionKey)] = reducers[actionKey] return map }, extraReducers) const reducer = createReducer(initialState, reducerMap) const actionMap = actionKeys.reduce( (map, action) => { const type = getType(slice, action) map[action] = createAction(type) return map }, {} as any ) const selectors = { [createSelectorName(slice)]: createSliceSelector(slice) } return { slice, reducer, actions: actionMap, selectors } }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
ArrowFunction
(map, actionKey) => { map[getType(slice, actionKey)] = reducers[actionKey] return map }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
ArrowFunction
(map, action) => { const type = getType(slice, action) map[action] = createAction(type) return map }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
InterfaceDeclaration
export interface Slice< S = any, AP extends { [key: string]: any } = { [key: string]: any } > { /** * The slice name. */ slice: string /** * The slice's reducer. */ reducer: Reducer<S> /** * Action creators for the types of actions that are handled by the slice * reducer. */ actions: { [type in keyof AP]: SliceActionCreator<AP[type]> } /** * Selectors for the slice reducer state. `createSlice()` inserts a single * selector that returns the entire slice state and whose name is * automatically derived from the slice name (e.g., `getCounter` for a slice * named `counter`). */ selectors: { [key: string]: (state: any) => S } }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
InterfaceDeclaration
/** * Options for `createSlice()`. */ export interface CreateSliceOptions< S = any, CR extends CaseReducers<S, any> = CaseReducers<S, any> > { /** * The slice's name. Used to namespace the generated action types and to * name the selector for retrieving the reducer's state. */ slice?: string /** * The initial state to be returned by the slice reducer. */ initialState: S /** * A mapping from action types to action-type-specific *case reducer* * functions. For every action type, a matching action creator will be * generated using `createAction()`. */ reducers: CR /** * A mapping from action types to action-type-specific *case reducer* * functions. These reducers should have existing action types used * as the keys, and action creators will _not_ be generated. */ extraReducers?: CaseReducers<S, any> }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
TypeAliasDeclaration
/** * An action creator atttached to a slice. */ export type SliceActionCreator<P> = P extends void ? () => PayloadAction<void> : (payload: P) => PayloadAction<P>
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
TypeAliasDeclaration
type CaseReducerActionPayloads<CR extends CaseReducers<any, any>> = { [T in keyof CR]: CR[T] extends (state: any) => any ? void : (CR[T] extends (state: any, action: PayloadAction<infer P>) => any ? P : void) }
cyprianos/circleci-react-redux
src/createSlice.ts
TypeScript
FunctionDeclaration
export function fakeEntrypoint(attributes?: Partial<Entrypoint>): Entrypoint { const base: Entrypoint = { id: 'da98cab3-ff94-4c68-98ca-b3ff949c6896', value: 'https://googl.co', tags: ['external'], }; return { ...base, ...attributes, }; }
AlexRogalskiy/gravitee-api-management
gravitee-apim-console-webui/src/entities/entrypoint/entrypoint.fixture.ts
TypeScript
ArrowFunction
(event: WebGLContextEvent) => this[$onWebGLContextLost](event)
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
ArrowFunction
(time: number) => this.render(time)
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
InterfaceDeclaration
export interface RendererOptions { debug?: boolean; }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
InterfaceDeclaration
export interface ContextLostEvent extends Event { type: 'contextlost'; sourceEvent: WebGLContextEvent; }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
static resetSingleton() { this[$singleton].dispose(); this[$singleton] = new Renderer({debug: isDebugMode()}); }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
setRendererSize(width: number, height: number) { if (this.canRender) { this.threeRenderer.setSize(width, height, false); } this.width = width; this.height = height; }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
registerScene(scene: ModelScene) { this.scenes.add(scene); if (this.canRender && this.scenes.size > 0) { this.threeRenderer.setAnimationLoop((time: number) => this.render(time)); } if (this.debugger != null) { this.debugger.addScene(scene); } }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
unregisterScene(scene: ModelScene) { this.scenes.delete(scene); if (this.canRender && this.scenes.size === 0) { (this.threeRenderer.setAnimationLoop as any)(null); } if (this.debugger != null) { this.debugger.removeScene(scene); } }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
async supportsPresentation() { return this.canRender && this[$arRenderer].supportsPresentation(); }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
async present(scene: ModelScene): Promise<void> { try { return await this[$arRenderer].present(scene); } catch (error) { await this[$arRenderer].stopPresenting(); throw error; } finally { // NOTE(cdata): Setting width and height to 0 will have the effect of // invoking a `setSize` the next time we render in this threeRenderer this.width = this.height = 0; } }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
stopPresenting(): Promise<void> { return this[$arRenderer].stopPresenting(); }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
render(t: number) { if (!this.canRender || this.isPresenting) { return; } const delta = t - this.lastTick; const dpr = resolveDpr(); if (dpr !== this.threeRenderer.getPixelRatio()) { this.threeRenderer.setPixelRatio(dpr); } for (let scene of this.scenes) { const {element, width, height, context} = scene; element[$tick](t, delta); if (!scene.visible || !scene.isDirty || scene.paused) { continue; } const camera = scene.getCamera(); if (width > this.width || height > this.height) { const maxWidth = Math.max(width, this.width); const maxHeight = Math.max(height, this.height); this.setRendererSize(maxWidth, maxHeight); } const {exposure, shadow} = scene; const exposureIsNumber = typeof exposure === 'number' && !(self as any).isNaN(exposure); this.threeRenderer.toneMappingExposure = exposureIsNumber ? exposure : 1.0; const shadowNeedsUpdate = this.threeRenderer.shadowMap.needsUpdate; if (shadow != null) { this.threeRenderer.shadowMap.needsUpdate = shadowNeedsUpdate || shadow.needsUpdate; shadow.needsUpdate = false; } // Need to set the render target in order to prevent // clearing the depth from a different buffer -- possibly // from something in this.threeRenderer.setRenderTarget(null); this.threeRenderer.setViewport(0, 0, width, height); this.threeRenderer.render(scene, camera); const widthDPR = width * dpr; const heightDPR = height * dpr; context.clearRect(0, 0, widthDPR, heightDPR); context.drawImage( this.threeRenderer.domElement, 0, this.canvas3D.height - heightDPR, widthDPR, heightDPR, 0, 0, widthDPR, heightDPR); scene.isDirty = false; } this.lastTick = t; }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
dispose() { if (this.textureUtils != null) { this.textureUtils.dispose(); } if (this.threeRenderer != null) { this.threeRenderer.dispose(); } this.textureUtils = null; (this as any).threeRenderer = null; this.scenes.clear(); this.canvas3D.removeEventListener( 'webglcontextlost', this[$webGLContextLostHandler] as EventListener); }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
MethodDeclaration
[$onWebGLContextLost](event: WebGLContextEvent) { this.dispatchEvent( {type: 'contextlost', sourceEvent: event} as ContextLostEvent); }
IvanNov7/model-viewer
packages/model-viewer/src/three-components/Renderer.ts
TypeScript
InterfaceDeclaration
export interface IRootState { name: string; age: number; entireDepartment: any[]; entireRole: any[]; entireMenu: any[]; }
Flandre3569/mx_cms
src/store/types.ts
TypeScript
InterfaceDeclaration
export interface IRootWithModule { login: IloginState; system: ISystemState; }
Flandre3569/mx_cms
src/store/types.ts
TypeScript
TypeAliasDeclaration
export type IStoreType = IRootState & IRootWithModule;
Flandre3569/mx_cms
src/store/types.ts
TypeScript
ArrowFunction
(option: any, disabledOptions: any) => { let value = `${option}`; if (option < 10) { value = `0${option}`; } let disabled = false; if (disabledOptions && disabledOptions.indexOf(option) >= 0) { disabled = true; } return { value, disabled }; }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ArrowFunction
(type: any, itemValue: any) => { const { onChange, defaultOpenValue, use12Hours } = this.props; const value = (this.props.value || defaultOpenValue).clone(); if (type === "hour") { if (use12Hours) { if (this.props.isAM) { value.hour(+itemValue % 12); } else { value.hour((+itemValue % 12) + 12); } } else { value.hour(+itemValue); } } else if (type === "minute") { value.minute(+itemValue); } else if (type === "ampm") { const ampm = itemValue.toUpperCase(); if (use12Hours) { if (ampm === "PM" && value.hour() < 12) { value.hour((value.hour() % 12) + 12); } if (ampm === "AM") { if (value.hour() >= 12) { value.hour(value.hour() - 12); } } } } else { value.second(+itemValue); } onChange(value); }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ArrowFunction
(range: any) => { if (this.props.onCurrentSelectPanelChange) { this.props.onCurrentSelectPanelChange(range); } }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript