type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
export declare function deepMergeResource< T extends string = string, A extends object =(object | undefined), R extends JSONAPIRelationshipsObject = (JSONAPIRelationshipsObject | undefined) >(target: JSONAPIResource<T, A, R>, source: JSONAPIResource<T, A, R>): JSONAPIResource<T, A, R>;
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
FunctionDeclaration
export default function createJSONAPIReducer(reducerId: string, config: JSONAPISliceConfigsObject): { reduce: Reducer; RESOURCE: Readonly<string>; updatesResources: () => PartialFSAMeta; deletesResource: (resource: JSONAPIResourceIdentifier) => PartialFSAMeta; createsRelationship: (...relations: (null | JSONAPIRelationshipUpdateConfig)[]) => PartialFSAMeta; deletesRelationship: (...relations: (null | JSONAPIRelationshipUpdateConfig)[]) => PartialFSAMeta; };
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
FunctionDeclaration
export declare function defineRelationship( relatedResource: JSONAPIResourceIdentifier, relationships?: JSONAPIRelationshipReferencesObject ): (null | JSONAPIRelationshipUpdateConfig);
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
InterfaceDeclaration
export interface JSONAPISliceConfig { target?: string; mergeMethod?(target: JSONAPIResource, source: JSONAPIResource): JSONAPIResource; reducer?(resource: JSONAPIResource): JSONAPIResource; }
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
InterfaceDeclaration
export interface JSONAPISliceConfigsObject { [r: string]: JSONAPISliceConfig; }
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
InterfaceDeclaration
export interface JSONAPIRelationshipReferencesObject { [r: string]: JSONAPIRelationshipReference; }
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
InterfaceDeclaration
export interface JSONAPIRelationshipUpdateConfig { id: string; type: string; relationships: JSONAPIRelationshipReferencesObject; }
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
TypeAliasDeclaration
export type JSONAPIRelationshipReference = string | JSONAPIResourceIdentifier | (string | JSONAPIResourceIdentifier)[];
FuelRats/fuelrats.com-redux-utils
types/redux-json-api.d.ts
TypeScript
ClassDeclaration
export class Commit { id: string; repoId: string; shortMessage: string; authorName: string; authorEmail: string; authorWhen: Date; insertion: number; deletion: number; ignored: boolean; }
eshockx/gitstatistics
src/main/angular-antd/src/app/domain/commit.ts
TypeScript
ArrowFunction
async subscription => { let exchangeName: string if (subscription.topicIdentifier) { exchangeName = subscription.topicIdentifier } else if (subscription.messageType) { const messageName = new subscription.messageType().$name exchangeName = messageName await this.assertExchange(messageName) } else { throw new Error('Unable to bind exchange to queue - no topic information provided') } this.logger.debug('Binding exchange to queue.', { exchangeName, queueName: this.configuration.queueName }) await this.channel.bindQueue(this.configuration.queueName, exchangeName, '') }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
ClassDeclaration
/** * A RabbitMQ transport adapter for @node-ts/bus. */ @injectable() export class RabbitMqTransport implements Transport<RabbitMqMessage> { private connection: Connection private channel: Channel private assertedExchanges: { [key: string]: boolean } = {} private maxRetries: number constructor ( @inject(BUS_RABBITMQ_INTERNAL_SYMBOLS.AmqpFactory) private readonly connectionFactory: () => Promise<Connection>, @inject(BUS_RABBITMQ_SYMBOLS.TransportConfiguration) private readonly configuration: RabbitMqTransportConfiguration, @inject(LOGGER_SYMBOLS.Logger) private readonly logger: Logger ) { this.maxRetries = configuration.maxRetries || DEFAULT_MAX_RETRIES } async initialize (handlerRegistry: HandlerRegistry): Promise<void> { this.logger.info('Initializing RabbitMQ transport') this.connection = await this.connectionFactory() this.channel = await this.connection.createChannel() await this.bindExchangesToQueue(handlerRegistry) this.logger.info('RabbitMQ transport initialized') } async dispose (): Promise<void> { await this.channel.close() await this.connection.close() } async publish<TEvent extends Event> (event: TEvent, messageAttributes?: MessageAttributes): Promise<void> { await this.publishMessage(event, messageAttributes) } async send<TCommand extends Command> (command: TCommand, messageAttributes?: MessageAttributes): Promise<void> { await this.publishMessage(command, messageAttributes) } async readNextMessage (): Promise<TransportMessage<RabbitMqMessage> | undefined> { const rabbitMessage = await this.channel.get(this.configuration.queueName, { noAck: false }) if (rabbitMessage === false) { return undefined } const payloadStr = rabbitMessage.content.toString('utf8') const payload = JSON.parse(payloadStr) as MessageType const attributes: MessageAttributes = { correlationId: rabbitMessage.properties.correlationId as string, attributes: rabbitMessage.properties.headers && rabbitMessage.properties.headers.attributes ? JSON.parse(rabbitMessage.properties.headers.attributes as string) as MessageAttributeMap : {}, stickyAttributes: rabbitMessage.properties.headers && rabbitMessage.properties.headers.stickyAttributes ? JSON.parse(rabbitMessage.properties.headers.stickyAttributes as string) as MessageAttributeMap : {} } return { id: undefined, domainMessage: payload, raw: rabbitMessage, attributes } } async deleteMessage (message: TransportMessage<RabbitMqMessage>): Promise<void> { this.logger.debug( 'Deleting message', { rawMessage: { ...message.raw, content: message.raw.content.toString() } } ) this.channel.ack(message.raw) } async returnMessage (message: TransportMessage<RabbitMqMessage>): Promise<void> { const msg = JSON.parse(message.raw.content.toString()) const attempt = message.raw.fields.deliveryTag const meta = { attempt, message: msg, rawMessage: message.raw } if (attempt >= this.maxRetries) { this.logger.debug('Message retries failed, sending to dead letter queue', meta) this.channel.reject(message.raw, false) } else { this.logger.debug('Returning message', meta) this.channel.nack(message.raw) } } private async assertExchange (messageName: string): Promise<void> { if (!this.assertedExchanges[messageName]) { this.logger.debug('Asserting exchange', { messageName }) await this.channel.assertExchange(messageName, 'fanout', { durable: true }) this.assertedExchanges[messageName] = true } } private async bindExchangesToQueue (handlerRegistry: HandlerRegistry): Promise<void> { await this.createDeadLetterQueue() await this.channel.assertQueue( this.configuration.queueName, { durable: true, deadLetterExchange } ) const subscriptionPromises = handlerRegistry.messageSubscriptions .map(async subscription => { let exchangeName: string if (subscription.topicIdentifier) { exchangeName = subscription.topicIdentifier } else if (subscription.messageType) { const messageName = new subscription.messageType().$name exchangeName = messageName await this.assertExchange(messageName) } else { throw new Error('Unable to bind exchange to queue - no topic information provided') } this.logger.debug('Binding exchange to queue.', { exchangeName, queueName: this.configuration.queueName }) await this.channel.bindQueue(this.configuration.queueName, exchangeName, '') }) await Promise.all(subscriptionPromises) } /** * Creates a dead letter exchange + queue, binds, and returns the * dead letter exchange name */ private async createDeadLetterQueue (): Promise<void> { await this.channel.assertExchange(deadLetterExchange, 'direct', { durable: true }) await this.channel.assertQueue(deadLetterQueue, { durable: true }) await this.channel.bindQueue(deadLetterQueue, deadLetterExchange, '') } private async publishMessage ( message: Message, messageOptions: MessageAttributes = new MessageAttributes() ): Promise<void> { await this.assertExchange(message.$name) const payload = JSON.stringify(message) this.channel.publish(message.$name, '', Buffer.from(payload), { correlationId: messageOptions.correlationId, headers: { attributes: messageOptions.attributes ? JSON.stringify(messageOptions.attributes) : undefined, stickyAttributes: messageOptions.stickyAttributes ? JSON.stringify(messageOptions.stickyAttributes) : undefined } }) } }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async initialize (handlerRegistry: HandlerRegistry): Promise<void> { this.logger.info('Initializing RabbitMQ transport') this.connection = await this.connectionFactory() this.channel = await this.connection.createChannel() await this.bindExchangesToQueue(handlerRegistry) this.logger.info('RabbitMQ transport initialized') }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async dispose (): Promise<void> { await this.channel.close() await this.connection.close() }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async publish<TEvent extends Event> (event: TEvent, messageAttributes?: MessageAttributes): Promise<void> { await this.publishMessage(event, messageAttributes) }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async send<TCommand extends Command> (command: TCommand, messageAttributes?: MessageAttributes): Promise<void> { await this.publishMessage(command, messageAttributes) }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async readNextMessage (): Promise<TransportMessage<RabbitMqMessage> | undefined> { const rabbitMessage = await this.channel.get(this.configuration.queueName, { noAck: false }) if (rabbitMessage === false) { return undefined } const payloadStr = rabbitMessage.content.toString('utf8') const payload = JSON.parse(payloadStr) as MessageType const attributes: MessageAttributes = { correlationId: rabbitMessage.properties.correlationId as string, attributes: rabbitMessage.properties.headers && rabbitMessage.properties.headers.attributes ? JSON.parse(rabbitMessage.properties.headers.attributes as string) as MessageAttributeMap : {}, stickyAttributes: rabbitMessage.properties.headers && rabbitMessage.properties.headers.stickyAttributes ? JSON.parse(rabbitMessage.properties.headers.stickyAttributes as string) as MessageAttributeMap : {} } return { id: undefined, domainMessage: payload, raw: rabbitMessage, attributes } }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async deleteMessage (message: TransportMessage<RabbitMqMessage>): Promise<void> { this.logger.debug( 'Deleting message', { rawMessage: { ...message.raw, content: message.raw.content.toString() } } ) this.channel.ack(message.raw) }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
async returnMessage (message: TransportMessage<RabbitMqMessage>): Promise<void> { const msg = JSON.parse(message.raw.content.toString()) const attempt = message.raw.fields.deliveryTag const meta = { attempt, message: msg, rawMessage: message.raw } if (attempt >= this.maxRetries) { this.logger.debug('Message retries failed, sending to dead letter queue', meta) this.channel.reject(message.raw, false) } else { this.logger.debug('Returning message', meta) this.channel.nack(message.raw) } }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
private async assertExchange (messageName: string): Promise<void> { if (!this.assertedExchanges[messageName]) { this.logger.debug('Asserting exchange', { messageName }) await this.channel.assertExchange(messageName, 'fanout', { durable: true }) this.assertedExchanges[messageName] = true } }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
private async bindExchangesToQueue (handlerRegistry: HandlerRegistry): Promise<void> { await this.createDeadLetterQueue() await this.channel.assertQueue( this.configuration.queueName, { durable: true, deadLetterExchange } ) const subscriptionPromises = handlerRegistry.messageSubscriptions .map(async subscription => { let exchangeName: string if (subscription.topicIdentifier) { exchangeName = subscription.topicIdentifier } else if (subscription.messageType) { const messageName = new subscription.messageType().$name exchangeName = messageName await this.assertExchange(messageName) } else { throw new Error('Unable to bind exchange to queue - no topic information provided') } this.logger.debug('Binding exchange to queue.', { exchangeName, queueName: this.configuration.queueName }) await this.channel.bindQueue(this.configuration.queueName, exchangeName, '') }) await Promise.all(subscriptionPromises) }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
/** * Creates a dead letter exchange + queue, binds, and returns the * dead letter exchange name */ private async createDeadLetterQueue (): Promise<void> { await this.channel.assertExchange(deadLetterExchange, 'direct', { durable: true }) await this.channel.assertQueue(deadLetterQueue, { durable: true }) await this.channel.bindQueue(deadLetterQueue, deadLetterExchange, '') }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
MethodDeclaration
private async publishMessage ( message: Message, messageOptions: MessageAttributes = new MessageAttributes() ): Promise<void> { await this.assertExchange(message.$name) const payload = JSON.stringify(message) this.channel.publish(message.$name, '', Buffer.from(payload), { correlationId: messageOptions.correlationId, headers: { attributes: messageOptions.attributes ? JSON.stringify(messageOptions.attributes) : undefined, stickyAttributes: messageOptions.stickyAttributes ? JSON.stringify(messageOptions.stickyAttributes) : undefined } }) }
Zehelein/bus
packages/bus-rabbitmq/src/rabbitmq-transport.ts
TypeScript
ArrowFunction
ref => ref.where('userId', '==', this.localStorage.getItem('currentUser'))
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
ArrowFunction
ref => ref.where('shared', 'array-contains', this.localStorage.getItem('currentUserEmail'))
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
ClassDeclaration
@Injectable({ providedIn: 'root' }) export class FirestoreService { private collection: string; constructor( private firestore: AngularFirestore, @Inject('LOCALSTORAGE') private localStorage: Storage ) { this.collection = 'draw'; } public create(canvas) { return this.firestore.collection(this.collection).add({ canvas: canvas, userId: this.localStorage.getItem('currentUser'), displayName: this.localStorage.getItem('currentUserName'), shared: [] }); } public getById(documentId: string) { return this.firestore.collection(this.collection).doc(documentId).valueChanges(); } public get() { return this.firestore.collection(this.collection, ref => ref.where('userId', '==', this.localStorage.getItem('currentUser'))) .valueChanges({ idField: 'docId'}); } public sharedWithMe() { return this.firestore.collection(this.collection, ref => ref.where('shared', 'array-contains', this.localStorage.getItem('currentUserEmail'))) .valueChanges({ idField: 'docId'}); } public update(id: string, data: Draw) { return this.firestore.collection(this.collection).doc(id).set(data); } }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
InterfaceDeclaration
interface Draw { docId: string; userId: string; displayName: String; canvas: any; shared: Array<string>; }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
MethodDeclaration
public create(canvas) { return this.firestore.collection(this.collection).add({ canvas: canvas, userId: this.localStorage.getItem('currentUser'), displayName: this.localStorage.getItem('currentUserName'), shared: [] }); }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
MethodDeclaration
public getById(documentId: string) { return this.firestore.collection(this.collection).doc(documentId).valueChanges(); }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
MethodDeclaration
public get() { return this.firestore.collection(this.collection, ref => ref.where('userId', '==', this.localStorage.getItem('currentUser'))) .valueChanges({ idField: 'docId'}); }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
MethodDeclaration
public sharedWithMe() { return this.firestore.collection(this.collection, ref => ref.where('shared', 'array-contains', this.localStorage.getItem('currentUserEmail'))) .valueChanges({ idField: 'docId'}); }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
MethodDeclaration
public update(id: string, data: Draw) { return this.firestore.collection(this.collection).doc(id).set(data); }
levapm/pencil-test
src/app/core/services/database.service.ts
TypeScript
FunctionDeclaration
function LabeledValue({ label, value }: Props): React.ReactElement { return ( <div className={styles.wrapper}> <strong className={styles.label}>{label}</strong> <span className={styles.value}>{value || '–'}
Sukriva/open-city-profile-ui
src/common/labeledValue/LabeledValue.tsx
TypeScript
TypeAliasDeclaration
type Props = { label: string; value: string | null | undefined; };
Sukriva/open-city-profile-ui
src/common/labeledValue/LabeledValue.tsx
TypeScript
ArrowFunction
(): ReturnedFunc => { const dispatcher = useDispatch(); return ({ target }: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => { dispatcher(ReduxFormsActions.setErrorInFormField(AllFormsTypes.MESSAGE, target.id as MessageFormInputs, false)); dispatcher(ReduxFormsActions.setFieldInMessageForm(target.id as MessageFormInputs, target.value)); }; }
Milosz08/ReactJS_Web_Application_Digititles_Imagine
src/hooks/footer/useFooterFormChangeState.ts
TypeScript
ArrowFunction
({ target }: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => { dispatcher(ReduxFormsActions.setErrorInFormField(AllFormsTypes.MESSAGE, target.id as MessageFormInputs, false)); dispatcher(ReduxFormsActions.setFieldInMessageForm(target.id as MessageFormInputs, target.value)); }
Milosz08/ReactJS_Web_Application_Digititles_Imagine
src/hooks/footer/useFooterFormChangeState.ts
TypeScript
TypeAliasDeclaration
type ReturnedFunc = ({ target }: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
Milosz08/ReactJS_Web_Application_Digititles_Imagine
src/hooks/footer/useFooterFormChangeState.ts
TypeScript
FunctionDeclaration
export default function App() { return ( <html lang="en"> <head> <meta charSet="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1" /> <Meta /> <Links /> {typeof document === "undefined" ? "__STYLES__" : null} </head> <body> <Outlet /> <ScrollRestoration /> <Scripts /> <LiveReload /> </body> </html> ); }
BasixKOR/remix
examples/styled-components/app/root.tsx
TypeScript
ArrowFunction
() => { const mutator = new FloatingNonuniformMutation(); test('Generation test', () => { const ind = new FloatingIndividual([2, 4, 5, 8], new NumericRange(0, 9)); const newInd = new FloatingIndividual(''); for (let i = 0; i < 1000; i++) { newInd.deepCopy(ind); expect(newInd.genotype).toEqual(ind.genotype); mutator.mutate(newInd, 0.99); expect(newInd.range).toEqual(ind.range); newInd.forEach(gene => expect(NumericRange.isValueInRange(gene, newInd.range)).toBeTruthy()); } }); }
GeneticsJS/GeneticsJS
src/__tests__/mutation/numeric/floating/FloatingNonUniformMutation.test.ts
TypeScript
ArrowFunction
() => { const ind = new FloatingIndividual([2, 4, 5, 8], new NumericRange(0, 9)); const newInd = new FloatingIndividual(''); for (let i = 0; i < 1000; i++) { newInd.deepCopy(ind); expect(newInd.genotype).toEqual(ind.genotype); mutator.mutate(newInd, 0.99); expect(newInd.range).toEqual(ind.range); newInd.forEach(gene => expect(NumericRange.isValueInRange(gene, newInd.range)).toBeTruthy()); } }
GeneticsJS/GeneticsJS
src/__tests__/mutation/numeric/floating/FloatingNonUniformMutation.test.ts
TypeScript
ArrowFunction
gene => expect(NumericRange.isValueInRange(gene, newInd.range)).toBeTruthy()
GeneticsJS/GeneticsJS
src/__tests__/mutation/numeric/floating/FloatingNonUniformMutation.test.ts
TypeScript
ArrowFunction
(): void => { this.emitter.emit('tick', {}); }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
ClassDeclaration
/** * Value Object */ export class Interval implements IInterval { // eslint-disable-next-line @typescript-eslint/no-explicit-any private static instance: Interval | undefined; public static create(): Interval { if (this.instance === undefined) { this.instance = new Interval(); } return this.instance; } private emitter = new NanoEvents<{tick: {}}>(); private constructor() {} private items = new Map<unknown, unknown>(); private intervalId: number | undefined; /** * just run with `window.setInterval` */ private startTick() { this.intervalId = window.setInterval((): void => { this.emitter.emit('tick', {}); }, 30); } /** * Weather running `window.setInterval` */ private isRunningTick(): boolean { return this.intervalId !== undefined; } /** * To stop running `window.setInterval` */ private stopTick(): void { if (!this.isRunningTick()) { return; } clearInterval(this.intervalId); this.intervalId = undefined; } private hasItems(): boolean { return this.items.size > 0; } /** * whether item has */ private has(item: unknown) { return this.items.has(item); } private add(item: unknown) { this.items.set(item, item); } private remove(item: unknown) { this.items.delete(item); } public async wait( item: unknown, condition: (onTick: (cb: () => void) => void) => Promise<void>, ): Promise<void> { this.add(item); if (this.has(item) && this.hasItems() && !this.isRunningTick()) { this.startTick(); } const onTick = this.emitter.on.bind(this.emitter, 'tick'); await condition(onTick); this.remove(item); if (!this.has(item) && !this.hasItems() && this.isRunningTick()) { this.stopTick(); } } }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
public static create(): Interval { if (this.instance === undefined) { this.instance = new Interval(); } return this.instance; }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
/** * just run with `window.setInterval` */ private startTick() { this.intervalId = window.setInterval((): void => { this.emitter.emit('tick', {}); }, 30); }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
/** * Weather running `window.setInterval` */ private isRunningTick(): boolean { return this.intervalId !== undefined; }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
/** * To stop running `window.setInterval` */ private stopTick(): void { if (!this.isRunningTick()) { return; } clearInterval(this.intervalId); this.intervalId = undefined; }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
private hasItems(): boolean { return this.items.size > 0; }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
/** * whether item has */ private has(item: unknown) { return this.items.has(item); }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
private add(item: unknown) { this.items.set(item, item); }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
private remove(item: unknown) { this.items.delete(item); }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
MethodDeclaration
public async wait( item: unknown, condition: (onTick: (cb: () => void) => void) => Promise<void>, ): Promise<void> { this.add(item); if (this.has(item) && this.hasItems() && !this.isRunningTick()) { this.startTick(); } const onTick = this.emitter.on.bind(this.emitter, 'tick'); await condition(onTick); this.remove(item); if (!this.has(item) && !this.hasItems() && this.isRunningTick()) { this.stopTick(); } }
nju33/react-dayo
packages/core-dayo/src/entities/interval/interval.ts
TypeScript
FunctionDeclaration
export function WarningDeleteModal( { name, handleRemoveFromList, closeModal, title, description, isVisible }: WarningDeleteModal){ const [ isLoading, setIsLoading ] = useState(false) return( <ModalContainer selector="#modal"> <AnimatePresence exitBeforeEnter> { isVisible && <motion.div className={styles.Modalbackground} layout initial={{ opacity: 0}}
GabrSobral/Carpe_Diem_ADMIN
src/components/WarningDeleteModal/index.tsx
TypeScript
InterfaceDeclaration
interface WarningDeleteModal{ name: string; handleRemoveFromList: () => void | Promise<void>; closeModal: () => void; title: "a atividade" | "a categoria" | 'a pergunta' | "o arquivo"; description: string; isVisible: boolean; }
GabrSobral/Carpe_Diem_ADMIN
src/components/WarningDeleteModal/index.tsx
TypeScript
MethodDeclaration
isLoading ? <Loading type="spin" color="#fff" height={24} width={24}
GabrSobral/Carpe_Diem_ADMIN
src/components/WarningDeleteModal/index.tsx
TypeScript
ArrowFunction
({ interaction }) =>{ let queue:Queue = interaction.client.player.getQueue(interaction.guild); if(queue == null) queue = interaction.client.player.createQueue(interaction.guild, { textChannel: interaction.channel }); interaction.followUp({embeds: [Embed(`Connected to Channel \`\` ${interaction.member.voice.channel.name} \`\``, 1)]}); queue.connect(interaction.member?.voice?.channel); }
aquieover0/Aquie
src/Commands/Player/join.ts
TypeScript
FunctionDeclaration
function isProc(proc: MockProc | undefined): asserts proc is MockProc { expect(proc).toBeInstanceOf(MockProc); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
(signal) => { this.signalsSent.push(signal); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { const proc = new MockProc(); currentProc = proc; return proc; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => restart$
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { jest.clearAllMocks(); log.messages.length = 0; currentProc = undefined; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
(server: DevServer) => { const subscription = server.run$.subscribe({ error(e) { throw e; }, }); subscriptions.push(subscription); return subscription; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { if (currentProc) { currentProc.removeAllListeners(); currentProc = undefined; } for (const sub of subscriptions) { sub.unsubscribe(); } subscriptions.length = 0; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { it('starts the dev server with the right options', () => { run(new DevServer(defaultOptions)).unsubscribe(); expect(execa.node.mock.calls).toMatchInlineSnapshot(` Array [ Array [ "some/script", Array [ "foo", "bar", "--logging.json=false", ], Object { "env": Object { "<inheritted process.env>": true, "ELASTIC_APM_SERVICE_NAME": "kibana", "isDevCliChild": "true", }, "nodeOptions": Array [], "stdio": "pipe", }, ], ] `); }); it('writes stdout and stderr lines to logger', () => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.stdout.write('hello '); currentProc.stderr.write('something '); currentProc.stdout.write('world\n'); currentProc.stderr.write('went wrong\n'); expect(log.messages).toMatchInlineSnapshot(` Array [ Object { "args": Array [ "hello world", ], "type": "write", }, Object { "args": Array [ "something went wrong", ], "type": "write", }, ] `); }); it('is ready when message sends SERVER_LISTENING message', () => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); let ready; subscriptions.push( server.isReady$().subscribe((_ready) => { ready = _ready; }) ); expect(ready).toBe(false); currentProc.mockListening(); expect(ready).toBe(true); }); it('is not ready when process exits', () => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); const ready$ = new Rx.BehaviorSubject<undefined | boolean>(undefined); subscriptions.push(server.isReady$().subscribe(ready$)); currentProc.mockListening(); expect(ready$.getValue()).toBe(true); currentProc.mockExit(0); expect(ready$.getValue()).toBe(false); }); it('logs about crashes when process exits with non-zero code', () => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); currentProc.mockExit(1); expect(log.messages).toMatchInlineSnapshot(` Array [ Object { "args": Array [ "server crashed", "with status code", 1, ], "type": "bad", }, ] `); }); it('does not restart the server when process exits with 0 and stdio streams complete', async () => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); const initialProc = currentProc; const ready$ = new Rx.BehaviorSubject<undefined | boolean>(undefined); subscriptions.push(server.isReady$().subscribe(ready$)); currentProc.mockExit(0); expect(ready$.getValue()).toBe(false); expect(initialProc).toBe(currentProc); // no restart or the proc would have been updated }); it('kills server and restarts when watcher says to', () => { run(new DevServer(defaultOptions)); const initialProc = currentProc; isProc(initialProc); restart$.next(); expect(initialProc.signalsSent).toEqual(['SIGKILL']); isProc(currentProc); expect(currentProc).not.toBe(initialProc); }); it('subscribes to sigint$, sigterm$, and processExit$ options', () => { run(new DevServer(defaultOptions)); expect(sigint$.observers).toHaveLength(1); expect(sigterm$.observers).toHaveLength(1); expect(processExit$.observers).toHaveLength(1); }); it('kills the server on sigint$ before listening', () => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }); it('kills the server on processExit$', () => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); processExit$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }); it('kills the server on sigterm$', () => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); sigterm$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }); it('sends SIGINT to child process on sigint$ after listening', () => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT']); }); it('sends SIGKILL to child process on double sigint$ after listening', () => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT', 'SIGKILL']); }); it('kills the server after sending SIGINT and gracefulTimeout is passed after listening', async () => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT']); await new Promise((resolve) => setTimeout(resolve, 1000)); expect(currentProc.signalsSent).toEqual(['SIGINT', 'SIGKILL']); }); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)).unsubscribe(); expect(execa.node.mock.calls).toMatchInlineSnapshot(` Array [ Array [ "some/script", Array [ "foo", "bar", "--logging.json=false", ], Object { "env": Object { "<inheritted process.env>": true, "ELASTIC_APM_SERVICE_NAME": "kibana", "isDevCliChild": "true", }, "nodeOptions": Array [], "stdio": "pipe", }, ], ] `); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.stdout.write('hello '); currentProc.stderr.write('something '); currentProc.stdout.write('world\n'); currentProc.stderr.write('went wrong\n'); expect(log.messages).toMatchInlineSnapshot(` Array [ Object { "args": Array [ "hello world", ], "type": "write", }, Object { "args": Array [ "something went wrong", ], "type": "write", }, ] `); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); let ready; subscriptions.push( server.isReady$().subscribe((_ready) => { ready = _ready; }) ); expect(ready).toBe(false); currentProc.mockListening(); expect(ready).toBe(true); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
(_ready) => { ready = _ready; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); const ready$ = new Rx.BehaviorSubject<undefined | boolean>(undefined); subscriptions.push(server.isReady$().subscribe(ready$)); currentProc.mockListening(); expect(ready$.getValue()).toBe(true); currentProc.mockExit(0); expect(ready$.getValue()).toBe(false); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); currentProc.mockExit(1); expect(log.messages).toMatchInlineSnapshot(` Array [ Object { "args": Array [ "server crashed", "with status code", 1, ], "type": "bad", }, ] `); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
async () => { const server = new DevServer(defaultOptions); run(server); isProc(currentProc); const initialProc = currentProc; const ready$ = new Rx.BehaviorSubject<undefined | boolean>(undefined); subscriptions.push(server.isReady$().subscribe(ready$)); currentProc.mockExit(0); expect(ready$.getValue()).toBe(false); expect(initialProc).toBe(currentProc); // no restart or the proc would have been updated }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); const initialProc = currentProc; isProc(initialProc); restart$.next(); expect(initialProc.signalsSent).toEqual(['SIGKILL']); isProc(currentProc); expect(currentProc).not.toBe(initialProc); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); expect(sigint$.observers).toHaveLength(1); expect(sigterm$.observers).toHaveLength(1); expect(processExit$.observers).toHaveLength(1); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); processExit$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); expect(currentProc.signalsSent).toEqual([]); sigterm$.next(); expect(currentProc.signalsSent).toEqual(['SIGKILL']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
() => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT', 'SIGKILL']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ArrowFunction
async () => { run(new DevServer(defaultOptions)); isProc(currentProc); currentProc.mockListening(); expect(currentProc.signalsSent).toEqual([]); sigint$.next(); expect(currentProc.signalsSent).toEqual(['SIGINT']); await new Promise((resolve) => setTimeout(resolve, 1000)); expect(currentProc.signalsSent).toEqual(['SIGINT', 'SIGKILL']); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
ClassDeclaration
class MockProc extends EventEmitter { public readonly signalsSent: string[] = []; stdout = new PassThrough(); stderr = new PassThrough(); kill = jest.fn((signal) => { this.signalsSent.push(signal); }); mockExit(code: number) { this.emit('exit', code, undefined); // close stdio streams this.stderr.end(); this.stdout.end(); } mockListening() { this.emit('message', ['SERVER_LISTENING'], undefined); } }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
MethodDeclaration
mockExit(code: number) { this.emit('exit', code, undefined); // close stdio streams this.stderr.end(); this.stdout.end(); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
MethodDeclaration
mockListening() { this.emit('message', ['SERVER_LISTENING'], undefined); }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
MethodDeclaration
error(e) { throw e; }
AlexanderWert/kibana
src/dev/cli_dev_mode/dev_server.test.ts
TypeScript
FunctionDeclaration
/** * Function to check if a version of request is supported by this library * * version is not supported if higher than the current one * version is not supported if the major is different * version is not supported if the version is in the exceptions array defined in config.json * * @param string version the version to check * @param IVersionSupportConfig versionConfiguration override the default configuration only for this check * * @returns boolean true, if version is supported false otherwise */ function isSupported(version: string, versionConfiguration?: Types.IVersionSupportConfig): boolean { versionConfiguration = versionConfiguration || Config.specificationVersion; return ( !!Semver.valid(version) && Semver.diff(version, versionConfiguration.current) !== 'major' && Semver.lte(version, versionConfiguration.current) && versionConfiguration.exceptions.indexOf(version) === -1 ); }
romaric-juniet/requestNetwork
packages/request-logic/src/version.ts
TypeScript
FunctionDeclaration
export function* accountRootSaga() { yield takeEvery(getType(actions.dummyAction), dummySaga) }
Meyhem/generator-reactux
example/src/features/account/saga.ts
TypeScript
FunctionDeclaration
function* dummySaga() { yield 0 }
Meyhem/generator-reactux
example/src/features/account/saga.ts
TypeScript
ArrowFunction
(r: any) => r instanceof HttpResponse
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<RegistrantProfile>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<RegistrantProfile>) => r.body as RegistrantProfile
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<RegistrationResult>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<RegistrationResult>) => r.body as RegistrationResult
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<GetSecurityQuestionsResponse>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<GetSecurityQuestionsResponse>) => r.body as GetSecurityQuestionsResponse
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<VerifySecurityQuestionsResponse>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<VerifySecurityQuestionsResponse>) => r.body as VerifySecurityQuestionsResponse
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<EvacuationFile>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<EvacuationFile>) => r.body as EvacuationFile
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<Array<EvacuationFileSummary>>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<Array<EvacuationFileSummary>>) => r.body as Array<EvacuationFileSummary>
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: HttpResponse<any>) => { return r as StrictHttpResponse<GetSecurityPhraseResponse>; }
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript
ArrowFunction
(r: StrictHttpResponse<GetSecurityPhraseResponse>) => r.body as GetSecurityPhraseResponse
SodhiA1/embc-ess-mod
responders/src/UI/embc-responder/src/app/core/api/services/registrations.service.ts
TypeScript