@harlem/utilities
Advanced tools
Comparing version 1.1.3 to 1.2.0
export default function clone(value: any): any; |
@@ -1,2 +0,93 @@ | ||
function t(t){return new t.constructor(t)}var r={default:function(){return null},boolean:t,number:t,string:t,error:t,date:t,regexp:t,function:function(t){return t},symbol:function(t){return Object(Symbol.prototype.valueOf.call(t))},array:function(t){return t.map(n)},object:function(t){var r={};for(var e in t)r[e]=n(t[e]);return r},map:function(t){var r=new Map;return t.forEach(function(t,e){r.set(e,n(t))}),r},set:function(t){var r=new Set;return t.forEach(function(t){r.add(n(t))}),r}};function n(t){if("object"!=typeof t||null===t)return t;var n,e=(n=t,Object.prototype.toString.call(n).slice(8,-1)).toLowerCase();return(r[e]||r.default)(t)}exports.clone=n,exports.overwrite=function(t,r){if("object"!=typeof t||"object"!=typeof r)return t;var n;for(n in t)n in r?t[n]=r[n]:delete t[n];return t}; | ||
var harlemUtilities = (() => { | ||
var __defProp = Object.defineProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, {get: all[name], enumerable: true}); | ||
}; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
clone: () => clone, | ||
overwrite: () => overwrite_default | ||
}); | ||
// src/clone.ts | ||
function getType(input) { | ||
return Object.prototype.toString.call(input).slice(8, -1); | ||
} | ||
function cloneIdentity(input) { | ||
return input; | ||
} | ||
function cloneBasic(input) { | ||
return new input.constructor(input); | ||
} | ||
function cloneSymbol(input) { | ||
return Object(Symbol.prototype.valueOf.call(input)); | ||
} | ||
function cloneObject(input) { | ||
const output = {}; | ||
for (const key in input) { | ||
output[key] = clone(input[key]); | ||
} | ||
return output; | ||
} | ||
function cloneArray(input) { | ||
return input.map(clone); | ||
} | ||
function cloneSet(input) { | ||
const output = new Set(); | ||
input.forEach((value) => { | ||
output.add(clone(value)); | ||
}); | ||
return output; | ||
} | ||
function cloneMap(input) { | ||
const output = new Map(); | ||
input.forEach((value, key) => { | ||
output.set(key, clone(value)); | ||
}); | ||
return output; | ||
} | ||
var CLONE_MAP = { | ||
default: () => null, | ||
boolean: cloneBasic, | ||
number: cloneBasic, | ||
string: cloneBasic, | ||
error: cloneBasic, | ||
date: cloneBasic, | ||
regexp: cloneBasic, | ||
function: cloneIdentity, | ||
symbol: cloneSymbol, | ||
array: cloneArray, | ||
object: cloneObject, | ||
map: cloneMap, | ||
set: cloneSet | ||
}; | ||
function clone(value) { | ||
if (typeof value !== "object" || value === null) { | ||
return value; | ||
} | ||
const type = getType(value).toLowerCase(); | ||
const cloner = CLONE_MAP[type] || CLONE_MAP.default; | ||
return cloner(value); | ||
} | ||
// src/overwrite.ts | ||
function overwrite_default(source, value) { | ||
if (typeof source !== "object" || typeof value !== "object") { | ||
return source; | ||
} | ||
let prop; | ||
for (prop in source) { | ||
if (prop in value) { | ||
source[prop] = value[prop]; | ||
continue; | ||
} | ||
delete source[prop]; | ||
} | ||
return source; | ||
} | ||
return src_exports; | ||
})(); | ||
//# sourceMappingURL=harlem-utilities.js.map |
@@ -1,2 +0,2 @@ | ||
var harlemUtilities=function(t){function n(t){return new t.constructor(t)}var r={default:function(){return null},boolean:n,number:n,string:n,error:n,date:n,regexp:n,function:function(t){return t},symbol:function(t){return Object(Symbol.prototype.valueOf.call(t))},array:function(t){return t.map(e)},object:function(t){var n={};for(var r in t)n[r]=e(t[r]);return n},map:function(t){var n=new Map;return t.forEach(function(t,r){n.set(r,e(t))}),n},set:function(t){var n=new Set;return t.forEach(function(t){n.add(e(t))}),n}};function e(t){if("object"!=typeof t||null===t)return t;var n,e=(n=t,Object.prototype.toString.call(n).slice(8,-1)).toLowerCase();return(r[e]||r.default)(t)}return t.clone=e,t.overwrite=function(t,n){if("object"!=typeof t||"object"!=typeof n)return t;var r;for(r in t)r in n?t[r]=n[r]:delete t[r];return t},t}({}); | ||
var harlemUtilities=(()=>{var f=Object.defineProperty;var l=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})};var S={};l(S,{clone:()=>o,overwrite:()=>c});function u(n){return Object.prototype.toString.call(n).slice(8,-1)}function i(n){return n}function r(n){return new n.constructor(n)}function p(n){return Object(Symbol.prototype.valueOf.call(n))}function s(n){let t={};for(let e in n)t[e]=o(n[e]);return t}function d(n){return n.map(o)}function b(n){let t=new Set;return n.forEach(e=>{t.add(o(e))}),t}function m(n){let t=new Map;return n.forEach((e,y)=>{t.set(y,o(e))}),t}var a={default:()=>null,boolean:r,number:r,string:r,error:r,date:r,regexp:r,function:i,symbol:p,array:d,object:s,map:m,set:b};function o(n){if(typeof n!="object"||n===null)return n;let t=u(n).toLowerCase();return(a[t]||a.default)(n)}function c(n,t){if(typeof n!="object"||typeof t!="object")return n;let e;for(e in n){if(e in t){n[e]=t[e];continue}delete n[e]}return n}return S;})(); | ||
//# sourceMappingURL=harlem-utilities.min.js.map |
export { default as clone } from './clone'; | ||
export { default as overwrite } from './overwrite'; |
export default function <T extends object>(source: T, value: any): any; |
{ | ||
"name": "@harlem/utilities", | ||
"version": "1.1.3", | ||
"amdName": "harlemUtilities", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -8,12 +9,13 @@ "author": "Andrew Courtice <andrewcourtice@users.noreply.github.com>", | ||
"homepage": "https://harlemjs.com", | ||
"main": "dist/harlem-utilities.js", | ||
"module": "dist/harlem-utilities.esm.js", | ||
"umd:main": "dist/harlem-utilities.umd.js", | ||
"unpkg": "dist/harlem-utilities.js", | ||
"main": "dist/harlem-utilities.cjs.js", | ||
"module": "dist/harlem-utilities.mjs", | ||
"unpkg": "dist/harlem-utilities.min.js", | ||
"types": "dist/index.d.ts", | ||
"source": "src/index.ts", | ||
"exports": { | ||
"require": "./dist/harlem-utilities.js", | ||
"import": "./dist/harlem-utilities.esm.js", | ||
"default": "./dist/harlem-utilities.esm.js" | ||
".": { | ||
"require": "./dist/harlem-utilities.cjs.js", | ||
"browser": "./dist/harlem-utilities.mjs", | ||
"import": "./dist/harlem-utilities.mjs" | ||
} | ||
}, | ||
@@ -37,6 +39,6 @@ "keywords": [ | ||
"dev": "microbundle watch --raw", | ||
"build": "microbundle build --raw", | ||
"build": "node build.js", | ||
"prepublish": "yarn build" | ||
}, | ||
"gitHead": "4345a656ed321f5210032f07627c9e146118bbd2" | ||
"gitHead": "549873cf8d6a6c7d1871e79ca6f11e87d3858004" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
36799
24
439
1