Skip to content

Instantly share code, notes, and snippets.

Avatar

Gar wraithgar

  • Tri-Cities, WA
View GitHub Profile
@wraithgar
wraithgar / promisify.js
Created May 24, 2020
Promisify all the functions in any object with a few lines of es6
View promisify.js
const handler = {
get: function (target, prop, receiver) {
if (typeof target[prop] !== 'function' ) {
return target[prop]
}
return function () {
return new Promise((resolve, reject) => {
Reflect.get(target, prop, receiver).apply(target, [...arguments, function (err, result) {
if (err) {
return reject(err)
@wraithgar
wraithgar / gen.js
Created Jul 7, 2020
quick and dirty password generator
View gen.js
'use strict'
const fs = require('fs')
const words = fs.readFileSync('/usr/share/dict/words', 'utf8').split('\n')
const passwords = []
for (let i = 0; i < 12; i++) {
const randomNumber = Math.floor(Math.random() * words.length)
passwords.push(words[randomNumber])
}
console.log(passwords.join('-'))
@wraithgar
wraithgar / lifecycle.txt
Created Feb 18, 2021
npm7 lifecycle scripts notes
View lifecycle.txt
npm event lifecycle
cache add
- prepare (pacote.tarball.stream @npmcli/run-script)
ci
- preinstall (@npmcli/run-script)
- install (@npmcli/run-script)
- postinstall (@npmcli/run-script)
- prepublish (@npmcli/run-script)
- preprepare (@npmcli/run-script)