This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from "node-fetch"; | |
import { setTimeout } from "node:timers/promises"; | |
const cancelTimeout = new AbortController(); | |
const cancelRequest = new AbortController(); | |
async function timeout(milliseconds) { | |
try { | |
await setTimeout(milliseconds, undefined, { signal: cancelTimeout.signal }); | |
cancelRequest.abort(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"url": "https://jsonplaceholder.typicode.com/todos/1" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parseArgs } from "node:util"; | |
const args = parseArgs({ | |
options: { | |
name: { | |
type: "string", | |
}, | |
verbose: { | |
type: "boolean", | |
short: "v", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node script.mjs --name "Budgie" --verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This could be any object, perhaps the | |
* response from a request to an API. | |
*/ | |
const deepObject = [ | |
{imGoing:{deeperUnderground:{theresToo:{muchPanic:{inThis:{town:["I'm going deeper underground","There's too much panic in this town"]}}}}}}, | |
{wellI:{gotToGo:{deeper:{gotToGo:{muchDeeper:true,theyGonna:{wreckItDown:true,theyGonna:["bring","it","down"]}}}}},rating:100} | |
]; | |
// @see https://nodejs.org/api/console.html#consoledirobj-options |
OlderNewer