module.exports = function (page, perPage, callback, self) { var pageErrors, perPageErrors; pageErrors = Utils.validateJSONWithSchema(page, "integer", IntegerSchema); perPageErrors = Utils.validateJSONWithSchema(perPage, "integer", IntegerSchema); if ( pageErrors ) return callback(new InvalidPayloadError("Must be an integer", pageErrors)); debug("Page: " + page); if ( perPageErrors ) return callback(new InvalidPayloadError("Must be an integer", perPageErrors)); debug("Per page: " + perPage); if ( perPage > 100 ) perPage = 100; async.waterfall( [ function (next) { self.requestsManager.verifyCredentials(next); }, function (next) { self.requestsManager.channels(page, perPage, next); } ], callback ); };
var create = function (armNames, numArms, settings, callback) { var tau = settings.tau; async.waterfall([ function (next) { if (!_.isNumber(tau) || _.isNaN(tau) || tau < 0) return next(new Error('invalid tau')); next(); }, function (next) { if (armNames) { softmaxDao.createByArmNames(armNames, tau, function (error, model) { next(error, model); }); } else { softmaxDao.createByNumArms(numArms, tau, function (error, model) { next(error, model); }); } } ], function (error, model) { if (error) return callback(error, {}); callback(error, model); }); };
module.exports = function (deviceTokens, badge, callback, self) { var deviceTokensErrors, stringErrors; deviceTokensErrors = Utils.validateJSONWithSchema(deviceTokens, "device_tokens", deviceTokensSchema); stringErrors = Utils.validateJSONWithSchema(badge, "string", stringSchema); if ( deviceTokensErrors ) return callback(new InvalidPayloadError("Device tokens must be an array with at least one item or unique items of type string", deviceTokensErrors)); debug("Device tokens: " + JSON.stringify(deviceTokens)); if ( stringErrors ) return callback(new InvalidPayloadError("Badge parameter must be a string (ex: \"+1\")", stringErrors)); debug("Badge: " + badge); async.waterfall( [ function (next) { self.requestsManager.verifyCredentials(next); }, function (next) { setBadgeForDeviceTokens(deviceTokens, badge, next, self); } ], callback ); };
function notifyPlatform(deviceTokens, notification, callback, self) { async.waterfall( [ function (next) { self.requestsManager.verifyCredentials(next); }, function (next) { self.requestsManager.notify(deviceTokens, notification, next); } ], callback ); }
module.exports = function (name, callback, self) { var nameErrors = Utils.validateJSONWithSchema(name, "string", stringSchema); if ( nameErrors ) return callback(new InvalidPayloadError("Must be a string", nameErrors)); async.waterfall( [ function (next) { self.requestsManager.verifyCredentials(next); }, function (next) { self.requestsManager.channel(name, next); } ], callback ); };
module.exports = function (deviceToken, callback, self) { var deviceTokenErrors = Utils.validateJSONWithSchema(deviceToken, "string", stringSchema); if ( deviceTokenErrors ) return callback(new InvalidPayloadError("Device token must be a string", deviceTokenErrors)); async.waterfall( [ function (next) { self.requestsManager.verifyCredentials(next); }, function (next) { self.requestsManager.device(deviceToken, next); } ], callback ); };
main: function (modelId, callback) { async.waterfall([ function (next) { if (!_.isString(modelId) || modelId.length !== 24) return next(new Error('invalid model_id')); next(); }, function (next) { banditModelDao.remove(modelId, function (error) { next(error); }); } ], function (error) { callback(error, {}); }); }
function( next ) { async.waterfall( [ _.partial( bs58Hash, 'md5', profile.id.toString() + Date.now() ), function( id, callback ) { const message = { user: profile, text: _.sample( messages ), room: 'public' }; socket.emit( 'send-message', message, function( message ) { console.log( message ); } ); callback(); }, _.partial( setTimeout, _, 2000 ) ], next ); },
var create = function (armNames, numArms, settings, callback) { async.waterfall([ function (next) { if (armNames) { ucb1Dao.createByArmNames(armNames, function (error, model) { next(error, model); }); } else { ucb1Dao.createByNumArms(numArms, function (error, model) { next(error, model); }); } } ], function (error, model) { if (error) return callback(error, {}); callback(error, model); }); };
function processCSS(processor, input, output, fn) { function doProcess(css, fn) { function onResult(result) { if (typeof result.warnings === 'function') { result.warnings().forEach(function(w) { console.warn(w.toString()); }); } fn(null, result); } var options = { from: input, to: output }; Object.keys(customSyntaxOptions).forEach(function(opt) { options[opt] = customSyntaxOptions[opt]; }); if (typeof mapOptions !== 'undefined') { options.map = mapOptions; } var result = processor.process(css, options); if (typeof result.then === 'function') { result.then(onResult).catch(fn); } else { process.nextTick(onResult.bind(null, result)); } } async.waterfall([ async.apply(readFile, input), doProcess, async.apply(writeResult, output) ], fn); }
module.exports = function upload(stream, idOrPath, tag, done) { var blob = blobManager.create(account); var tx = db.begin(); var blobId, file, version, fileId; async.waterfall([ function writeBlob(callback) { blob.put(stream, callback); }, function afterBlobWritten(callback) { blobId = undefined // iBlobId; self.byUuidOrPath(idOrPath).get(callback); }, function afterFileFetched(callback) { file = undefined; //iFile; var previousId = file ? file.version : null; version = { userAccountId: userAccount.id, date: new Date(), blobId: blobId, creatorId: userAccount.id, previousId: previousId, mergedId: null, mergeType: 'mine', comment: '', tag: tag }; version.id = Version.createHash(version); Version.insert(version).execWithin(tx, callback); }, function afterVersionInserted(callback) { if (!file) { var splitPath = idOrPath.split('/'); var fileName = splitPath[splitPath.length - 1]; var newId = uuid.v1(); self.createQuery(idOrPath, { id: newId, userAccountId: userAccount.id, type: 'file', name: fileName, version: version.id }, function (err, q) { if (err) return backoff(err); q.execWithin(tx, function (err) { callback(err, newId); }); }) } else return callback(null, file.id); }, function afterFileExists(iFileId, callback) { fileId = iFileId; FileVersion.insert({fileId: fileId, versionId: version.id}) .execWithin(tx, callback); }, function afterFileVersionInserted(callback) { File.whereUpdate({id: fileId}, { version: version.id }) .execWithin(tx, callback); }, function afterFileUpdated(callback) { tx.commit(callback); } ], function (err) { if (err) tx.rollback(); done(err); }); }
module.exports = function(url, callback) { if (arguments.length === 0) { callback = defaultCallback; url = null; } if (arguments.length === 1) { if (typeof url === 'function') { callback = url; url = null; } else { callback = defaultCallback; } } if (!url) url = getUrl(); var dates = {}; async.waterfall([ function(next) { cp.exec('git for-each-ref --format "%(refname:short) %09 %(taggerdate:short)" refs/tags', function(err, stdout) { if (err) return next(err); var list = []; String(stdout).split('\n').forEach(function(v) { var _v = v.split('\t'); if (!_v || !_v[0]) { return; } var ver = _v[0].trim(); list.push(ver); dates[ver] = _v[1].trim(); }); list.sort(semver.compare); var _list = _.clone(list); _list.shift(); list.pop(); next(null, _.zip(list, _list)); }); }, function(pair, next) { function matcher(subject) { var match = subject.match(COMMIT_PATTERN); if (match && match[1] && match[4]) { return match; } var _s = subject.split(' '); if (_s[0] === 'Merge' && _s[1] === 'pull' && _s[2] === 'request') { return; } if (_s.length === 1 && semver.valid(_s[0])) { return; } var list = [ subject, _s[0].replace(/\./g, '').toLowerCase(), null, null, subject ]; list.index = 0; list.input = subject; return list; } var str = ''; async.eachSeries(pair, function(p, done) { cchangelog({ repository: url, version: p[1], file: '', from: p[0], to: p[1], grep: '', matcher: matcher, date: dates[p[1]] }, function(err, result) { if (err) return done(err); str = result + str; done(); }); }, function(err) { if (err) return next(err); next(null, str); }); }, function(contents, next) { fs.writeFile('CHANGELOG.md', contents, { encoding: 'utf8' }, next); }, ], callback); };
global.main.commands['_.dist.core'] = function() { var args = require('yargs').argv; var fs = require('fs-extra'); var path = require('path'); var async = require('neo-async'); var child_process = require('child_process'); var optimizer = args._[1] || args.optimizer || 'uglify'; if (fs.existsSync(path.join(global.main.path.core, '/build/pack/core.server.js')) === true) { if (fs.existsSync(path.join(global.main.path.core, '/dist/core/')) === true) { rmdirSync(path.join(global.main.path.core, '/dist/core/')); } fs.mkdirSync(path.join(global.main.path.core, '/dist/core/')); fs.mkdirSync(path.join(global.main.path.core, '/dist/core/docs/')); fs.mkdirSync(path.join(global.main.path.core, '/dist/core/boot/')); var tasks = []; tasks.push(function(callback) { child_process.spawn(process.execPath, [ global.main.path.core + '/node_modules/ljve-jsdoc/jsdoc.js', global.main.path.core + '/build/pack/core.server.js', '-c', global.main.path.core + '/.jsdocrc', '-d', global.main.path.core + '/dist/core/docs/', '--verbose' ], { stdio: 'inherit' }).on('exit', function(code, signal) { if (code > 0) { callback(new Error('jsdoc generation failed')); } else { callback(); } }); }); tasks.push(function(callback) { var child; switch (optimizer) { case 'closure': child = child_process.spawn('java', [ '-jar', global.main.path.core + '/project/tools/compiler.jar', '--js', global.main.path.core + '/build/core/bootstrap.server.js.boot', '--js_output_file', global.main.path.core + '/dist/core/boot/bootstrap.server.js.boot', '--language_in', 'ECMASCRIPT5', '--compilation_level', 'SIMPLE_OPTIMIZATIONS' ], { stdio: 'inherit' }); break; case 'uglify': default: child = child_process.spawn(process.execPath, [ global.main.path.core + '/node_modules/uglify-js/bin/uglifyjs', global.main.path.core + '/build/core/bootstrap.server.js.boot', '-o', global.main.path.core + '/dist/core/boot/bootstrap.server.js.boot', //'--in-source-map', //global.main.path.core + '/build/core/bootstrap.server.js.boot.map', //'--source-map', //global.main.path.core + '/dist/core/boot/bootstrap.server.js.boot.map', '--acorn', '-c', //'-m', '-v', '-p', 'relative', //'--source-map-include-sources' ], { stdio: 'inherit' }); break; } child.on('exit', function(code, signal) { if (code > 0) { callback(new Error('minification of bootstrap failed')); } else { callback(); } }); }); ['core.server.js.boot', 'core.server.js'].forEach(function(file) { tasks.push(function(callback) { var child; switch (optimizer) { case 'closure': child = child_process.spawn('java', [ '-jar', global.main.path.core + '/project/tools/compiler.jar', '--js', global.main.path.core + '/build/pack/' + file, '--js_output_file', global.main.path.core + '/dist/core/boot/' + file + '.min', '--language_in', 'ECMASCRIPT5', '--compilation_level', 'SIMPLE_OPTIMIZATIONS' ], { stdio: 'inherit' }); break; case 'uglify': default: child = child_process.spawn(process.execPath, [ global.main.path.core + '/node_modules/uglify-js/bin/uglifyjs', global.main.path.core + '/build/pack/' + file, '-o', global.main.path.core + '/dist/core/boot/' + file + '.min', //'--in-source-map', //global.main.path.core + '/build/pack/' + file + '.map', //'--source-map', //global.main.path.core + '/dist/core/boot/' + file + '.map', '--acorn', '-c', //'-m', '-v', '-p', 'relative', //'--source-map-include-sources' ], { stdio: 'inherit' }); break; } child.on('exit', function(code, signal) { if (code > 0) { callback(new Error('minification of core ' + file + ' failed')); } else { fs.copySync(global.main.path.core + '/build/pack/' + file, global.main.path.core + '/dist/core/boot/' + file); fs.copySync(global.main.path.core + '/build/pack/' + file + '.map', global.main.path.core + '/dist/core/boot/' + file + '.map'); callback(); } }); }); }); async.waterfall(tasks, function(errors, results) { if (errors == null) { console.log('done'); } }); } else { console.warn('please build before trying to generate dist files and docs'); } };
function benchNeoAsync (done) { neoAsync.waterfall(toCall, done) }