Deriving a new Array from an existing Array:
['■','●','▲'].slice(1, 3) ⟼ ['●','▲']
['■','●','■'].filter(x => x==='■') ⟼ ['■','■']
['▲','●'].map(x => x+x) ⟼ ['▲▲','●●']
['▲','●'].flatMap(x => [x,x]) ⟼ ['▲','▲','●','●']
{ | |
"recommendations": [ | |
"dbaeumer.vscode-eslint", | |
"esbenp.prettier-vscode", | |
"streetsidesoftware.code-spell-checker", | |
"GitHub.vscode-pull-request-github", | |
"ms-playwright.playwright", | |
"pflannery.vscode-versionlens", | |
"ZixuanChen.vitest-explorer" | |
] |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
import foo from 'foo'
instead of const foo = require('foo')
to import the package. You also need to put "type": "module"
in your package.json and more. Follow the below guide.await import(…)
from CommonJS instead of require(…)
.List of useful npx (NPM Package Runner) commands.
Using NPX we can execute/run node binaries without the need to install it locally or globally.
'use strict'; | |
const functions = require('firebase-functions'); | |
const fastify = require('./fastify'); | |
exports.greetFromFastify = functions.https.onRequest(fastify); |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
git fetch --all -p; git branch -vv | grep ": gone]" | awk '{ print $1 }' | xargs -r -n 1 git branch -D |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000