I hereby claim:
- I am naholyr on github.
- I am naholyr (https://keybase.io/naholyr) on keybase.
- I have a public key whose fingerprint is EC19 8266 EF73 F79E 84AA E931 B111 3B99 36F2 E232
To claim this, I am signing this object:
| // ( T1 => Promise<T2> ) => Array<T1> => Promise<Array<T2>> | |
| export const concurrent = foo => vals => | |
| Promise.all(vals.map(foo)) | |
| export const series = foo => vals => | |
| vals.reduce((p, val) => p.then(rs => foo(val).then(r => rs.concat([val]))), Promise.resolve([])) | |
| // Usage: promiseOfValues.then(promiseAll.concurrent(functionReturningAPromiseFromAValue)) |
| "use strict"; | |
| const { readFileSync } = require("fs") | |
| const { parse } = require("json5") | |
| const { merge } = require("lodash") | |
| module.exports = merge({}, | |
| // Global defaults | |
| requireConfig("defaults"), | |
| // Environment defaults |
| #!/bin/bash | |
| # Run from your project's root | |
| # Run "npm install" or "npm update" before | |
| # Requirement: jq (https://stedolan.github.io/jq/) | |
| required () { | |
| grep -R "from ['\"]${1}[\\/'\"]\|require(['\"]${1}[\\/'\"]" --exclude-dir=node_modules --include='*.js' > /dev/null | |
| } |
| # Requires zsh | |
| # Requires xdotool | |
| the_command="?????" | |
| preexec() | |
| { | |
| if [ "x$TTY" != "x" ]; then | |
| the_command="$2" | |
| fi |
| import config from '…' | |
| import Redis from 'ioredis' | |
| const client = new Redis(config.redis) | |
| const cachePrefix = config.cache.prefix | |
| const cacheDefaultTTL = config.cache.defaultTTL | |
| // (string) => Promise<any> | |
| export function get (key /* string */) { | |
| return client.get(cachePrefix + key) |
| // generic reusable | |
| app.use(timeMiddleware('session', session)); | |
| // … | |
| function timeMiddleware (description, middleware) { | |
| return function (req, res, next) { | |
| var start = process.hrtime(); | |
| middleware(req, res, function (err) { |
| var Promise = require('bluebird'); | |
| var request = require('request-promise'); | |
| var io = require('socket.io-client'); | |
| var jar = request.jar(); | |
| /** | |
| * Connect to web interface | |
| */ | |
| request({ | |
| uri: loginActionUrl, |
| // foo() fait une opération compliquée | |
| // mais c'est codé un peu avec les pieds et un des EventEmitter déclaré (et non exposé) | |
| // dans la fonction émet parfois un "error" non catché qui pète mon application :( | |
| var foo = require("./module-pourri"); | |
| // Ça fait parfois péter mon app :( | |
| //foo(); |
I hereby claim:
To claim this, I am signing this object:
| function dirTree (filename, cb) { | |
| fs.lstat(filename, function (err, stat) { | |
| if (err) { | |
| return cb(err); | |
| } | |
| var info = { | |
| "path": filename, | |
| "name": path.basename(filename) |