Deriving a new Array from an existing Array:
['■','●','▲'].slice(1, 3) ⟼ ['●','▲']
['■','●','■'].filter(x => x==='■') ⟼ ['■','■']
['▲','●'].map(x => x+x) ⟼ ['▲▲','●●']
['▲','●'].flatMap(x => [x,x]) ⟼ ['▲','▲','●','●']
import * as path from 'node:path'; | |
import * as fs from 'node:fs/promises'; | |
const nodeModules = path.resolve('node_modules'); | |
let moduleNames = await fs.readdir(nodeModules); | |
moduleNames = (await Promise.all( | |
moduleNames.map(async name => { | |
if (name.startsWith('.')) { | |
return []; |
#!/bin/bash | |
## (c) 2022 Micael Levi L. C. | |
## This script requires: | |
## - npm (https://nodejs.org) | |
## - jq (https://stedolan.github.io/jq) | |
file="${1:-./package.json}" | |
[ -r "$file" ] || { echo "The file $file is not readable" ; exit 1 ; } |
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ devtools: true }); | |
const page = await browser.newPage(); | |
// Grants permission for changing geolocation | |
const context = browser.defaultBrowserContext(); | |
await context.overridePermissions('https://www.google.com/', ['geolocation']); |
import * as app from '.'; | |
import * as api from '@nestjs/common'; | |
@api.Controller() | |
export class TestController { | |
@api.Get() | |
@app.ResponseValidator(app.TestDto) | |
get() { | |
return new app.TestDto(); | |
} |
Profile | download (kb/s) | upload (kb/s) | latency (ms) |
---|---|---|---|
Native | 0 | 0 | 0 |
GPRS | 50 | 20 | 500 |
56K Dial-up | 50 | 30 | 120 |
Mobile EDGE | 240 | 200 | 840 |
2G Regular | 250 | 50 | 300 |
2G Good | 450 | 150 | 150 |
3G Slow | 780 | 330 | 200 |
Sometimes you don't need all of jQuery's modules. Officially, you can use their Grunt script to build a slimmed-down jQuery, but what if Webpack is more your thing? Enter this guide.
fabric.Canvas.prototype.historyInit = function () { | |
this.historyUndo = []; | |
this.historyNextState = this.historyNext(); | |
this.on({ | |
"object:added": this.historySaveAction, | |
"object:removed": this.historySaveAction, | |
"object:modified": this.historySaveAction | |
}) | |
} |
import { createConnection, getConnection, Entity, getRepository } from "typeorm"; | |
import { PrimaryGeneratedColumn, Column } from "typeorm"; | |
@Entity() | |
export class MyEntity { | |
@PrimaryGeneratedColumn() | |
id?: number; | |
@Column() | |
name?: string; |