type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
() => { return request(testServer) .post('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + projectid + '/images') .expect(httpStatus.BAD_REQUEST) .then((res) => { assert.deepStrictEqual(res.body, { error : 'File not provided'...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'File not provided' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { return request(testServer) .post('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + projectid + '/images') .attach('image', './package.json') .expect(httpStatus.BAD_REQUEST) .then((res) => { assert.deep...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'Unsupported file type application/json' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { return request(testServer) .post('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + projectid + '/images') .attach('image', './src/tests/utils/resources/test-02.jpg') .expect(httpStatus.BAD_REQUEST) .then((res) => { ...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'Image label not provided' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
async () => { const project = await store.storeProject('studentid', TESTCLASS, 'text', 'invalid', 'en', [], false); return request(testServer) .post('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + project.id + '/images') .attach('image', './src/te...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'Only images projects allow image uploads' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { return request(testServer) .post('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + projectid + '/images') .attach('image', './src/tests/utils/resources/test-02.jpg') .field('label', 'MYSTERY') .expect(httpStatus.BAD_REQUE...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'Unrecognised label' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { it('should upload a file', async () => { const USER = 'TESTSTUDENT'; const LABEL = 'testlabel'; const project = await store.storeProject(USER, TESTCLASS, 'images', 'test uploads', 'en', [], false); await store.addLabelToProject(USER, TESTCLASS, project.id...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
async () => { const USER = 'TESTSTUDENT'; const LABEL = 'testlabel'; const project = await store.storeProject(USER, TESTCLASS, 'images', 'test uploads', 'en', [], false); await store.addLabelToProject(USER, TESTCLASS, project.id, LABEL); const IMAGESURL = '/...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert(res.body.id); assert.strictEqual(res.body.isstored, true); assert.strictEqual(res.body.label, LABEL); assert.strictEqual(res.body.projectid, project.id); assert(res.body.imageurl.startsWith(IMAGESURL...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { let projectid = ''; before(() => { return store.storeProject('studentid', TESTCLASS, 'images', 'invalids', 'en', [], false) .then((proj) => { projectid = proj.id; }); }); it('should handle non-existent images', (...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { return store.storeProject('studentid', TESTCLASS, 'images', 'invalids', 'en', [], false) .then((proj) => { projectid = proj.id; }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(proj) => { projectid = proj.id; }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { return request(testServer) .get('/api/classes/' + TESTCLASS + '/students/studentid/projects/' + projectid + '/images/someimageid') .expect(httpStatus.NOT_FOUND) .then((res) => { assert.deepStrictEqual(res.body, { error : 'File not ...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, { error : 'File not found' }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => { function readFileToBuffer(path: string) { return new Promise((resolve, reject) => { fs.readFile(path, (err, data) => { if (err) { return reject(err); } return resolve(data); ...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(resolve, reject) => { fs.readFile(path, (err, data) => { if (err) { return reject(err); } return resolve(data); }); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(err, data) => { if (err) { return reject(err); } return resolve(data); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
async () => { let id; const filepath = './src/tests/utils/resources/test-01.jpg'; const contents = await readFileToBuffer(filepath); const userid = uuid(); const project = await store.storeProject(userid, TESTCLASS, 'images', 'valid', 'en', [], false); ...
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert(res.body.id); id = res.body.id; assert.strictEqual(res.body.projectid, projectid); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
(res) => { assert.deepStrictEqual(res.body, contents); assert.strictEqual(res.header['content-type'], 'image/jpeg'); assert.strictEqual(res.header['cache-control'], 'max-age=31536000'); }
DGraveling/taxinomitis
src/tests/restapi/imageuploads.ts
TypeScript
ArrowFunction
() => UserService
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
ClassDeclaration
@Controller('user') export class UserController { constructor( @Inject(forwardRef(() => UserService)) private readonly userService: UserService, ) {} @Post() create(@Body() createUserDto: CreateUserDto) { return this.userService.create(createUserDto); } @Get('getByEmail') getUserByEmail(@Pa...
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Post() create(@Body() createUserDto: CreateUserDto) { return this.userService.create(createUserDto); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Get('getByEmail') getUserByEmail(@Param('email') email: string) { return this.userService.getUserByEmail(email); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Get() findAll() { return this.userService.findAll(); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Get('/:id') findById(@Param('id') id: string) { return this.userService.getById(id); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Patch(':id') update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { return this.userService.update(id, updateUserDto); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Delete(':id') remove(@Param('id') id: string) { return this.userService.remove(id); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('/join-to-room') async joinToRoom( @Body('userId') userId: string, @Body('roomId') roomId: string, ) { return this.userService.joinToRoom(userId, roomId); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Post('/leave-from-room') async leaveFromRoom(@Body('userId') userId: string): Promise<IUser> { return this.userService.leaveFromRoom(userId); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
MethodDeclaration
@Get('/room/:roomId') getAllUsersFromRoom(@Param('roomId') roomId: string): Promise<IUser[]> { return this.userService.getAllUsersFromRoom(roomId); }
balelkin/onix_home_work
src/components/user/user.controller.ts
TypeScript
ArrowFunction
props => { const { defaultVisibled = true, className, forwardedRef, wrapperClassName, innerClassName } = props; const [visibled, setVisibled] = useState(defaultVisibled); return ( <Input {...props} ref={forwardedRef} className={classNames(baseCls, className)} w...
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
ArrowFunction
(props, ref) => { return <Password {...props} forwardedRef={ref} />; }
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
InterfaceDeclaration
export interface IPasswordProps extends IInputProps { /** 默认可见 */ defaultVisibled?: boolean; }
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
InterfaceDeclaration
interface IForwardRefProps extends IPasswordProps { forwardedRef?: React.Ref<any>; }
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
MethodDeclaration
classNames(baseCls, className)
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
MethodDeclaration
classNames( getPrefixCls
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
MethodDeclaration
getPrefixCls('toggle', baseCls)
pwcong/rc-component-x
packages/input/password.tsx
TypeScript
FunctionDeclaration
function Image(props: ImageProps) { const { src, ratio, ...other } = props; return ( <Box {...other} sx={{ position: 'relative', '& div': { paddingTop: `${Math.round(ratio * 100)}%`, }, '& img': { position: 'absolute', top: 0, ...
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingHero() { return ( <Container> <Typography variant="h1" align="center" sx={{ mt: 9, mx: 'auto' }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingKPI() { return ( <Grid container spacing={1} sx={{ mb: { md: 15 } }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingMission() { return ( <Box sx={{ position: 'relative' }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingVision() { return ( <Container sx={{ my: 15 }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingTeam() { return ( <Box sx={{ bgcolor: 'greyF3', pt: 15, pb: 10 }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingCompany() { return ( <Box sx={{ bgcolor: 'greyEA', pt: 12, pb: 11 }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingContributors() { return ( <Box sx={{ bgcolor: 'greyF3', pt: 10, pb: 9 }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingEmeriti() { return ( <Box sx={{ bgcolor: 'greyEA', pt: 10, pb: 9 }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingJoinUs() { return ( <Box sx={{ bgcolor: 'secondary.main', color: 'secondary.contrastText', overflow: 'hidden', }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
function BrandingSupportUs() { return ( <Container sx={{ mt: [10, 18], mb: [12, 20] }}
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
FunctionDeclaration
export default function Page() { return ( <BrandingRoot> <Head title="About Us - Material-UI" description="Material-UI started back in 2014 to unify React and Material Design. Today, Material-UI has grown to become one of the world's most popular React libraries – used by a vibrant communit...
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
ArrowFunction
(member) => ( <Grid item
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
InterfaceDeclaration
interface ImageProps { src: string; ratio: number; sx?: BoxProps['sx']; }
Code0017/material-ui
docs/pages/branding/about.tsx
TypeScript
ArrowFunction
() => ` <div> <h2 class="banner-title"> Can't find your data? <span class="banner-title-link"> You may be looking for the <a href="https://gdc-portal.nci.nih.gov/legacy-archive/search/f" target="_blank">GDC Legacy...
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
ClassDeclaration
class HeaderController implements IHeaderController { bannerDismissed: boolean; isCollapsed: boolean = true; currentLang: string = "en"; addedLanguages: boolean = false; languages: any = { "en": "English", "fr": "French", "es": "Spanish" }; cookieEnabled: any; /* @ngI...
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
InterfaceDeclaration
export interface IHeaderController { bannerDismissed: boolean; isCollapsed: boolean; currentLang: string; addedLanguages: boolean; languages: any; cookieEnabled: any; getToken(): void; collapse(event: any): void; toggleCollapsed(): void; setLanguage(): void; shouldShowOptio...
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
getToken(): void { this.UserService.getToken(); }
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
collapse(event: any): void { if (event.which === 1 || event.which === 13) { this.isCollapsed = true; } }
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
toggleCollapsed(): void { this.isCollapsed = !this.isCollapsed; }
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
setLanguage(): void { this.gettextCatalog.setCurrentLanguage(this.currentLang); }
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
shouldShowOption(option: string): boolean { var showOption = true, currentState = (<any>_).get(this.$state, 'current.name', '').toLowerCase(); switch(option.toLowerCase()) { case 'quick-search': if (currentState === 'home') { showOption = false; } ...
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
dismissBanner(): void { this.bannerDismissed = true; this.$rootScope.$emit('hideBanner'); }
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
MethodDeclaration
showBannerModal(): void { if (!this.$uibModalStack.getTop()) { this.$uibModal.open({ templateUrl: "core/templates/modal.html", controller: "WarningController", controllerAs: "wc", backdrop: "static", keyboard: false, backdropClass: "warning-back...
IGS/portal-ui
app/scripts/components/header/header.controller.ts
TypeScript
ArrowFunction
({ iconUrl, onOpen, name, onDragStart }: Props) => { const ref = useRef<HTMLDivElement>(null); const [selected, setSelected] = useState(false); useEffect(() => { if (!selected) { return; } const handleClick = (e: MouseEvent) => { if (ref.current != null && ref.current.contains(e.target a...
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
ArrowFunction
() => { if (!selected) { return; } const handleClick = (e: MouseEvent) => { if (ref.current != null && ref.current.contains(e.target as Element)) { return; } setSelected(false); }; document.addEventListener("click", handleClick); return () => document.removeEvent...
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
ArrowFunction
(e: MouseEvent) => { if (ref.current != null && ref.current.contains(e.target as Element)) { return; } setSelected(false); }
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
ArrowFunction
() => document.removeEventListener("click", handleClick)
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
InterfaceDeclaration
interface Props { iconUrl: string; name: string; onOpen: () => void; onDragStart?: (e: React.DragEvent<HTMLDivElement>) => void; }
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
MethodDeclaration
classnames("desktop-icon", { selected })
Toughee/webamp
packages/webamp/demo/js/DesktopIcon.tsx
TypeScript
ArrowFunction
(_, {defaultRender}) => { return defaultRender(_); }
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
(_, record) => ( <Space> {record.labels.map(({name, color}) => ( <Tag color={color} key={name}> {name} </Tag> ))} </Space> )
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
({name, color}) => ( <Tag color={color}
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
(value) => { return { startTime: value[0], endTime: value[1], }; }
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
(text, record, _, action) => [ <a key="editable" onClick={()
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
() => { const actionRef = useRef<ActionType>(); return ( <PageContainer title={false}> <ProTable<GithubIssueItem, API.PageParams> columns={columns} actionRef={actionRef} cardBordered request={async (params = {}, sort, filter)
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
(values, type) => { if (type === 'get') { return { ...values, created_at: [values.startTime, values.endTime], }; } return values; }
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
ArrowFunction
(page) => console.log(page)
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
TypeAliasDeclaration
type GithubIssueItem = { url: string; id: number; number: number; title: string; labels: { name: string; color: string; }[]; state: string; comments: number; created_at: string; updated_at: string; closed_at?: string; };
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
MethodDeclaration
async (params = {}, sort, filter)
htaoji1988/bill99cloud-web
src/pages/UserManage/index.tsx
TypeScript
FunctionDeclaration
function requireHID(install?: boolean): any { if (HID) return HID; return HID = nodeutil.lazyRequire("node-hid", install); }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function isInstalled(info?: boolean): boolean { return !!requireHID(!!info); }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function listAsync() { if (!requireHID(true)) return Promise.resolve(); return getHF2DevicesAsync() .then(devices => { pxt.log(`found ${devices.length} HID devices`); devices.forEach(device => pxt.log(device)); }) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function serialAsync() { if (!requireHID(true)) return Promise.resolve(); return initAsync() .then(d => { d.autoReconnect = true connectSerial(d) }) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function dmesgAsync() { return initAsync() .then(d => d.talkAsync(pxt.HF2.HF2_CMD_DMESG) .then(resp => { console.log(U.fromUTF8(U.uint8ArrayToString(resp))) return d.disconnectAsync() })) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
function hex(n: number) { return ("000" + n.toString(16)).slice(-4) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function deviceInfo(h: HidDevice) { return `${h.product} (by ${h.manufacturer} at USB ${hex(h.vendorId)}:${hex(h.productId)})` }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
function getHF2Devices(): HidDevice[] { const hid = requireHID(false); if (!hid) return []; let devices = hid.devices() as HidDevice[] for (let d of devices) { pxt.debug(JSON.stringify(d)) } let serial = pxt.appTarget.serial return devices.filter(d => (serial && parseInt(ser...
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function getHF2DevicesAsync(): Promise<HidDevice[]> { return Promise.resolve(getHF2Devices()); }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function hf2ConnectAsync(path: string, raw = false) { if (!requireHID(true)) return Promise.resolve(undefined); // in .then() to make sure we catch errors let h = new HF2.Wrapper(new HidIO(path)) h.rawMode = raw return h.reconnectAsync(true).then(() => h) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function mkPacketIOAsync() { return Promise.resolve() .then(() => { // in .then() to make sure we catch errors return new HidIO(null) }) }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function initAsync(path: string = null): Promise<HF2.Wrapper> { if (!hf2Dev) { hf2Dev = hf2ConnectAsync(path) } return hf2Dev }
IoTDan/pxt
cli/hid.ts
TypeScript
FunctionDeclaration
export function connectSerial(w: HF2.Wrapper) { process.stdin.on("data", (buf: Buffer) => { w.sendSerialAsync(new Uint8Array(buf)).done() }) w.onSerial = (arr, iserr) => { let buf = new Buffer(arr) if (iserr) process.stderr.write(buf) else process.stdout.write(buf) } }
IoTDan/pxt
cli/hid.ts
TypeScript
ArrowFunction
devices => { pxt.log(`found ${devices.length} HID devices`); devices.forEach(device => pxt.log(device)); }
IoTDan/pxt
cli/hid.ts
TypeScript
ArrowFunction
device => pxt.log(device)
IoTDan/pxt
cli/hid.ts
TypeScript
ArrowFunction
d => { d.autoReconnect = true connectSerial(d) }
IoTDan/pxt
cli/hid.ts
TypeScript
ArrowFunction
d => d.talkAsync(pxt.HF2.HF2_CMD_DMESG) .then(resp => { console.log(U.fromUTF8(U.uint8ArrayToString(resp))) return d.disconnectAsync() })
IoTDan/pxt
cli/hid.ts
TypeScript
ArrowFunction
resp => { console.log(U.fromUTF8(U.uint8ArrayToString(resp))) return d.disconnectAsync() }
IoTDan/pxt
cli/hid.ts
TypeScript