type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
InterfaceDeclaration
export interface Service { hello: PostReq<string, string>; farewell: PostReq<(string|null), (string|null)>; blobs: CrudReqs<{}|null>; }
bacek/adl
haskell/compiler/tests/test24/ts-output/test24.ts
TypeScript
ArrowFunction
() => { beforeEach(() => TestBed.configureTestingModule({})); it('should be created', () => { const service: ActivityListService = TestBed.get(ActivityListService); expect(service).toBeTruthy(); }); }
m91michel/scrum-retro-planner
src/app/services/activity-list.service.spec.ts
TypeScript
ArrowFunction
() => TestBed.configureTestingModule({})
m91michel/scrum-retro-planner
src/app/services/activity-list.service.spec.ts
TypeScript
ArrowFunction
() => { const service: ActivityListService = TestBed.get(ActivityListService); expect(service).toBeTruthy(); }
m91michel/scrum-retro-planner
src/app/services/activity-list.service.spec.ts
TypeScript
InterfaceDeclaration
interface ReceivedInvitationMetadata { $type: 'com.linkedin.voyager.common.CollectionMetadata'; paginationToken: string; }
brunohafonso95/linkedin-private-api
src/responses/received-invitations.response.get.ts
TypeScript
TypeAliasDeclaration
export type GetReceivedInvitationResponse = LinkedInCollectionResponse< string, MiniProfile | LinkedInInvitation, ReceivedInvitationMetadata >;
brunohafonso95/linkedin-private-api
src/responses/received-invitations.response.get.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-chart', templateUrl: './chart.component.html', styleUrls: ['./chart.component.scss'] }) export class ChartComponent implements OnInit { types: string[] = ["spline", "stackedspline", "fullstackedspline"]; constructor() { } architecturesInfo: any[] = [{ year: 1997, flowers: 263, orders: 226, users: 10 }, { year: 1999, flowers: 169, orders: 256, users: 66 }, { year: 2001, flowers: 57, orders: 257, users: 143 }, { year: 2003, flowers: 0, orders: 163, users: 127 }, { year: 2005, flowers: 0, orders: 103, users: 36 }, { year: 2007, flowers: 0, orders: 91, users: 3 }]; ngOnInit(): void { } }
yeuho938/Dev-Angular-New-Version
src/app/modules/admin/components/chart/chart.component.ts
TypeScript
ArrowFunction
(props: ListActionsProps) => { const [isOpen, setIsOpen] = useState(false); return ( <EuiFlexGroup justifyContent="spaceBetween" alignItems="center"> <EuiFlexItem grow={false} style={{ marginRight: '16px' }}
AMoo-Miki/anomaly-detection-dashboards-plugin
public/pages/DetectorsList/components/ListActions/ListActions.tsx
TypeScript
InterfaceDeclaration
interface ListActionsProps { onStartDetectors(): void; onStopDetectors(): void; onDeleteDetectors(): void; isActionsDisabled: boolean; isStartDisabled: boolean; isStopDisabled: boolean; }
AMoo-Miki/anomaly-detection-dashboards-plugin
public/pages/DetectorsList/components/ListActions/ListActions.tsx
TypeScript
ArrowFunction
() => { it('create an instance', () => { const pipe = new SlotByDayPipe(); expect(pipe).toBeTruthy(); }); }
Basileum/angular6-scheduler
scheduler6/src/app/utils/scheduler/multislider/slot-by-day.pipe.spec.ts
TypeScript
ArrowFunction
() => { const pipe = new SlotByDayPipe(); expect(pipe).toBeTruthy(); }
Basileum/angular6-scheduler
scheduler6/src/app/utils/scheduler/multislider/slot-by-day.pipe.spec.ts
TypeScript
ArrowFunction
() => ({ election_seen_penalty: 0.0033333, election_removal_pct: 40, price_oracle_public_keys: [ '13Btezbvbwr9LhKmDQLgBnJUgjhZighEjNPLeu79dqBbmXRwoWm', '13CFFcmPtMvNQCpWQRXCTqXPnXtcsibDWVwiQRKpUCt4nqtF7RE', '1431WVQvoV7RAJpoLCaBrTKner1Soed4bk69DddcrHUTCWHV6pj', '136n9BEbreGUNgXJWtyzkBQcXiNzdMQ5GBoP8L2J6ZReFUAwUjy', '14sqAYg1qxzjKTtyHLYZdH6yDtA3KgyoARhWN1cvLZ94dZw5vEc', '145J6Aye86pKTJrUHREiXu7qqppZBcWY1bvWo8id7ZjxyuainYj', '13dUGHis1PdrSwxdseoyZKzQhc8WuWcueAWdT95sDVGDNhGRWV9', '14EzXp4i1xYA7SNyim6R4J5aXN1yHYKNiPrrJ2WEvoDnxmLgaCg', '147yRbowD1krUCC1DhhSMhpFEqnkwb26mHBow5nk9q43AakSHNA', ], max_xor_filter_size: 102400, max_subnet_num: 5, min_subnet_size: 8, })
HeliumEx/helium-js
packages/http/src/resources/__tests__/Vars.spec.ts
TypeScript
ArrowFunction
() => { nock('https://api.helium.io').get('/v1/vars').reply(200, { data: varsFixture(), }) it('retrieves chain vars', async () => { const client = new Client() const vars = await client.vars.get() expect(vars.electionRemovalPct).toBe(40) expect(vars.priceOraclePublicKeys[0]).toBe( '13Btezbvbwr9LhKmDQLgBnJUgjhZighEjNPLeu79dqBbmXRwoWm', ) }) }
HeliumEx/helium-js
packages/http/src/resources/__tests__/Vars.spec.ts
TypeScript
ArrowFunction
async () => { const client = new Client() const vars = await client.vars.get() expect(vars.electionRemovalPct).toBe(40) expect(vars.priceOraclePublicKeys[0]).toBe( '13Btezbvbwr9LhKmDQLgBnJUgjhZighEjNPLeu79dqBbmXRwoWm', ) }
HeliumEx/helium-js
packages/http/src/resources/__tests__/Vars.spec.ts
TypeScript
ArrowFunction
(feedbackInfo: FeedbackInfo): string => { const { product, packageName, packageVersion, labels } = feedbackInfo; return [product, packageName, packageVersion, ...(labels || [])].join('|'); }
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
async (feedbackInfo?: FeedbackInfo) => new Promise(async (resolve, reject) => { const combinedFeedbackInfo = { // default value assignment ...{ product: 'n/a', labels: [], packageName: '', packageVersion: '', sessionId: '', contentId: '', tabId: '', }, ...defaultFeedbackInfo, ...feedbackInfo, }; const newFeedbackInfoHash = hashFeedbackInfo(combinedFeedbackInfo); if (!showJiraCollectorDialog || feedbackInfoHash !== newFeedbackInfoHash) { try { showJiraCollectorDialog = await loadJiraCollectorDialogScript( [combinedFeedbackInfo.product, ...combinedFeedbackInfo.labels], combinedFeedbackInfo.packageName, coreVersion, combinedFeedbackInfo.packageVersion, combinedFeedbackInfo.sessionId, combinedFeedbackInfo.contentId, combinedFeedbackInfo.tabId, ); feedbackInfoHash = newFeedbackInfoHash; } catch (err) { reject(err); } } const timeoutId = window.setTimeout(showJiraCollectorDialog, 0); // Return the timoutId for consumers to call clearTimeout if they need to. resolve(timeoutId); })
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
async (resolve, reject) => { const combinedFeedbackInfo = { // default value assignment ...{ product: 'n/a', labels: [], packageName: '', packageVersion: '', sessionId: '', contentId: '', tabId: '', }, ...defaultFeedbackInfo, ...feedbackInfo, }; const newFeedbackInfoHash = hashFeedbackInfo(combinedFeedbackInfo); if (!showJiraCollectorDialog || feedbackInfoHash !== newFeedbackInfoHash) { try { showJiraCollectorDialog = await loadJiraCollectorDialogScript( [combinedFeedbackInfo.product, ...combinedFeedbackInfo.labels], combinedFeedbackInfo.packageName, coreVersion, combinedFeedbackInfo.packageVersion, combinedFeedbackInfo.sessionId, combinedFeedbackInfo.contentId, combinedFeedbackInfo.tabId, ); feedbackInfoHash = newFeedbackInfoHash; } catch (err) { reject(err); } } const timeoutId = window.setTimeout(showJiraCollectorDialog, 0); // Return the timoutId for consumers to call clearTimeout if they need to. resolve(timeoutId); }
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
(feedbackInfo: FeedbackInfo): EditorPlugin => { defaultFeedbackInfo = feedbackInfo; return { name: 'feedbackDialog', pluginsOptions: { quickInsert: ({ formatMessage }) => [ { id: 'feedbackdialog', title: formatMessage(messages.feedbackDialog), description: formatMessage(messages.feedbackDialogDescription), priority: 400, keywords: ['bug'], icon: () => <IconFeedback />, action(insert, state) { const tr = insert(''); openFeedbackDialog(feedbackInfo); return addAnalytics(state, tr, { action: ACTION.OPENED, actionSubject: ACTION_SUBJECT.FEEDBACK_DIALOG, attributes: { inputMethod: INPUT_METHOD.QUICK_INSERT }, eventType: EVENT_TYPE.UI, }); }, }, ], }, }; }
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
({ formatMessage }) => [ { id: 'feedbackdialog', title: formatMessage(messages.feedbackDialog), description: formatMessage(messages.feedbackDialogDescription), priority: 400, keywords: ['bug'], icon: () => <IconFeedback />, action(insert, state) { const tr = insert(''); openFeedbackDialog(feedbackInfo); return addAnalytics(state, tr, { action: ACTION.OPENED, actionSubject: ACTION_SUBJECT.FEEDBACK_DIALOG, attributes: { inputMethod: INPUT_METHOD.QUICK_INSERT }, eventType: EVENT_TYPE.UI, }); }, }, ]
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
() => <IconFeedback />,
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
MethodDeclaration
action(insert, state) { const tr = insert(''); openFeedbackDialog(feedbackInfo); return addAnalytics(state, tr, { action: ACTION.OPENED, actionSubject: ACTION_SUBJECT.FEEDBACK_DIALOG, attributes: { inputMethod: INPUT_METHOD.QUICK_INSERT }, eventType: EVENT_TYPE.UI, }); }
cozy/editor-core
src/plugins/feedback-dialog/index.tsx
TypeScript
ArrowFunction
async () => { if (!req.body || !req.body.isbn || !req.body.name) { throw new Error("Missing required fields for product"); } const isbn = req.body.isbn; const name = req.body.name; const product = new Product(); product.isbn = isbn; product.name = name; product.quantity = 0; product.requests = []; res.status(201); return await ProductController.saveProduct(product) .catch(e => { throw new Error(e); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
e => { throw new Error(e); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for product delete"); } const isbn = req.body.isbn; return await ProductController.deleteProduct(isbn) .catch(e => { throw new Error(e); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async () => { if (!req.body || !req.body.product || !req.body.product.isbn) { throw new Error("Missing required fields for product update"); } let product = req.body.product as ProductDocument; return await ProductController.updateProduct(product) .catch(e => { throw new Error(e); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async () => { if (!req.body || !req.body.pRequest || !req.body.isbn) { throw new Error("Missing required fields for adding requests"); } let isbn = req.body.isbn; let pRequest = req.body.pRequest as ProductRequest; pRequest.createdAt = Date.now(); return await ProductController.addProductRequest(isbn, pRequest) .catch(e => { throw new Error(e); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for adding to inventory"); } let isbn = req.body.isbn; return await ProductController.addToInventory(isbn) .catch(e => { throw new Error(e); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.find((err, data) => { if (err) { reject(err); } else { resolve(data); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(err, data) => { if (err) { reject(err); } else { resolve(data); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.find({isbn: product.isbn}, async (err, data) => { if (err) { reject(err); } else if (data && data.length > 0) { reject(new Error("already exists")); } else { const savedProduct = await product.save(); resolve(savedProduct); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async (err, data) => { if (err) { reject(err); } else if (data && data.length > 0) { reject(new Error("already exists")); } else { const savedProduct = await product.save(); resolve(savedProduct); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product) => { if (err) { reject(err); } else if (product) { resolve(await product.remove()); } else { reject("not found"); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async (err, product) => { if (err) { reject(err); } else if (product) { resolve(await product.remove()); } else { reject("not found"); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.findOneAndUpdate({isbn: product.isbn}, product, {new: true},async (err, newProduct) => { if (err) { reject(err); } else if (newProduct) { resolve(newProduct); } else { reject("product not found"); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async (err, newProduct) => { if (err) { reject(err); } else if (newProduct) { resolve(newProduct); } else { reject("product not found"); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.requests = [...product.requests, pRequest]; await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.requests = [...product.requests, pRequest]; await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.quantity += 1; let index = product.requests.findIndex(x => x.isActive); if (index > -1) { product.requests[index].isActive = false; } await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.quantity += 1; let index = product.requests.findIndex(x => x.isActive); if (index > -1) { product.requests[index].isActive = false; } await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
x => x.isActive
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ClassDeclaration
export default class ProductController { public static async getList(req: Request, res: Response) { return await jsonResponse(res, ProductController.getAllProducts); } public static async create(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn || !req.body.name) { throw new Error("Missing required fields for product"); } const isbn = req.body.isbn; const name = req.body.name; const product = new Product(); product.isbn = isbn; product.name = name; product.quantity = 0; product.requests = []; res.status(201); return await ProductController.saveProduct(product) .catch(e => { throw new Error(e); }); }); } public static async delete(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for product delete"); } const isbn = req.body.isbn; return await ProductController.deleteProduct(isbn) .catch(e => { throw new Error(e); }); }); } public static async update(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.product || !req.body.product.isbn) { throw new Error("Missing required fields for product update"); } let product = req.body.product as ProductDocument; return await ProductController.updateProduct(product) .catch(e => { throw new Error(e); }); }); } public static async addRequest(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.pRequest || !req.body.isbn) { throw new Error("Missing required fields for adding requests"); } let isbn = req.body.isbn; let pRequest = req.body.pRequest as ProductRequest; pRequest.createdAt = Date.now(); return await ProductController.addProductRequest(isbn, pRequest) .catch(e => { throw new Error(e); }); }); } public static async addInventory(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for adding to inventory"); } let isbn = req.body.isbn; return await ProductController.addToInventory(isbn) .catch(e => { throw new Error(e); }); }); } public static async getAllProducts() { return new Promise((resolve, reject) => { Product.find((err, data) => { if (err) { reject(err); } else { resolve(data); } }); }); }; private static async saveProduct(product: ProductDocument) { return new Promise((resolve, reject) => { Product.find({isbn: product.isbn}, async (err, data) => { if (err) { reject(err); } else if (data && data.length > 0) { reject(new Error("already exists")); } else { const savedProduct = await product.save(); resolve(savedProduct); } }); }); }; private static async deleteProduct(isbn: string) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product) => { if (err) { reject(err); } else if (product) { resolve(await product.remove()); } else { reject("not found"); } }); }); }; private static async updateProduct(product: ProductDocument) { return new Promise((resolve, reject) => { Product.findOneAndUpdate({isbn: product.isbn}, product, {new: true},async (err, newProduct) => { if (err) { reject(err); } else if (newProduct) { resolve(newProduct); } else { reject("product not found"); } }); }); }; private static async addProductRequest(isbn: string, pRequest: ProductRequest) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.requests = [...product.requests, pRequest]; await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }); }; private static async addToInventory(isbn: string) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.quantity += 1; let index = product.requests.findIndex(x => x.isActive); if (index > -1) { product.requests[index].isActive = false; } await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }); }; }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async getList(req: Request, res: Response) { return await jsonResponse(res, ProductController.getAllProducts); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async create(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn || !req.body.name) { throw new Error("Missing required fields for product"); } const isbn = req.body.isbn; const name = req.body.name; const product = new Product(); product.isbn = isbn; product.name = name; product.quantity = 0; product.requests = []; res.status(201); return await ProductController.saveProduct(product) .catch(e => { throw new Error(e); }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async delete(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for product delete"); } const isbn = req.body.isbn; return await ProductController.deleteProduct(isbn) .catch(e => { throw new Error(e); }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async update(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.product || !req.body.product.isbn) { throw new Error("Missing required fields for product update"); } let product = req.body.product as ProductDocument; return await ProductController.updateProduct(product) .catch(e => { throw new Error(e); }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async addRequest(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.pRequest || !req.body.isbn) { throw new Error("Missing required fields for adding requests"); } let isbn = req.body.isbn; let pRequest = req.body.pRequest as ProductRequest; pRequest.createdAt = Date.now(); return await ProductController.addProductRequest(isbn, pRequest) .catch(e => { throw new Error(e); }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async addInventory(req: Request, res: Response) { await jsonResponse(res, async () => { if (!req.body || !req.body.isbn) { throw new Error("Missing required fields for adding to inventory"); } let isbn = req.body.isbn; return await ProductController.addToInventory(isbn) .catch(e => { throw new Error(e); }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
public static async getAllProducts() { return new Promise((resolve, reject) => { Product.find((err, data) => { if (err) { reject(err); } else { resolve(data); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
private static async saveProduct(product: ProductDocument) { return new Promise((resolve, reject) => { Product.find({isbn: product.isbn}, async (err, data) => { if (err) { reject(err); } else if (data && data.length > 0) { reject(new Error("already exists")); } else { const savedProduct = await product.save(); resolve(savedProduct); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
private static async deleteProduct(isbn: string) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product) => { if (err) { reject(err); } else if (product) { resolve(await product.remove()); } else { reject("not found"); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
private static async updateProduct(product: ProductDocument) { return new Promise((resolve, reject) => { Product.findOneAndUpdate({isbn: product.isbn}, product, {new: true},async (err, newProduct) => { if (err) { reject(err); } else if (newProduct) { resolve(newProduct); } else { reject("product not found"); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
private static async addProductRequest(isbn: string, pRequest: ProductRequest) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.requests = [...product.requests, pRequest]; await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
MethodDeclaration
private static async addToInventory(isbn: string) { return new Promise((resolve, reject) => { Product.findOne({isbn: isbn}, async (err, product: ProductDocument) => { if (err) { reject(err); } else if (product) { product.quantity += 1; let index = product.requests.findIndex(x => x.isActive); if (index > -1) { product.requests[index].isActive = false; } await product.save((err, newProduct) => { if (err) { reject(err); } else { resolve(newProduct); } }); } else { reject("product not found"); } }); }); }
rotemgrim/accessibe-inventory
back/src/controllers/ProductController.ts
TypeScript
ArrowFunction
(editor: Editor, api: WordCountApi) => { Events.fireWordCountUpdate(editor, api); }
Azel333/animasi
asset/vendor/tinymce/modules/tinymce/src/plugins/wordcount/main/ts/core/WordCounter.ts
TypeScript
ArrowFunction
(editor: Editor, api: WordCountApi, delay: number) => { const debouncedUpdate = Delay.debounce(() => updateCount(editor, api), delay); editor.on('init', () => { updateCount(editor, api); Delay.setEditorTimeout(editor, () => { editor.on('SetContent BeforeAddUndo Undo Redo keyup', debouncedUpdate); }, 0); }); }
Azel333/animasi
asset/vendor/tinymce/modules/tinymce/src/plugins/wordcount/main/ts/core/WordCounter.ts
TypeScript
ArrowFunction
() => updateCount(editor, api)
Azel333/animasi
asset/vendor/tinymce/modules/tinymce/src/plugins/wordcount/main/ts/core/WordCounter.ts
TypeScript
ArrowFunction
() => { updateCount(editor, api); Delay.setEditorTimeout(editor, () => { editor.on('SetContent BeforeAddUndo Undo Redo keyup', debouncedUpdate); }, 0); }
Azel333/animasi
asset/vendor/tinymce/modules/tinymce/src/plugins/wordcount/main/ts/core/WordCounter.ts
TypeScript
ArrowFunction
() => { editor.on('SetContent BeforeAddUndo Undo Redo keyup', debouncedUpdate); }
Azel333/animasi
asset/vendor/tinymce/modules/tinymce/src/plugins/wordcount/main/ts/core/WordCounter.ts
TypeScript
ArrowFunction
data=>{ this.ipos=data; }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
ArrowFunction
data=>{ this.ipos=this.ipos.filter(ipos => ipos.id !== id); }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
ArrowFunction
ipos => ipos.id !== id
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-updateipodetails', templateUrl: './updateipodetails.component.html', styleUrls: ['./updateipodetails.component.css'] }) export class UpdateipodetailsComponent implements OnInit { constructor(private ipoService :IpoService, private router : Router) {} ipos:Ipo[]; ngOnInit() { this.ipoService.getAllIpos().subscribe(data=>{ this.ipos=data; }) } deleteIpo(id:number) { this.ipoService.deleteIpo(id).subscribe(data=>{ this.ipos=this.ipos.filter(ipos => ipos.id !== id); }); } updateIpo(ipos: Ipo) { localStorage.removeItem('ipoId'); localStorage.setItem('ipoId', ipos.id.toString()); this.router.navigate(['ipo-update']); } }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.ipoService.getAllIpos().subscribe(data=>{ this.ipos=data; }) }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
MethodDeclaration
deleteIpo(id:number) { this.ipoService.deleteIpo(id).subscribe(data=>{ this.ipos=this.ipos.filter(ipos => ipos.id !== id); }); }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
MethodDeclaration
updateIpo(ipos: Ipo) { localStorage.removeItem('ipoId'); localStorage.setItem('ipoId', ipos.id.toString()); this.router.navigate(['ipo-update']); }
prasannachinnapareddy/StockExchage
final/src/app/updateipodetails/updateipodetails.component.ts
TypeScript
FunctionDeclaration
function ShortcutPage({ file, renderStackOffset = 0 }: IShortcutPageProps) { useManagedRenderStack({ depth: renderStackOffset, id: 'ShortcutPage', file, }); const { file: pointingFile, loading, error } = useFileMeta(file.shortcutDetails?.targetId); return ( <> {loading && <InlineLoading description="Loading shortcut metadata..." />}
cw1997/gdocwiki
src/pages/ContentPage/ShortcutPage.tsx
TypeScript
InterfaceDeclaration
export interface IShortcutPageProps { file: gapi.client.drive.File; renderStackOffset?: number; }
cw1997/gdocwiki
src/pages/ContentPage/ShortcutPage.tsx
TypeScript
FunctionDeclaration
export default function getStyle(theme: Theme = {}) { const appStyle = {...defaultStyle, ...theme}; return StyleSheet.create({ container: { paddingLeft: 5, paddingRight: 5, backgroundColor: appStyle.calendarBackground }, dayContainer: { flex: 1, alignItems: 'center' }, emptyDayContainer: { flex: 1 }, monthView: { backgroundColor: appStyle.calendarBackground }, week: { marginVertical: appStyle.weekVerticalMargin, flexDirection: 'row', justifyContent: 'space-around' }, weekSelectionComponent: { borderRadius: 3, borderWidth: 1, borderColor: appStyle.arrowColor, width: 30, aspectRatio: 1 }, weekSelectionComponentChecked: { borderWidth: 11, borderRadius: 5 }, // @ts-expect-error ...(theme['stylesheet.calendar.main'] || {}) }); }
riamon-v/react-native-calendars
src/calendar/style.ts
TypeScript
ArrowFunction
(resolve, reject) => { url = url.replace(/^http/, "ws"); const webSocket = new this.webSocketConstructor(url); if (transferFormat === TransferFormat.Binary) { webSocket.binaryType = "arraybuffer"; } // tslint:disable-next-line:variable-name webSocket.onopen = (_event: Event) => { this.logger.log(LogLevel.Information, `WebSocket connected to ${url}`); this.webSocket = webSocket; resolve(); }; webSocket.onerror = (event: Event) => { let error: any = null; // ErrorEvent is a browser only type we need to check if the type exists before using it if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) { error = event.error; } reject(error); }; webSocket.onmessage = (message: MessageEvent) => { this.logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this.logMessageContent)}.`); if (this.onreceive) { this.onreceive(message.data); } }; webSocket.onclose = (event: CloseEvent) => this.close(event); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ArrowFunction
(_event: Event) => { this.logger.log(LogLevel.Information, `WebSocket connected to ${url}`); this.webSocket = webSocket; resolve(); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ArrowFunction
(event: Event) => { let error: any = null; // ErrorEvent is a browser only type we need to check if the type exists before using it if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) { error = event.error; } reject(error); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ArrowFunction
(message: MessageEvent) => { this.logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this.logMessageContent)}.`); if (this.onreceive) { this.onreceive(message.data); } }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ArrowFunction
(event: CloseEvent) => this.close(event)
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ClassDeclaration
/** @private */ export class WebSocketTransport implements ITransport { private readonly logger: ILogger; private readonly accessTokenFactory: (() => string | Promise<string>) | undefined; private readonly logMessageContent: boolean; private readonly webSocketConstructor: WebSocketConstructor; private webSocket?: WebSocket; public onreceive: ((data: string | ArrayBuffer) => void) | null; public onclose: ((error?: Error) => void) | null; constructor(accessTokenFactory: (() => string | Promise<string>) | undefined, logger: ILogger, logMessageContent: boolean, webSocketConstructor: WebSocketConstructor) { this.logger = logger; this.accessTokenFactory = accessTokenFactory; this.logMessageContent = logMessageContent; this.webSocketConstructor = webSocketConstructor; this.onreceive = null; this.onclose = null; } public async connect(url: string, transferFormat: TransferFormat): Promise<void> { Arg.isRequired(url, "url"); Arg.isRequired(transferFormat, "transferFormat"); Arg.isIn(transferFormat, TransferFormat, "transferFormat"); this.logger.log(LogLevel.Trace, "(WebSockets transport) Connecting"); if (this.accessTokenFactory) { const token = await this.accessTokenFactory(); if (token) { url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`; } } return new Promise<void>((resolve, reject) => { url = url.replace(/^http/, "ws"); const webSocket = new this.webSocketConstructor(url); if (transferFormat === TransferFormat.Binary) { webSocket.binaryType = "arraybuffer"; } // tslint:disable-next-line:variable-name webSocket.onopen = (_event: Event) => { this.logger.log(LogLevel.Information, `WebSocket connected to ${url}`); this.webSocket = webSocket; resolve(); }; webSocket.onerror = (event: Event) => { let error: any = null; // ErrorEvent is a browser only type we need to check if the type exists before using it if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) { error = event.error; } reject(error); }; webSocket.onmessage = (message: MessageEvent) => { this.logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this.logMessageContent)}.`); if (this.onreceive) { this.onreceive(message.data); } }; webSocket.onclose = (event: CloseEvent) => this.close(event); }); } public send(data: any): Promise<void> { if (this.webSocket && this.webSocket.readyState === this.webSocketConstructor.OPEN) { this.logger.log(LogLevel.Trace, `(WebSockets transport) sending data. ${getDataDetail(data, this.logMessageContent)}.`); this.webSocket.send(data); return Promise.resolve(); } return Promise.reject("WebSocket is not in the OPEN state"); } public stop(): Promise<void> { if (this.webSocket) { // Clear websocket handlers because we are considering the socket closed now this.webSocket.onclose = () => {}; this.webSocket.onmessage = () => {}; this.webSocket.onerror = () => {}; this.webSocket.close(); this.webSocket = undefined; // Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning // This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects this.close(undefined); } return Promise.resolve(); } private close(event?: CloseEvent): void { // webSocket will be null if the transport did not start successfully this.logger.log(LogLevel.Trace, "(WebSockets transport) socket closed."); if (this.onclose) { if (event && (event.wasClean === false || event.code !== 1000)) { this.onclose(new Error(`Websocket closed with status code: ${event.code} (${event.reason})`)); } else { this.onclose(); } } } }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
MethodDeclaration
public async connect(url: string, transferFormat: TransferFormat): Promise<void> { Arg.isRequired(url, "url"); Arg.isRequired(transferFormat, "transferFormat"); Arg.isIn(transferFormat, TransferFormat, "transferFormat"); this.logger.log(LogLevel.Trace, "(WebSockets transport) Connecting"); if (this.accessTokenFactory) { const token = await this.accessTokenFactory(); if (token) { url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`; } } return new Promise<void>((resolve, reject) => { url = url.replace(/^http/, "ws"); const webSocket = new this.webSocketConstructor(url); if (transferFormat === TransferFormat.Binary) { webSocket.binaryType = "arraybuffer"; } // tslint:disable-next-line:variable-name webSocket.onopen = (_event: Event) => { this.logger.log(LogLevel.Information, `WebSocket connected to ${url}`); this.webSocket = webSocket; resolve(); }; webSocket.onerror = (event: Event) => { let error: any = null; // ErrorEvent is a browser only type we need to check if the type exists before using it if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) { error = event.error; } reject(error); }; webSocket.onmessage = (message: MessageEvent) => { this.logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this.logMessageContent)}.`); if (this.onreceive) { this.onreceive(message.data); } }; webSocket.onclose = (event: CloseEvent) => this.close(event); }); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
MethodDeclaration
public send(data: any): Promise<void> { if (this.webSocket && this.webSocket.readyState === this.webSocketConstructor.OPEN) { this.logger.log(LogLevel.Trace, `(WebSockets transport) sending data. ${getDataDetail(data, this.logMessageContent)}.`); this.webSocket.send(data); return Promise.resolve(); } return Promise.reject("WebSocket is not in the OPEN state"); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
MethodDeclaration
public stop(): Promise<void> { if (this.webSocket) { // Clear websocket handlers because we are considering the socket closed now this.webSocket.onclose = () => {}; this.webSocket.onmessage = () => {}; this.webSocket.onerror = () => {}; this.webSocket.close(); this.webSocket = undefined; // Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning // This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects this.close(undefined); } return Promise.resolve(); }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
MethodDeclaration
private close(event?: CloseEvent): void { // webSocket will be null if the transport did not start successfully this.logger.log(LogLevel.Trace, "(WebSockets transport) socket closed."); if (this.onclose) { if (event && (event.wasClean === false || event.code !== 1000)) { this.onclose(new Error(`Websocket closed with status code: ${event.code} (${event.reason})`)); } else { this.onclose(); } } }
FraserKillip/SignalR
clients/ts/signalr/src/WebSocketTransport.ts
TypeScript
ArrowFunction
({ host, password, port, username, }: Mqtt): Promise<Server> => { return new Promise((resolve: (server: Server) => void): void => { const server = new Server({ host, port, }); server.on('ready', () => { if (username && password) { server.authenticate = (client: {}, actualUsername: string, actualPassword: string, callback: (error: null, authenticated: boolean) => void): void => { const authenticated = actualUsername === username && actualPassword.toString() === password; callback(null, authenticated); }; } resolve(server); }); }); }
TonyBrobston/logs-to-mqtt-publisher
tests/utils/moscaHelper.ts
TypeScript
ArrowFunction
(resolve: (server: Server) => void): void => { const server = new Server({ host, port, }); server.on('ready', () => { if (username && password) { server.authenticate = (client: {}, actualUsername: string, actualPassword: string, callback: (error: null, authenticated: boolean) => void): void => { const authenticated = actualUsername === username && actualPassword.toString() === password; callback(null, authenticated); }; } resolve(server); }); }
TonyBrobston/logs-to-mqtt-publisher
tests/utils/moscaHelper.ts
TypeScript
ArrowFunction
() => { if (username && password) { server.authenticate = (client: {}, actualUsername: string, actualPassword: string, callback: (error: null, authenticated: boolean) => void): void => { const authenticated = actualUsername === username && actualPassword.toString() === password; callback(null, authenticated); }; } resolve(server); }
TonyBrobston/logs-to-mqtt-publisher
tests/utils/moscaHelper.ts
TypeScript
ArrowFunction
(client: {}, actualUsername: string, actualPassword: string, callback: (error: null, authenticated: boolean) => void): void => { const authenticated = actualUsername === username && actualPassword.toString() === password; callback(null, authenticated); }
TonyBrobston/logs-to-mqtt-publisher
tests/utils/moscaHelper.ts
TypeScript
FunctionDeclaration
async function bootstrap() { const app = await NestFactory.create(AppModule); app.useGlobalPipes(new ValidationPipe()); const config = new DocumentBuilder() .setTitle('homework example') .setDescription('The homework API description') .setVersion('1.0') .addTag('homework') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); await app.listen(3000); }
slilp/example-nestjs-typeorm
src/main.ts
TypeScript
FunctionDeclaration
function App() { return ( <Routes /> ); }
rafapaivadeandrade/Ecoleta
Web/src/App.tsx
TypeScript
FunctionDeclaration
function handleRequestSort(event: any, property: string) { const isDesc = orderBy === property && order === 'desc'; setOrder(isDesc ? 'asc' : 'desc'); setOrderBy(property); }
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
FunctionDeclaration
function handleChangePage(event: any, newPage: number) { setPage(newPage); }
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
FunctionDeclaration
function handleChangeRowsPerPage(event: any) { setRowsPerPage(+event.target.value); setPage(0); }
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
ArrowFunction
(props: IProps) => { const algorithms = props.algorithms; const [order, setOrder] = React.useState<Order>('asc'); const [orderBy, setOrderBy] = React.useState('Name'); const [page, setPage] = React.useState(0); const [rowsPerPage, setRowsPerPage] = React.useState(3); function handleRequestSort(event: any, property: string) { const isDesc = orderBy === property && order === 'desc'; setOrder(isDesc ? 'asc' : 'desc'); setOrderBy(property); } function handleChangePage(event: any, newPage: number) { setPage(newPage); } function handleChangeRowsPerPage(event: any) { setRowsPerPage(+event.target.value); setPage(0); } const { showMore } = props; let sortedData = sortBy(algorithms, orderBy); if (order === 'desc') { sortedData = sortedData.reverse(); } return ( <Paper> <div> <Table aria-labelledby="tableTitle"> <AlgorithmTableHead order={order as Order} orderBy={orderBy} onRequestSort={handleRequestSort} /> <TableBody> {sortedData .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) .map((algorithm) => ( <TableRow hover={true} tabIndex={-1} key={algorithm.id}> <TableCell component="td" scope="row"> {moment(algorithm.created).format('DD-MM-YYYY')} </TableCell> <TableCell component="td" scope="row"> {algorithm.name} </TableCell> <TableCell component="td" scope="row"> <Fab size="small" onClick={()
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
ArrowFunction
(algorithm) => ( <TableRow hover={true}
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
InterfaceDeclaration
interface IProps { showMore: boolean; algorithms: IAlgorithm[]; onEdit: (algorithm: IAlgorithm) => void; }
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
TypeAliasDeclaration
// Functions for Sorting type Order = 'asc' | 'desc';
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
MethodDeclaration
moment(algorithm
EYRA-Benchmark/eyra-frontend
src/components/AlgorithmsTable/index.tsx
TypeScript
FunctionDeclaration
function SlideTransition(props: SlideProps) { return <Slide {...props} direction="up" timeout={TRANSITION_TIMEOUT} />; }
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript
ArrowFunction
({ message, setMessage, messageType = 'error', }) => { const classes = useStyles(); const [open, setOpen] = useState(message ? true : false); const timeoutRef = useRef<number>(0); useEffect(() => { return () => window.clearTimeout(timeoutRef.current); }, []); const handleClose = () => { window.clearTimeout(timeoutRef.current); setOpen(false); timeoutRef.current = window.setTimeout( () => setMessage(''), TRANSITION_TIMEOUT ); }; useEffect(() => { setOpen(message ? true : false); }, [message]); return ( <Snackbar open={open} onClose={handleClose} anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript
ArrowFunction
() => { return () => window.clearTimeout(timeoutRef.current); }
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript
ArrowFunction
() => window.clearTimeout(timeoutRef.current)
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript
ArrowFunction
() => { window.clearTimeout(timeoutRef.current); setOpen(false); timeoutRef.current = window.setTimeout( () => setMessage(''), TRANSITION_TIMEOUT ); }
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript
ArrowFunction
() => setMessage('')
hyperledger/firefly-ui
src/components/Snackbar/MessageSnackbar.tsx
TypeScript