var withKeepStartCount = function (json, property, count) { traverse(json).forEach(function (node) { if (this.key === property) { node = "" + node; // make sure it's a string var l = node.length; var end = node.substring(l - count); this.update(_.padEnd(end, l, REPLACECHAR)); } }); return json; }
traverse(defaultJsonObject).reduce(function (acc, x) { if (this.isLeaf && this.key!=='value' ) { acc += ', '+this.key } return acc; }, '')
bench([ function JSONStrinfify (done) { const obj = { a: 1, b: 2, c: 4224, d: 'eeeeeeeew' } const stringified = JSON.stringify(obj) regex.test(stringified) done() }, function propertyIteration (done) { const obj = { a: 1, b: 2, c: 4224, d: 'eeeeeeeew' } traverse(obj).forEach((x) => { if (typeof x === 'string') { regex.test(x) } }) done() } ], 1000)
var flattenProps = function (props) { return traverse(props).reduce(function (acc) { // If its an array, it is not empty, and it has only one item. if (Array.isArray(this.node) && this.node.length === 1 && this.level < 3 && !this.node[0].properties && this.parent && this.parent.node) { acc[this.key] = ( (typeof this.node[0] === "string") ? xss(this.node[0].replace(/(<([^>]+)>)|\n|\t/ig,"")) : this.node[0] ); } if (this.level === 3) { var node = _.get(this, 'parent.parent.node'); if (node && node[0] && node[0].type && node[0].type[1]) acc[node.key] = '__ref__' + node[0].type[1]; } return acc; }, {}); }
traverse(mdata).reduce(function (acc) { if (this.key === 'type' && this.notLeaf) { var props = this.parent.node['properties'], size = props.length ? props.length : Object.keys(props).length || 0; if (size) { acc.push({ id: this.node[1], type: this.node[0], props: flattenProps(props), path: this.path, length: size, level: this.level }); } } return acc; }, [])
traverse(auth).forEach(function (val) { if ('string' === typeof val) { const match = ENV_VAR_REGEX.exec(val);
function hasUndefinedValues (obj) { let has traverse(obj).forEach(function (val) { if (val === undefined) { has = true /* eslint no-invalid-this: "off" */ this.update(undefined, true) // stop traversing } }) return has }
var items = traverse(data.items).forEach(function(item) { if (this.key === "type" && this.notLeaf) { index++; return traverse(props).reduce(function(acc) { if (this.key === "content" && this.notLeaf) { if ( }; var result = traverse(items).reduce(function(acc) { if (this.key === "type" && this.notLeaf) { var props = this.parent.node["properties"],
traverse(mdata).forEach(function(item) { if (this.key === 'type' && this.notLeaf) { index ++; this.node.push(index); //console.log(this.node); } })
var withFixedLength = function (json, property, count) { traverse(json).forEach(function (node) { if (this.key === property) { this.update(_.padEnd('', count, REPLACECHAR)); } }); return json; }
var withAll = function (json, property) { traverse(json).forEach(function (node) { if (this.key === property) { node = "" + node; // make sure it's a string var l = node.length; this.update(_.padStart('', l, REPLACECHAR)); } }); return json; }
var withKeepEndCount = function (json, property, count) { traverse(json).forEach(function (node) { if (this.key === property) { node = "" + node; // make sure it's a string var l = node.length; var end = node.substring(l - count); this.update(_.padStart(end, l, REPLACECHAR)); } }); return json; }
traverse(defaultJsonObject).reduce(function (acc, x) { if (this.isLeaf && this.key!=='value' ) { acc += ', '+this.key } return acc; }, '')
bench([ function JSONStrinfify(done) { const obj = { a: 1, b: 2, c: 4224, d: 'eeeeeeeew' } const stringified = JSON.stringify(obj) regex.test(stringified) done() }, function propertyIteration(done) { const obj = { a: 1, b: 2, c: 4224, d: 'eeeeeeeew' } traverse(obj).forEach((x) => { if (typeof x === 'string') { regex.test(x) } }) done() } ], 1000)