abstract
Version:
Abstraction of JavaScript Objects.
741 lines • 50.4 kB
JavaScript
/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['utility.js']) {
_$jscoverage['utility.js'] = [];
_$jscoverage['utility.js'][14] = 0;
_$jscoverage['utility.js'][15] = 0;
_$jscoverage['utility.js'][18] = 0;
_$jscoverage['utility.js'][32] = 0;
_$jscoverage['utility.js'][33] = 0;
_$jscoverage['utility.js'][36] = 0;
_$jscoverage['utility.js'][37] = 0;
_$jscoverage['utility.js'][40] = 0;
_$jscoverage['utility.js'][42] = 0;
_$jscoverage['utility.js'][50] = 0;
_$jscoverage['utility.js'][62] = 0;
_$jscoverage['utility.js'][63] = 0;
_$jscoverage['utility.js'][65] = 0;
_$jscoverage['utility.js'][67] = 0;
_$jscoverage['utility.js'][68] = 0;
_$jscoverage['utility.js'][71] = 0;
_$jscoverage['utility.js'][72] = 0;
_$jscoverage['utility.js'][74] = 0;
_$jscoverage['utility.js'][97] = 0;
_$jscoverage['utility.js'][99] = 0;
_$jscoverage['utility.js'][100] = 0;
_$jscoverage['utility.js'][101] = 0;
_$jscoverage['utility.js'][102] = 0;
_$jscoverage['utility.js'][105] = 0;
_$jscoverage['utility.js'][107] = 0;
_$jscoverage['utility.js'][109] = 0;
_$jscoverage['utility.js'][111] = 0;
_$jscoverage['utility.js'][126] = 0;
_$jscoverage['utility.js'][128] = 0;
_$jscoverage['utility.js'][129] = 0;
_$jscoverage['utility.js'][130] = 0;
_$jscoverage['utility.js'][133] = 0;
_$jscoverage['utility.js'][135] = 0;
_$jscoverage['utility.js'][137] = 0;
_$jscoverage['utility.js'][150] = 0;
_$jscoverage['utility.js'][151] = 0;
_$jscoverage['utility.js'][152] = 0;
_$jscoverage['utility.js'][153] = 0;
_$jscoverage['utility.js'][155] = 0;
_$jscoverage['utility.js'][158] = 0;
_$jscoverage['utility.js'][159] = 0;
_$jscoverage['utility.js'][187] = 0;
_$jscoverage['utility.js'][188] = 0;
_$jscoverage['utility.js'][190] = 0;
_$jscoverage['utility.js'][193] = 0;
_$jscoverage['utility.js'][195] = 0;
_$jscoverage['utility.js'][197] = 0;
_$jscoverage['utility.js'][202] = 0;
_$jscoverage['utility.js'][205] = 0;
_$jscoverage['utility.js'][206] = 0;
_$jscoverage['utility.js'][209] = 0;
_$jscoverage['utility.js'][210] = 0;
_$jscoverage['utility.js'][213] = 0;
_$jscoverage['utility.js'][214] = 0;
_$jscoverage['utility.js'][228] = 0;
_$jscoverage['utility.js'][229] = 0;
_$jscoverage['utility.js'][255] = 0;
_$jscoverage['utility.js'][256] = 0;
_$jscoverage['utility.js'][259] = 0;
_$jscoverage['utility.js'][283] = 0;
_$jscoverage['utility.js'][284] = 0;
_$jscoverage['utility.js'][285] = 0;
_$jscoverage['utility.js'][290] = 0;
_$jscoverage['utility.js'][291] = 0;
_$jscoverage['utility.js'][294] = 0;
_$jscoverage['utility.js'][312] = 0;
_$jscoverage['utility.js'][313] = 0;
_$jscoverage['utility.js'][316] = 0;
_$jscoverage['utility.js'][317] = 0;
_$jscoverage['utility.js'][320] = 0;
_$jscoverage['utility.js'][321] = 0;
_$jscoverage['utility.js'][324] = 0;
_$jscoverage['utility.js'][326] = 0;
_$jscoverage['utility.js'][328] = 0;
_$jscoverage['utility.js'][329] = 0;
_$jscoverage['utility.js'][334] = 0;
_$jscoverage['utility.js'][373] = 0;
_$jscoverage['utility.js'][374] = 0;
_$jscoverage['utility.js'][378] = 0;
_$jscoverage['utility.js'][381] = 0;
_$jscoverage['utility.js'][403] = 0;
_$jscoverage['utility.js'][404] = 0;
_$jscoverage['utility.js'][405] = 0;
_$jscoverage['utility.js'][407] = 0;
_$jscoverage['utility.js'][408] = 0;
_$jscoverage['utility.js'][409] = 0;
_$jscoverage['utility.js'][410] = 0;
_$jscoverage['utility.js'][411] = 0;
_$jscoverage['utility.js'][415] = 0;
_$jscoverage['utility.js'][416] = 0;
_$jscoverage['utility.js'][419] = 0;
_$jscoverage['utility.js'][421] = 0;
_$jscoverage['utility.js'][424] = 0;
_$jscoverage['utility.js'][427] = 0;
_$jscoverage['utility.js'][430] = 0;
_$jscoverage['utility.js'][454] = 0;
_$jscoverage['utility.js'][455] = 0;
_$jscoverage['utility.js'][458] = 0;
_$jscoverage['utility.js'][459] = 0;
_$jscoverage['utility.js'][462] = 0;
_$jscoverage['utility.js'][464] = 0;
_$jscoverage['utility.js'][481] = 0;
_$jscoverage['utility.js'][482] = 0;
_$jscoverage['utility.js'][485] = 0;
_$jscoverage['utility.js'][489] = 0;
_$jscoverage['utility.js'][490] = 0;
_$jscoverage['utility.js'][491] = 0;
_$jscoverage['utility.js'][495] = 0;
_$jscoverage['utility.js'][525] = 0;
_$jscoverage['utility.js'][526] = 0;
_$jscoverage['utility.js'][527] = 0;
_$jscoverage['utility.js'][528] = 0;
_$jscoverage['utility.js'][529] = 0;
_$jscoverage['utility.js'][531] = 0;
_$jscoverage['utility.js'][532] = 0;
_$jscoverage['utility.js'][533] = 0;
_$jscoverage['utility.js'][535] = 0;
_$jscoverage['utility.js'][536] = 0;
_$jscoverage['utility.js'][539] = 0;
_$jscoverage['utility.js'][543] = 0;
_$jscoverage['utility.js'][560] = 0;
_$jscoverage['utility.js'][561] = 0;
_$jscoverage['utility.js'][563] = 0;
_$jscoverage['utility.js'][565] = 0;
_$jscoverage['utility.js'][566] = 0;
_$jscoverage['utility.js'][572] = 0;
_$jscoverage['utility.js'][576] = 0;
_$jscoverage['utility.js'][592] = 0;
_$jscoverage['utility.js'][593] = 0;
_$jscoverage['utility.js'][597] = 0;
_$jscoverage['utility.js'][598] = 0;
_$jscoverage['utility.js'][601] = 0;
_$jscoverage['utility.js'][614] = 0;
_$jscoverage['utility.js'][618] = 0;
_$jscoverage['utility.js'][626] = 0;
_$jscoverage['utility.js'][628] = 0;
_$jscoverage['utility.js'][630] = 0;
_$jscoverage['utility.js'][632] = 0;
_$jscoverage['utility.js'][633] = 0;
_$jscoverage['utility.js'][636] = 0;
_$jscoverage['utility.js'][638] = 0;
_$jscoverage['utility.js'][640] = 0;
_$jscoverage['utility.js'][644] = 0;
_$jscoverage['utility.js'][648] = 0;
_$jscoverage['utility.js'][663] = 0;
_$jscoverage['utility.js'][665] = 0;
_$jscoverage['utility.js'][687] = 0;
_$jscoverage['utility.js'][688] = 0;
_$jscoverage['utility.js'][690] = 0;
_$jscoverage['utility.js'][691] = 0;
_$jscoverage['utility.js'][693] = 0;
_$jscoverage['utility.js'][695] = 0;
_$jscoverage['utility.js'][696] = 0;
_$jscoverage['utility.js'][698] = 0;
_$jscoverage['utility.js'][720] = 0;
_$jscoverage['utility.js'][721] = 0;
_$jscoverage['utility.js'][724] = 0;
_$jscoverage['utility.js'][725] = 0;
_$jscoverage['utility.js'][728] = 0;
_$jscoverage['utility.js'][743] = 0;
_$jscoverage['utility.js'][744] = 0;
_$jscoverage['utility.js'][745] = 0;
_$jscoverage['utility.js'][747] = 0;
_$jscoverage['utility.js'][771] = 0;
_$jscoverage['utility.js'][772] = 0;
_$jscoverage['utility.js'][773] = 0;
_$jscoverage['utility.js'][779] = 0;
_$jscoverage['utility.js'][781] = 0;
_$jscoverage['utility.js'][782] = 0;
_$jscoverage['utility.js'][785] = 0;
_$jscoverage['utility.js'][787] = 0;
_$jscoverage['utility.js'][790] = 0;
_$jscoverage['utility.js'][807] = 0;
_$jscoverage['utility.js'][808] = 0;
_$jscoverage['utility.js'][811] = 0;
_$jscoverage['utility.js'][812] = 0;
_$jscoverage['utility.js'][815] = 0;
_$jscoverage['utility.js'][829] = 0;
_$jscoverage['utility.js'][830] = 0;
_$jscoverage['utility.js'][833] = 0;
_$jscoverage['utility.js'][834] = 0;
_$jscoverage['utility.js'][835] = 0;
_$jscoverage['utility.js'][836] = 0;
_$jscoverage['utility.js'][839] = 0;
_$jscoverage['utility.js'][877] = 0;
_$jscoverage['utility.js'][880] = 0;
_$jscoverage['utility.js'][881] = 0;
_$jscoverage['utility.js'][884] = 0;
_$jscoverage['utility.js'][886] = 0;
_$jscoverage['utility.js'][888] = 0;
_$jscoverage['utility.js'][890] = 0;
_$jscoverage['utility.js'][891] = 0;
_$jscoverage['utility.js'][893] = 0;
_$jscoverage['utility.js'][898] = 0;
_$jscoverage['utility.js'][900] = 0;
}
_$jscoverage['utility.js'][14]++;
function Utility() {
_$jscoverage['utility.js'][15]++;
return Object.keys(arguments)? require("lodash").pick.apply(null, [Utility, Array.prototype.slice.call(arguments)]): Utility;
}
_$jscoverage['utility.js'][18]++;
Object.defineProperties(module.exports = Utility, {json: {value: {parse: (function parse(json) {
_$jscoverage['utility.js'][32]++;
if (Buffer && json instanceof Buffer) {
_$jscoverage['utility.js'][33]++;
json = json.toString();
}
_$jscoverage['utility.js'][36]++;
var parsed = false;
_$jscoverage['utility.js'][37]++;
try {
_$jscoverage['utility.js'][37]++;
parsed = JSON.parse(json);
}
catch (e) {
_$jscoverage['utility.js'][37]++;
parsed = false;
}
_$jscoverage['utility.js'][40]++;
if (! parsed && "string" === typeof json) {
}
_$jscoverage['utility.js'][42]++;
return parsed? parsed: json;
}), stringify: (function stringify(obj) {
_$jscoverage['utility.js'][50]++;
return JSON.stringify(obj);
}), pack: (function pack() {
}), unpack: (function pack() {
})}, configurable: false, enumerable: true, writable: true}, realpath: {value: (function realpath() {
_$jscoverage['utility.js'][62]++;
var join_path = require("path").join;
_$jscoverage['utility.js'][63]++;
var fs = require("fs");
_$jscoverage['utility.js'][65]++;
var _path = arguments.length > 1? join_path.apply({}, arguments): arguments[0];
_$jscoverage['utility.js'][67]++;
try {
_$jscoverage['utility.js'][68]++;
return fs.realpathSync(_path);
}
catch (error) {
_$jscoverage['utility.js'][71]++;
try {
_$jscoverage['utility.js'][72]++;
return require.resolve(_path);
}
catch (error) {
_$jscoverage['utility.js'][74]++;
return null;
}
}
}), configurable: false, enumerable: true, writable: true}, console: {value: {json: (function json(data, depth) {
_$jscoverage['utility.js'][97]++;
try {
_$jscoverage['utility.js'][99]++;
if ("string" === typeof data && ("object" === typeof depth || "function" === typeof depth)) {
_$jscoverage['utility.js'][100]++;
console.log("\n" + "===============" + data + " Properties===============");
_$jscoverage['utility.js'][101]++;
data = depth;
_$jscoverage['utility.js'][102]++;
depth = arguments[2] || 1;
}
_$jscoverage['utility.js'][105]++;
var output = require("util").inspect(data, false, "number" === typeof depth? (depth - 1): 1, true);
_$jscoverage['utility.js'][107]++;
console.log(output);
}
catch (error) {
_$jscoverage['utility.js'][109]++;
console.error("Error with console.json()", error);
}
_$jscoverage['utility.js'][111]++;
return arguments[0];
}), method: (function method(data, object) {
_$jscoverage['utility.js'][126]++;
try {
_$jscoverage['utility.js'][128]++;
if ("string" === typeof data && ("object" === typeof object || "function" === typeof object)) {
_$jscoverage['utility.js'][129]++;
console.log("\n" + "===============" + data + " Methods===============");
_$jscoverage['utility.js'][130]++;
data = object;
}
_$jscoverage['utility.js'][133]++;
module.exports.json(_.methods(data));
}
catch (error) {
_$jscoverage['utility.js'][135]++;
console.error("Error with console.methods()", error);
}
_$jscoverage['utility.js'][137]++;
return arguments[0];
}), keys: (function keys(data) {
_$jscoverage['utility.js'][150]++;
function Iterate(target) {
_$jscoverage['utility.js'][151]++;
var result = [];
_$jscoverage['utility.js'][152]++;
for (var key in target) {
_$jscoverage['utility.js'][153]++;
result.push(key);
}
_$jscoverage['utility.js'][155]++;
return result;
}
_$jscoverage['utility.js'][158]++;
console.log([Object.keys(data) + Object.getOwnPropertyNames(data) + Iterate(data)]);
_$jscoverage['utility.js'][159]++;
return data;
}), table: (function table(data) {
_$jscoverage['utility.js'][187]++;
try {
_$jscoverage['utility.js'][188]++;
var table = require("cli-table");
}
catch (error) {
_$jscoverage['utility.js'][190]++;
return console.log(data);
}
_$jscoverage['utility.js'][193]++;
var rows = [];
_$jscoverage['utility.js'][195]++;
if (_.isObject(data) && data.rows) {
_$jscoverage['utility.js'][197]++;
table = new table({"head": data.head || [], "colWidths": data.colWidths || []});
_$jscoverage['utility.js'][202]++;
rows = data.rows;
}
else {
_$jscoverage['utility.js'][205]++;
table = new table();
_$jscoverage['utility.js'][206]++;
rows = data;
}
_$jscoverage['utility.js'][209]++;
_.each(rows, (function (row) {
_$jscoverage['utility.js'][210]++;
if (! _.isEmpty(row)) {
_$jscoverage['utility.js'][210]++;
table.push(row);
}
}));
_$jscoverage['utility.js'][213]++;
try {
_$jscoverage['utility.js'][214]++;
console.log(table.toString());
}
catch (error) {
}
}), report: (function report() {
_$jscoverage['utility.js'][228]++;
module.exports.console.json.apply(module.exports, arguments);
_$jscoverage['utility.js'][229]++;
module.exports.console.methods.apply(module.exports, arguments);
})}, configurable: false, enumerable: true, writable: true}, merge: {value: (function merge(a, b) {
_$jscoverage['utility.js'][255]++;
if (a && b) {
_$jscoverage['utility.js'][256]++;
for (var key in b) {
_$jscoverage['utility.js'][256]++;
a[key] = b[key];
}
}
_$jscoverage['utility.js'][259]++;
return a;
}), configurable: false, enumerable: true, writable: true}, embed: {value: (function embed(target) {
_$jscoverage['utility.js'][283]++;
if ("object" === typeof target || target.keys) {
_$jscoverage['utility.js'][284]++;
for (var key in target) {
_$jscoverage['utility.js'][285]++;
this[key] = target[key];
}
}
_$jscoverage['utility.js'][290]++;
if ("function" === typeof target) {
_$jscoverage['utility.js'][291]++;
return Utility.embed(this);
}
_$jscoverage['utility.js'][294]++;
return this;
}), configurable: false, enumerable: true, writable: true}, regroup: {value: (function regroup(object, group_key, keys) {
_$jscoverage['utility.js'][312]++;
if (_.isObject(object)) {
_$jscoverage['utility.js'][313]++;
object = _.flatten(_.values(object));
}
_$jscoverage['utility.js'][316]++;
function Group(item) {
_$jscoverage['utility.js'][317]++;
return item[group_key];
}
_$jscoverage['utility.js'][320]++;
if (group_key) {
_$jscoverage['utility.js'][321]++;
object = _.groupBy(object, Group);
}
_$jscoverage['utility.js'][324]++;
if (! _.isEmpty(keys)) {
_$jscoverage['utility.js'][326]++;
keys = _.isArray(keys)? keys: [keys];
_$jscoverage['utility.js'][328]++;
_.each(object, (function (items, key) {
_$jscoverage['utility.js'][329]++;
object[key] = _.map(items, (function (item) {
_$jscoverage['utility.js'][329]++;
return _.pick(item, keys);
}));
}));
}
_$jscoverage['utility.js'][334]++;
return object;
}), configurable: false, enumerable: true, writable: true}, noop: {value: (function noop() {
}), configurable: false, enumerable: true, writable: true}, apply: {value: require("async").apply, configurable: true, enumerable: true, writable: true}, defaults: {value: (function defaults(target, defaults) {
_$jscoverage['utility.js'][373]++;
if (! target && ! defaults) {
_$jscoverage['utility.js'][374]++;
return ({});
}
_$jscoverage['utility.js'][378]++;
target = Object.keys(target || {}).length? target: {};
_$jscoverage['utility.js'][381]++;
return require("lodash").defaults.apply({}, arguments);
}), configurable: true, enumerable: true, writable: true}, watch: {value: (function watch(target, prop, handler) {
_$jscoverage['utility.js'][403]++;
var oldval = target[prop];
_$jscoverage['utility.js'][404]++;
var newval = oldval;
_$jscoverage['utility.js'][405]++;
var description = Object.getOwnPropertyDescriptor(target, prop) || {};
_$jscoverage['utility.js'][407]++;
switch (typeof target[prop]) {
case "function":
_$jscoverage['utility.js'][408]++;
break;
case "object":
_$jscoverage['utility.js'][409]++;
break;
case "string":
_$jscoverage['utility.js'][410]++;
break;
case "number":
_$jscoverage['utility.js'][411]++;
break;
}
_$jscoverage['utility.js'][415]++;
if (description.configurable === false || ! (delete target[prop])) {
_$jscoverage['utility.js'][416]++;
return target;
}
_$jscoverage['utility.js'][419]++;
return Object.defineProperty(target, prop, {get: (function get() {
_$jscoverage['utility.js'][421]++;
return newval;
}), set: (function set(val) {
_$jscoverage['utility.js'][424]++;
oldval = newval;
_$jscoverage['utility.js'][427]++;
newval = val;
_$jscoverage['utility.js'][430]++;
return newval = handler.call(target, prop, oldval, val);
}), enumerable: description.enumerable, configurable: true});
}), configurable: true, enumerable: true, writable: true}, unwatch: {value: (function unwatch(prop) {
_$jscoverage['utility.js'][454]++;
var val = this[prop];
_$jscoverage['utility.js'][455]++;
var description = Object.getOwnPropertyDescriptor(this, prop);
_$jscoverage['utility.js'][458]++;
if (description.configurable === false || ! (delete this[prop])) {
_$jscoverage['utility.js'][459]++;
return this;
}
_$jscoverage['utility.js'][462]++;
this[prop] = val;
_$jscoverage['utility.js'][464]++;
return this;
}), configurable: true, enumerable: true, writable: true}, query: {value: (function query(obj, str) {
_$jscoverage['utility.js'][481]++;
if (! str) {
_$jscoverage['utility.js'][482]++;
return obj;
}
_$jscoverage['utility.js'][485]++;
if ("object" === typeof str) {
}
_$jscoverage['utility.js'][489]++;
try {
_$jscoverage['utility.js'][490]++;
return str.split(".").reduce((function (o, x) {
_$jscoverage['utility.js'][491]++;
return o[x];
}), obj);
}
catch (error) {
_$jscoverage['utility.js'][495]++;
return null;
}
}), configurable: true, enumerable: true, writable: true}, unwrap: {value: (function unwrap(string, value, hash, seperator) {
_$jscoverage['utility.js'][525]++;
if (hash == null) {
_$jscoverage['utility.js'][525]++;
hash = {};
}
_$jscoverage['utility.js'][526]++;
if (seperator == null) {
_$jscoverage['utility.js'][526]++;
seperator = ".";
}
_$jscoverage['utility.js'][527]++;
var parts = string.split(seperator);
_$jscoverage['utility.js'][528]++;
var refHash = hash;
_$jscoverage['utility.js'][529]++;
var depth = 0;
_$jscoverage['utility.js'][531]++;
parts.forEach((function (part) {
_$jscoverage['utility.js'][532]++;
if (depth == parts.length - 1) {
_$jscoverage['utility.js'][533]++;
refHash[part] = value;
}
else {
_$jscoverage['utility.js'][535]++;
if (refHash[part] == null) {
_$jscoverage['utility.js'][535]++;
refHash[part] = {};
}
_$jscoverage['utility.js'][536]++;
refHash = refHash[part];
}
_$jscoverage['utility.js'][539]++;
depth++;
}));
_$jscoverage['utility.js'][543]++;
return hash;
}), configurable: true, enumerable: true, writable: true}, mixin: {value: (function mixin(source, target) {
_$jscoverage['utility.js'][560]++;
source = this.prototype || arguments[0] || {};
_$jscoverage['utility.js'][561]++;
target = arguments.length == 2? arguments[1]: arguments[1] || {};
_$jscoverage['utility.js'][563]++;
for (var key in source) {
_$jscoverage['utility.js'][565]++;
try {
_$jscoverage['utility.js'][566]++;
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key) || {value: source[key], enumerable: false, writable: true, configurable: true});
}
catch (error) {
_$jscoverage['utility.js'][572]++;
console.error(error);
}
}
_$jscoverage['utility.js'][576]++;
return target;
}), configurable: true, writable: true, enumerable: false}, inherit: {value: (function inherit(target, source) {
_$jscoverage['utility.js'][592]++;
target = target || {};
_$jscoverage['utility.js'][593]++;
source = source || {};
_$jscoverage['utility.js'][597]++;
Object.getOwnPropertyNames(source).forEach((function (key) {
_$jscoverage['utility.js'][598]++;
if (! target.hasOwnProperty(key)) {
_$jscoverage['utility.js'][598]++;
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
}
}));
_$jscoverage['utility.js'][601]++;
return target;
}), enumerable: true}, flatten: {value: (function flatten(data, options) {
_$jscoverage['utility.js'][614]++;
options = Utility.defaults(options, {delimiter: 1});
_$jscoverage['utility.js'][618]++;
return Array.prototype.concat(data).join(options.delimiter).toLowerCase();
}), enumerable: true}, flatten_obj: {value: (function flatten_obj(obj) {
_$jscoverage['utility.js'][626]++;
var list = {};
_$jscoverage['utility.js'][628]++;
(function callee(o, r) {
_$jscoverage['utility.js'][630]++;
r = r || "";
_$jscoverage['utility.js'][632]++;
if (typeof o != "object") {
_$jscoverage['utility.js'][633]++;
return true;
}
_$jscoverage['utility.js'][636]++;
for (var c in o) {
_$jscoverage['utility.js'][638]++;
if (callee(o[c], r + "." + c)) {
_$jscoverage['utility.js'][640]++;
list[r.substring(1) + "." + c] = o[c];
}
}
_$jscoverage['utility.js'][644]++;
return false;
})(obj);
_$jscoverage['utility.js'][648]++;
return list;
}), enumerable: true}, inherit_full: {value: (function inherit_prototype(target, constructor) {
_$jscoverage['utility.js'][663]++;
target.super_ = constructor;
_$jscoverage['utility.js'][665]++;
target.prototype = Object.create(constructor.prototype, {constructor: {value: constructor, enumerable: false, writable: true, configurable: true}});
}), configurable: true, enumerable: true, writable: true}, constructors: {value: (function constructors(context, options) {
_$jscoverage['utility.js'][687]++;
context = context || {};
_$jscoverage['utility.js'][688]++;
options = options || {};
_$jscoverage['utility.js'][690]++;
var matches = {};
_$jscoverage['utility.js'][691]++;
var path = [];
_$jscoverage['utility.js'][693]++;
do {
_$jscoverage['utility.js'][695]++;
if (context.constructor) {
_$jscoverage['utility.js'][696]++;
path.push(context.constructor.name);
_$jscoverage['utility.js'][698]++;
Object.defineProperty(matches, context.constructor.name, {enumerable: true, writable: true, value: {name: context.constructor.name, properties: {constructor: {type: typeof context.constructor, properties: Object.getOwnPropertyNames(context.constructor)}, prototype: {type: typeof context.constructor.prototype, properties: Object.keys(context.constructor.prototype)}}}});
}
}
while (context = Object.getPrototypeOf(context));
_$jscoverage['utility.js'][720]++;
if (options.format === "schema") {
_$jscoverage['utility.js'][721]++;
return matches || {};
}
_$jscoverage['utility.js'][724]++;
if (options.delimiter) {
_$jscoverage['utility.js'][725]++;
return path.join(options.delimiter);
}
_$jscoverage['utility.js'][728]++;
return path;
}), configurable: true, enumerable: true, writable: true}, unique: {value: (function unique(array) {
_$jscoverage['utility.js'][743]++;
var b = [];
_$jscoverage['utility.js'][744]++;
for (var i = 0; i < array.length; i++) {
_$jscoverage['utility.js'][745]++;
if (b.indexOf(array[i]) == -1) {
_$jscoverage['utility.js'][745]++;
b.push(array[i]);
}
}
_$jscoverage['utility.js'][747]++;
return b;
}), configurable: true, enumerable: true, writable: true}, hash: {value: (function hash(obj) {
_$jscoverage['utility.js'][771]++;
var result;
_$jscoverage['utility.js'][772]++;
var string = JSON.stringify(arguments[0] || {});
_$jscoverage['utility.js'][773]++;
var options = Utility.defaults(arguments[1], {type: "md5", silent_fail: true, random: false});
_$jscoverage['utility.js'][779]++;
try {
_$jscoverage['utility.js'][781]++;
if (options.random) {
_$jscoverage['utility.js'][782]++;
string = Math.random().toString();
}
_$jscoverage['utility.js'][785]++;
result = require("crypto").createHash(options.type.toLowerCase()).update(string).digest("hex");
}
catch (error) {
_$jscoverage['utility.js'][787]++;
result = options.silent_fail? "": error;
}
_$jscoverage['utility.js'][790]++;
return result;
}), configurable: true, enumerable: true, writable: true}, auto: {value: require("async").auto}, queue: {value: require("async").queue}, times: {value: require("async").times}, extend: {value: require("lodash").extend}, values: {value: require("lodash").values}, map: {value: require("lodash").map}, each: {value: require("lodash").each}, reduce: {value: (function reduce(arr, iterator, memo) {
_$jscoverage['utility.js'][807]++;
if (arr.reduce) {
_$jscoverage['utility.js'][808]++;
return arr.reduce(iterator, memo);
}
_$jscoverage['utility.js'][811]++;
_each(arr, (function (x, i, a) {
_$jscoverage['utility.js'][812]++;
memo = iterator(memo, x, i, a);
}));
_$jscoverage['utility.js'][815]++;
return memo;
}), configurable: false, enumerable: true, writable: true}, keys: {value: (function keys(obj) {
_$jscoverage['utility.js'][829]++;
if (Object.keys) {
_$jscoverage['utility.js'][830]++;
return Object.keys(obj);
}
_$jscoverage['utility.js'][833]++;
var keys = [];
_$jscoverage['utility.js'][834]++;
for (var k in obj) {
_$jscoverage['utility.js'][835]++;
if (obj.hasOwnProperty(k)) {
_$jscoverage['utility.js'][836]++;
keys.push(k);
}
}
_$jscoverage['utility.js'][839]++;
return keys;
}), configurable: false, enumerable: true, writable: true}, toArray: {value: require("lodash").toArray}, where: {value: require("lodash").where}, if: {value: {"PlainObject": require("lodash").isPlainObject, "Function": require("lodash").isFunction, "Object": require("lodash").isObject, "String": require("lodash").isString}, configurable: false, enumerable: true, writable: true}, log: {value: Object.defineProperties((function () {
_$jscoverage['utility.js'][877]++;
var output = {};
_$jscoverage['utility.js'][880]++;
if (this.event) {
_$jscoverage['utility.js'][881]++;
output.event = this.event;
}
_$jscoverage['utility.js'][884]++;
Utility.each(arguments, (function (item, key) {
_$jscoverage['utility.js'][886]++;
if (Utility["if"].PlainObject(item)) {
}
_$jscoverage['utility.js'][888]++;
output.format = typeof item;
_$jscoverage['utility.js'][890]++;
if (key === 0) {
_$jscoverage['utility.js'][891]++;
output.data = item;
}
else {
_$jscoverage['utility.js'][893]++;
output[key] = item;
}
}));
_$jscoverage['utility.js'][898]++;
console.log(require("util").inspect(output, Utility.log.config));
_$jscoverage['utility.js'][900]++;
return this;
}), {"config": {value: {"showHidden": true, "depth": 2, "colors": true}, "writable": true}}), enumerable: true}});
_$jscoverage['utility.js'].source = ["/**"," * Helper Utility for Abstract"," *"," * @example"," *"," * // Select specific methods to load"," * var my_tools = Abstract.utility( 'if', 'extend', 'flatten', 'unwatch', 'watch' );"," *"," * @for abstract"," * @submodule abstract-utility"," * @author potanin@UD"," * @date 6/17/13"," */","function Utility() {"," return Object.keys( arguments ) ? require( 'lodash' ).pick.apply( null, [ Utility, Array.prototype.slice.call( arguments ) ] ) : Utility;","}","","Object.defineProperties( module.exports = Utility, {"," json: {"," value: {"," /**"," * Safely parse JSON"," *"," * @method parse"," * @for Json"," *"," * @param json"," * @return {parsed|json}"," */"," parse: function parse( json ) {",""," if( Buffer && json instanceof Buffer ) {"," json = json.toString()"," }",""," var parsed = false;"," try { parsed = JSON.parse( json ); } catch (e) { parsed = false; }",""," // Perhaps try to strip some line braks or special characters.."," if( !parsed && 'string' === typeof json ) {}",""," return parsed ? parsed : json;"," },"," /**"," *"," * @param obj"," * @returns {boolean}"," */"," stringify: function stringify( obj ) {"," return JSON.stringify( obj );"," },"," pack: function pack() {},"," unpack: function pack() {}"," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," realpath: {"," value: function realpath() {",""," var join_path = require( 'path' ).join;"," var fs = require( 'fs' );",""," var _path = arguments.length > 1 ? join_path.apply( {}, arguments ) : arguments[0];",""," try {"," return fs.realpathSync( _path );"," } catch ( error ) {",""," try {"," return require.resolve( _path );"," } catch( error ) {"," return null;"," }"," }",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," console: {"," value: {"," /**"," * Prety Print complex objects"," *"," * @param data"," * @param depth"," *"," * @requires lodash"," * @method console_json"," * @return {Object} The first argument."," */"," json: function json( data, depth ) {",""," try {",""," if( 'string' === typeof data && ( 'object' === typeof depth || 'function' === typeof depth ) ) {"," console.log( \"\\n\" + '===============' + data + ' Properties===============' );"," data = depth;"," depth = arguments[2] || 1"," }",""," var output = require( 'util' ).inspect( data, false, 'number' === typeof depth ? ( depth - 1 ) : 1, true );",""," console.log( output );",""," } catch( error ) { console.error( 'Error with console.json()', error ); }",""," return arguments[0];",""," },"," /**"," * Pretty Print and Object's Methods"," *"," * @param data"," * @param object"," *"," * @requires lodash"," * @method console_methods"," * @return {Object} The first argument."," */"," method: function method( data, object ) {",""," try {",""," if( 'string' === typeof data && ( 'object' === typeof object || 'function' === typeof object ) ) {"," console.log( \"\\n\" + '===============' + data + ' Methods===============' );"," data = object;"," }",""," module.exports.json( _.methods( data ) );",""," } catch( error ) { console.error( 'Error with console.methods()', error ); }",""," return arguments[0];",""," },"," /**"," * Get all Object Keys"," *"," * @param data"," *"," * @method console_keys"," * @return {Object} The first argument."," */"," keys: function keys( data ) {",""," function Iterate( target ) {"," var result = [];"," for( var key in target ) {"," result.push( key );"," }"," return result;"," }",""," console.log([ Object.keys( data ) + Object.getOwnPropertyNames( data ) + Iterate( data ) ]);"," return data;"," },"," /**"," * Draw data in table style"," *"," * @example"," *"," * //console.table"," * console.table(["," * { .. row .. }"," * ]);"," *"," * //console.table"," * console.table({"," * 'head': [ 'I/O ID', 'Endpoint', 'Description' ],"," * 'colWidths': [ 30, 50, 50 ],"," * 'rows': ["," * [ 'one', 'two', 'three' ],"," * [ 'one', 'two', 'three' ]"," * ]"," * });"," *"," * @param {object} data"," * @method table"," * @for Utility"," */"," table: function table( data ) {",""," try {"," var table = require( 'cli-table' );"," } catch (error) {"," return console.log( data );"," }",""," var rows = [];",""," if( _.isObject( data ) && data.rows ) {",""," table = new table({"," 'head': data.head || [],"," 'colWidths': data.colWidths || []"," });",""," rows = data.rows;",""," } else {"," table = new table;"," rows = data;"," }",""," _.each( rows, function( row ) {"," if( !_.isEmpty( row ) ) { table.push( row ); }"," });",""," try {"," console.log( table.toString() );"," } catch( error ) {"," //console.trace( error.message, error );"," }",""," },"," /**"," * Console a variable report"," *"," * @method report"," * @for Utility"," * @param {object} arguments*"," */"," report: function report() {"," module.exports.console.json.apply( module.exports, arguments );"," module.exports.console.methods.apply( module.exports, arguments );"," }"," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," merge: {"," /**"," * Merge object b with object a."," *"," * @example"," * var a = { foo: 'bar' }"," * , b = { bar: 'baz' };"," *"," * utils.merge(a, b);"," * // => { foo: 'bar', bar: 'baz' }"," *"," * @param {Object} a"," * @param {Object} b"," * @return {Object}"," *"," * @source connect"," */"," value: function merge( a, b ){",""," if (a && b) {"," for (var key in b) { a[key] = b[key]; }"," }",""," return a;",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," embed: {"," /**"," * Shallow Merge of Current Object with Another, and Function Mounting"," *"," * Functions in exact same manner as"," * the Connect utilities \"merge\" method"," *"," * @param {Object} target"," *"," * @method embed"," *"," * @chainable"," *"," * @return {Object}"," */"," value: function embed( target ) {",""," if( 'object' === typeof target || target.keys ) {"," for( var key in target ) {"," this[key] = target[ key ];"," }"," }",""," // If second argument is a function, we do some magic"," if( 'function' === typeof target ) {"," return Utility.embed( this );"," }",""," return this;",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," regroup: {"," /**"," * Re-group an object by a key, and optionally pick specific keys in the new object."," *"," * If an object is passed, it is assumed to be grouped, thus flattening the values."," * Arrays are used as they are."," *"," * @param target"," */"," value: function regroup( object, group_key, keys ) {",""," if( _.isObject( object ) ) {"," object = _.flatten( _.values( object ) );"," }",""," function Group( item ) {"," return item[ group_key ];"," }",""," if( group_key ) {"," object = _.groupBy( object, Group );"," }",""," if( !_.isEmpty( keys ) ) {",""," keys = _.isArray( keys ) ? keys : [ keys ];",""," _.each( object, function( items, key ) {"," object[ key ] = _.map( items, function( item ) { return _.pick( item, keys ); })"," })",""," }",""," return object;",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," noop: {"," /**"," * Not a function, that's for sure."," * This method does not accept any arguments."," */"," value: function noop() {"," // console.log( arguments )"," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," apply: {"," /**"," * Creates a continuation function with some arguments already applied."," *"," * @uses async"," */"," value: require( 'async' ).apply,"," configurable: true,"," enumerable: true,"," writable: true"," },"," defaults: {"," /**"," * Configure Defaults for an Object"," *"," * @returns {Object}"," */"," value: function defaults( target, defaults ) {",""," // If no arguments, return empty object"," if( !target && !defaults ) {"," return {};"," }",""," // Ensure target is an object"," target = Object.keys( target || {} ).length ? target : {};",""," // Lodash-it"," return require( 'lodash' ).defaults.apply( {}, arguments );",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," watch: {"," /**"," * Watch a Single Property"," *"," * @param {Object} prop"," * @param {callback} handler"," *"," * @method watch"," * @for abstract-utility"," *"," * @chainable"," *"," * @return {Object} newval"," */"," value: function watch( target, prop, handler ) {"," var oldval = target[prop];"," var newval = oldval;"," var description = Object.getOwnPropertyDescriptor( target, prop ) || {};",""," switch( typeof target[prop] ) {"," case 'function':break;"," case 'object':break;"," case 'string':break;"," case 'number':break;"," }",""," // Delete original property and replace with getter/setter if possible"," if( description.configurable === false || !( delete target[ prop ] ) ) {"," return target;"," }",""," return Object.defineProperty( target, prop, {"," get: function get() {"," return newval;"," },"," set: function set( val ) {"," oldval = newval;",""," // Set value"," newval = val;",""," // Execute hander and potentially mody value"," return newval = handler.call( target, prop, oldval, val );",""," },"," enumerable: description.enumerable,"," configurable: true"," });",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," unwatch: {"," /**"," * Unwatch a Single Property"," *"," * @param {Object} prop"," *"," * @method unwatch"," * @for abstract-utility"," *"," * @return null"," */"," value: function unwatch( prop ) {"," var val = this[prop];"," var description = Object.getOwnPropertyDescriptor( this, prop );",""," // Shouldn't happen, but just in case."," if( description.configurable === false || !( delete this[ prop ] ) ) {"," return this;"," }",""," this[prop] = val;",""," return this;",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," query: {"," /**"," * Get property value using a dot notation path."," *"," * @param obj"," * @param str"," * @returns {*}"," */"," value: function query( obj, str ) {",""," if( !str ) {"," return obj;"," }",""," if( 'object' === typeof str ) {"," // @todo Convert Object to dot notation, using the first full dot notation path."," }",""," try {"," return str.split( '.' ).reduce( function( o, x ) {"," return o[x]"," }, obj);",""," } catch( error ) {"," return null;"," }",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," unwrap: {"," /**"," * Unwrap dot notation string to nested Object"," *"," * @example"," *"," * Utility.unwrap( 'first_name', 'john' ); // -> { first_name: 'John' }"," * Utility.unwrap( 'name.first', 'john' ); // -> { name: { first: 'John' } }"," * Utility.unwrap( 'first_name' ); // -> null"," * Utility.unwrap( 'name.first' ); // -> null"," *"," * // Will not modify object if already exists"," * Utility.unwrap( 'name.first.fail', 'Anything' );"," *"," * @param string"," * @param value"," * @param hash"," * @param seperator"," * @,etjpd unwrap"," * @return {*}"," */"," value: function unwrap( string, value, hash, seperator ) {"," if( hash == null ) { hash = {}; }"," if( seperator == null ) { seperator = '.'; }"," var parts = string.split( seperator );"," var refHash = hash;"," var depth = 0;",""," parts.forEach( function( part ) {"," if( depth == parts.length - 1 ) {"," refHash[part] = value;"," } else {"," if( refHash[part] == null ) { refHash[part] = {}; }"," refHash = refHash[part];"," }",""," depth++;",""," });",""," return hash;",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," mixin: {"," /**"," * Mixin current prototype into target object"," *"," * Honors property descriptor settings, if available."," *"," * @param source"," * @param target"," */"," value: function mixin( source, target ) {"," source = this.prototype || arguments[0] || {};"," target = arguments.length == 2 ? arguments[1] : arguments[1] || {};",""," for( var key in source ) {",""," try {"," Object.defineProperty( target, key, Object.getOwnPropertyDescriptor( source, key ) || {"," value: source[key],"," enumerable: false,"," writable: true,"," configurable: true"," });"," } catch( error ) { console.error( error ); }",""," }",""," return target;",""," },"," configurable: true,"," writable: true,"," enumerable: false"," },"," inherit: {"," /**"," * Carefully Inherit Properties"," *"," * @param target {Object} Object to add properties to."," * @param target {Object} Source object."," * @returns {Object} Extended target."," */"," value: function inherit( target, source ) {"," target = target || {};"," source = source || {};",""," //if( target instanceof source ) {}",""," Object.getOwnPropertyNames( source ).forEach( function( key ) {"," if( !target.hasOwnProperty( key ) ) { Object.defineProperty( target, key, Object.getOwnPropertyDescriptor( source, key ) ); }"," });",""," return target;",""," },"," enumerable: true"," },"," flatten: {"," /**"," * Flatten Array"," *"," * @todo Notice - nested arrays will not honor delimiter."," */"," value: function flatten( data, options ) {",""," options = Utility.defaults( options, {"," delimiter: 1"," });",""," return Array.prototype.concat( data ).join( options.delimiter ).toLowerCase();",""," },"," enumerable: true"," },"," flatten_obj: {"," value: function flatten_obj( obj ) {",""," var list = {};",""," (function callee(o, r) {",""," r = r || '';",""," if (typeof o != 'object') {"," return true;"," }",""," for (var c in o) {",""," if ( callee( o[c], r + \".\" + c ) ) {",""," list[r.substring(1) + \".\" + c] = o[c]"," }"," }",""," return false;",""," })(obj);",""," return list;"," },"," enumerable: true"," },"," inherit_full: {"," /**"," * Inherit the prototype methods from one constructor into another."," *"," * Copy of the Node.js util.inherits method."," *"," * @param {function} target Constructor function which needs to inherit the prototype."," * @param {function} constructor Constructor function to inherit prototype from."," */"," value: function inherit_prototype( target, constructor ) {",""," target.super_ = constructor;",""," target.prototype = Object.create( constructor.prototype, {"," constructor: {"," value: constructor,"," enumerable: false,"," writable: true,"," configurable: true"," }"," });",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," constructors: {"," /**"," * Walk up the prototype chain, creating a JSON-Schema-esque structure"," *"," * @param context {Object} The object to walk through."," * @return {Object} JSON Schema-esque constructor chain."," */"," value: function constructors( context, options ) {"," context = context || {};"," options = options || {};",""," var matches = {};"," var path = [];",""," do {",""," if( context.constructor ) {"," path.push( context.constructor.name );",""," Object.defineProperty( matches, context.constructor.name, {"," enumerable: true,"," writable: true,"," value: {"," name: context.constructor.name,"," properties: {"," constructor: {"," type: typeof context.constructor,"," properties: Object.getOwnPropertyNames( context.constructor )"," },"," prototype: {"," type: typeof context.constructor.prototype,"," properties: Object.keys( context.constructor.prototype )"," }"," }"," }"," });",""," }",""," } while ( context = Object.getPrototypeOf( context ) );",""," if( options.format === 'schema' ) {"," return matches || {};"," }",""," if( options.delimiter ) {"," return path.join( options.delimiter );"," }",""," return path;",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," unique: {"," /**"," * Return unique values of an array"," *"," * @param array"," * @returns {Array}"," */"," value: function unique( array ){"," var b = [];"," for(var i=0; i<array.length; i++){"," if(b.indexOf(array[i]) == -1) b.push(array[i]);"," }"," return b;"," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," hash: {"," /**"," * Generate a unique hash for an Object, using md5 on default."," *"," * @example"," *"," * var _hash = Utility.hash({ type: 'some_object', name: 'Bob'});"," *"," * console.log( _hash ); // -> 147ce3e2ccb7db6b928b303ce42bdafa"," *"," * @param obj {Object} Object to generate a hash for."," * @param options {Object} options for hash generation."," * @param options {String} options.type Type of hash to generate, defaulting to md5."," * @param options {String} options.silent_fail Do not throw errors, return empty string if there was an error when true."," *"," */"," value: function hash( obj ) {",""," var result;"," var string = JSON.stringify( arguments[0] || {} );"," var options = Utility.defaults( arguments[1], {"," type: 'md5',"," silent_fail: true,"," random: false"," });",""," try {",""," if( options.random ) {"," string = Math.random().toString();"," }",""," result = require( 'crypto' ).createHash( options.type.toLowerCase() ).update( string ).digest( 'hex' );"," } catch ( error ) {"," result = options.silent_fail ? '' : error;"," }",""," return result;",""," },"," configurable: true,"," enumerable: true,"," writable: true"," },"," auto: { value: require( 'async' ).auto },"," queue: { value: require( 'async' ).queue },"," times: { value: require( 'async' ).times },"," extend: { value: require( 'lodash' ).extend },"," values: { value: require( 'lodash' ).values },"," map: { value: require( 'lodash' ).map },"," each: { value: require( 'lodash' ).each },"," reduce: {"," value: function reduce(arr, iterator, memo) {",""," if (arr.reduce) {"," return arr.reduce(iterator, memo);"," }",""," _each(arr, function (x, i, a) {"," memo = iterator(memo, x, i, a);"," });",""," return memo;",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," keys: {"," /**"," *"," * @source async"," */"," value: function keys(obj) {",""," if (Object.keys) {"," return Object.keys(obj);"," }",""," var keys = [];"," for (var k in obj) {"," if (obj.hasOwnProperty(k)) {"," keys.push(k);"," }"," }"," return keys;",""," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," toArray: { value: require( 'lodash' ).toArray },"," where: { value: require( 'lodash' ).where },"," if: {"," value: {"," \"PlainObject\": require( 'lodash' ).isPlainObject,"," \"Function\": require( 'lodash' ).isFunction,"," \"Object\": require( 'lodash' ).isObject,"," \"String\": require( 'lodash' ).isString,"," },"," configurable: false,"," enumerable: true,"," writable: true"," },"," log: {"," /**"," * Output variables to console log."," *"," * Settings can be configured like so:"," * abstract.log.config.depth = 2;"," * abstract.log.config.colors = true;"," *"," * @param {Object|String} data A config object"," * @example"," * Abstract.log( data )"," *"," * method log"," * @return {Object} Abstract constructor."," * @chainable"," */"," value: Object.defineProperties( function() {",""," var output = {};",""," // Capture Event Name"," if( this.event ) {"," output.event = this.event;"," }",""," Utility.each( arguments, function( item, key ) {",""," if( Utility.if.PlainObject( item ) ) {}",""," output[ 'format' ] = typeof item;",""," if( key === 0 ) {"," output[ 'data' ] = item;"," } else {"," output[ key ] = item;"," }",""," });",""," console.log( require( 'util' ).inspect( output, ( Utility ).log.config ) );",""," return this;"," }, { \"config\": { value: { \"showHidden\": true, \"depth\": 2, \"colors\": true }, \"writable\": true } }),"," enumerable: true"," }","});"];