idea-toolbox
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -38,3 +38,7 @@ 'use strict'; | ||
function Obj2N(obj, maxDepth, currentDepth) { | ||
if(!obj || typeof obj != 'object') return obj; | ||
// stop the execution if obj is not an object (if it's a string, works as ES2N) | ||
if(obj == null || obj == undefined) return null; | ||
else if(typeof obj == 'string') return ES2N(obj); | ||
else if(typeof obj != 'object') return obj; | ||
// go deeper in the object | ||
if(!maxDepth) maxDepth = 0; | ||
@@ -46,3 +50,4 @@ if(!currentDepth) currentDepth = 0; | ||
else if(typeof obj[prop] == 'object' && Array.isArray(obj[prop]) && currentDepth < maxDepth) | ||
obj[prop].forEach(el => el = Obj2N(el, maxDepth, currentDepth+1)); | ||
obj[prop].forEach((el, index, arr) => arr[index] = Obj2N(el, maxDepth, currentDepth+1)); | ||
// a standard forEach won't work with elements different from objects (e.g. strings) | ||
else if(typeof obj[prop] == 'object' && !Array.isArray(obj[prop]) && currentDepth < maxDepth) | ||
@@ -49,0 +54,0 @@ obj[prop] = Obj2N(obj[prop], maxDepth, currentDepth+1); |
{ | ||
"name": "idea-toolbox", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "IDEA's utility functions", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10642
191