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 |
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
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
{ | |
"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 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
diff --git a/api-after/package.json b/api-after/package.json | |
index 8efee6f..f51a9c8 100644 | |
--- a/api-after/package.json | |
+++ b/api-after/package.json | |
@@ -11,6 +11,9 @@ | |
"license": "MIT", | |
"dependencies": { | |
"cors": "^2.8.5", | |
- "express": "^4.17.1" | |
+ "express": "^4.17.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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Title</title> | |
<meta charset="utf-8" /> | |
<style> | |
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); | |
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); | |
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic); |
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
#! /usr/bin/env node | |
import { format as formatDate } from "timeago.js"; | |
import { | |
getPackageDetails, | |
getPackageDownloadStats, | |
} from "./package-stats.js"; | |
function getLatestVersion({ packageDetails }) { |
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
HTTP/1.1 400 Bad Request | |
Content-Type: application/problem+json | |
Content-Language: en | |
{ | |
"type": "https://example.net/validation-error", | |
"title": "Your request parameters didn't validate.", | |
"invalid-params": [ | |
{ | |
"name": "age", |
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
✅ Casting "" (type: string) with Boolean() === false | |
✅ Casting "" (type: string) with !! === false | |
✅ Casting "a" (type: string) with Boolean() === true | |
✅ Casting "a" (type: string) with !! === true | |
✅ Casting 0 (type: number) with Boolean() === false | |
✅ Casting 0 (type: number) with !! === false | |
✅ Casting 0.5 (type: number) with Boolean() === true | |
✅ Casting 0.5 (type: number) with !! === true | |
✅ Casting 9007199254740992 (type: bigint) with Boolean() === true | |
✅ Casting 9007199254740992 (type: bigint) with !! === true |
NewerOlder