🎉 All free or open source.
Note: Updated for 2022-23+
fetch('https://api.github.com/orgs/nodejs') | |
.then(response => response.json()) | |
.then(data => { | |
console.log(data) // result from `response.json()` above | |
}) | |
.catch(error => console.error(error)) |
// OPTION #1: no temp streamProcessor var | |
fetch(...) | |
.then(progressHelper(console.log)) | |
// ⚠️ OR️ ️⚠️ | |
// OPTION #2: define a `streamProcessor` to hold our console logger | |
const streamProcessor = progressHelper(console.log) | |
fetch(...) | |
.then(streamProcessor) |
🎉 All free or open source.
Note: Updated for 2022-23+
require('dotenv').config() | |
const http = require('http') | |
const express = require('express') | |
const session = require('express-session') | |
const FileStore = require('session-file-store')(session) | |
const bodyParser = require('body-parser') | |
const morgan = require('morgan') | |
const cors = require('cors') | |
const passport = require('passport') |
{ | |
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | |
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | |
// List of extensions which should be recommended for users of this workspace. | |
"recommendations": [ | |
"streetsidesoftware.code-spell-checker", | |
"kisstkondoros.vscode-codemetrics", | |
"ms-azuretools.vscode-docker", | |
"dbaeumer.vscode-eslint", |
/** | |
* `filteredFlagFactory` supports 3 states of a feature flag: | |
* - True, | |
* - False, | |
* - and restricted by ID(s). | |
* | |
*/ | |
export function filteredFlagFactory( | |
flagValue: string, | |
defaultIdField = 'userId' |
/** | |
* Handle process signal events easily with `addSignalListener()`. | |
* | |
* Automatically returns a convenient method to unregister your event handler(s), in case you need that functionality. | |
* | |
* ## Examples | |
* | |
* ```js | |
* addSignalListener(['SIGINT', 'SIGHUP', 'SIGUSR2'], (signal, event) => | |
* console.log(`Process received a signal! ${signal}`, { event }); |
export const batchStream = (size: number) => | |
async function* batchStream<TStreamType>(stream: AsyncIterable<TStreamType>) { | |
let buffer: TStreamType[] = []; | |
for await (const chunk of stream) { | |
buffer.push(chunk); | |
if (buffer.length >= size) { | |
yield buffer; | |
buffer = []; | |
} | |
} |
{ | |
// TypeScript configuration | |
// Use the project-local typescript version / may be desired, comment out on old TS versions | |
"typescript.tsdk": "node_modules/typescript/lib", | |
"typescript.preferences.importModuleSpecifier": "relative", | |
// Terminal settings | |
"terminal.integrated.scrollback": 100000, // Terminal scrollback line limit | |
// Set terminal font size to match VS Code font size. See: https://www.NerdFonts.com/ | |
"terminal.integrated.fontFamily": "'MesloLGS NF', 'Hack Nerd Font', Menlo, Monaco, 'Courier New', monospace", |