type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
_update(key: Buffer, val: Account, modified: boolean, deleted: boolean): void { const keyHex = key.toString('hex') const it = this._cache.find(keyHex) if (it.node) { this._cache = it.update({ val: val, modified: modified, deleted: deleted, }) } else { this._cache = this._cache.insert(keyHex, { val: val, modified: modified, deleted: deleted, }) } }
Aminadav/ethereumjs-vm
lib/state/cache.ts
TypeScript
InterfaceDeclaration
/* * Copyright 2020 The Backstage Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export interface Config { /** Configuration options for the auth plugin */ auth?: { /** * The 'environment' attribute * @visibility frontend */ environment?: string; session?: { /** * The secret attribute of session object. * @visibility secret */ secret?: string; }; /** To control how to store JWK data in auth-backend */ keyStore?: { provider?: 'database' | 'memory' | 'firestore'; firestore?: { /** The host to connect to */ host?: string; /** The port to connect to */ port?: number; /** Whether to use SSL when connecting. */ ssl?: boolean; /** The Google Cloud Project ID */ projectId?: string; /** * Local file containing the Service Account credentials. * You can omit this value to automatically read from * GOOGLE_APPLICATION_CREDENTIALS env which is useful for local * development. */ keyFilename?: string; /** The path to use for the collection. Defaults to 'sessions' */ path?: string; /** Timeout used for database operations. Defaults to 10000ms */ timeout?: number; }; }; /** * The available auth-provider options and attributes */ providers?: { google?: { [authEnv: string]: { [key: string]: string }; }; github?: { [authEnv: string]: { [key: string]: string }; }; gitlab?: { [authEnv: string]: { [key: string]: string }; }; saml?: { entryPoint: string; logoutUrl?: string; issuer: string; cert: string; audience?: string; privateKey?: string; authnContext?: string[]; identifierFormat?: string; decryptionPvk?: string; signatureAlgorithm?: 'sha256' | 'sha512'; digestAlgorithm?: string; acceptedClockSkewMs?: number; }; okta?: { [authEnv: string]: { [key: string]: string }; }; oauth2?: { [authEnv: string]: { clientId: string; clientSecret: string; authorizationUrl: string; tokenUrl: string; scope?: string; disableRefresh?: boolean; }; }; oidc?: { [authEnv: string]: { [key: string]: string }; }; auth0?: { [authEnv: string]: { [key: string]: string }; }; microsoft?: { [authEnv: string]: { [key: string]: string }; }; onelogin?: { [authEnv: string]: { [key: string]: string }; }; awsalb?: { issuer?: string; region: string; }; }; }; }
AaronvDiepen/backstage
plugins/auth-backend/config.d.ts
TypeScript
ArrowFunction
resolve => { let resolver: IResolver = { handler: (this.writing_++ === 0 && this.reading_ === 0) ? null : resolve, accessType: AccessType.WRITE, lockType: LockType.HOLD }; this.queue_.push_back(resolver); if (resolver.handler === null) resolve(); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
ArrowFunction
resolve => { // CONSTRUCT RESOLVER WITH PREDICATION let resolver: IResolver = { handler: (this.writing_++ === 0 && this.reading_ === 0) ? null : resolve, accessType: AccessType.WRITE, lockType: LockType.KNOCK }; let it: List.Iterator<IResolver> = this.queue_.insert(this.queue_.end(), resolver); if (resolver.handler === null) resolve(true); // SUCCESS else { // AUTOMATIC UNLOCK AFTER TIMEOUT sleep_for(ms).then(() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.writing_; this._Cancel(it); } }); } }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
ArrowFunction
() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.writing_; this._Cancel(it); } }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
ArrowFunction
resolve => { let resolver: IResolver = { handler: (this.writing_ === 0) ? null : resolve, accessType: AccessType.READ, lockType: LockType.HOLD } this.queue_.push_back(resolver); ++this.reading_; if (resolver.handler === null) resolve(); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
ArrowFunction
resolve => { // CONSTRUCT RESOLVER WITH PREDICATION let resolver: IResolver = { handler: (this.writing_ === 0) ? null : resolve, accessType: AccessType.READ, lockType: LockType.KNOCK }; ++this.reading_; let it: List.Iterator<IResolver> = this.queue_.insert(this.queue_.end(), resolver); if (resolver.handler === null) resolve(true); else { // AUTOMATIC UNLOCK AFTER TIMEOUT sleep_for(ms).then(() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.reading_; this._Cancel(it); } }); } }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
ArrowFunction
() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.reading_; this._Cancel(it); } }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
InterfaceDeclaration
/** * @hidden */ interface IResolver { handler: Function | null; accessType: AccessType; // read or write lockType: LockType; // void or boolean }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
TypeAliasDeclaration
export type shared_timed_mutex = SharedTimedMutex;
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @hidden */ private _Current_access_type(): AccessType | null { return this.queue_.empty() ? null : this.queue_.front().accessType; }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/* --------------------------------------------------------- WRITE LOCK --------------------------------------------------------- */ /** * @inheritDoc */ public async lock(): Promise<void> { return new Promise<void>(resolve => { let resolver: IResolver = { handler: (this.writing_++ === 0 && this.reading_ === 0) ? null : resolve, accessType: AccessType.WRITE, lockType: LockType.HOLD }; this.queue_.push_back(resolver); if (resolver.handler === null) resolve(); }); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public async try_lock(): Promise<boolean> { if (this.writing_ !== 0 || this.reading_ !== 0) return false; ++this.writing_; this.queue_.push_back({ handler: null, accessType: AccessType.WRITE, lockType: LockType.KNOCK }); return true; }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public try_lock_for(ms: number): Promise<boolean> { return new Promise<boolean>(resolve => { // CONSTRUCT RESOLVER WITH PREDICATION let resolver: IResolver = { handler: (this.writing_++ === 0 && this.reading_ === 0) ? null : resolve, accessType: AccessType.WRITE, lockType: LockType.KNOCK }; let it: List.Iterator<IResolver> = this.queue_.insert(this.queue_.end(), resolver); if (resolver.handler === null) resolve(true); // SUCCESS else { // AUTOMATIC UNLOCK AFTER TIMEOUT sleep_for(ms).then(() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.writing_; this._Cancel(it); } }); } }); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public try_lock_until(at: Date): Promise<boolean> { // COMPUTE MILLISECONDS TO WAIT let now: Date = new Date(); let ms: number = at.getTime() - now.getTime(); return this.try_lock_for(ms); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public async unlock(): Promise<void> { if (this._Current_access_type() !== AccessType.WRITE) throw new InvalidArgument(`Error on std.${this.source_.constructor.name}.unlock(): this mutex is free on the unique lock.`); --this.writing_; this.queue_.pop_front(); this._Release(); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/* --------------------------------------------------------- READ LOCK --------------------------------------------------------- */ /** * @inheritDoc */ public async lock_shared(): Promise<void> { return new Promise<void>(resolve => { let resolver: IResolver = { handler: (this.writing_ === 0) ? null : resolve, accessType: AccessType.READ, lockType: LockType.HOLD } this.queue_.push_back(resolver); ++this.reading_; if (resolver.handler === null) resolve(); }); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public async try_lock_shared(): Promise<boolean> { if (this.writing_ !== 0) return false; ++this.reading_; this.queue_.push_back({ handler: null, accessType: AccessType.READ, lockType: LockType.KNOCK }); return true; }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public try_lock_shared_for(ms: number): Promise<boolean> { return new Promise<boolean>(resolve => { // CONSTRUCT RESOLVER WITH PREDICATION let resolver: IResolver = { handler: (this.writing_ === 0) ? null : resolve, accessType: AccessType.READ, lockType: LockType.KNOCK }; ++this.reading_; let it: List.Iterator<IResolver> = this.queue_.insert(this.queue_.end(), resolver); if (resolver.handler === null) resolve(true); else { // AUTOMATIC UNLOCK AFTER TIMEOUT sleep_for(ms).then(() => { // NOT YET, THEN DO UNLOCK if (it.value.handler !== null) { --this.reading_; this._Cancel(it); } }); } }); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public try_lock_shared_until(at: Date): Promise<boolean> { // COMPUTE MILLISECONDS TO WAIT let now: Date = new Date(); let ms: number = at.getTime() - now.getTime(); return this.try_lock_shared_for(ms); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @inheritDoc */ public async unlock_shared(): Promise<void> { if (this._Current_access_type() !== AccessType.READ) throw new InvalidArgument(`Error on std.${this.source_.constructor.name}.unlock_shared(): this mutex is free on the shared lock.`); --this.reading_; this.queue_.pop_front(); this._Release(); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/* --------------------------------------------------------- RELEASE --------------------------------------------------------- */ /** * @hidden */ private _Release(): void { // STEP TO THE NEXT LOCKS let current: AccessType = this._Current_access_type()!; for (let resolver of this.queue_) { // DIFFERENT ACCESS TYPE COMES? if (resolver.accessType !== current) break; // NOT RESOLVED YET? if (resolver.handler !== null) { // CLEAR FIRST let handler: Function | null = resolver.handler; resolver.handler = null; // CALL LATER if (resolver.lockType === LockType.HOLD) handler(); else handler(true); } // STOP AFTER WRITE LOCK if (resolver.accessType === AccessType.WRITE) break; } }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
MethodDeclaration
/** * @hidden */ private _Cancel(it: List.Iterator<IResolver>): void { //---- // POP THE RELEASE //---- // DO RASE this.queue_.erase(it); // EXTRACT HANDLER TO AVOID THE `this._Release()` let handler: Function = it.value.handler!; it.value.handler = null; //---- // POST-PROCESS //---- // CHECK THE PREVIOUS RESOLVER let prev: List.Iterator<IResolver> = it.prev(); // RELEASE IF IT IS THE LASTEST RESOLVER if (prev.equals(this.queue_.end()) === false && prev.value.handler === null) this._Release(); // (LAZY) RETURNS FAILURE handler(false); }
opencollective/tstl
src/thread/SharedTimedMutex.ts
TypeScript
FunctionDeclaration
function DrawerView(props: Props) { const [lock, setLock] = useState(false) const [visibleBgColor, setVisibleBgColor] = useState(false) // 延迟显示防止启动时闪烁 useEffect(() => { setTimeout(() => setVisibleBgColor(true), 700) }, []) drawerController = { setLock: (lock = true) => setLock(lock) } return ( <Drawer.Navigator initialRouteName="main" edgeWidth={50} drawerStyle={{ width: Dimensions.get('window').width * 0.6, elevation: 10, backgroundColor: visibleBgColor ? 'white' : 'transparent', zIndex: 1000 }}
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
ArrowFunction
() => { setTimeout(() => setVisibleBgColor(true), 700) }
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
ArrowFunction
() => setVisibleBgColor(true)
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
ArrowFunction
(lock = true) => setLock(lock)
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
InterfaceDeclaration
export interface Props { children(): JSX.Element }
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
InterfaceDeclaration
export interface DrawerController { setLock(lock?: boolean): void }
koharubiyori/Moegirl-RN
src/views/drawer/Index.tsx
TypeScript
ArrowFunction
() => { it('should display messgae', inject([], () => { const queue = new Subject<string>(); queue.first(s => s == 'hello').subscribe( console.log, console.log); queue.next('a'); queue.next('hello'); queue.error('oops'); queue.next('hello'); })); }
serge-jacquemin-busi/pro-state
src/app/playground/playground.spec.ts
TypeScript
ArrowFunction
() => { const queue = new Subject<string>(); queue.first(s => s == 'hello').subscribe( console.log, console.log); queue.next('a'); queue.next('hello'); queue.error('oops'); queue.next('hello'); }
serge-jacquemin-busi/pro-state
src/app/playground/playground.spec.ts
TypeScript
ArrowFunction
s => s == 'hello'
serge-jacquemin-busi/pro-state
src/app/playground/playground.spec.ts
TypeScript
EnumDeclaration
export enum Floor { Normal, Pit }
HolyMeekrob/i-shove-you-so-much
src/model/floor.ts
TypeScript
FunctionDeclaration
function insertIntoSetTracker( tier: number, statMix: string, armorSet: IntermediateProcessArmorSet, setTracker: SetTracker ): void { if (setTracker.length === 0) { setTracker.push({ tier, statMixes: [{ statMix, armorSets: [armorSet] }] }); return; } for (let tierIndex = 0; tierIndex < setTracker.length; tierIndex++) { const currentTier = setTracker[tierIndex]; if (tier > currentTier.tier) { setTracker.splice(tierIndex, 0, { tier, statMixes: [{ statMix, armorSets: [armorSet] }] }); return; } if (tier === currentTier.tier) { const currentStatMixes = currentTier.statMixes; for (let statMixIndex = 0; statMixIndex < currentStatMixes.length; statMixIndex++) { const currentStatMix = currentStatMixes[statMixIndex]; if (statMix > currentStatMix.statMix) { currentStatMixes.splice(statMixIndex, 0, { statMix, armorSets: [armorSet] }); return; } if (currentStatMix.statMix === statMix) { for ( let armorSetIndex = 0; armorSetIndex < currentStatMix.armorSets.length; armorSetIndex++ ) { if ( getPower(armorSet.armor) > getPower(currentStatMix.armorSets[armorSetIndex].armor) ) { currentStatMix.armorSets.splice(armorSetIndex, 0, armorSet); } else { currentStatMix.armorSets.push(armorSet); } return; } } if (statMixIndex === currentStatMixes.length - 1) { currentStatMixes.push({ statMix, armorSets: [armorSet] }); return; } } } if (tierIndex === setTracker.length - 1) { setTracker.push({ tier, statMixes: [{ statMix, armorSets: [armorSet] }] }); return; } } }
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
FunctionDeclaration
/** * Gets the stat values of an item with masterwork. */ function getStatValuesWithMWProcess( item: ProcessItem, assumeMasterwork: boolean | null, orderedStatValues: number[] ) { const baseStats = { ...item.baseStats }; // Checking energy tells us if it is Armour 2.0 (it can have value 0) if (item.sockets && item.energy) { let masterworkSocketHashes: number[] = []; // only get masterwork sockets if we aren't manually adding the values if (!assumeMasterwork) { const masterworkSocketCategory = item.sockets.categories.find( (category) => category.categoryStyle === DestinySocketCategoryStyle.EnergyMeter ); if (masterworkSocketCategory) { masterworkSocketHashes = masterworkSocketCategory.sockets .map((socket) => socket.plug?.plugItemHash ?? NaN) .filter((val) => !isNaN(val)); } } if (masterworkSocketHashes.length) { for (const socket of item.sockets.sockets) { const plugHash = socket.plug?.plugItemHash ?? NaN; if (socket.plug?.stats && masterworkSocketHashes.includes(plugHash)) { for (const statHash of orderedStatValues) { if (socket.plug.stats[statHash]) { baseStats[statHash] += socket.plug.stats[statHash]; } } } } } if (assumeMasterwork) { for (const statHash of orderedStatValues) { baseStats[statHash] += 2; } } } // mapping out from stat values to ensure ordering and that values don't fall below 0 from locked mods return orderedStatValues.map((statHash) => Math.max(baseStats[statHash], 0)); }
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
FunctionDeclaration
function flattenSets(sets: IntermediateProcessArmorSet[]): ProcessArmorSet[] { return sets.map((set) => ({ ...set, armor: set.armor.map((item) => item.id), })); }
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(statType) => statHashes[statType]
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(statType) => !statFilters[statType].ignored
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(i) => -i.baseStats[TOTAL_STAT_HASH]
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(l) => l[l.length - 1].baseStats[TOTAL_STAT_HASH]
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(item) => (item.equippingLabel ? 1 : 0)
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(set) => set.statMixes.map((mix) => mix.armorSets)
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(mix) => mix.armorSets
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(category) => category.categoryStyle === DestinySocketCategoryStyle.EnergyMeter
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(socket) => socket.plug?.plugItemHash ?? NaN
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(statHash) => Math.max(baseStats[statHash], 0)
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
(set) => ({ ...set, armor: set.armor.map((item) => item.id), })
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
TypeAliasDeclaration
type SetTracker = { tier: number; statMixes: { statMix: string; armorSets: IntermediateProcessArmorSet[] }[]; }[];
nomadjsdev/DIM
src/app/loadout-builder/processWorker/process.ts
TypeScript
ArrowFunction
dropDown => dropDown.label === label
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
ArrowFunction
dropDown => dropDown.labelKey === labelKey
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
ClassDeclaration
export class DropDowns { list: DropDown[]; constructor() { this.list = []; } add(label: string) { const dropDown = new DropDown(label); this.list.push(dropDown); return dropDown; } isEmpty() { return this.list.length === 0; } findDropDownByLabel(label: string) { return this.list.find(dropDown => dropDown.label === label); } findDropDownByLabelKey(labelKey: string) { return this.list.find(dropDown => dropDown.labelKey === labelKey); } }
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
MethodDeclaration
add(label: string) { const dropDown = new DropDown(label); this.list.push(dropDown); return dropDown; }
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
MethodDeclaration
isEmpty() { return this.list.length === 0; }
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
MethodDeclaration
findDropDownByLabel(label: string) { return this.list.find(dropDown => dropDown.label === label); }
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
MethodDeclaration
findDropDownByLabelKey(labelKey: string) { return this.list.find(dropDown => dropDown.labelKey === labelKey); }
MykolaGolubyev/react-component-viewer
src/components/viewer/dropdown/DropDowns.ts
TypeScript
ArrowFunction
(image) => ({ path: image.filename, })
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
ArrowFunction
(image) => image.path
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
MethodDeclaration
async index(_req: Request, res: Response) { const productsRepository = getRepository(Products); const products = await productsRepository.find({ relations: ["images", "category"], }); return res.json(productView.renderMany(products)); }
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
MethodDeclaration
async show(req: Request, res: Response) { const { id } = req.params; const productsRepository = getRepository(Products); const product = await productsRepository.findOneOrFail(id, { relations: ["images", "category"], }); return res.json(productView.render(product)); }
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
MethodDeclaration
async create(req: Request, res: Response) { const { name, description, price, quantity, category: category_id, } = req.body; const productsRepository = getRepository(Products); const requestImages = req.files as Express.Multer.File[]; const images = requestImages.map((image) => ({ path: image.filename, })); const categoryRepository = getRepository(Category); const category = await categoryRepository.findOneOrFail(category_id); const data = { name, description, price, quantity, category, images, }; const schema = Yup.object().shape({ name: Yup.string().required(), description: Yup.string().required(), price: Yup.number().required(), quantity: Yup.number().required(), images: Yup.array( Yup.object().shape({ path: Yup.string().required(), }) ), category: Yup.object() .shape({ name: Yup.string().required(), id: Yup.number().required(), }) .required(), }); await schema.validate(data, { abortEarly: false, }); const product = productsRepository.create(data); await productsRepository.save(product); return res.status(201).json(productView.render(product)); }
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
MethodDeclaration
async update(req: Request, res: Response) { const { id } = req.params; const { name, description, price, quantity, category: category_id, } = req.body; const productsRepository = getRepository(Products); const product = await productsRepository.findOneOrFail(id, { relations: ["images", "category"], }); const categoryRepository = getRepository(Category); const category = await categoryRepository.findOneOrFail(category_id); const requestImages = req.files as Express.Multer.File[]; const images = requestImages.map((image) => ({ path: image.filename, })); const data = { name, description, price, quantity, category, images, }; const schema = Yup.object().shape({ name: Yup.string().required(), description: Yup.string().required(), price: Yup.number().required(), quantity: Yup.number().required(), images: Yup.array( Yup.object().shape({ path: Yup.string().required(), }) ), category: Yup.object() .shape({ name: Yup.string().required(), id: Yup.number().required(), }) .required(), }); await schema.validate(data, { abortEarly: false, }); const imagesRepository = getRepository(Images); const imagesNames = product.images.map((image) => image.path); deleteImages(imagesNames); await imagesRepository.remove(product.images); const imagesFromDB = imagesRepository.create(images); product.name = name; product.description = description; product.price = price; product.quantity = quantity; product.images = imagesFromDB; product.category = category; await productsRepository.save(product); return res.status(200).json(productView.render(product)); }
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
MethodDeclaration
async delete(req: Request, res: Response) { const { id } = req.params; const productsRepository = getRepository(Products); const product = await productsRepository.findOneOrFail(id, { relations: ["images"], }); const imagesNames = product.images.map((image) => image.path); deleteImages(imagesNames); await productsRepository.remove(product); return res.status(204).json(); }
Gu7z/migueis-api
src/controllers/ProductsController.ts
TypeScript
ArrowFunction
(data: any[])=> { return { committees: data[1], tags: data[0] } }
tbtimes/zombie-campaigns-database
src/app/committee.service.ts
TypeScript
ClassDeclaration
@Injectable() export class CommitteeService { constructor(private http: HttpClient) { } getCommittees(): Observable<{committees: Committee[], tags: string[]}> { return forkJoin([ this.http.get("assets/all_tags.json"), this.http.get("assets/tags_by_comm.json") ]) .map((data: any[])=> { return { committees: data[1], tags: data[0] } }); } }
tbtimes/zombie-campaigns-database
src/app/committee.service.ts
TypeScript
MethodDeclaration
getCommittees(): Observable<{committees: Committee[], tags: string[]}> { return forkJoin([ this.http.get("assets/all_tags.json"), this.http.get("assets/tags_by_comm.json") ]) .map((data: any[])=> { return { committees: data[1], tags: data[0] } }); }
tbtimes/zombie-campaigns-database
src/app/committee.service.ts
TypeScript
ArrowFunction
() => { const dispatch = useDispatch() // @ts-ignore const { project_id } = useParams() const project = useSelector<RootState, Project>( // eslint-disable-next-line eqeqeq (state) => state?.project?.data?.find((pro) => pro.id == project_id)! ) const dataSource = useSelector<RootState, SourceMapModelState['data']>( (state) => state.sourceMap?.data ) const loading = useSelector<RootState, boolean>( (state) => state.loading.effects['sourceMap/get']! ) useMount(() => { dispatch({ type: 'sourceMap/get', payload: { project }, }) }) return ( <section className={styles.root}> <Zone title="SourceMap"> <Table<SourceMap> dataSource={dataSource} loading={loading} rowKey={(record)
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
ArrowFunction
// eslint-disable-next-line eqeqeq (state) => state?.project?.data?.find((pro) => pro.id == project_id)!
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
ArrowFunction
(pro) => pro.id == project_id
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
ArrowFunction
(state) => state.sourceMap?.data
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
ArrowFunction
(state) => state.loading.effects['sourceMap/get']!
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
ArrowFunction
() => { dispatch({ type: 'sourceMap/get', payload: { project }, }) }
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
MethodDeclaration
dayjs(item?.createdAt)
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
MethodDeclaration
onOk() { dispatch({ type: 'sourceMap/delete', payload: { sourceMap_id: item?.id, project, }, }) }
xunge0613/ohbug-web-app
src/pages/Settings/Project/SourceMap/SourceMap.tsx
TypeScript
FunctionDeclaration
export function test_MultiParserTemplate() { const xml = global.loadModule("xml-parser-tests/itemTemplates.xml") const view: any = builder.parse(xml); TKUnit.assertNotNull(view.items) TKUnit.assertEqual(view.items.length, 1); }
elektropay/NativeScript
tests/app/xml-parser-tests/xml-parser-tests.ts
TypeScript
ArrowFunction
eventData => { return { events: eventData.events.map(event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, blocked_users:event.blocked_users, verify:event.verify }; }), maxEvents: eventData.maxEvents }; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, blocked_users:event.blocked_users, verify:event.verify }; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
transformedEventData => { this.events = transformedEventData.events; this.eventsUpdated.next({ events: [...this.events], eventCount: transformedEventData.maxEvents }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
(eventTBAdata) => { return eventTBAdata.eventTBA; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
eventTBAdata => { this.eventTBA = eventTBAdata; this.eventTBAUpdated.next({ eventTBA: this.eventTBA }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
eventData => { return { events: eventData.events.map(event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, verify: event.verify }; }), maxEvents: eventData.maxEvents }; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, verify: event.verify }; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
responseData => { this.router.navigate(['/']); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
response => { console.log(response); this.eventTBA.announcements.push({_id: response._id,announcement: msg.tba}); this.eventTBAUpdated.next({ eventTBA: this.eventTBA }) }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
response => { console.log(response.message); this.eventTBA.announcements[this.eventTBA.announcements.indexOf(eventTBAold)].announcement = eventnewTBA; this.eventTBAUpdated.next({ eventTBA: this.eventTBA }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
response => { this.router.navigate(['/']); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
ArrowFunction
response => { console.log(response.message); this.eventTBA.announcements.splice(this.eventTBA.announcements.indexOf(eventTBA),1); this.eventTBAUpdated.next({ eventTBA: this.eventTBA }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEvents(eventsPerPage: number, currentPage: number) { const queryParams = `?pagesize=${eventsPerPage}&page=${currentPage}`; this.http .get<{ message: string; events: any; maxEvents: number }>( BACKEND_URL + queryParams ) .pipe( map(eventData => { return { events: eventData.events.map(event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, blocked_users:event.blocked_users, verify:event.verify }; }), maxEvents: eventData.maxEvents }; }) ) .subscribe(transformedEventData => { this.events = transformedEventData.events; this.eventsUpdated.next({ events: [...this.events], eventCount: transformedEventData.maxEvents }); }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEventUpdateListener() { return this.eventsUpdated.asObservable(); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEvent(id: string) { return this.http.get<{ _id: string; title: string; content: string; imagePath: string; startDate: string; endDate: string; category: string; creator: string; address: { street: string, city: string, state: string, country: string, zipcode: string }; max_users: Number; eventFee: Number; event_manager: { name: string, email: string, phone: string }; is_private: Boolean; verify:Boolean; }>(BACKEND_URL + id); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
addUserToEvent(data: any) { return this.http .post<{ accepted: boolean ,message: string }>( BACKEND_URL+ 'addusertoevent', data ); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
rejectInvitation(data: any) { return this.http .post<{ delete: boolean,message: string }>( BACKEND_URL+ 'rejectinvitation', data ); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
storeEventId(eventId: any) { this.dialogBoxEventId = eventId; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEventId() { return this.dialogBoxEventId; }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
invite(email: any, eventId: String, from: String) { return this.http .post<{ message: string}>( BACKEND_URL + 'invitations', { email: email, eventId: eventId, from: from } ); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEventTBA(id:string) { this.http.get<{ message: string , eventTBA: EventTBA , }> (BACKEND_URL + 'tba/' + id) .pipe(map((eventTBAdata) => { return eventTBAdata.eventTBA; })) .subscribe(eventTBAdata => { this.eventTBA = eventTBAdata; this.eventTBAUpdated.next({ eventTBA: this.eventTBA }); }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEventTBAUpdateListener() { return this.eventTBAUpdated.asObservable(); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
getEventByCity(city: string) { const queryParams = `?city=${city}`; this.http .get<{ message: string; events: any; maxEvents: number }>( BACKEND_URL + 'city/' + queryParams ) .pipe( map(eventData => { return { events: eventData.events.map(event => { return { title: event.title, content: event.content, id: event._id, imagePath: event.imagePath, startDate: event.startDate, endDate: event.endDate, category: event.category, creator: event.creator, is_private: event.is_private, max_users: event.max_users, eventFee: event.eventFee, eventManagerName: event.event_manager[0].name, eventManagerEmail: event.event_manager[0].email, eventManagerPhone: event.event_manager[0].phone, street: event.address[0].street, city: event.address[0].city, state: event.address[0].state, country: event.address[0].country, zipcode: event.address[0].zipcode, verify: event.verify }; }), maxEvents: eventData.maxEvents }; }) ) .subscribe(transformedEventData => { this.events = transformedEventData.events; this.eventsUpdated.next({ events: [...this.events], eventCount: transformedEventData.maxEvents }); }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
addEvent( title: string, content: string, image: File, startDate: string, endDate: string, category: string, is_private: Boolean, max_users: Number, eventFee: Number, eventManagerName: string, eventManagerEmail: string, eventManagerPhone: string, street: string, city: string, state: string, country: string, zipcode: string) { const eventData = new FormData(); const address = [{ street: street, city: city, state: state, country: country, zipcode: zipcode }]; const event_manager = [{ name: eventManagerName, email: eventManagerEmail, phone: eventManagerPhone }]; if (max_users === null) { max_users = -1; } if (eventFee === null) { eventFee = 0; } eventData.append('title', title); eventData.append('content', content); eventData.append('image', image, title); eventData.append('startDate', startDate); eventData.append('endDate', endDate); eventData.append('category', category); const privacy = (is_private === true); eventData.append('is_private', privacy.toString()); eventData.append('max_users', max_users.toString()); eventData.append('eventFee', eventFee.toString()); eventData.append('event_manager', JSON.stringify(event_manager)); eventData.append('address', JSON.stringify(address)); this.http .post<{ message: string; event: Event }>( BACKEND_URL, eventData ) .subscribe(responseData => { this.router.navigate(['/']); }); }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
postTBA(msg: any, id:string){ this.http .post<{ message:string, _id: string }>( BACKEND_URL + 'tba/' + id, msg ).subscribe(response => { console.log(response); this.eventTBA.announcements.push({_id: response._id,announcement: msg.tba}); this.eventTBAUpdated.next({ eventTBA: this.eventTBA }) }) }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript
MethodDeclaration
updateEventTBA(eventTBAold: any, eventId: string,eventnewTBA: string ) { this.http.post<{message: string}>(BACKEND_URL + 'tba?eventId=' + eventId + '&eventTBAId=' + eventTBAold._id, {eventTBA: eventnewTBA} ) .subscribe(response => { console.log(response.message); this.eventTBA.announcements[this.eventTBA.announcements.indexOf(eventTBAold)].announcement = eventnewTBA; this.eventTBAUpdated.next({ eventTBA: this.eventTBA }); }) }
sonusourav/instigo-webapp
src/app/events/events.service.ts
TypeScript