constructor (options) { super() if (typeof options === 'string' || Array.isArray(options)) { options = { cmd: options } } this.cmd = options.cmd this.cwd = path.resolve(options.cwd || '.') this.wait = options.wait || 1e3 this.port = null this[kProcess] = null }
sql(query, options, callback) { return this.loadMethod( () => this.request('sql', { query }), (response) => (Array.isArray(response) ? response.map((body) => new SqlQuery(body)) : new SqlQuery(response)), options, callback ); }
function getCommonName(crt) { var attrs = crt.issuer && crt.issuer.attributes; if (Array.isArray(attrs)) { for (var i = 0, len = attrs.length; i < len; i++) { var attr = attrs[i]; if (attr && attr.name === 'commonName') { return attr.value; } } } return ''; }
removeLanguage(locales) { if (Array.isArray(locales)) { locales.forEach((locale) => this.removeLanguage(locale)); } else { delete this.domainManagers[locales]; const index = this.locales.indexOf(locales); if (index !== -1) { this.locales.splice(index, 1); } } }
function getMongooseSchema(value, handleId = false) { if (isOfMongooseType(value)) { return getMongooseTypeFromValue(value); } if (Array.isArray(value)) { return getMongooseArraySchema(value); } if (typeof value === 'object') { return getMongooseEmbeddedSchema(value, handleId); } return null; }
compile(pipeline) { let code; if (Array.isArray(pipeline) && pipeline[0].startsWith('//')) { code = pipeline.slice(1).join('\n'); } else { code = Array.isArray(pipeline) ? pipeline.join('\n') : pipeline; } const header = '(async () => {\n'; const footer = '\n})();'; const wrapped = header + this.transpile(code) + footer; return wrapped; }
constructor(params) { super((value) => { if (Array.isArray(value)) { return value.filter(val => !!val).length > 0; } return !!value; }, params); this.params.type = this.params.type || 'to be true'; }
function parseRuleJson(rules, callback) { if (!Array.isArray(rules)) { rules = [rules]; } Q.all(rules.map(function(rule) { var defer = Q.defer(); readRuleList(rule, function(data) { defer.resolve(data); }, true); return defer.promise; })).spread(callback); }
add(entry) { if (Array.isArray(entry)) { this._logEntries = this._logEntries.concat(entry); } this._logEntries.push(entry); }
/** * {{> setCookie }} */ async setCookie(cookie) { if (Array.isArray(cookie)) { return this.browserContext.addCookies(cookie); } return this.browserContext.addCookies([cookie]); }
registerDependency(dependencies) { if (!Array.isArray(dependencies)) { dependencies = [dependencies]; } dependencies.forEach(dependency => { const {id} = dependency; if (!this.dependencies[id]) { this.dependencies[id] = {...dependency, satisfied: false}; } }); this.emit(EventTypes.UI_DEPENDENCIES_CHANGE); }
function customizer(objValue, srcValue, key) { // Arrays and `context` options should just replace the existing value // and not be deep merged. if (Array.isArray(objValue) || ['context'].includes(key)) { return srcValue; } }
constructor(params) { super((value) => { if (Array.isArray(value)) { return value.length === 0; } return !value; }, params); this.params.type = 'to be empty'; }
// NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray( ar ) { return Array.isArray( ar ); }
function toArray(item) { if (!Array.isArray(item)) { return [item]; } return item; }