@lumino/coreutils
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -36,2 +36,44 @@ /** | ||
/** | ||
* A type alias for a partial JSON value. | ||
* | ||
* Note: Partial here means that JSON object attributes can be `undefined`. | ||
*/ | ||
export declare type PartialJSONValue = JSONPrimitive | PartialJSONObject | PartialJSONArray; | ||
/** | ||
* A type definition for a partial JSON object. | ||
* | ||
* Note: Partial here means that the JSON object attributes can be `undefined`. | ||
*/ | ||
export interface PartialJSONObject { | ||
[key: string]: PartialJSONValue | undefined; | ||
} | ||
/** | ||
* A type definition for a partial JSON array. | ||
* | ||
* Note: Partial here means that JSON object attributes can be `undefined`. | ||
*/ | ||
export interface PartialJSONArray extends Array<PartialJSONValue> { | ||
} | ||
/** | ||
* A type definition for a readonly partial JSON object. | ||
* | ||
* Note: Partial here means that JSON object attributes can be `undefined`. | ||
*/ | ||
export interface ReadonlyPartialJSONObject { | ||
readonly [key: string]: ReadonlyPartialJSONValue | undefined; | ||
} | ||
/** | ||
* A type definition for a readonly partial JSON array. | ||
* | ||
* Note: Partial here means that JSON object attributes can be `undefined`. | ||
*/ | ||
export interface ReadonlyPartialJSONArray extends ReadonlyArray<ReadonlyPartialJSONValue> { | ||
} | ||
/** | ||
* A type alias for a readonly partial JSON value. | ||
* | ||
* Note: Partial here means that JSON object attributes can be `undefined`. | ||
*/ | ||
export declare type ReadonlyPartialJSONValue = JSONPrimitive | ReadonlyPartialJSONObject | ReadonlyPartialJSONArray; | ||
/** | ||
* The namespace for JSON-specific functions. | ||
@@ -55,3 +97,3 @@ */ | ||
*/ | ||
function isPrimitive(value: ReadonlyJSONValue): value is JSONPrimitive; | ||
function isPrimitive(value: ReadonlyPartialJSONValue): value is JSONPrimitive; | ||
/** | ||
@@ -66,2 +108,4 @@ * Test whether a JSON value is an array. | ||
function isArray(value: ReadonlyJSONValue): value is ReadonlyJSONArray; | ||
function isArray(value: PartialJSONValue): value is PartialJSONArray; | ||
function isArray(value: ReadonlyPartialJSONValue): value is ReadonlyPartialJSONArray; | ||
/** | ||
@@ -76,2 +120,4 @@ * Test whether a JSON value is an object. | ||
function isObject(value: ReadonlyJSONValue): value is ReadonlyJSONObject; | ||
function isObject(value: PartialJSONValue): value is PartialJSONObject; | ||
function isObject(value: ReadonlyPartialJSONValue): value is ReadonlyPartialJSONObject; | ||
/** | ||
@@ -86,3 +132,3 @@ * Compare two JSON values for deep equality. | ||
*/ | ||
function deepEqual(first: ReadonlyJSONValue, second: ReadonlyJSONValue): boolean; | ||
function deepEqual(first: ReadonlyPartialJSONValue, second: ReadonlyPartialJSONValue): boolean; | ||
/** | ||
@@ -95,3 +141,3 @@ * Create a deep copy of a JSON value. | ||
*/ | ||
function deepCopy<T extends ReadonlyJSONValue>(value: T): T; | ||
function deepCopy<T extends ReadonlyPartialJSONValue>(value: T): T; | ||
} |
@@ -131,3 +131,3 @@ "use strict"; | ||
for (var key in first) { | ||
if (!(key in second)) { | ||
if (first[key] !== undefined && !(key in second)) { | ||
return false; | ||
@@ -138,3 +138,3 @@ } | ||
for (var key in second) { | ||
if (!(key in first)) { | ||
if (second[key] !== undefined && !(key in first)) { | ||
return false; | ||
@@ -145,5 +145,17 @@ } | ||
for (var key in first) { | ||
if (!deepEqual(first[key], second[key])) { | ||
// Get the values. | ||
var firstValue = first[key]; | ||
var secondValue = second[key]; | ||
// If both are undefined, ignore the key. | ||
if (firstValue === undefined && secondValue === undefined) { | ||
continue; | ||
} | ||
// If only one value is undefined, the objects are not equal. | ||
if (firstValue === undefined || secondValue === undefined) { | ||
return false; | ||
} | ||
// Compare the values. | ||
if (!deepEqual(firstValue, secondValue)) { | ||
return false; | ||
} | ||
} | ||
@@ -169,3 +181,8 @@ // At this point, the objects are equal. | ||
for (var key in value) { | ||
result[key] = deepCopy(value[key]); | ||
// Ignore undefined values. | ||
var subvalue = value[key]; | ||
if (subvalue === undefined) { | ||
continue; | ||
} | ||
result[key] = deepCopy(subvalue); | ||
} | ||
@@ -172,0 +189,0 @@ return result; |
{ | ||
"name": "@lumino/coreutils", | ||
"version": "1.3.1", | ||
"description": "lumino Core Utilities", | ||
"homepage": "https://github.com/luminojs/lumino", | ||
"version": "1.4.0", | ||
"description": "Lumino Core Utilities", | ||
"homepage": "https://github.com/jupyterlab/lumino", | ||
"bugs": { | ||
"url": "https://github.com/luminojs/lumino/issues" | ||
"url": "https://github.com/jupyterlab/lumino/issues" | ||
}, | ||
@@ -28,5 +28,6 @@ "license": "BSD-3-Clause", | ||
"type": "git", | ||
"url": "https://github.com/luminojs/lumino.git" | ||
"url": "https://github.com/jupyterlab/lumino.git" | ||
}, | ||
"scripts": { | ||
"api": "api-extractor run --local --verbose", | ||
"build": "tsc --build", | ||
@@ -44,2 +45,3 @@ "build:test": "tsc --build tests && cd tests && webpack", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.6.0", | ||
"@types/chai": "^3.4.35", | ||
@@ -64,3 +66,3 @@ "@types/mocha": "^2.2.39", | ||
}, | ||
"gitHead": "69babebb9528218bfecc3d3104a1b913d90e9f14" | ||
"gitHead": "15fff95b04349ef7247e8e2e7a5f54c61171d613" | ||
} |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
32194
828
0
0
16