Creating an array where under some conditions we include extra pairs of values.
var mysqlArgs = ['-h', mysqlConfig.host, '-d', mysqlConfig.database];
if (mysqlConfig.user) {
mysqlArgs.push('-U', mysqlConfig.user);
}
zfs list -H -o name -r zmirror | while read -r line; do zfs list -t snapshot -o name -s creation -r "$line" | tail -1; done |
A test for a module performing trivial transformation on data from an external service:
it('returns the first element in the response', function () {
var serviceResponse = [{a: 1}]
serviceStub.returns(serviceResponse)
expect(subject()).to.equal(serviceResponse[0])
})
var cookie = require('cookie') | |
module.exports.forRequest = function (req) { | |
return { | |
get: function (name) { return req.cookies[name] }, | |
set: function (name, value, options) { | |
req.res.cookie(name, value, options) | |
} | |
} | |
} |
var when = require('when') | |
// An array of promises that must resolve before we can submit | |
var preSubmitActions = [] | |
function loadSomeScript() { | |
// An example use case. We want to delay the submit until | |
// some script has loaded. We start loading the script in postRender | |
// so it may or may not be finished by the time someone clicks submit |
var app = require('express')() | |
, server = require('http').createServer(app) | |
app.use(function (req, res, next) { | |
console.log('Handling', req.path, process.pid) | |
var d = require('domain').create() | |
d.add(req) | |
d.add(res) |