Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* [Symbol.iterator] () {
const definitions = this.definitions
const t = require('typical')
let def
let value
let name
let event
let singularDefaultSet = false
let unknownFound = false
let origArg
for (let arg of this.argv) {
if (t.isPlainObject(arg)) {
origArg = arg.origArg
arg = arg.arg
}
if (unknownFound && this.options.stopAtFirstUnknown) {
yield { event: 'unknown_value', arg, name: '_unknown', value: undefined }
continue
}
/* handle long or short option */
if (argvTools.isOption(arg)) {
def = definitions.get(arg)
value = undefined
if (def) {
value = def.isBoolean() ? true : null
event = 'set'
function customiser (previousValue, newValue, key, object, source) {
/* deep merge plain objects */
if (t.isPlainObject(previousValue) && t.isPlainObject(newValue)) {
return assignWith(previousValue, newValue, customiser)
/* overwrite arrays if the new array has items */
} else if (Array.isArray(previousValue) && Array.isArray(newValue) && newValue.length) {
return newValue
/* ignore incoming arrays if empty */
} else if (Array.isArray(newValue) && !newValue.length) {
return previousValue
} else if (!t.isDefined(previousValue) && Array.isArray(newValue)) {
return newValue
}
}
function testValue(value, test){
if (t.isPlainObject(test)){
return o.exists(value, test);
} else if (Array.isArray(test)){
var tests = test;
return tests.some(function(test){
return testValue(value, test);
});
} else if (test instanceof RegExp){
return test.test(value);
} else if (typeof test === "function"){
return test(value);
} else {
return test === value;
}
}
screenView (name, options) {
if (this._disabled) return this
options = options || {}
if (options.hitParams && t.isPlainObject(options.hitParams)) {
options.hitParams = objToMap(options.hitParams)
}
let hit = this._createHit(new Map([
[ 't', 'screenview' ],
[ 'cd', name ]
]), options)
if (!hit.has('an')) throw new Error("'an' parameter required (App name)")
if (!hit.has('cd')) throw new Error("'cd' parameter required (screen name)")
this._hits.push(hit)
return hit
}
exception (options) {
if (this._disabled) return this
options = options || {}
if (options.hitParams && t.isPlainObject(options.hitParams)) {
options.hitParams = objToMap(options.hitParams)
}
let hit = this._createHit(new Map([
[ 't', 'exception' ]
]), options)
if (t.isDefined(options.exd)) hit.set('exd', options.exd)
if (t.isDefined(options.exf)) hit.set('exf', options.exf ? 1 : 0)
this._hits.push(hit)
return hit
}
value: function event(category, action, options) {
if (this._disabled) return this;
if (!(category && action)) throw new Error('category and action required');
options = options || {};
if (options.hitParams && t.isPlainObject(options.hitParams)) {
options.hitParams = objToMap(options.hitParams);
}
var hit = this._createHit(new Map([['t', 'event'], ['ec', category], ['ea', action]]), options);
if (t.isDefined(options.el)) hit.set('el', options.el);
if (t.isDefined(options.ev)) hit.set('ev', options.ev);
this._hits.push(hit);
return hit;
}
}, {
function exists(array, value){
if (t.isPlainObject(value)){
var query = value;
var found = false;
var index = 0;
var item;
while(!found && (item = array[index++])){
found = o.exists(item, query);
}
return found;
} else {
return array.indexOf(value) > -1;
}
}
var rows = content.map(function (string) {
return { column: ansi.format(string) };
});
var _table = new Table(rows, {
padding: defaultPadding,
maxWidth: 80
});
return _table.renderLines();
} else if (Array.isArray(content) && content.every(t.isPlainObject)) {
var _table2 = new Table(content.map(function (row) {
return ansiFormatRow(row);
}), {
padding: defaultPadding
});
return _table2.renderLines();
} else if (t.isPlainObject(content)) {
if (!content.options || !content.data) {
throw new Error('must have an "options" or "data" property\n' + JSON.stringify(content));
}
var options = Object.assign({ padding: defaultPadding }, content.options);
if (options.columns) {
options.columns = options.columns.map(function (column) {
if (column.nowrap) {
column.noWrap = column.nowrap;
delete column.nowrap;
}
return column;
});
}
var _table3 = new Table(content.data.map(function (row) {
arrayify(array).forEach(function(item, index){
if (t.isPlainObject(query)){
if(o.exists(item, query)){
result.push(item);
toSplice.push(index);
}
} else {
if (query(item)){
result.push(item);
toSplice.push(index);
}
}
});
for (var i = 0; i < toSplice.length; i++){