@canvas-js/utils
Advanced tools
Comparing version 0.13.0-next.2 to 0.13.0-next.3
@@ -18,1 +18,2 @@ export type JSValue = null | boolean | number | string | Uint8Array | JSArray | JSObject; | ||
export declare function merge(from: JSValue, into: JSValue): JSValue; | ||
export declare function update(from: JSValue, into: JSValue): JSValue; |
@@ -70,1 +70,41 @@ // Values | ||
} | ||
export function update(from, into) { | ||
if (from === null) { | ||
return from; | ||
} | ||
else if (typeof from === "boolean") { | ||
return from; | ||
} | ||
else if (typeof from === "number") { | ||
return from; | ||
} | ||
else if (typeof from === "string") { | ||
return from; | ||
} | ||
else if (from instanceof Uint8Array) { | ||
return from; | ||
} | ||
else if (Array.isArray(from)) { | ||
return from; | ||
} | ||
else { | ||
// update fields without recursive merging | ||
if (!isObject(from)) | ||
return from; | ||
if (!isObject(into)) | ||
return from; | ||
const result = { ...into }; | ||
for (const key of Object.keys(from)) { | ||
if (from[key] === undefined) { | ||
result[key] = into[key]; | ||
} | ||
else if (into[key] === undefined) { | ||
result[key] = from[key]; | ||
} | ||
else { | ||
result[key] = from[key]; | ||
} | ||
} | ||
return result; | ||
} | ||
} |
{ | ||
"name": "@canvas-js/utils", | ||
"version": "0.13.0-next.2", | ||
"version": "0.13.0-next.3", | ||
"author": "Canvas Technologies, Inc. (https://canvas.xyz)", | ||
@@ -19,4 +19,4 @@ "type": "module", | ||
"dependencies": { | ||
"@canvas-js/interfaces": "0.13.0-next.2" | ||
"@canvas-js/interfaces": "0.13.0-next.3" | ||
} | ||
} |
14377
337
+ Added@canvas-js/interfaces@0.13.0-next.3(transitive)
- Removed@canvas-js/interfaces@0.13.0-next.2(transitive)