diff --git a/src/appdb.js b/src/appdb.js index 5d5d648b3..21788649b 100644 --- a/src/appdb.js +++ b/src/appdb.js @@ -498,7 +498,7 @@ function getAppStoreIds(callback) { function setAddonConfig(appId, addonId, env, callback) { assert.strictEqual(typeof appId, 'string'); assert.strictEqual(typeof addonId, 'string'); - assert(util.isArray(env)); + assert(Array.isArray(env)); assert.strictEqual(typeof callback, 'function'); unsetAddonConfig(appId, addonId, function (error) { diff --git a/src/apps.js b/src/apps.js index ae0771b5e..d1d7c4aa4 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1833,7 +1833,7 @@ function exec(app, options, callback) { assert.strictEqual(typeof callback, 'function'); var cmd = options.cmd || [ '/bin/bash' ]; - assert(util.isArray(cmd) && cmd.length > 0); + assert(Array.isArray(cmd) && cmd.length > 0); if (app.installationState !== exports.ISTATE_INSTALLED || app.runState !== exports.RSTATE_RUNNING) { return callback(new BoxError(BoxError.BAD_STATE, 'App not installed or running')); diff --git a/src/backupdb.js b/src/backupdb.js index 541d93d14..e012a4767 100644 --- a/src/backupdb.js +++ b/src/backupdb.js @@ -119,7 +119,7 @@ function add(id, data, callback) { assert.strictEqual(typeof data.type, 'string'); assert.strictEqual(typeof data.identifier, 'string'); assert.strictEqual(typeof data.state, 'string'); - assert(util.isArray(data.dependsOn)); + assert(Array.isArray(data.dependsOn)); assert.strictEqual(typeof data.manifest, 'object'); assert.strictEqual(typeof data.format, 'string'); assert.strictEqual(typeof callback, 'function'); diff --git a/src/database.js b/src/database.js index 963c26786..020e5a26c 100644 --- a/src/database.js +++ b/src/database.js @@ -96,7 +96,7 @@ function query() { } function transaction(queries, callback) { - assert(util.isArray(queries)); + assert(Array.isArray(queries)); assert.strictEqual(typeof callback, 'function'); callback = once(callback); diff --git a/src/dns/cloudflare.js b/src/dns/cloudflare.js index b0c32dc34..36dabfb30 100644 --- a/src/dns/cloudflare.js +++ b/src/dns/cloudflare.js @@ -110,7 +110,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -206,7 +206,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/digitalocean.js b/src/dns/digitalocean.js index 54f826811..e97daf784 100644 --- a/src/dns/digitalocean.js +++ b/src/dns/digitalocean.js @@ -82,7 +82,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -185,7 +185,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/gandi.js b/src/dns/gandi.js index 0b500698b..ea6281dac 100644 --- a/src/dns/gandi.js +++ b/src/dns/gandi.js @@ -39,7 +39,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -98,7 +98,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/gcdns.js b/src/dns/gcdns.js index a83de3518..109962fe6 100644 --- a/src/dns/gcdns.js +++ b/src/dns/gcdns.js @@ -73,7 +73,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -144,7 +144,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/godaddy.js b/src/dns/godaddy.js index 0a3a24c85..3e339d344 100644 --- a/src/dns/godaddy.js +++ b/src/dns/godaddy.js @@ -45,7 +45,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -118,7 +118,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/interface.js b/src/dns/interface.js index 1651d8e5c..963fc523d 100644 --- a/src/dns/interface.js +++ b/src/dns/interface.js @@ -34,7 +34,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); // Result: none @@ -57,7 +57,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); // Result: none diff --git a/src/dns/linode.js b/src/dns/linode.js index 94133a4bf..f0299f153 100644 --- a/src/dns/linode.js +++ b/src/dns/linode.js @@ -135,7 +135,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -217,7 +217,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/manual.js b/src/dns/manual.js index 893ce2c83..0398521c6 100644 --- a/src/dns/manual.js +++ b/src/dns/manual.js @@ -31,7 +31,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); debug('upsert: %s for zone %s of type %s with values %j', location, domainObject.zoneName, type, values); @@ -52,7 +52,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); return callback(); diff --git a/src/dns/namecom.js b/src/dns/namecom.js index b2a8ce32d..6a1298e5a 100644 --- a/src/dns/namecom.js +++ b/src/dns/namecom.js @@ -157,7 +157,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -200,7 +200,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/netcup.js b/src/dns/netcup.js index 351334ef5..adc59b186 100644 --- a/src/dns/netcup.js +++ b/src/dns/netcup.js @@ -90,7 +90,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -183,7 +183,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/noop.js b/src/dns/noop.js index 83b5c951b..ed6efe119 100644 --- a/src/dns/noop.js +++ b/src/dns/noop.js @@ -26,7 +26,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); debug('upsert: %s for zone %s of type %s with values %j', location, domainObject.zoneName, type, values); @@ -47,7 +47,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); return callback(); diff --git a/src/dns/route53.js b/src/dns/route53.js index 9ef67b71a..413edd58e 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -97,7 +97,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, @@ -178,7 +178,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); const dnsConfig = domainObject.config, diff --git a/src/dns/wildcard.js b/src/dns/wildcard.js index fc1e5058c..7930c676e 100644 --- a/src/dns/wildcard.js +++ b/src/dns/wildcard.js @@ -31,7 +31,7 @@ function upsert(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); debug('upsert: %s for zone %s of type %s with values %j', location, domainObject.zoneName, type, values); @@ -52,7 +52,7 @@ function del(domainObject, location, type, values, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); return callback(); diff --git a/src/docker.js b/src/docker.js index 8a6afece6..6bca8e645 100644 --- a/src/docker.js +++ b/src/docker.js @@ -303,7 +303,7 @@ function getLowerUpIp() { // see getifaddrs and IFF_LOWER_UP and netdevice function createSubcontainer(app, name, cmd, options, callback) { assert.strictEqual(typeof app, 'object'); assert.strictEqual(typeof name, 'string'); - assert(!cmd || util.isArray(cmd)); + assert(!cmd || Array.isArray(cmd)); assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof callback, 'function'); diff --git a/src/domains.js b/src/domains.js index 372c86072..ea5105756 100644 --- a/src/domains.js +++ b/src/domains.js @@ -398,7 +398,7 @@ function upsertDnsRecords(location, domain, type, values, callback) { assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); debug('upsertDNSRecord: %s on %s type %s values', location, domain, type, values); @@ -418,7 +418,7 @@ function removeDnsRecords(location, domain, type, values, callback) { assert.strictEqual(typeof location, 'string'); assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof type, 'string'); - assert(util.isArray(values)); + assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); debug('removeDNSRecord: %s on %s type %s values', location, domain, type, values); diff --git a/src/eventlog.js b/src/eventlog.js index 4f69a7bfa..b39cfa33a 100644 --- a/src/eventlog.js +++ b/src/eventlog.js @@ -75,14 +75,14 @@ exports = module.exports = { ACTION_PROCESS_CRASH: 'system.crash' }; -var assert = require('assert'), +const assert = require('assert'), debug = require('debug')('box:eventlog'), eventlogdb = require('./eventlogdb.js'), notifications = require('./notifications.js'), util = require('util'), uuid = require('uuid'); -var NOOP_CALLBACK = function (error) { if (error) debug(error); }; +const NOOP_CALLBACK = function (error) { if (error) debug(error); }; function add(action, source, data, callback) { assert.strictEqual(typeof action, 'string'); @@ -144,7 +144,7 @@ function getAllPaged(actions, search, page, perPage, callback) { } function getByCreationTime(creationTime, callback) { - assert(util.isDate(creationTime)); + assert(util.types.isDate(creationTime)); assert.strictEqual(typeof callback, 'function'); eventlogdb.getByCreationTime(creationTime, function (error, events) { diff --git a/src/eventlogdb.js b/src/eventlogdb.js index 53266dea3..749607411 100644 --- a/src/eventlogdb.js +++ b/src/eventlogdb.js @@ -12,7 +12,7 @@ exports = module.exports = { _clear: clear }; -var assert = require('assert'), +const assert = require('assert'), async = require('async'), BoxError = require('./boxerror.js'), database = require('./database.js'), @@ -20,7 +20,7 @@ var assert = require('assert'), safe = require('safetydance'), util = require('util'); -var EVENTLOG_FIELDS = [ 'id', 'action', 'source', 'data', 'creationTime' ].join(','); +const EVENTLOG_FIELDS = [ 'id', 'action', 'source', 'data', 'creationTime' ].join(','); function postProcess(eventLog) { // usually we have sourceJson and dataJson, however since this used to be the JSON data type, we don't @@ -77,7 +77,7 @@ function getAllPaged(actions, search, page, perPage, callback) { } function getByCreationTime(creationTime, callback) { - assert(util.isDate(creationTime)); + assert(util.types.isDate(creationTime)); assert.strictEqual(typeof callback, 'function'); var query = 'SELECT ' + EVENTLOG_FIELDS + ' FROM eventlog WHERE creationTime >= ? ORDER BY creationTime DESC'; @@ -150,7 +150,7 @@ function clear(callback) { } function delByCreationTime(creationTime, callback) { - assert(util.isDate(creationTime)); + assert(util.types.isDate(creationTime)); assert.strictEqual(typeof callback, 'function'); // remove notifications that reference the events as well diff --git a/src/mailboxdb.js b/src/mailboxdb.js index e32d5be71..4b2540c30 100644 --- a/src/mailboxdb.js +++ b/src/mailboxdb.js @@ -348,7 +348,7 @@ function getByOwnerId(ownerId, callback) { function setAliasesForName(name, domain, aliases, callback) { assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof domain, 'string'); - assert(util.isArray(aliases)); + assert(Array.isArray(aliases)); assert.strictEqual(typeof callback, 'function'); database.query('SELECT ' + MAILBOX_FIELDS + ' FROM mailboxes WHERE name = ? AND domain = ?', [ name, domain ], function (error, results) { diff --git a/src/routes/apps.js b/src/routes/apps.js index 8aec08a2a..14b9e13eb 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -662,7 +662,7 @@ function exec(req, res, next) { var cmd = null; if (req.query.cmd) { cmd = safe.JSON.parse(req.query.cmd); - if (!util.isArray(cmd) || cmd.length < 1) return next(new HttpError(400, 'cmd must be array with atleast size 1')); + if (!Array.isArray(cmd) || cmd.length < 1) return next(new HttpError(400, 'cmd must be array with atleast size 1')); } var columns = req.query.columns ? parseInt(req.query.columns, 10) : null; @@ -703,7 +703,7 @@ function execWebSocket(req, res, next) { var cmd = null; if (req.query.cmd) { cmd = safe.JSON.parse(req.query.cmd); - if (!util.isArray(cmd) || cmd.length < 1) return next(new HttpError(400, 'cmd must be array with atleast size 1')); + if (!Array.isArray(cmd) || cmd.length < 1) return next(new HttpError(400, 'cmd must be array with atleast size 1')); } var columns = req.query.columns ? parseInt(req.query.columns, 10) : null; diff --git a/src/shell.js b/src/shell.js index 8a7d4a8d5..fd923a97e 100644 --- a/src/shell.js +++ b/src/shell.js @@ -35,7 +35,7 @@ function exec(tag, cmd, callback) { function spawn(tag, file, args, options, callback) { assert.strictEqual(typeof tag, 'string'); assert.strictEqual(typeof file, 'string'); - assert(util.isArray(args)); + assert(Array.isArray(args)); assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof callback, 'function'); @@ -80,7 +80,7 @@ function spawn(tag, file, args, options, callback) { function sudo(tag, args, options, callback) { assert.strictEqual(typeof tag, 'string'); - assert(util.isArray(args)); + assert(Array.isArray(args)); assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof callback, 'function'); diff --git a/src/test/dns-test.js b/src/test/dns-test.js index 0ba49ba4f..6b5e012c4 100644 --- a/src/test/dns-test.js +++ b/src/test/dns-test.js @@ -1025,7 +1025,7 @@ describe('dns provider', function () { expect(options).to.be.an(Object); var elem = queue.shift(); - if (!util.isArray(elem)) throw (new Error('Mock answer required')); + if (!Array.isArray(elem)) throw (new Error('Mock answer required')); // if no callback passed, return a req object with send(); if (typeof callback !== 'function') { @@ -1184,7 +1184,7 @@ describe('dns provider', function () { var callback = arguments[--arguments.length]; var elem = queue.shift(); - if (!util.isArray(elem)) throw (new Error('Mock answer required')); + if (!Array.isArray(elem)) throw (new Error('Mock answer required')); // if no callback passed, return a req object with send(); if (typeof callback !== 'function') {