Code Snippets TypeScript

Short texts TypeScript 🧑‍💻 Code snippets TypeScript ✍️ Reading lists TypeScript 👀

Hooks

## Reusable react hooks. import * as React from ‘react’ /** Passed a ref and a condition, * triggers a focus event on the referent * if the condition is true. * Useful for managing focus for keyboard and screen reader users. * @example * // an element referenced by ‘ref’ * // will focus […]

Hooks

## Reusable react hooks. import * as React from ‘react’ /** Passed a ref and a condition, * triggers a focus event on the referent * if the condition is true. * Useful for managing focus for keyboard and screen reader users. * @example * // an element referenced by ‘ref’ * // will focus […]

Hooks

## Reusable react hooks. import * as React from ‘react’ /** Passed a ref and a condition, * triggers a focus event on the referent * if the condition is true. * Useful for managing focus for keyboard and screen reader users. * @example * // an element referenced by ‘ref’ * // will focus […]

Hooks

## Reusable react hooks. import * as React from ‘react’ /** Passed a ref and a condition, * triggers a focus event on the referent * if the condition is true. * Useful for managing focus for keyboard and screen reader users. * @example * // an element referenced by ‘ref’ * // will focus […]

Code describing a system to handle CPU-intensive jobs on NodeJS servers

class JobProcessor { private assignedJobs = new Map(); private queue = new Queue(); private nWorkers = 5; async loadOutstandingJobs() { // load ‘pending’ or ‘processing’ jobs from DB const jobs = await services.Job .findMany({ $or: [ { status: ‘pending’ }, { status: ‘processing’ } ] }); jobs.forEach(job => this.queue.enqueue(job)); } async registerJob(job: any) { // […]