type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
h => h < 12 && h > 0
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ArrowFunction
option => formatOption(option, disabledOptions)
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ArrowFunction
c => (format.match(/\sA/) ? c.toUpperCase() : c)
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ArrowFunction
c => ({ value: c })
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
ClassDeclaration
export class Combobox extends Component<IComboboxProps, {}> { public onItemChange = (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); }; public onEnterSelectPanel = (range: any) => { if (this.props.onCurrentSelectPanelChange) { this.props.onCurrentSelectPanelChange(range); } }; public getHourSelect(hour: any) { const { prefixCls, hourOptions, disabledHours, showHour, use12Hours } = this.props; if (!showHour) { return null; } const disabledOptions = disabledHours && disabledHours(); let hourOptionsAdj; let hourAdj; if (use12Hours) { hourOptionsAdj = [12].concat(hourOptions.filter(h => h < 12 && h > 0)); hourAdj = hour % 12 || 12; } else { hourOptionsAdj = hourOptions; hourAdj = hour; } return ( <Select prefixCls={prefixCls} options={hourOptionsAdj.map(option => formatOption(option, disabledOptions) )} selectedIndex={hourOptionsAdj.indexOf(hourAdj)} type="hour" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "hour")} /> ); } public getMinuteSelect(minute: any) { const { prefixCls, minuteOptions, disabledMinutes, defaultOpenValue, showMinute } = this.props; if (!showMinute) { return null; } const value = this.props.value || defaultOpenValue; const disabledOptions = disabledMinutes && disabledMinutes(value.hour()); return ( <Select prefixCls={prefixCls} options={minuteOptions.map(option => formatOption(option, disabledOptions) )} selectedIndex={minuteOptions.indexOf(minute)} type="minute" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "minute")} /> ); } public getSecondSelect(second: any) { const { prefixCls, secondOptions, disabledSeconds, showSecond, defaultOpenValue } = this.props; if (!showSecond) { return null; } const value = this.props.value || defaultOpenValue; const disabledOptions = disabledSeconds && disabledSeconds(value.hour(), value.minute()); return ( <Select prefixCls={prefixCls} options={secondOptions.map(option => formatOption(option, disabledOptions) )} selectedIndex={secondOptions.indexOf(second)} type="second" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "second")} /> ); } public getAMPMSelect() { const { prefixCls, use12Hours, format } = this.props; if (!use12Hours) { return null; } const AMPMOptions = ["am", "pm"] // If format has A char, then we should uppercase AM/PM .map(c => (format.match(/\sA/) ? c.toUpperCase() : c)) .map(c => ({ value: c })); const selected = this.props.isAM ? 0 : 1; return ( <Select prefixCls={prefixCls} options={AMPMOptions} selectedIndex={selected} type="ampm" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "ampm")} /> ); } public render() { const { prefixCls, defaultOpenValue } = this.props; const value = this.props.value || defaultOpenValue; return ( <div className={`${prefixCls}-combobox`}
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
InterfaceDeclaration
interface IComboboxProps { format: string; defaultOpenValue: moment.Moment; prefixCls: string; value?: moment.Moment; onChange: (...args: any[]) => any; showHour?: boolean; showMinute?: boolean; showSecond?: boolean; hourOptions: any[]; minuteOptions: any[]; secondOptions: any[]; disabledHours?: (...args: any[]) => any; disabledMinutes?: (...args: any[]) => any; disabledSeconds?: (...args: any[]) => any; onCurrentSelectPanelChange?: (...args: any[]) => any; use12Hours?: boolean; isAM?: boolean; }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
MethodDeclaration
public getHourSelect(hour: any) { const { prefixCls, hourOptions, disabledHours, showHour, use12Hours } = this.props; if (!showHour) { return null; } const disabledOptions = disabledHours && disabledHours(); let hourOptionsAdj; let hourAdj; if (use12Hours) { hourOptionsAdj = [12].concat(hourOptions.filter(h => h < 12 && h > 0)); hourAdj = hour % 12 || 12; } else { hourOptionsAdj = hourOptions; hourAdj = hour; } return ( <Select prefixCls={prefixCls} options={hourOptionsAdj.map(option => formatOption(option, disabledOptions) )} selectedIndex={hourOptionsAdj.indexOf(hourAdj)} type="hour" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "hour")} /> ); }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
MethodDeclaration
public getMinuteSelect(minute: any) { const { prefixCls, minuteOptions, disabledMinutes, defaultOpenValue, showMinute } = this.props; if (!showMinute) { return null; } const value = this.props.value || defaultOpenValue; const disabledOptions = disabledMinutes && disabledMinutes(value.hour()); return ( <Select prefixCls={prefixCls} options={minuteOptions.map(option => formatOption(option, disabledOptions) )} selectedIndex={minuteOptions.indexOf(minute)} type="minute" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "minute")} /> ); }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
MethodDeclaration
public getSecondSelect(second: any) { const { prefixCls, secondOptions, disabledSeconds, showSecond, defaultOpenValue } = this.props; if (!showSecond) { return null; } const value = this.props.value || defaultOpenValue; const disabledOptions = disabledSeconds && disabledSeconds(value.hour(), value.minute()); return ( <Select prefixCls={prefixCls} options={secondOptions.map(option => formatOption(option, disabledOptions) )} selectedIndex={secondOptions.indexOf(second)} type="second" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "second")} /> ); }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
MethodDeclaration
public getAMPMSelect() { const { prefixCls, use12Hours, format } = this.props; if (!use12Hours) { return null; } const AMPMOptions = ["am", "pm"] // If format has A char, then we should uppercase AM/PM .map(c => (format.match(/\sA/) ? c.toUpperCase() : c)) .map(c => ({ value: c })); const selected = this.props.isAM ? 0 : 1; return ( <Select prefixCls={prefixCls} options={AMPMOptions} selectedIndex={selected} type="ampm" onSelect={this.onItemChange} onMouseEnter={this.onEnterSelectPanel.bind(this, "ampm")} /> ); }
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
MethodDeclaration
public render() { const { prefixCls, defaultOpenValue } = this.props; const value = this.props.value || defaultOpenValue; return ( <div className={`${prefixCls}-combobox`}
Anddd7/molb-libui
src/components/timePicker/Combobox.tsx
TypeScript
InterfaceDeclaration
interface PaperPropsVariantOverrides { centered: true; }
BearerPipelineTest/hetty
admin/src/lib/mui/theme.ts
TypeScript
FunctionDeclaration
export declare function extendCandle(candle: any, decimalPlaces: number): any;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
ClassDeclaration
export declare class JsonDataSource implements DataSource { sub: any; marketId: string; _decimalPlaces: number; get decimalPlaces(): number; constructor(marketId: string, decimalPlaces: number); onReady(): Promise<{ decimalPlaces: number; supportedIntervals: Interval[]; priceMonitoringBounds: {}; }>; query(interval: Interval, _from: string, _to: string): Promise<any[]>; subscribeData(_interval: Interval, _onSubscriptionData: (datum: any) => void): void; unsubscribeData(): void; subscribeAnnotations(onSubscriptionAnnotation: (annotations: Annotation[]) => void): void; unsubscribeAnnotations(): void; }
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
onReady(): Promise<{ decimalPlaces: number; supportedIntervals: Interval[]; priceMonitoringBounds: {}; }>;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
query(interval: Interval, _from: string, _to: string): Promise<any[]>;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
subscribeData(_interval: Interval, _onSubscriptionData: (datum: any) => void): void;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
unsubscribeData(): void;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
subscribeAnnotations(onSubscriptionAnnotation: (annotations: Annotation[]) => void): void;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
MethodDeclaration
unsubscribeAnnotations(): void;
0xkarl/pennant
dist/types/stories/data-source/json-data-source.d.ts
TypeScript
ArrowFunction
() => { const dispatch = useAppDispatch(); const params = useParams(); const navigate = useNavigate(); const poolAddress = params?.poolAddress ?? ''; const pool = useAppSelector((state) => userSelector.poolById(state, poolAddress)); const inTokenInfo = useAppSelector((state) => tokensSelector.tokenByAddress(state, pool?.firstToken?.address), ); const outTokenInfo = useAppSelector((state) => tokensSelector.tokenByAddress(state, pool?.secondToken?.address), ); const handleRemovePool = useCallback(() => { dispatch(userActions.removePoolLiquidity(poolAddress)); navigate(-1); }, [dispatch, navigate, poolAddress]); useEffect(() => { dispatch(swapActions.updatePairPriceByPool(params?.poolAddress ?? '')); }, []); return ( <div className={cssPrefix}> <PoolHeader linkTo={'../../pool'} label={<Arrow />}
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
(state) => userSelector.poolById(state, poolAddress)
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
(state) => tokensSelector.tokenByAddress(state, pool?.firstToken?.address)
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
(state) => tokensSelector.tokenByAddress(state, pool?.secondToken?.address)
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
() => { dispatch(userActions.removePoolLiquidity(poolAddress)); navigate(-1); }
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
() => { dispatch(swapActions.updatePairPriceByPool(params?.poolAddress ?? '')); }
scuderia1000/tondex
src/containers/pool/remove/RemovePool.tsx
TypeScript
ArrowFunction
_ => { this.authService.setLoggedUser(user) this.favouriteCourses = user.favouriteMovies }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
ArrowFunction
() => { this.getCourses(); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
ArrowFunction
response => { this.courses = response; }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-course-cards-list', templateUrl: './course-cards-list.component.html', styleUrls: ['./course-cards-list.component.scss'] }) export class CoursesCardsListComponent implements OnInit, OnDestroy { courses: Course[]; formGroup: FormGroup; destroy$ = new Subject<boolean>(); isAdmin = false favouriteCourses: string constructor(private coursesService: CoursesService, private fb: FormBuilder, private authService: AuthenticationService) { } ngOnInit(): void { this.getCourses(); this.formGroup = this.fb.group({ search: [''] }); this.isAdmin = this.authService.getIsAdmin() this.favouriteCourses = this.authService.getFavouriteCourses() } ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); } onCourseSelected(title: string): void { let user = this.authService.getLoggedUser() if(!user.favouriteMovies.includes(title)) { if(user.favouriteMovies.length > 0) { title = `, ${title}` } user.favouriteMovies = `${user.favouriteMovies}${title}` this.authService.updateUser(user).pipe( takeUntil(this.destroy$) ).subscribe(_ => { this.authService.setLoggedUser(user) this.favouriteCourses = user.favouriteMovies }); } } onSearch(): void { // get title from form const searchValue = this.formGroup.controls.search.value; this.getCourses(searchValue); } onClearSearch(): void { this.formGroup.get('search').setValue(null); this.getCourses(); } onDelete(id: number): void { this.coursesService.deleteCourse(id).pipe( takeUntil(this.destroy$) ).subscribe(() => { this.getCourses(); }); } private getCourses(searchValue?: string): void { this.coursesService.getCourses(searchValue).pipe( // map(response => response.filter(x => x.rating > 7)), takeUntil(this.destroy$) ).subscribe(response => { this.courses = response; }, error => { console.log(error); }); } }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
ngOnInit(): void { this.getCourses(); this.formGroup = this.fb.group({ search: [''] }); this.isAdmin = this.authService.getIsAdmin() this.favouriteCourses = this.authService.getFavouriteCourses() }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
onCourseSelected(title: string): void { let user = this.authService.getLoggedUser() if(!user.favouriteMovies.includes(title)) { if(user.favouriteMovies.length > 0) { title = `, ${title}` } user.favouriteMovies = `${user.favouriteMovies}${title}` this.authService.updateUser(user).pipe( takeUntil(this.destroy$) ).subscribe(_ => { this.authService.setLoggedUser(user) this.favouriteCourses = user.favouriteMovies }); } }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
onSearch(): void { // get title from form const searchValue = this.formGroup.controls.search.value; this.getCourses(searchValue); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
onClearSearch(): void { this.formGroup.get('search').setValue(null); this.getCourses(); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
onDelete(id: number): void { this.coursesService.deleteCourse(id).pipe( takeUntil(this.destroy$) ).subscribe(() => { this.getCourses(); }); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
MethodDeclaration
private getCourses(searchValue?: string): void { this.coursesService.getCourses(searchValue).pipe( // map(response => response.filter(x => x.rating > 7)), takeUntil(this.destroy$) ).subscribe(response => { this.courses = response; }, error => { console.log(error); }); }
hristo1998/Courseing
course-app/src/app/courses/course-cards-list/course-cards-list.component.ts
TypeScript
ClassDeclaration
export class MessageContentTest extends AbstractTest { public run(): void { const that = this describe("MessageContent", function () { let transport: Transport let recipient1: AccountController let recipient2: AccountController let sender: AccountController this.timeout(40000) before(async function () { transport = new Transport(that.connection, that.config, that.loggerFactory) await TestUtil.clearAccounts(that.connection) await transport.init() const accounts = await TestUtil.provideAccounts(transport, 3, MessageContentTest.name) recipient1 = accounts[0] recipient2 = accounts[1] sender = accounts[2] await TestUtil.addRelationship(sender, recipient1) await TestUtil.addRelationship(sender, recipient2) }) describe("Any Content", function () { it("should send the message", async function () { const value: any = await SerializableAsync.from({ any: "content", submitted: true }) expect(value).instanceOf(JSONWrapperAsync) await TestUtil.sendMessage(sender, recipient1, value) }) it("should correctly store the message (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(1) const message = messages[0] const content = message.cache!.content as any expect(content).instanceOf(JSONWrapperAsync) expect(content.value.any).equals("content") expect(content.value.submitted).equals(true) }) it("should correctly serialize the message (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(1) const message = messages[0] const object = message.toJSON() as any expect(object.cache.content).to.exist expect(object.cache.content.any).equals("content") expect(object.cache.content.submitted).equals(true) }) it("should correctly store the message (recipient)", async function () { const messagesSync = await TestUtil.syncUntilHasMessages(recipient1) expect(messagesSync).lengthOf(1) const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(1) const message = messages[0] const content = message.cache!.content as any expect(content).instanceOf(JSONWrapperAsync) expect(content.value.any).equals("content") expect(content.value.submitted).equals(true) }) it("should correctly serialize the message (recipient)", async function () { const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(1) const message = messages[0] const object = message.toJSON() as any expect(object.cache.content).to.exist expect(object.cache.content.any).equals("content") expect(object.cache.content.submitted).equals(true) }) }) describe("Mail", function () { it("should send the message", async function () { const value: Mail = await Mail.from({ body: "Test", subject: "Test Subject", to: [recipient1.identity.address] }) const message = await TestUtil.sendMessage(sender, recipient1, value) expect(message).to.exist }) it("should correctly store the me4ssage (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(2) const message = messages[1] expect(message.cache!.content).instanceOf(Mail) const content: Mail = message.cache!.content as Mail expect(content.body).equals("Test") expect(content.subject).equals("Test Subject") expect(content.to).to.be.an("Array") expect(content.to[0]).instanceOf(CoreAddress) expect(content.to[0].toString()).equals(recipient1.identity.address.toString()) }) it("should correctly store the message (recipient)", async function () { const messagesSync = await TestUtil.syncUntilHasMessages(recipient1) expect(messagesSync).lengthOf(1) const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(2) const message = messages[1] const content: Mail = message.cache!.content as Mail expect(content.body).equals("Test") expect(content.subject).equals("Test Subject") expect(content.to).to.be.an("Array") expect(content.to[0]).instanceOf(CoreAddress) expect(content.to[0].toString()).equals(recipient1.identity.address.toString()) }) }) after(async function () { await recipient1.close() await recipient2.close() await sender.close() }) }) } }
nmshd/cns-transport
test/modules/messages/MessageContent.test.ts
TypeScript
ClassDeclaration
@type("Mail") class Mail extends SerializableAsync implements IMail { @serialize({ type: CoreAddress }) @validate() public to: CoreAddress[] @serialize({ type: CoreAddress }) @validate({ nullable: true }) public cc: CoreAddress[] = [] @serialize() @validate() public subject: string @serialize() @validate() public body: string public static async from(value: IMail): Promise<Mail> { if (typeof value.cc === "undefined") { value.cc = [] } if (typeof value.body === "undefined" && (value as any).content) { value.body = (value as any).content delete (value as any).content } const obj: Mail = await super.fromT(value, Mail) return obj } }
nmshd/cns-transport
test/modules/messages/MessageContent.test.ts
TypeScript
InterfaceDeclaration
interface IMail extends ISerializableAsync { to: ICoreAddress[] cc?: ICoreAddress[] subject: string body: string }
nmshd/cns-transport
test/modules/messages/MessageContent.test.ts
TypeScript
MethodDeclaration
public run(): void { const that = this describe("MessageContent", function () { let transport: Transport let recipient1: AccountController let recipient2: AccountController let sender: AccountController this.timeout(40000) before(async function () { transport = new Transport(that.connection, that.config, that.loggerFactory) await TestUtil.clearAccounts(that.connection) await transport.init() const accounts = await TestUtil.provideAccounts(transport, 3, MessageContentTest.name) recipient1 = accounts[0] recipient2 = accounts[1] sender = accounts[2] await TestUtil.addRelationship(sender, recipient1) await TestUtil.addRelationship(sender, recipient2) }) describe("Any Content", function () { it("should send the message", async function () { const value: any = await SerializableAsync.from({ any: "content", submitted: true }) expect(value).instanceOf(JSONWrapperAsync) await TestUtil.sendMessage(sender, recipient1, value) }) it("should correctly store the message (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(1) const message = messages[0] const content = message.cache!.content as any expect(content).instanceOf(JSONWrapperAsync) expect(content.value.any).equals("content") expect(content.value.submitted).equals(true) }) it("should correctly serialize the message (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(1) const message = messages[0] const object = message.toJSON() as any expect(object.cache.content).to.exist expect(object.cache.content.any).equals("content") expect(object.cache.content.submitted).equals(true) }) it("should correctly store the message (recipient)", async function () { const messagesSync = await TestUtil.syncUntilHasMessages(recipient1) expect(messagesSync).lengthOf(1) const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(1) const message = messages[0] const content = message.cache!.content as any expect(content).instanceOf(JSONWrapperAsync) expect(content.value.any).equals("content") expect(content.value.submitted).equals(true) }) it("should correctly serialize the message (recipient)", async function () { const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(1) const message = messages[0] const object = message.toJSON() as any expect(object.cache.content).to.exist expect(object.cache.content.any).equals("content") expect(object.cache.content.submitted).equals(true) }) }) describe("Mail", function () { it("should send the message", async function () { const value: Mail = await Mail.from({ body: "Test", subject: "Test Subject", to: [recipient1.identity.address] }) const message = await TestUtil.sendMessage(sender, recipient1, value) expect(message).to.exist }) it("should correctly store the me4ssage (sender)", async function () { const messages = await sender.messages.getMessagesByAddress(recipient1.identity.address) expect(messages).lengthOf(2) const message = messages[1] expect(message.cache!.content).instanceOf(Mail) const content: Mail = message.cache!.content as Mail expect(content.body).equals("Test") expect(content.subject).equals("Test Subject") expect(content.to).to.be.an("Array") expect(content.to[0]).instanceOf(CoreAddress) expect(content.to[0].toString()).equals(recipient1.identity.address.toString()) }) it("should correctly store the message (recipient)", async function () { const messagesSync = await TestUtil.syncUntilHasMessages(recipient1) expect(messagesSync).lengthOf(1) const messages = await recipient1.messages.getMessagesByAddress(sender.identity.address) expect(messages).lengthOf(2) const message = messages[1] const content: Mail = message.cache!.content as Mail expect(content.body).equals("Test") expect(content.subject).equals("Test Subject") expect(content.to).to.be.an("Array") expect(content.to[0]).instanceOf(CoreAddress) expect(content.to[0].toString()).equals(recipient1.identity.address.toString()) }) }) after(async function () { await recipient1.close() await recipient2.close() await sender.close() }) }) }
nmshd/cns-transport
test/modules/messages/MessageContent.test.ts
TypeScript
MethodDeclaration
public static async from(value: IMail): Promise<Mail> { if (typeof value.cc === "undefined") { value.cc = [] } if (typeof value.body === "undefined" && (value as any).content) { value.body = (value as any).content delete (value as any).content } const obj: Mail = await super.fromT(value, Mail) return obj }
nmshd/cns-transport
test/modules/messages/MessageContent.test.ts
TypeScript
ArrowFunction
() => { let component: NgxCheckboxComponent; let fixture: ComponentFixture<NgxCheckboxComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ NgxCheckboxComponent ] }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(NgxCheckboxComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }
DavidRnR/ngx-checkbox
src/app/modules/ngx-checkbox/ngx-checkbox.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ declarations: [ NgxCheckboxComponent ] }) .compileComponents(); }
DavidRnR/ngx-checkbox
src/app/modules/ngx-checkbox/ngx-checkbox.component.spec.ts
TypeScript
ArrowFunction
() => { fixture = TestBed.createComponent(NgxCheckboxComponent); component = fixture.componentInstance; fixture.detectChanges(); }
DavidRnR/ngx-checkbox
src/app/modules/ngx-checkbox/ngx-checkbox.component.spec.ts
TypeScript
ArrowFunction
() => { let component: SummaryComponent; let fixture: ComponentFixture<SummaryComponent>; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [SummaryComponent], }).compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(SummaryComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }
DZemlyak/angular
apps/website/src/app/demos/submodules/dyn-forms/components/stepper/summary/summary.component.spec.ts
TypeScript
ArrowFunction
async () => { await TestBed.configureTestingModule({ declarations: [SummaryComponent], }).compileComponents(); }
DZemlyak/angular
apps/website/src/app/demos/submodules/dyn-forms/components/stepper/summary/summary.component.spec.ts
TypeScript
ArrowFunction
() => { fixture = TestBed.createComponent(SummaryComponent); component = fixture.componentInstance; fixture.detectChanges(); }
DZemlyak/angular
apps/website/src/app/demos/submodules/dyn-forms/components/stepper/summary/summary.component.spec.ts
TypeScript
ArrowFunction
({title}: Props) => { return ( <header> <h1>{title}</h1> <hr /> </header> ) }
cadumega/EstudosReactB7Web-vite
src/components/Btn.tsx
TypeScript
TypeAliasDeclaration
type Props = { //title: string; // Especifiquei como uma prop obrigatoria title?: string; //opcional a prop }
cadumega/EstudosReactB7Web-vite
src/components/Btn.tsx
TypeScript
FunctionDeclaration
export function requestPiletsFromGraphQL(client: UrqlClient) { return gqlQuery<PiletQueryResult>(client, piletsQuery).then(({ pilets }) => pilets); }
MattShrider/piral
src/packages/piral-urql/src/pilets.ts
TypeScript
ArrowFunction
({ pilets }) => pilets
MattShrider/piral
src/packages/piral-urql/src/pilets.ts
TypeScript
InterfaceDeclaration
export interface PiletQueryResult { pilets: Array<PiletMetadata>; }
MattShrider/piral
src/packages/piral-urql/src/pilets.ts
TypeScript
ArrowFunction
() => { const snackMessageInitialState = {}; it('should display a snack message', () => { const snackMessage = 'Welcome to Kari4me'; const expectedAction = { snack: { message: snackMessage, withName: false, }, type: DISPLAY_SNACK_MESSAGE, }; const store = reduxMockStore({}, snackMessageInitialState); store.dispatch(displaySnackMessage(snackMessage)); expect(store.getActions()[0]).toEqual(expectedAction); }); }
mashafrancis/guacamole-fe
src/store/modules/snack/snack.actions.test.ts
TypeScript
ArrowFunction
() => { const snackMessage = 'Welcome to Kari4me'; const expectedAction = { snack: { message: snackMessage, withName: false, }, type: DISPLAY_SNACK_MESSAGE, }; const store = reduxMockStore({}, snackMessageInitialState); store.dispatch(displaySnackMessage(snackMessage)); expect(store.getActions()[0]).toEqual(expectedAction); }
mashafrancis/guacamole-fe
src/store/modules/snack/snack.actions.test.ts
TypeScript
FunctionDeclaration
function RsvpButton({ event, onSuccess, onError, }: RsvpButtonProps & RouteComponentProps) { const account = AuthProviderInstance.account; const hasJoinedEvent = useMemo<boolean>( () => !!account && (event.participants ?.map((person) => person.id) ?.includes(account.localAccountId) || event.owner?.id === account.localAccountId), [account, event.owner, event.participants] ); const handleClick = useCallback(async () => { try { await joinOrDropEvent(event.id, hasJoinedEvent); if (onSuccess) { onSuccess(); } } catch (e) { if (onError) { onError(e); } } }, [hasJoinedEvent, event, onSuccess, onError]); const isOwner = account && event.owner?.id === account.localAccountId; if (isOwner) { return null; } return ( <Button variant="highlight" onClick={handleClick} disabled={account == null}
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
FunctionDeclaration
async function joinOrDropEvent( eventId: string, hasJoinedEvent: boolean ): Promise<boolean> { if (hasJoinedEvent) { await dropEvent(eventId); return true; } else { await joinEvent(eventId); return false; } }
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
ArrowFunction
() => !!account && (event.participants ?.map((person) => person.id) ?.includes(account.localAccountId) || event.owner?.id === account.localAccountId)
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
ArrowFunction
(person) => person.id
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
ArrowFunction
async () => { try { await joinOrDropEvent(event.id, hasJoinedEvent); if (onSuccess) { onSuccess(); } } catch (e) { if (onError) { onError(e); } } }
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
TypeAliasDeclaration
type RsvpButtonProps = { event: Event; onSuccess?: () => void; onError?: (e: Error) => void; };
Itera/mad-learning
src/components/inputs/RsvpButton/RsvpButton.tsx
TypeScript
TypeAliasDeclaration
type Ipc = { on: (k: string, handler: any) => void; invoke: <T>(k: string) => Promise<T>; send: (k: string, payload?: any) => void; };
T4rk1n/dazzler
src/electron/renderer/ipc.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.post(namespace, has_auth(), has_body, mk_valid_body_mw_ignore(schema, ['id', 'username']), (request: restify.Request, res: restify.Response, next: restify.Next) => { createCategorise(request as CategoriseBodyReq) .then(categorise => { res.json(201, categorise); return next(); }) .catch(next); } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { createCategorise(request as CategoriseBodyReq) .then(categorise => { res.json(201, categorise); return next(); }) .catch(next); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
categorise => { res.json(201, categorise); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(namespace, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { // TODO: Add query params getManyCategorise(request as unknown as Request & IOrmReq) .then(categorises => { res.json({ categorises }); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { // TODO: Add query params getManyCategorise(request as unknown as Request & IOrmReq) .then(categorises => { res.json({ categorises }); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
categorises => { res.json({ categorises }); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/csv`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getAllCategorise(request as unknown as Request & IOrmReq) .then(categorises => { /*res.writeHead(200, { 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename=export.csv' }); console.info('categorises:', categorises, ';');*/ const fields = Object.keys(categorises[0]); const opts = { fields }; try { const parser = new Parser(opts); const csv = parser.parse(categorises); console.log(csv); res.json({ csv }); } catch (err) { console.error(err); } return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getAllCategorise(request as unknown as Request & IOrmReq) .then(categorises => { /*res.writeHead(200, { 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename=export.csv' }); console.info('categorises:', categorises, ';');*/ const fields = Object.keys(categorises[0]); const opts = { fields }; try { const parser = new Parser(opts); const csv = parser.parse(categorises); console.log(csv); res.json({ csv }); } catch (err) { console.error(err); } return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
categorises => { /*res.writeHead(200, { 'Content-Type': 'text/csv', 'Content-Disposition': 'attachment; filename=export.csv' }); console.info('categorises:', categorises, ';');*/ const fields = Object.keys(categorises[0]); const opts = { fields }; try { const parser = new Parser(opts); const csv = parser.parse(categorises); console.log(csv); res.json({ csv }); } catch (err) { console.error(err); } return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/next`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getNextArtifactByCategory(request as unknown as Request & IOrmReq & {user_id: string}) .then(artifacts => { res.json({ artifacts }); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getNextArtifactByCategory(request as unknown as Request & IOrmReq & {user_id: string}) .then(artifacts => { res.json({ artifacts }); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
artifacts => { res.json({ artifacts }); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/next_diff`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseDiffC(request as unknown as Request & IOrmReq & {user_id: string}) .then(artifactLocations => { res.json({ artifactLocations }); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseDiffC(request as unknown as Request & IOrmReq & {user_id: string}) .then(artifactLocations => { res.json({ artifactLocations }); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
artifactLocations => { res.json({ artifactLocations }); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/stats`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getStatsArtifactByCategory(request as unknown as Request & IOrmReq & {user_id: string}) .then(stats => { res.json(stats); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getStatsArtifactByCategory(request as unknown as Request & IOrmReq & {user_id: string}) .then(stats => { res.json(stats); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
stats => { res.json(stats); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/agg_stats`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseStats(request as unknown as Request & IOrmReq & {user_id: string}) .then(stats => { res.json(stats); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseStats(request as unknown as Request & IOrmReq & {user_id: string}) .then(stats => { res.json(stats); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(app: restify.Server, namespace: string = '') => app.get(`${namespace}/cat_diff`, has_auth(), (request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseDiff(request as unknown as Request & IOrmReq & {user_id: string}) .then(categorise_diff => { res.json(categorise_diff); return next(); }) .catch(next) } )
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(request: restify.Request, res: restify.Response, next: restify.Next) => { getCategoriseDiff(request as unknown as Request & IOrmReq & {user_id: string}) .then(categorise_diff => { res.json(categorise_diff); return next(); }) .catch(next) }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
categorise_diff => { res.json(categorise_diff); return next(); }
healthplatform/healthplatform-nodejs-rest-api
api/categorise/routes.ts
TypeScript
ArrowFunction
(result) => { return <ResultadoDto>{ status: true, mensagem: "Usuário cadastrado com sucesso!" } }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
ArrowFunction
(error) => { return <ResultadoDto>{ status: false, mensagem: "Houve um errro ao cadastrar o usuário" } }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
ClassDeclaration
@Injectable() export class UsuarioService { constructor( @Inject('USUARIO_REPOSITORY') private usuarioRepository: Repository<Usuario>, ) {} async listar(): Promise<Usuario[]> { return this.usuarioRepository.find(); } async cadastrar(data: UsuarioCadastrarDto): Promise<ResultadoDto>{ let usuario = new Usuario() usuario.email = data.email usuario.nome = data.nome usuario.senha = bcrypt.hashSync(data.senha, 8) usuario.telefone = data.telefone usuario.cpf = data.cpf return this.usuarioRepository.save(usuario) .then((result) => { return <ResultadoDto>{ status: true, mensagem: "Usuário cadastrado com sucesso!" } }) .catch((error) => { return <ResultadoDto>{ status: false, mensagem: "Houve um errro ao cadastrar o usuário" } }) } async findOne(email: string): Promise<Usuario | undefined> { return this.usuarioRepository.findOne({email: email}); } }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
MethodDeclaration
async listar(): Promise<Usuario[]> { return this.usuarioRepository.find(); }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
MethodDeclaration
async cadastrar(data: UsuarioCadastrarDto): Promise<ResultadoDto>{ let usuario = new Usuario() usuario.email = data.email usuario.nome = data.nome usuario.senha = bcrypt.hashSync(data.senha, 8) usuario.telefone = data.telefone usuario.cpf = data.cpf return this.usuarioRepository.save(usuario) .then((result) => { return <ResultadoDto>{ status: true, mensagem: "Usuário cadastrado com sucesso!" } }) .catch((error) => { return <ResultadoDto>{ status: false, mensagem: "Houve um errro ao cadastrar o usuário" } }) }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
MethodDeclaration
async findOne(email: string): Promise<Usuario | undefined> { return this.usuarioRepository.findOne({email: email}); }
evelynarruda/Teste
src/usuario/usuario.service.ts
TypeScript
ArrowFunction
() => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], imports: [ RouterTestingModule ], }).compileComponents(); })); it('should create the app', async(() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); })); }
2Future4U/angular-multi-layout-scaffolding
src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], imports: [ RouterTestingModule ], }).compileComponents(); }
2Future4U/angular-multi-layout-scaffolding
src/app/app.component.spec.ts
TypeScript
ArrowFunction
(i) => typesToArray[i] === obj.constructor
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ArrowFunction
(model) => { model.once('comm:close', () => { delete this._models[model_id]; }); }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ArrowFunction
() => { delete this._models[model_id]; }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ClassDeclaration
export class MockComm implements widgets.IClassicComm { constructor() { this.comm_id = `mock-comm-id-${numComms}`; numComms += 1; } on_open(fn: Function): void { this._on_open = fn; } on_close(fn: Function): void { this._on_close = fn; } on_msg(fn: Function): void { this._on_msg = fn; } _process_msg(msg: any): any { if (this._on_msg) { return this._on_msg(msg); } else { return Promise.resolve(); } } open(): string { if (this._on_open) { this._on_open(); } return ''; } close(): string { if (this._on_close) { this._on_close(); } return ''; } send(): string { return ''; } comm_id: string; target_name: string; _on_msg: Function | null = null; _on_open: Function | null = null; _on_close: Function | null = null; }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ClassDeclaration
class TestWidget extends widgets.WidgetModel { defaults(): Backbone.ObjectHash { return { ...super.defaults(), _model_module: 'test-widgets', _model_name: 'TestWidget', _model_module_version: '1.0.0', _view_module: 'test-widgets', _view_name: 'TestWidgetView', _view_module_version: '1.0.0', _view_count: null as any, }; } }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ClassDeclaration
class TestWidgetView extends widgets.WidgetView { render(): void { this._rendered += 1; super.render(); } remove(): void { this._removed += 1; super.remove(); } _removed = 0; _rendered = 0; }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript
ClassDeclaration
class BinaryWidget extends TestWidget { static serializers = { ...widgets.WidgetModel.serializers, array: array_serialization, }; defaults(): Backbone.ObjectHash { return { ...super.defaults(), _model_name: 'BinaryWidget', _view_name: 'BinaryWidgetView', array: new Int8Array(0), }; } }
KGerring/ipywidgets
packages/base/test/src/dummy-manager.ts
TypeScript