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
return Promise.promisify(fs.readdir)(config.path).filter(function (fileName) { | |
return config.mask.test(fileName); | |
}).map(function (fileName) { | |
var fullPath = path.join(config.path, fileName); | |
return Promise.promisify(fs.stat)(fullPath).tap(function (stat) { | |
stat.fullPath = fullPath; | |
stat.fileName = fileName; | |
}); | |
}).filter(function (stat) { | |
return stat.isFile(); |
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 Transform = require('stream').Transform, | |
inherits = require('util').inherits; | |
module.exports = ThrottleStream; | |
function ThrottleStream(opts) { | |
if (!(this instanceof ThrottleStream)) | |
return new ThrottleStream(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
'use strict'; | |
var Transform = require('stream').Transform, | |
inherits = require('util').inherits; | |
var noBuf = new Buffer(0); | |
module.exports = LineStream; | |
function LineStream(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
/* jshint node: true */ | |
"use strict"; | |
var Promise = require('bluebird'); | |
var crypto = require('crypto'); | |
var dgram = require('dgram'); | |
var events = require('events'); | |
var fs = require('fs'); | |
var srp = require('srp'); | |
var util = require('util'); |
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 Promise = require('bluebird'), | |
redis = require('redis'); | |
var db = redis.createClient(); | |
Promise.promisifyAll(Object.getPrototypeOf(redis), { suffix: '$' }); | |
function _scan(cmd, key) { | |
function recurse(ttl, cur) { | |
return cmd(key, cur).then(function (cur, val) { | |
if (cur) { |
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 Promise=require('bluebird'); | |
var SerialPort = require("serialport").SerialPort | |
var openedPort=false; | |
var puerto; | |
var Serial = function(puerto) { | |
var self = this; | |
self.openedPort = false; | |
//crea un objeto serialport, abre el puerto |
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
// config.amqp = connection parameters | |
var worker = new Worker( | |
extend({ }, { | |
exchange: 'exchange', | |
bindings: { | |
'exchange': [ | |
// queue we process from | |
'class.method.job', | |
'class.method.settled' | |
] |
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 sequelize = new Sequelize('postgres:/tmp'); | |
var CM = sequelize.transactionManager.ConnectorManager; | |
sequelize.transactionManager.ConnectorManager = function (sequelize, config) { | |
var cm = new CM(sequelize, config); | |
cm.pg.defaults.database = 'database_name'; | |
return cm; | |
} | |
sequelize.getQueryInterface().QueryGenerator |
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 pg = require('pg'); | |
var request = require('request'); | |
var Promise = require('bluebird'); // version 2.0! | |
// pg interface is a bit awkward to promisify | |
var connect = Promise.promisify(pg.connect, pg); | |
pg.connect = function (connString) { | |
return connect(connString).spread(function (client, done) { | |
client.done = done; | |
Promise.promisify(client, { suffix: '$' }); |
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
HTML: | |
<form action="/api/thing" method="post" enctype="multipart/form-data"> | |
<input name="caption"> | |
<input type="file" name="file"> | |
<input type="submit" value="Submit"> | |
</form> | |
Request: |