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
function dumpMemory(port) { | |
return getMemSize(port) | |
.then(function (size) { | |
var result = new Buffer(size); | |
return copyChunkLoop(result, 0, size) | |
}); | |
} |
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
var Transform = require('stream').Transform; | |
var util = require('util'); | |
function AggregateStream(reducer) { | |
Transform.call(this, { readableObjectMode: true }); | |
if (typeof reducer !== 'function') { | |
throw new Error('Must supply a reducer'); | |
} | |
this.aggregated = void 0; | |
this.reducer = reducer; |
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
function getDockerStuff() { | |
return new Promise((resolve, reject) => { | |
let data = ''; | |
foo.create(name, template, config, function onComplete(exitCode, errors) { | |
if (exitCode !== null) { | |
reject(errors); | |
} else { | |
resolve(data); | |
} |
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
'use strict'; | |
var extend = require('xtend'), | |
Pool = require('./pool'), | |
RateLimiter = require('./ratelimiter'); | |
module.exports = InputQueue; | |
function InputQueue(opts) { | |
opts = opts || { }; |
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
function delay(ms) { | |
// error checking wouldn't hurt | |
return new Promise(resolve => setTimeout(resolve, delay)); | |
} | |
function retryWithDelay(fn, delay, retries) { | |
if (retries <= 0) { | |
return Promise.reject(new Error('out of retries')); | |
} | |
return fn().catch(err => { | |
// typed catch or checking the kind of error here would be a good thing |
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
myndzi@seckzi:~/test$ node foo | |
pg pool: function (options) { | |
var config = { Client: Client }; | |
for (var key in options) { | |
config[key] = options[key]; | |
} | |
Pool.call(this, config); | |
} | |
myndzi@seckzi:~/test$ npm ls | |
[email protected] /home/myndzi/test |
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
var EventEmitter = require('events').EventEmitter, | |
inherits = require('util').inherits; | |
var ID = 0; | |
function Fetcher(url) { | |
EventEmitter.call(this); | |
this.id = ID++; | |
this.url = url; | |
} |
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
var split = require('binary-split-streams2'), | |
fs = require('fs'); | |
function requestStream(url) { | |
return Kefir.stream(emitter => { | |
let req = bhttp.get(url, { stream: true }) | |
.pipe(split()); // default is \n -- no regex support, use a different module if you need variable line terminators | |
req.on('data', chunk => emitter.emit(chunk)); | |
req.on('error', err => { | |
emitter.error(err); emitter.end(); |
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
foo | bar | |
---|---|---|
1 | 2 | |
3 | 4 | |
5 | 6 | |
7 | 8 |
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
var qb = knex.select('songs.id', 'songs.name AS song', 'artists.name AS artist', 'songs.path', 'albums.name AS album') | |
.from('songs') | |
.join('genreAssociation', 'songs.id', 'genreAssociation.id_songs') | |
.join('artists', 'songs.id_artists', 'artists.id') | |
.join('albums', 'songs.id_albums', 'albums.id') | |
.where('genreAssociation.id', req.params.id) | |
if (req.session.playedSongs && req.session.playedSongs.length != 0 && req.session.playedSongs != []) { | |
qb.whereNotIn('songs.id', req.session.playedSongs); | |
} |