type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
done => { const callStream = new Http2CallStream( 'foo', {} as Http2Channel, callStreamArgs, filterStackFactory ); const http2Stream = new ClientHttp2StreamMock({ payload: Buffer.concat([serialize(message), serialize(message)]), // 42 bytes frameLengths: testCase.frameLengths, }); callStream.once( 'data', assert2.mustCall(buffer => { assert.strictEqual(buffer.toString('utf8'), message); }) ); callStream.once( 'data', assert2.mustCall(buffer => { assert.strictEqual(buffer.toString('utf8'), message); }) ); callStream.once('end', assert2.mustCall(() => {})); callStream.attachHttp2Stream(http2Stream); assert2.afterMustCallsSatisfied(done); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
done => { const callStream = new Http2CallStream( 'foo', {} as Http2Channel, callStreamArgs, filterStackFactory ); const http2Stream = new ClientHttp2StreamMock({ payload: Buffer.alloc(0), frameLengths: [], }); let streamFlushed = false; http2Stream.once( 'write', assert2.mustCall((chunk: Buffer) => { const dataLength = chunk.readInt32BE(1); const encodedMessage = chunk.slice(5).toString('utf8'); assert.strictEqual(dataLength, message.length); assert.strictEqual(encodedMessage, message); streamFlushed = true; }) ); callStream.write( { message: Buffer.from(message) }, assert2.mustCall(() => { // Ensure this is called only after contents are written to http2Stream assert.ok(streamFlushed); }) ); callStream.end(assert2.mustCall(() => {})); callStream.attachHttp2Stream(http2Stream); assert2.afterMustCallsSatisfied(done); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
(chunk: Buffer) => { const dataLength = chunk.readInt32BE(1); const encodedMessage = chunk.slice(5).toString('utf8'); assert.strictEqual(dataLength, message.length); assert.strictEqual(encodedMessage, message); streamFlushed = true; }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
() => { // Ensure this is called only after contents are written to http2Stream assert.ok(streamFlushed); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
done => { const callStream = new Http2CallStream( 'foo', {} as Http2Channel, callStreamArgs, filterStackFactory ); const http2Stream = new ClientHttp2StreamMock({ payload: Buffer.alloc(0), frameLengths: [], }); http2Stream.once( 'write', assert2.mustCall((chunk: Buffer) => { const dataLength = chunk.readInt32BE(1); const encodedMessage = chunk.slice(5).toString('utf8'); assert.strictEqual(dataLength, message.length); assert.strictEqual(encodedMessage, message); }) ); callStream.attachHttp2Stream(http2Stream); callStream.write( { message: Buffer.from(message) }, assert2.mustCall(() => {}) ); callStream.end(assert2.mustCall(() => {})); assert2.afterMustCallsSatisfied(done); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
(chunk: Buffer) => { const dataLength = chunk.readInt32BE(1); const encodedMessage = chunk.slice(5).toString('utf8'); assert.strictEqual(dataLength, message.length); assert.strictEqual(encodedMessage, message); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
() => { const callStream = new Http2CallStream( 'foo', {} as Http2Channel, callStreamArgs, filterStackFactory ); const http2Stream = new ClientHttp2StreamMock({ payload: Buffer.alloc(0), frameLengths: [], }); callStream.once( 'status', assert2.mustCall(status => { assert.strictEqual(status.code, Status.INTERNAL); }) ); callStream.attachHttp2Stream(http2Stream); http2Stream.emit('error'); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
status => { assert.strictEqual(status.code, Status.INTERNAL); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ClassDeclaration
class ClientHttp2StreamMock extends stream.Duplex implements http2.ClientHttp2Stream { constructor(private readonly dataFrames: DataFrames) { super(); } emitResponse(responseCode: number, metadata?: Metadata) { this.emit('response', { [HTTP2_HEADER_STATUS]: responseCode, ...(metadata ? metadata.toHttp2Headers() : {}), }); } bytesRead = 0; dataFrame = 0; aborted = false; closed = false; destroyed = false; endAfterHeaders = false; pending = false; rstCode = 0; readonly bufferSize: number = 0; readonly sentHeaders: OutgoingHttpHeaders = {}; readonly sentInfoHeaders?: OutgoingHttpHeaders[] = []; readonly sentTrailers?: OutgoingHttpHeaders = undefined; // tslint:disable:no-any session: http2.Http2Session = {} as any; state: http2.StreamState = {} as any; // tslint:enable:no-any close = mockFunction; priority = mockFunction; rstStream = mockFunction; rstWithNoError = mockFunction; rstWithProtocolError = mockFunction; rstWithCancel = mockFunction; rstWithRefuse = mockFunction; rstWithInternalError = mockFunction; setTimeout = mockFunction; _read() { if (this.dataFrame === this.dataFrames.frameLengths.length) { if (this.bytesRead < this.dataFrames.payload.length) { this.push( this.dataFrames.payload.slice( this.bytesRead, this.dataFrames.payload.length ) ); } this.push(null); return; } const from = this.bytesRead; this.bytesRead += this.dataFrames.frameLengths[this.dataFrame++]; this.push(this.dataFrames.payload.slice(from, this.bytesRead)); } _write(chunk: Buffer, encoding: string, cb: Function) { this.emit('write', chunk); cb(); } sendTrailers(headers: OutgoingHttpHeaders) { return this; } }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
InterfaceDeclaration
interface DataFrames { payload: Buffer; frameLengths: number[]; }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
MethodDeclaration
emitResponse(responseCode: number, metadata?: Metadata) { this.emit('response', { [HTTP2_HEADER_STATUS]: responseCode, ...(metadata ? metadata.toHttp2Headers() : {}), }); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
MethodDeclaration
_read() { if (this.dataFrame === this.dataFrames.frameLengths.length) { if (this.bytesRead < this.dataFrames.payload.length) { this.push( this.dataFrames.payload.slice( this.bytesRead, this.dataFrames.payload.length ) ); } this.push(null); return; } const from = this.bytesRead; this.bytesRead += this.dataFrames.frameLengths[this.dataFrame++]; this.push(this.dataFrames.payload.slice(from, this.bytesRead)); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
MethodDeclaration
_write(chunk: Buffer, encoding: string, cb: Function) { this.emit('write', chunk); cb(); }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
MethodDeclaration
sendTrailers(headers: OutgoingHttpHeaders) { return this; }
SProst/grpc-node
packages/grpc-js/test/test-call-stream.ts
TypeScript
ArrowFunction
medium => this.requestOtpAction(medium)
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
ArrowFunction
action => action != null
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
ArrowFunction
() => { this.addSub(this.authService.newOtp({ medium }).subscribe(res => { this.notificationService.snackBar(this.i18n.password.otpSent((res || []).join(', '))); this.otpSent.emit(null); })); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
ArrowFunction
res => { this.notificationService.snackBar(this.i18n.password.otpSent((res || []).join(', '))); this.otpSent.emit(null); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
ArrowFunction
() => this.i18n.password.otpReceiveBySent(medium)
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
ClassDeclaration
/** * Component used to display a password input */ @Component({ selector: 'password-input', templateUrl: 'password-input.component.html', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: PasswordInputComponent, multi: true }, { provide: NG_VALIDATORS, useExisting: PasswordInputComponent, multi: true }, ], }) export class PasswordInputComponent extends BaseControlComponent<string> implements OnInit, Validator { @Input() passwordInput: PasswordInput; @Input() placeholder: string; @Input() autocomplete = 'off'; private _showIcon: boolean | string = false; @Input() get showIcon(): boolean | string { return this._showIcon; } set showIcon(showIcon: boolean | string) { this._showIcon = truthyAttr(showIcon); } @Output() enter = new EventEmitter<string>(); @Output() otpSent = new EventEmitter<void>(); @ViewChild('passwordField') passwordField: ElementRef; @ViewChild('vkDisplay') vkDisplay: ElementRef; virtualKeyboard: boolean; currentVKCombinations: string[][]; enteredVKPassword: string[]; otp: boolean; otpActions: ActionWithIcon[]; constructor( injector: Injector, @Optional() @Host() @SkipSelf() controlContainer: ControlContainer, private authService: AuthService, private notificationService: NotificationService, public layout: LayoutService) { super(injector, controlContainer); } ngOnInit(): void { super.ngOnInit(); const input = this.passwordInput; // Initialize the one-time-password fields this.otp = input.mode === PasswordModeEnum.OTP; if (this.otp) { this.otpActions = (input.otpSendMediums || []) .map(medium => this.requestOtpAction(medium)) .filter(action => action != null); } // Initialize the virtual keyboard fields this.virtualKeyboard = input.inputMethod === PasswordInputMethodEnum.VIRTUAL_KEYBOARD; if (this.virtualKeyboard) { this.enteredVKPassword = []; this.updateVKButtons(); } // Ensure we have a proper placeholder if (this.placeholder == null) { this.placeholder = this.passwordInput.name; } } /** * Returns an action to request a new OTP * @param medium The send medium */ private requestOtpAction(medium: SendMediumEnum): ActionWithIcon { let icon: string; let label: string; switch (medium) { case SendMediumEnum.EMAIL: icon = 'email'; label = this.i18n.general.sendMedium.email; break; case SendMediumEnum.SMS: icon = 'textsms'; label = this.i18n.general.sendMedium.sms; break; default: return null; } return new ActionWithIcon(icon, label, () => { this.addSub(this.authService.newOtp({ medium }).subscribe(res => { this.notificationService.snackBar(this.i18n.password.otpSent((res || []).join(', '))); this.otpSent.emit(null); })); }); } vkKey(combination: string) { this.enteredVKPassword.push(combination); this.updateVKButtons(); } vkClear() { this.enteredVKPassword = []; this.updateVKButtons(); } vkBack() { this.enteredVKPassword.splice(this.enteredVKPassword.length - 1, 1); this.updateVKButtons(); } private updateVKButtons(): void { if (this.enteredVKPassword.length < this.passwordInput.buttons.length) { this.currentVKCombinations = chunk(this.passwordInput.buttons[this.enteredVKPassword.length], this.passwordInput.buttonsPerRow); } this.formControl.setValue(this.enteredVKPassword.length === 0 ? '' : this.passwordInput.id + '|' + this.enteredVKPassword.join('|')); } onDisabledChange(isDisabled: boolean): void { if (this.passwordField && this.passwordField.nativeElement) { this.passwordField.nativeElement.disabled = isDisabled; } } focus() { if (this.passwordField && this.passwordField.nativeElement) { this.passwordField.nativeElement.focus(); } } // Validator methods validate(c: AbstractControl): ValidationErrors { if (!c.touched) { return null; } const value = c.value; if (value == null || value === '') { return { required: true, }; } return null; } otpDisableMessageFunction(medium: string): (remaining: number) => string { return () => this.i18n.password.otpReceiveBySent(medium); } registerOnValidatorChange() { } }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
ngOnInit(): void { super.ngOnInit(); const input = this.passwordInput; // Initialize the one-time-password fields this.otp = input.mode === PasswordModeEnum.OTP; if (this.otp) { this.otpActions = (input.otpSendMediums || []) .map(medium => this.requestOtpAction(medium)) .filter(action => action != null); } // Initialize the virtual keyboard fields this.virtualKeyboard = input.inputMethod === PasswordInputMethodEnum.VIRTUAL_KEYBOARD; if (this.virtualKeyboard) { this.enteredVKPassword = []; this.updateVKButtons(); } // Ensure we have a proper placeholder if (this.placeholder == null) { this.placeholder = this.passwordInput.name; } }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
/** * Returns an action to request a new OTP * @param medium The send medium */ private requestOtpAction(medium: SendMediumEnum): ActionWithIcon { let icon: string; let label: string; switch (medium) { case SendMediumEnum.EMAIL: icon = 'email'; label = this.i18n.general.sendMedium.email; break; case SendMediumEnum.SMS: icon = 'textsms'; label = this.i18n.general.sendMedium.sms; break; default: return null; } return new ActionWithIcon(icon, label, () => { this.addSub(this.authService.newOtp({ medium }).subscribe(res => { this.notificationService.snackBar(this.i18n.password.otpSent((res || []).join(', '))); this.otpSent.emit(null); })); }); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
vkKey(combination: string) { this.enteredVKPassword.push(combination); this.updateVKButtons(); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
vkClear() { this.enteredVKPassword = []; this.updateVKButtons(); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
vkBack() { this.enteredVKPassword.splice(this.enteredVKPassword.length - 1, 1); this.updateVKButtons(); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
private updateVKButtons(): void { if (this.enteredVKPassword.length < this.passwordInput.buttons.length) { this.currentVKCombinations = chunk(this.passwordInput.buttons[this.enteredVKPassword.length], this.passwordInput.buttonsPerRow); } this.formControl.setValue(this.enteredVKPassword.length === 0 ? '' : this.passwordInput.id + '|' + this.enteredVKPassword.join('|')); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
onDisabledChange(isDisabled: boolean): void { if (this.passwordField && this.passwordField.nativeElement) { this.passwordField.nativeElement.disabled = isDisabled; } }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
focus() { if (this.passwordField && this.passwordField.nativeElement) { this.passwordField.nativeElement.focus(); } }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
// Validator methods validate(c: AbstractControl): ValidationErrors { if (!c.touched) { return null; } const value = c.value; if (value == null || value === '') { return { required: true, }; } return null; }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
otpDisableMessageFunction(medium: string): (remaining: number) => string { return () => this.i18n.password.otpReceiveBySent(medium); }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
MethodDeclaration
registerOnValidatorChange() { }
Kcire6/CyclosInfoUGT
src/app/shared/password-input.component.ts
TypeScript
FunctionDeclaration
function WeeklyChart(PlyFirebase) { function arrayToObject(arr) { const res = {}; arr.forEach(curr => { res[curr.chordKey] = curr; }); return res; } function createWeeklyChart(weeklyChart: WeeklyChart) { // convert songs into objects weeklyChart.songs = this.arrayToObject(weeklyChart.songs); return new Promise((resolve, reject) => { PlyFirebase.insert('weeklyCharts', weeklyChart) .then(result => resolve(result)) .catch(error => reject(error)); }); } function getLatestChart() { return new Promise((resolve, reject) => { PlyFirebase.selecteByAggregate('weeklyCharts', 'dateCreated') .then(result => resolve(result)) .catch(error => reject(error)); }); } return { createWeeklyChart, getLatestChart, arrayToObject, }; }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
FunctionDeclaration
function arrayToObject(arr) { const res = {}; arr.forEach(curr => { res[curr.chordKey] = curr; }); return res; }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
FunctionDeclaration
function createWeeklyChart(weeklyChart: WeeklyChart) { // convert songs into objects weeklyChart.songs = this.arrayToObject(weeklyChart.songs); return new Promise((resolve, reject) => { PlyFirebase.insert('weeklyCharts', weeklyChart) .then(result => resolve(result)) .catch(error => reject(error)); }); }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
FunctionDeclaration
function getLatestChart() { return new Promise((resolve, reject) => { PlyFirebase.selecteByAggregate('weeklyCharts', 'dateCreated') .then(result => resolve(result)) .catch(error => reject(error)); }); }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ArrowFunction
curr => { res[curr.chordKey] = curr; }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ArrowFunction
(resolve, reject) => { PlyFirebase.insert('weeklyCharts', weeklyChart) .then(result => resolve(result)) .catch(error => reject(error)); }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ArrowFunction
result => resolve(result)
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ArrowFunction
error => reject(error)
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ArrowFunction
(resolve, reject) => { PlyFirebase.selecteByAggregate('weeklyCharts', 'dateCreated') .then(result => resolve(result)) .catch(error => reject(error)); }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
InterfaceDeclaration
interface Song { artist: string; title: string; rank: number; chordKey: string; }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
InterfaceDeclaration
interface WeeklyChart { dateCreated: number; weekNumber: number; year: number; songs: Song[]; }
team-playalong/playalong-monorepo
packages/playalong-web/app/pages/ply-weekly-chart/weeklyChart.service.ts
TypeScript
ClassDeclaration
@Module({ imports: [], controllers: [AppController, ProductsController, DiscordController], providers: [AppService, ProductsService, DiscordService], }) export class AppModule {}
decent-linuxxx/rest_api
src/app.module.ts
TypeScript
ClassDeclaration
export class CreateCategoryDto { @IsString() @IsNotEmpty() readonly name: string; @IsString() @IsNotEmpty() readonly description: string; }
kasteion/javascript-backend-learning-route
0018-backend-nestjs/platzi-store/src/dto/category.dto.ts
TypeScript
ClassDeclaration
export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}
kasteion/javascript-backend-learning-route
0018-backend-nestjs/platzi-store/src/dto/category.dto.ts
TypeScript
ArrowFunction
({ loading, item, ticker, onToggle, checked }) => { const { t } = useTranslation(); if (loading) { return <UnlockTokensRowSkeleton />; } const date = item.timestamp.format("DD MMM YYYY"); const time = item.timestamp.format("HH:mm:ss"); const relativeTime = item.timestamp.fromNow(); return ( <TableRow> <TableCell variant="start" isCompact> <Amount className="font-bold text-theme-secondary-900 dark:text-theme-secondary-200" value={item.amount.toHuman()} ticker={ticker} /> </TableCell> <TableCell isCompact> <time className="text-theme-secondary-700" dateTime={item.timestamp.toDate().toUTCString()}> {date} {t("COMMON.AT")} {time} ({relativeTime}) </time> </TableCell> <TableCell variant="end" isCompact innerClassName="justify-end"> {item.isReady ? ( <div className="flex items-center"> <div className="flex items-center"> <span className="text-theme-secondary-700" data-testid="UnlockableBalanceRow__status"> {t("TRANSACTION.UNLOCK_TOKENS.UNLOCKABLE")} </span> <Icon name="LockOpen" size="lg" className="text-theme-primary-600 mr-3 ml-2" /> </div> <Checkbox checked={checked} onChange={onToggle} /> </div>
NayiemWillems/desktop-wallet-1
src/domains/transaction/components/UnlockTokens/blocks/UnlockTokensSelect/UnlockTokensRow.tsx
TypeScript
MethodDeclaration
t("TRANSACTION.UNLOCK_TOKENS.UNLOCKABLE")
NayiemWillems/desktop-wallet-1
src/domains/transaction/components/UnlockTokens/blocks/UnlockTokensSelect/UnlockTokensRow.tsx
TypeScript
MethodDeclaration
t("TRANSACTION.UNLOCK_TOKENS.LOCKED")
NayiemWillems/desktop-wallet-1
src/domains/transaction/components/UnlockTokens/blocks/UnlockTokensSelect/UnlockTokensRow.tsx
TypeScript
ClassDeclaration
export default class User { id: number; username: string; bio: string; profile_name: string; avatar: string; style?: string; constructor( id: number, username: string, avatar: string, bio: string, profile_name: string ) { this.id = id; this.username = username; this.avatar = avatar; this.bio = bio; this.profile_name = profile_name; } }
pacokleitz/strugl
client/lib/user.ts
TypeScript
ArrowFunction
(event: Event) => { if (!this.props.open) { return; } <<<<<<< HEAD if ( this.menuRef.current && !this.menuRef.current.contains(event.target as Node) ) { this.props.setOpen(false); } }
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
ArrowFunction
child => { const props = {onClick: () => this.props.setOpen(!this.props.open)}; if (React.isValidElement(child)) { return React.cloneElement(child, props); } return child; }
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
ArrowFunction
() => this.props.setOpen(!this.props.open)
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
ClassDeclaration
class BurgerMenu extends React.Component<{open: boolean; setOpen: Function}> { ======= import { StyledBurger } from './StyledBurger'; import { StyledMenu } from './StyledMenu'; class BurgerMenu extends React.Component<{open: boolean, setOpen: Function}> { >>>>>>> 6fe7a7deb55bd77f5f91c4e387bc7ec9e2da9486 private menuRef = React.createRef<HTMLDivElement>(); componentDidMount() { document.addEventListener('mousedown', this.handleClickOutside); } componentWillUnmount() { document.removeEventListener('mousedown', this.handleClickOutside); } handleClickOutside = (event: Event) => { if (!this.props.open) { return; } <<<<<<< HEAD if ( this.menuRef.current && !this.menuRef.current.contains(event.target as Node) ) { this.props.setOpen(false); } }; render() { const childrenWithProps = React.Children.map(this.props.children, child => { const props = {onClick: () => this.props.setOpen(!this.props.open)}; if (React.isValidElement(child)) { return React.cloneElement(child, props); } return child; }); return ( <div ref={this.menuRef}> <StyledBurger open={this.props.open} onClick={() => this.props.setOpen(!this.props.open)}
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
MethodDeclaration
componentDidMount() { document.addEventListener('mousedown', this.handleClickOutside); }
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
MethodDeclaration
componentWillUnmount() { document.removeEventListener('mousedown', this.handleClickOutside); }
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
MethodDeclaration
render() { const childrenWithProps = React.Children.map(this.props.children, child => { const props = {onClick: () => this.props.setOpen(!this.props.open)}; if (React.isValidElement(child)) { return React.cloneElement(child, props); } return child; }); return ( <div ref={this.menuRef}> <StyledBurger open={this.props.open} onClick={() => this.props.setOpen(!this.props.open)}
gxchris95/stave
src/app/components/burgerMenu/BurgerMenu.tsx
TypeScript
ArrowFunction
e => { this._currentSnippets.length = 0; let selectFn: (snippet: ISnippet) => boolean; if (e.selection.isEmpty()) { // empty selection -> real text (no whitespace) left of cursor const prefix = getNonWhitespacePrefix(editor.getModel(), editor.getPosition()); selectFn = prefix && (snippet => endsWith(prefix, snippet.prefix)); } else { // actual selection -> snippet must be a full match const selected = editor.getModel().getValueInRange(e.selection); selectFn = snippet => selected === snippet.prefix; } if (selectFn) { snippetService.visitSnippets(editor.getModel().getLanguageIdentifier().id, s => { if (selectFn(s)) { this._currentSnippets.push(s); } return true; }); } hasSnippets.set(this._currentSnippets.length === 1); //todo@joh make it work with N }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ArrowFunction
snippet => endsWith(prefix, snippet.prefix)
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ArrowFunction
snippet => selected === snippet.prefix
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ArrowFunction
s => { if (selectFn(s)) { this._currentSnippets.push(s); } return true; }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ArrowFunction
x => x.performSnippetCompletions()
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ClassDeclaration
@commonEditorContribution export class TabCompletionController implements editorCommon.IEditorContribution { private static ID = 'editor.tabCompletionController'; static ContextKey = new RawContextKey<boolean>('hasSnippetCompletions', undefined); public static get(editor: editorCommon.ICommonCodeEditor): TabCompletionController { return editor.getContribution<TabCompletionController>(TabCompletionController.ID); } private _snippetController: SnippetController2; private _cursorChangeSubscription: IDisposable; private _currentSnippets: ISnippet[] = []; constructor( editor: editorCommon.ICommonCodeEditor, @IContextKeyService contextKeyService: IContextKeyService, @ISnippetsService snippetService: ISnippetsService ) { this._snippetController = SnippetController2.get(editor); const hasSnippets = TabCompletionController.ContextKey.bindTo(contextKeyService); this._cursorChangeSubscription = editor.onDidChangeCursorSelection(e => { this._currentSnippets.length = 0; let selectFn: (snippet: ISnippet) => boolean; if (e.selection.isEmpty()) { // empty selection -> real text (no whitespace) left of cursor const prefix = getNonWhitespacePrefix(editor.getModel(), editor.getPosition()); selectFn = prefix && (snippet => endsWith(prefix, snippet.prefix)); } else { // actual selection -> snippet must be a full match const selected = editor.getModel().getValueInRange(e.selection); selectFn = snippet => selected === snippet.prefix; } if (selectFn) { snippetService.visitSnippets(editor.getModel().getLanguageIdentifier().id, s => { if (selectFn(s)) { this._currentSnippets.push(s); } return true; }); } hasSnippets.set(this._currentSnippets.length === 1); //todo@joh make it work with N }); } dispose(): void { this._cursorChangeSubscription.dispose(); } performSnippetCompletions(): void { if (this._currentSnippets.length === 1) { const snippet = this._currentSnippets[0]; this._snippetController.insert(snippet.codeSnippet, snippet.prefix.length, 0); // } else { // todo@joh - show suggest widget with proposals } } getId(): string { return TabCompletionController.ID; } }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
MethodDeclaration
public static get(editor: editorCommon.ICommonCodeEditor): TabCompletionController { return editor.getContribution<TabCompletionController>(TabCompletionController.ID); }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
MethodDeclaration
dispose(): void { this._cursorChangeSubscription.dispose(); }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
MethodDeclaration
performSnippetCompletions(): void { if (this._currentSnippets.length === 1) { const snippet = this._currentSnippets[0]; this._snippetController.insert(snippet.codeSnippet, snippet.prefix.length, 0); // } else { // todo@joh - show suggest widget with proposals } }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
MethodDeclaration
getId(): string { return TabCompletionController.ID; }
BugraC/vscode
src/vs/workbench/parts/snippets/electron-browser/tabCompletion.ts
TypeScript
ClassDeclaration
@Injectable() export class PlaylistParser { parse($body) { const $playlists = $body.find('div.list_album').eq(0).find('li'); const self = this; const playlists = $playlists.map(function (i, elem) { return self.getPlaylist($(this)); }).get(); return playlists; } private getPlaylist($playlist) { const $name = $playlist.find('div.info_album a.name_song'); const name = $name.text(); const $singer = $playlist.find('div.info_album a.name_singer'); const singer = $singer.map(function (i, elem) { return $(this).text(); }).get().join(', '); const $url = $playlist.find('div.box-left-album a'); const url = $url.attr('href'); const $avatar = $playlist.find('div.box-left-album span.avatar img'); const avatar = $avatar.attr('src'); return { name, singer, avatar, url }; } }
huuthanhla/RankSong
src/modules/online/home/playlist.parser.ts
TypeScript
MethodDeclaration
parse($body) { const $playlists = $body.find('div.list_album').eq(0).find('li'); const self = this; const playlists = $playlists.map(function (i, elem) { return self.getPlaylist($(this)); }).get(); return playlists; }
huuthanhla/RankSong
src/modules/online/home/playlist.parser.ts
TypeScript
MethodDeclaration
private getPlaylist($playlist) { const $name = $playlist.find('div.info_album a.name_song'); const name = $name.text(); const $singer = $playlist.find('div.info_album a.name_singer'); const singer = $singer.map(function (i, elem) { return $(this).text(); }).get().join(', '); const $url = $playlist.find('div.box-left-album a'); const url = $url.attr('href'); const $avatar = $playlist.find('div.box-left-album span.avatar img'); const avatar = $avatar.attr('src'); return { name, singer, avatar, url }; }
huuthanhla/RankSong
src/modules/online/home/playlist.parser.ts
TypeScript
ArrowFunction
({ duration = 1, delay = 0, circle = false, co, width, height = '100%', className, ...props }: SkeletonProps & React.ComponentPropsWithoutRef<'div'>) => { const computedClassNames = clsx(className); const theme = useTheme() as Theme; const styles = css({ width: width, height: height, borderRadius: circle ? '50%' : '4px', background: 'linear-gradient(90deg,rgba(255, 255, 255, 0) 40%,rgba(255, 255, 255, .5) 50%,rgba(255, 255, 255, 0) 60%) ' + theme ? theme.mode == 'light' ? theme.color.greyLight : theme.color.grey : '#F3F4F6', backgroundSize: '200% 100%', backgroundPositionX: '180%', animation: `${anim} ${duration}s ${delay}s ease-in-out infinite`, ...(typeof co == 'function' ? co(theme) : co), }); return <div css={styles} aria-label='skeleton' className={computedClassNames} {...props} />; }
fogcity/components
src/components/Skeleton/index.tsx
TypeScript
TypeAliasDeclaration
type SkeletonProps = { duration?: number; delay?: number; circle?: boolean; width?: string; height?: string; co?: ((theme: Theme) => React.CSSProperties) | React.CSSProperties; };
fogcity/components
src/components/Skeleton/index.tsx
TypeScript
FunctionDeclaration
export default function ButtonDemo() { return ( <Page title="Button 按钮" className="button-demo"> <Block title="按钮颜色"> <Space> <Button variant="contained" color="primary"> 主要按钮 </Button> <Button variant="contained" color="info"> 信息按钮 </Button> <Button variant="contained" color="success"> 成功按钮 </Button> <Button variant="contained" color="warning"> 警告按钮 </Button> <Button variant="contained" color="danger"> 危险按钮 </Button> <Button variant="contained" color="default"> 默认按钮 </Button> </Space> </Block> <Block title="文本按钮"> <Space> <Button variant="text" color="primary"> 主要按钮 </Button> <Button variant="text" color="info"> 信息按钮 </Button> <Button variant="text" color="success"> 成功按钮 </Button> <Button variant="text" color="warning"> 警告按钮 </Button> <Button variant="text" color="danger"> 危险按钮 </Button> <Button variant="text" color="default"> 默认按钮 </Button> </Space> </Block> <Block title="轮廓按钮"> <Space> <Button variant="outlined" color="primary"> 主要按钮 </Button> <Button variant="outlined" color="info"> 信息按钮 </Button> <Button variant="outlined" color="success"> 成功按钮 </Button> <Button variant="outlined" color="warning"> 警告按钮 </Button> <Button variant="outlined" color="danger"> 危险按钮 </Button> <Button variant="outlined" color="default"> 默认按钮 </Button> </Space> </Block> <Block title="细边框按钮"> <Space> <Button variant="outlined" color="primary" hairline> 主要按钮 </Button> <Button variant="outlined" color="info" hairline> 信息按钮 </Button> <Button variant="outlined" color="success" hairline> 成功按钮 </Button> <Button variant="outlined" color="warning" hairline> 警告按钮 </Button> <Button variant="outlined" color="danger" hairline> 危险按钮 </Button> <Button variant="outlined" color="default" hairline> 默认按钮 </Button> </Space> </Block> <Block title="禁止状态"> <Space> <Button variant="contained" color="primary" disabled> 主要按钮 </Button> <Button variant="contained" color="info" disabled> 信息按钮 </Button> <Button variant="contained" color="success" disabled> 成功按钮 </Button> <Button variant="contained" color="warning" disabled> 警告按钮 </Button> <Button variant="contained" color="danger" disabled> 危险按钮 </Button> <Button variant="contained" color="default" disabled> 默认按钮 </Button> </Space> </Block> <Block title="加载状态"> <Space> <Button color="success" loading /> <Button color="success" loading={{ type: "spinner" }}
bingtsingw/taroify
packages/demo/src/pages/basic/button/index.tsx
TypeScript
ArrowFunction
(auction: AuctionView) => { const [priceUSD, setPriceUSD] = useState<number | undefined>(undefined) const id = auction?.thumbnail?.metadata?.pubkey const tokenInfo = useTokenList().subscribedTokens.filter( m => m.address == auction.auction.info.tokenMint )[0] const { amount: _amount } = useAuctionStatus(auction) const state = useAuctionCountdown(auction) const { data } = useExtendedArt(id) const amount = typeof _amount === 'string' ? parseFloat(_amount) : _amount let solVal = `${amount}` if (amount >= 1) { solVal = formatAmount(amount) } const remainingHours = (state?.hours || 0) + (state?.days || 0) * 24 const remainingMinutes = state?.minutes || 0 const remainingSeconds = state?.seconds || 0 const solPrice = useSolPrice() const altSplPrice = useAllSplPrices().filter(a => a.tokenMint == tokenInfo?.address)[0] ?.tokenPrice const tokenPrice = tokenInfo?.address == WRAPPED_SOL_MINT.toBase58() ? solPrice : altSplPrice useEffect(() => { setPriceUSD(tokenPrice * amount) }, [amount, tokenPrice, altSplPrice]) const usdValFormatted = currency(priceUSD || 0).format() const priceNaN = isNaN(amount) return { data: data, value: { usdValFormatted, usdVal: priceUSD, solVal, priceNaN }, remaining: { remainingHours, remainingMinutes, remainingSeconds, }, } }
Muffintechxyz/metaplex
js/packages/web/src/hooks/useNFTData.tsx
TypeScript
ArrowFunction
m => m.address == auction.auction.info.tokenMint
Muffintechxyz/metaplex
js/packages/web/src/hooks/useNFTData.tsx
TypeScript
ArrowFunction
a => a.tokenMint == tokenInfo?.address
Muffintechxyz/metaplex
js/packages/web/src/hooks/useNFTData.tsx
TypeScript
ArrowFunction
() => { setPriceUSD(tokenPrice * amount) }
Muffintechxyz/metaplex
js/packages/web/src/hooks/useNFTData.tsx
TypeScript
InterfaceDeclaration
interface IInputArtifact { account: string id: string }
Rossalli/charlescd
butler/src/app/v2/core/integrations/spinnaker/connector/utils/base-stage-helm.ts
TypeScript
InterfaceDeclaration
export interface IBaseHelmStage { stageEnabled: IStageEnabled | Record<string, unknown> completeOtherBranchesThenFail: false continuePipeline: true failPipeline: false expectedArtifacts: ICreateProduceArtifact[] inputArtifacts: IInputArtifact[] name: string namespace: string outputName: string overrides: { 'image.tag': string name: string circleId: string } templateRenderer: 'HELM2' type: 'bakeManifest' refId: string requisiteStageRefIds: string[] }
Rossalli/charlescd
butler/src/app/v2/core/integrations/spinnaker/connector/utils/base-stage-helm.ts
TypeScript
ArrowFunction
(event) => this._button_click(event)
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
ClassDeclaration
export abstract class AbstractButtonView extends WidgetView { model: AbstractButton protected icon_views: {[key: string]: AbstractIconView} protected buttonEl: HTMLButtonElement initialize(options: any): void { super.initialize(options) this.icon_views = {} this.render() } connect_signals(): void { super.connect_signals() this.connect(this.model.change, () => this.render()) } remove(): void { remove_views(this.icon_views) super.remove() } _render_button(...children: (string | HTMLElement)[]): HTMLButtonElement { return button({ type: "button", disabled: this.model.disabled, class: [`bk-bs-btn`, `bk-bs-btn-${this.model.button_type}`], }, ...children) } render(): void { super.render() empty(this.el) this.buttonEl = this._render_button(this.model.label) this.buttonEl.addEventListener("click", (event) => this._button_click(event)) this.el.appendChild(this.buttonEl) const icon = this.model.icon if (icon != null) { build_views(this.icon_views, [icon], {parent: this}) prepend(this.buttonEl, this.icon_views[icon.id].el, nbsp) } } _button_click(event: Event): void { event.preventDefault() this.change_input() } change_input(): void { if (this.model.callback != null) this.model.callback.execute(this.model) } }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
ClassDeclaration
export abstract class AbstractButton extends Widget { constructor(attrs?: Partial<AbstractButton.Attrs>, opts?: AbstractButton.Opts) { super(attrs, opts) } static initClass() { this.prototype.type = "AbstractButton" this.define({ label: [ p.String, "Button" ], icon: [ p.Instance ], button_type: [ p.String, "default" ], // TODO (bev) callback: [ p.Instance ], }) } }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
InterfaceDeclaration
export interface Attrs extends Widget.Attrs { label: string icon: AbstractIcon button_type: ButtonType callback: any // XXX }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
InterfaceDeclaration
export interface Opts extends Widget.Opts {}
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
InterfaceDeclaration
export interface AbstractButton extends AbstractButton.Attrs {}
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
TypeAliasDeclaration
export type ButtonType = "default" | "primary" | "success" | "warning" | "danger" | "link"
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
initialize(options: any): void { super.initialize(options) this.icon_views = {} this.render() }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
connect_signals(): void { super.connect_signals() this.connect(this.model.change, () => this.render()) }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
remove(): void { remove_views(this.icon_views) super.remove() }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
_render_button(...children: (string | HTMLElement)[]): HTMLButtonElement { return button({ type: "button", disabled: this.model.disabled, class: [`bk-bs-btn`, `bk-bs-btn-${this.model.button_type}`], }, ...children) }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
render(): void { super.render() empty(this.el) this.buttonEl = this._render_button(this.model.label) this.buttonEl.addEventListener("click", (event) => this._button_click(event)) this.el.appendChild(this.buttonEl) const icon = this.model.icon if (icon != null) { build_views(this.icon_views, [icon], {parent: this}) prepend(this.buttonEl, this.icon_views[icon.id].el, nbsp) } }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
_button_click(event: Event): void { event.preventDefault() this.change_input() }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
change_input(): void { if (this.model.callback != null) this.model.callback.execute(this.model) }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
MethodDeclaration
static initClass() { this.prototype.type = "AbstractButton" this.define({ label: [ p.String, "Button" ], icon: [ p.Instance ], button_type: [ p.String, "default" ], // TODO (bev) callback: [ p.Instance ], }) }
hanteng/bokeh
bokehjs/src/coffee/models/widgets/abstract_button.ts
TypeScript
ArrowFunction
(ref: Toaster) => (this.toaster = ref)
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => !!appState.gitHubToken || !appState.isTokenDialogShowing
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => !appState.isGenericDialogShowing
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => { let text; if (gistId) { text = actionType; } else if (activeGistAction === GistActionState.updating) { text = 'Updating...'; } else if (activeGistAction === GistActionState.publishing) { text = 'Publishing...'; } else if (activeGistAction === GistActionState.deleting) { text = 'Deleting...'; } else { text = 'Publish'; } return text; }
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => { switch (actionType) { case GistActionType.publish: return 'upload'; case GistActionType.update: return 'refresh'; case GistActionType.delete: return 'delete'; } }
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => { const { gistId } = this.props.appState; const { actionType } = this.state; if (!gistId) { return null; } const menu = ( <Menu> <MenuItem text="Publish" active={actionType === GistActionType.publish}
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript
ArrowFunction
() => { const { gitHubPublishAsPublic, gistId } = this.props.appState; const { actionType } = this.state; if (gistId && actionType !== GistActionType.publish) { return null; } const privacyIcon = gitHubPublishAsPublic ? 'unlock' : 'lock'; const privacyMenu = ( <Menu> <MenuItem text="Private" icon="lock" active={!gitHubPublishAsPublic}
FAWLKTZ/fiddle
src/renderer/components/commands-action-button.tsx
TypeScript