@phosphor/coreutils
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,2 +5,3 @@ "use strict"; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/*----------------------------------------------------------------------------- | ||
@@ -7,0 +8,0 @@ | Copyright (c) 2014-2017, PhosphorJS Contributors |
@@ -59,21 +59,12 @@ /** | ||
/** | ||
* Compare two JSON arrays for deep equality. | ||
* Create a deep copy of a JSON value. | ||
* | ||
* @param first - The first JSON array of interest. | ||
* @param value - The JSON value to copy. | ||
* | ||
* @param second - The second JSON array of interest. | ||
* | ||
* @returns `true` if the arrays are equal, `false` otherwise. | ||
* @returns A deep copy of the given JSON value. | ||
*/ | ||
function deepArrayEqual(first: JSONArray, second: JSONArray): boolean; | ||
/** | ||
* Compare two JSON objects for deep equality. | ||
* | ||
* @param first - The first JSON array of interest. | ||
* | ||
* @param second - The second JSON array of interest. | ||
* | ||
* @returns `true` if the arrays are equal, `false` otherwise. | ||
*/ | ||
function deepObjectEqual(first: JSONObject, second: JSONObject): boolean; | ||
function deepCopy(value: JSONPrimitive): JSONPrimitive; | ||
function deepCopy(value: JSONArray): JSONArray; | ||
function deepCopy(value: JSONObject): JSONObject; | ||
function deepCopy(value: JSONValue): JSONValue; | ||
} |
@@ -9,2 +9,3 @@ /*----------------------------------------------------------------------------- | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -84,10 +85,17 @@ * The namespace for JSON-specific functions. | ||
JSONExt.deepEqual = deepEqual; | ||
function deepCopy(value) { | ||
// Do nothing for primitive values. | ||
if (isPrimitive(value)) { | ||
return value; | ||
} | ||
// Deep copy an array. | ||
if (isArray(value)) { | ||
return deepArrayCopy(value); | ||
} | ||
// Deep copy an object. | ||
return deepObjectCopy(value); | ||
} | ||
JSONExt.deepCopy = deepCopy; | ||
/** | ||
* Compare two JSON arrays for deep equality. | ||
* | ||
* @param first - The first JSON array of interest. | ||
* | ||
* @param second - The second JSON array of interest. | ||
* | ||
* @returns `true` if the arrays are equal, `false` otherwise. | ||
*/ | ||
@@ -112,11 +120,4 @@ function deepArrayEqual(first, second) { | ||
} | ||
JSONExt.deepArrayEqual = deepArrayEqual; | ||
/** | ||
* Compare two JSON objects for deep equality. | ||
* | ||
* @param first - The first JSON array of interest. | ||
* | ||
* @param second - The second JSON array of interest. | ||
* | ||
* @returns `true` if the arrays are equal, `false` otherwise. | ||
*/ | ||
@@ -149,3 +150,22 @@ function deepObjectEqual(first, second) { | ||
} | ||
JSONExt.deepObjectEqual = deepObjectEqual; | ||
/** | ||
* Create a deep copy of a JSON array. | ||
*/ | ||
function deepArrayCopy(value) { | ||
var result = new Array(value.length); | ||
for (var i = 0, n = value.length; i < n; ++i) { | ||
result[i] = deepCopy(value[i]); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Create a deep copy of a JSON object. | ||
*/ | ||
function deepObjectCopy(value) { | ||
var result = {}; | ||
for (var key in value) { | ||
result[key] = deepCopy(value[key]); | ||
} | ||
return result; | ||
} | ||
})(JSONExt = exports.JSONExt || (exports.JSONExt = {})); |
@@ -9,2 +9,3 @@ /*----------------------------------------------------------------------------- | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -11,0 +12,0 @@ * An object which stores MIME data for general application use. |
@@ -9,2 +9,3 @@ /*----------------------------------------------------------------------------- | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
@@ -11,0 +12,0 @@ * A class which wraps a promise into a delegate object. |
{ | ||
"name": "@phosphor/coreutils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "PhosphorJS - Core Utilities", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
16410
488
1