+1
-0
@@ -16,2 +16,3 @@ # fast-copy CHANGELOG | ||
| - Can now create a custom copier, allowing maximum performance for specific use-cases | ||
| - Correctly handle primitive wrappers, e.g. `new String('foo')` | ||
@@ -18,0 +19,0 @@ ## 2.1.7 |
+129
-54
@@ -8,2 +8,5 @@ 'use strict'; | ||
| var toStringObject = Object.prototype.toString; | ||
| /** | ||
| * @classdesc Fallback cache for when WeakMap is not natively supported | ||
| */ | ||
| var LegacyCache = /** @class */ (function () { | ||
@@ -99,8 +102,13 @@ function LegacyCache() { | ||
| } | ||
| /** | ||
| * Get the properites used when copying objects strictly. This includes both keys and symbols. | ||
| */ | ||
| var getStrictProperties = SUPPORTS_SYMBOL | ||
| ? getStrictPropertiesModern | ||
| : getOwnPropertyNames; | ||
| /** | ||
| * Striclty copy all properties contained on the object. | ||
| */ | ||
| function copyOwnPropertiesStrict(value, clone, state) { | ||
| var properties = getStrictProperties(value); | ||
| var copier = state.copier; | ||
| for (var index = 0, length_1 = properties.length, property = void 0, descriptor = void 0; index < length_1; ++index) { | ||
@@ -115,3 +123,3 @@ property = properties[index]; | ||
| // the loose assignment. | ||
| clone[property] = copier(value[property], state); | ||
| clone[property] = state.copier(value[property], state); | ||
| continue; | ||
@@ -121,3 +129,3 @@ } | ||
| if (!descriptor.get && !descriptor.set) { | ||
| descriptor.value = copier(descriptor.value, state); | ||
| descriptor.value = state.copier(descriptor.value, state); | ||
| } | ||
@@ -134,37 +142,62 @@ try { | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| function copyArrayLoose(array, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(array, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| for (var index = 0, length_2 = array.length; index < length_2; ++index) { | ||
| clone[index] = copier(array[index], state); | ||
| clone[index] = state.copier(array[index], state); | ||
| } | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| function copyArrayStrict(array, state) { | ||
| var clone = new state.Constructor(); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| return copyOwnPropertiesStrict(array, clone, state); | ||
| } | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| function copyArrayBuffer(arrayBuffer, _state) { | ||
| return arrayBuffer.slice(0); | ||
| } | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| function copyBlob(blob, _state) { | ||
| return blob.slice(0, blob.size, blob.type); | ||
| } | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| function copyDataView(dataView, state) { | ||
| return new state.Constructor(copyArrayBuffer(dataView.buffer)); | ||
| } | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| function copyDate(date, state) { | ||
| return new state.Constructor(date.getTime()); | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| function copyMapLoose(map, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(map, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(map, clone); | ||
| map.forEach(function (value, key) { | ||
| clone.set(key, copier(value, state)); | ||
| clone.set(key, state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| function copyMapStrict(map, state) { | ||
@@ -175,8 +208,7 @@ return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state); | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -188,8 +220,7 @@ } | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -201,3 +232,3 @@ } | ||
| if (propertyIsEnumerable.call(object, symbol)) { | ||
| clone[symbol] = copier(object[symbol], state); | ||
| clone[symbol] = state.copier(object[symbol], state); | ||
| } | ||
@@ -208,4 +239,3 @@ } | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
@@ -216,4 +246,4 @@ var copyObjectLoose = SUPPORTS_SYMBOL | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
@@ -226,2 +256,11 @@ function copyObjectStrict(object, state) { | ||
| } | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| function copyPrimitiveWrapper(primitiveObject, state) { | ||
| return new state.Constructor(primitiveObject.valueOf()); | ||
| } | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| function copyRegExp(regExp, state) { | ||
@@ -232,14 +271,26 @@ var clone = new state.Constructor(regExp.source, getRegExpFlags(regExp)); | ||
| } | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| function copySelf(value, _state) { | ||
| return value; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| function copySetLoose(set, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(set, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(set, clone); | ||
| set.forEach(function (value) { | ||
| clone.add(copier(value, state)); | ||
| clone.add(state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| function copySetStrict(set, state) { | ||
@@ -250,33 +301,62 @@ return copyOwnPropertiesStrict(set, copySetLoose(set, state), state); | ||
| var isArray = Array.isArray; | ||
| var getPrototypeOf = Object.getPrototypeOf; | ||
| var assign = Object.assign, getPrototypeOf = Object.getPrototypeOf; | ||
| var DEFAULT_LOOSE_OPTIONS = { | ||
| array: copyArrayLoose, | ||
| arrayBuffer: copyArrayBuffer, | ||
| blob: copyBlob, | ||
| dataView: copyDataView, | ||
| date: copyDate, | ||
| error: copySelf, | ||
| map: copyMapLoose, | ||
| object: copyObjectLoose, | ||
| regExp: copyRegExp, | ||
| set: copySetLoose, | ||
| }; | ||
| var DEFAULT_STRICT_OPTIONS = assign({}, DEFAULT_LOOSE_OPTIONS, { | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }); | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| * Get the copiers used for each specific object tag. | ||
| */ | ||
| function createCopier(options) { | ||
| var _a = options.array, array = _a === void 0 ? copyArrayLoose : _a, _b = options.arrayBuffer, arrayBuffer = _b === void 0 ? copyArrayBuffer : _b, _c = options.blob, blob = _c === void 0 ? copyBlob : _c, _d = options.dataView, dataView = _d === void 0 ? copyDataView : _d, _e = options.date, date = _e === void 0 ? copyDate : _e, _f = options.error, error = _f === void 0 ? copySelf : _f, _g = options.map, map = _g === void 0 ? copyMapLoose : _g, _h = options.object, object = _h === void 0 ? copyObjectLoose : _h, _j = options.regExp, regExp = _j === void 0 ? copyRegExp : _j, _k = options.set, set = _k === void 0 ? copySetLoose : _k; | ||
| var tagSpecificCopiers = { | ||
| Array: array, | ||
| ArrayBuffer: arrayBuffer, | ||
| Blob: blob, | ||
| DataView: dataView, | ||
| Date: date, | ||
| Error: error, | ||
| Float32Array: arrayBuffer, | ||
| Float64Array: arrayBuffer, | ||
| Int8Array: arrayBuffer, | ||
| Int16Array: arrayBuffer, | ||
| Int32Array: arrayBuffer, | ||
| Map: map, | ||
| Object: object, | ||
| function getTagSpecificCopiers(options) { | ||
| return { | ||
| Arguments: options.object, | ||
| Array: options.array, | ||
| ArrayBuffer: options.arrayBuffer, | ||
| Blob: options.blob, | ||
| Boolean: copyPrimitiveWrapper, | ||
| DataView: options.dataView, | ||
| Date: options.date, | ||
| Error: options.error, | ||
| Float32Array: options.arrayBuffer, | ||
| Float64Array: options.arrayBuffer, | ||
| Int8Array: options.arrayBuffer, | ||
| Int16Array: options.arrayBuffer, | ||
| Int32Array: options.arrayBuffer, | ||
| Map: options.map, | ||
| Number: copyPrimitiveWrapper, | ||
| Object: options.object, | ||
| Promise: copySelf, | ||
| RegExp: regExp, | ||
| Set: set, | ||
| RegExp: options.regExp, | ||
| Set: options.set, | ||
| String: copyPrimitiveWrapper, | ||
| WeakMap: copySelf, | ||
| WeakSet: copySelf, | ||
| Uint8Array: arrayBuffer, | ||
| Uint8ClampedArray: arrayBuffer, | ||
| Uint16Array: arrayBuffer, | ||
| Uint32Array: arrayBuffer, | ||
| Uint64Array: arrayBuffer, | ||
| Uint8Array: options.arrayBuffer, | ||
| Uint8ClampedArray: options.arrayBuffer, | ||
| Uint16Array: options.arrayBuffer, | ||
| Uint32Array: options.arrayBuffer, | ||
| Uint64Array: options.arrayBuffer, | ||
| }; | ||
| } | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| */ | ||
| function createCopier(options) { | ||
| var normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options); | ||
| var tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions); | ||
| var array = tagSpecificCopiers.Array, object = tagSpecificCopiers.Object; | ||
| function copier(value, state) { | ||
@@ -320,8 +400,3 @@ state.prototype = state.Constructor = undefined; | ||
| function createStrictCopier(options) { | ||
| return createCopier(Object.assign({ | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }, options)); | ||
| return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options)); | ||
| } | ||
@@ -328,0 +403,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["import type { CreateCopierOptions } from './index';\n\nexport interface Cache {\n _keys?: any[];\n _values?: any[];\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\nclass LegacyCache {\n _keys: any[] = [];\n _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value = any> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\nfunction copyOwnPropertiesStrict<Value extends any>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n const { copier } = state;\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n const { cache, copier } = state;\n\n cache.set(array, clone);\n\n for (let index: number = 0, length = array.length; index < length; ++index) {\n clone[index] = copier(array[index], state);\n }\n\n return clone;\n}\n\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, copier(value, state));\n });\n\n return clone;\n}\n\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n const symbols: symbol[] = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Get a copy of the object based on loose rules, meaning all enumerable keys\n * and symbols are copied, but property descriptors are not considered.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Get a copy of the object based on strict rules, meaning all keys and symbols\n * are copied based on the original property descriptors.\n */\nexport function copyObjectStrict<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(copier(value, state));\n });\n\n return clone;\n}\n\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const {\n array = copyArrayLoose,\n arrayBuffer = copyArrayBuffer,\n blob = copyBlob,\n dataView = copyDataView,\n date = copyDate,\n error = copySelf,\n map = copyMapLoose,\n object = copyObjectLoose,\n regExp = copyRegExp,\n set = copySetLoose,\n } = options;\n\n const tagSpecificCopiers: Record<string, InternalCopier> = {\n Array: array,\n ArrayBuffer: arrayBuffer,\n Blob: blob,\n DataView: dataView,\n Date: date,\n Error: error,\n Float32Array: arrayBuffer,\n Float64Array: arrayBuffer,\n Int8Array: arrayBuffer,\n Int16Array: arrayBuffer,\n Int32Array: arrayBuffer,\n Map: map,\n Object: object,\n Promise: copySelf,\n RegExp: regExp,\n Set: set,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: arrayBuffer,\n Uint8ClampedArray: arrayBuffer,\n Uint16Array: arrayBuffer,\n Uint32Array: arrayBuffer,\n Uint64Array: arrayBuffer,\n };\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(\n Object.assign(\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n },\n options\n )\n );\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":";;;;AAUQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;AAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,CAAY;AAClB,IAAU,cAAc,GAAK,MAAM,CAAC,SAAS,SAArB,CAAsB;AAEtD,IAAA,WAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,WAAA,GAAA;QACE,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;QAClB,IAAO,CAAA,OAAA,GAAU,E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E;AACnB,YAAA,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,WAAW,EAAE;AACpB,YAAA,MAAM,EAAA,MAAA;AACN,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC,CAAC;AACL,KAAC,CAAC;AACJ,CAAC;AAED;;;AAGG;AACG,SAAU,kBAAkB,CAAC,OAA4B,EAAA;AAC7D,IAAA,OAAO,YAAY,CACjB,MAAM,CAAC,MAAM,CACX;AACE,QAAA,KAAK,EAAE,eAAe;AACtB,QAAA,GAAG,EAAE,aAAa;AAClB,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,GAAG,EAAE,aAAa;KACnB,EACD,OAAO,CACR,CACF,CAAC;AACJ,CAAC;AAED;;;;AAIG;IACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;AAEjD;;AAEG;AACH,YAAe,YAAY,CAAC,EAAE,CAAC;;;;;;;"} | ||
| {"version":3,"file":"index.cjs","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\n/**\n * @classdesc Fallback cache for when WeakMap is not natively supported\n */\nclass LegacyCache {\n private _keys: any[] = [];\n private _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier<any>;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\n/**\n * Get the properites used when copying objects strictly. This includes both keys and symbols.\n */\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\n/**\n * Striclty copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = state.copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = state.copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0, length = array.length; index < length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer.\n */\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n const symbols = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/ban-types\n Value extends Boolean | Number | String\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { assign, getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\nconst DEFAULT_LOOSE_OPTIONS: Required<CreateCopierOptions> = {\n array: copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n blob: copyBlob,\n dataView: copyDataView,\n date: copyDate,\n error: copySelf,\n map: copyMapLoose,\n object: copyObjectLoose,\n regExp: copyRegExp,\n set: copySetLoose,\n};\nconst DEFAULT_STRICT_OPTIONS: Required<CreateCopierOptions> = assign(\n {},\n DEFAULT_LOOSE_OPTIONS,\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n }\n);\n\n/**\n * Get the copiers used for each specific object tag.\n */\nfunction getTagSpecificCopiers(\n options: Required<CreateCopierOptions>\n): Record<string, InternalCopier<any>> {\n return {\n Arguments: options.object,\n Array: options.array,\n ArrayBuffer: options.arrayBuffer,\n Blob: options.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: options.dataView,\n Date: options.date,\n Error: options.error,\n Float32Array: options.arrayBuffer,\n Float64Array: options.arrayBuffer,\n Int8Array: options.arrayBuffer,\n Int16Array: options.arrayBuffer,\n Int32Array: options.arrayBuffer,\n Map: options.map,\n Number: copyPrimitiveWrapper,\n Object: options.object,\n Promise: copySelf,\n RegExp: options.regExp,\n Set: options.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: options.arrayBuffer,\n Uint8ClampedArray: options.arrayBuffer,\n Uint16Array: options.arrayBuffer,\n Uint32Array: options.arrayBuffer,\n Uint64Array: options.arrayBuffer,\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);\n const tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);\n const { Array: array, Object: object } = tagSpecificCopiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":";;;;AAMQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;AAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,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,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5B,SAAA;QAED,IAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAE5D,QAAA,IAAI,iBAAiB,EAAE;AACrB,YAAA,OAAO,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxC,SAAA;AAED,QAAA,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACxE;IAED,OAAO,SAAS,IAAI,CAAQ,KAAY,EAAA;QACtC,OAAO,MAAM,CAAC,KAAK,EAAE;AACnB,YAAA,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,WAAW,EAAE;AACpB,YAAA,MAAM,EAAA,MAAA;AACN,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC,CAAC;AACL,KAAC,CAAC;AACJ,CAAC;AAED;;;AAGG;AACG,SAAU,kBAAkB,CAAC,OAA4B,EAAA;IAC7D,OAAO,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;AAIG;IACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;AAEjD;;AAEG;AACH,YAAe,YAAY,CAAC,EAAE,CAAC;;;;;;;"} |
| import type { Cache } from './utils'; | ||
| export declare type InternalCopier<Value = any> = (value: Value, state: State) => Value; | ||
| export declare type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
| export interface State { | ||
| Constructor: any; | ||
| cache: Cache; | ||
| copier: InternalCopier; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| export declare function copyArrayLoose(array: any[], state: State): any; | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| export declare function copyArrayStrict<Value extends any[]>(array: Value, state: State): Value; | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| export declare function copyArrayBuffer<Value extends ArrayBuffer>(arrayBuffer: Value, _state: State): Value; | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| export declare function copyBlob<Value extends Blob>(blob: Value, _state: State): Value; | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| export declare function copyDataView<Value extends DataView>(dataView: Value, state: State): Value; | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| export declare function copyDate<Value extends Date>(date: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| export declare function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends {}>(object: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
| export declare const copyObjectLoose: typeof copyObjectLooseModern; | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
| export declare function copyObjectStrict<Value extends {}>(object: Value, state: State): Value; | ||
| export declare function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| export declare function copyPrimitiveWrapper<Value extends Boolean | Number | String>(primitiveObject: Value, state: State): Value; | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| export declare function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value; | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| export declare function copySelf<Value>(value: Value, _state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| export declare function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value; | ||
| export {}; |
| export interface Cache { | ||
| _keys?: any[]; | ||
| _values?: any[]; | ||
| has: (value: any) => boolean; | ||
@@ -22,7 +20,7 @@ set: (key: any, value: any) => void; | ||
| export declare const getRegExpFlags: typeof getRegExpFlagsModern; | ||
| declare function getTagModern(value: any): string; | ||
| declare function getTagLegacy(value: any): string; | ||
| /** | ||
| * Get the tag of the value passed, so that the correct copier can be used. | ||
| */ | ||
| export declare const getTag: typeof getTagModern; | ||
| export declare const getTag: typeof getTagLegacy; | ||
| export {}; |
+129
-54
| var toStringFunction = Function.prototype.toString; | ||
| var create = Object.create; | ||
| var toStringObject = Object.prototype.toString; | ||
| /** | ||
| * @classdesc Fallback cache for when WeakMap is not natively supported | ||
| */ | ||
| var LegacyCache = /** @class */ (function () { | ||
@@ -94,8 +97,13 @@ function LegacyCache() { | ||
| } | ||
| /** | ||
| * Get the properites used when copying objects strictly. This includes both keys and symbols. | ||
| */ | ||
| var getStrictProperties = SUPPORTS_SYMBOL | ||
| ? getStrictPropertiesModern | ||
| : getOwnPropertyNames; | ||
| /** | ||
| * Striclty copy all properties contained on the object. | ||
| */ | ||
| function copyOwnPropertiesStrict(value, clone, state) { | ||
| var properties = getStrictProperties(value); | ||
| var copier = state.copier; | ||
| for (var index = 0, length_1 = properties.length, property = void 0, descriptor = void 0; index < length_1; ++index) { | ||
@@ -110,3 +118,3 @@ property = properties[index]; | ||
| // the loose assignment. | ||
| clone[property] = copier(value[property], state); | ||
| clone[property] = state.copier(value[property], state); | ||
| continue; | ||
@@ -116,3 +124,3 @@ } | ||
| if (!descriptor.get && !descriptor.set) { | ||
| descriptor.value = copier(descriptor.value, state); | ||
| descriptor.value = state.copier(descriptor.value, state); | ||
| } | ||
@@ -129,37 +137,62 @@ try { | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| function copyArrayLoose(array, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(array, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| for (var index = 0, length_2 = array.length; index < length_2; ++index) { | ||
| clone[index] = copier(array[index], state); | ||
| clone[index] = state.copier(array[index], state); | ||
| } | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| function copyArrayStrict(array, state) { | ||
| var clone = new state.Constructor(); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| return copyOwnPropertiesStrict(array, clone, state); | ||
| } | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| function copyArrayBuffer(arrayBuffer, _state) { | ||
| return arrayBuffer.slice(0); | ||
| } | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| function copyBlob(blob, _state) { | ||
| return blob.slice(0, blob.size, blob.type); | ||
| } | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| function copyDataView(dataView, state) { | ||
| return new state.Constructor(copyArrayBuffer(dataView.buffer)); | ||
| } | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| function copyDate(date, state) { | ||
| return new state.Constructor(date.getTime()); | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| function copyMapLoose(map, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(map, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(map, clone); | ||
| map.forEach(function (value, key) { | ||
| clone.set(key, copier(value, state)); | ||
| clone.set(key, state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| function copyMapStrict(map, state) { | ||
@@ -170,8 +203,7 @@ return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state); | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -183,8 +215,7 @@ } | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -196,3 +227,3 @@ } | ||
| if (propertyIsEnumerable.call(object, symbol)) { | ||
| clone[symbol] = copier(object[symbol], state); | ||
| clone[symbol] = state.copier(object[symbol], state); | ||
| } | ||
@@ -203,4 +234,3 @@ } | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
@@ -211,4 +241,4 @@ var copyObjectLoose = SUPPORTS_SYMBOL | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
@@ -221,2 +251,11 @@ function copyObjectStrict(object, state) { | ||
| } | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| function copyPrimitiveWrapper(primitiveObject, state) { | ||
| return new state.Constructor(primitiveObject.valueOf()); | ||
| } | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| function copyRegExp(regExp, state) { | ||
@@ -227,14 +266,26 @@ var clone = new state.Constructor(regExp.source, getRegExpFlags(regExp)); | ||
| } | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| function copySelf(value, _state) { | ||
| return value; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| function copySetLoose(set, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(set, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(set, clone); | ||
| set.forEach(function (value) { | ||
| clone.add(copier(value, state)); | ||
| clone.add(state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| function copySetStrict(set, state) { | ||
@@ -245,33 +296,62 @@ return copyOwnPropertiesStrict(set, copySetLoose(set, state), state); | ||
| var isArray = Array.isArray; | ||
| var getPrototypeOf = Object.getPrototypeOf; | ||
| var assign = Object.assign, getPrototypeOf = Object.getPrototypeOf; | ||
| var DEFAULT_LOOSE_OPTIONS = { | ||
| array: copyArrayLoose, | ||
| arrayBuffer: copyArrayBuffer, | ||
| blob: copyBlob, | ||
| dataView: copyDataView, | ||
| date: copyDate, | ||
| error: copySelf, | ||
| map: copyMapLoose, | ||
| object: copyObjectLoose, | ||
| regExp: copyRegExp, | ||
| set: copySetLoose, | ||
| }; | ||
| var DEFAULT_STRICT_OPTIONS = assign({}, DEFAULT_LOOSE_OPTIONS, { | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }); | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| * Get the copiers used for each specific object tag. | ||
| */ | ||
| function createCopier(options) { | ||
| var _a = options.array, array = _a === void 0 ? copyArrayLoose : _a, _b = options.arrayBuffer, arrayBuffer = _b === void 0 ? copyArrayBuffer : _b, _c = options.blob, blob = _c === void 0 ? copyBlob : _c, _d = options.dataView, dataView = _d === void 0 ? copyDataView : _d, _e = options.date, date = _e === void 0 ? copyDate : _e, _f = options.error, error = _f === void 0 ? copySelf : _f, _g = options.map, map = _g === void 0 ? copyMapLoose : _g, _h = options.object, object = _h === void 0 ? copyObjectLoose : _h, _j = options.regExp, regExp = _j === void 0 ? copyRegExp : _j, _k = options.set, set = _k === void 0 ? copySetLoose : _k; | ||
| var tagSpecificCopiers = { | ||
| Array: array, | ||
| ArrayBuffer: arrayBuffer, | ||
| Blob: blob, | ||
| DataView: dataView, | ||
| Date: date, | ||
| Error: error, | ||
| Float32Array: arrayBuffer, | ||
| Float64Array: arrayBuffer, | ||
| Int8Array: arrayBuffer, | ||
| Int16Array: arrayBuffer, | ||
| Int32Array: arrayBuffer, | ||
| Map: map, | ||
| Object: object, | ||
| function getTagSpecificCopiers(options) { | ||
| return { | ||
| Arguments: options.object, | ||
| Array: options.array, | ||
| ArrayBuffer: options.arrayBuffer, | ||
| Blob: options.blob, | ||
| Boolean: copyPrimitiveWrapper, | ||
| DataView: options.dataView, | ||
| Date: options.date, | ||
| Error: options.error, | ||
| Float32Array: options.arrayBuffer, | ||
| Float64Array: options.arrayBuffer, | ||
| Int8Array: options.arrayBuffer, | ||
| Int16Array: options.arrayBuffer, | ||
| Int32Array: options.arrayBuffer, | ||
| Map: options.map, | ||
| Number: copyPrimitiveWrapper, | ||
| Object: options.object, | ||
| Promise: copySelf, | ||
| RegExp: regExp, | ||
| Set: set, | ||
| RegExp: options.regExp, | ||
| Set: options.set, | ||
| String: copyPrimitiveWrapper, | ||
| WeakMap: copySelf, | ||
| WeakSet: copySelf, | ||
| Uint8Array: arrayBuffer, | ||
| Uint8ClampedArray: arrayBuffer, | ||
| Uint16Array: arrayBuffer, | ||
| Uint32Array: arrayBuffer, | ||
| Uint64Array: arrayBuffer, | ||
| Uint8Array: options.arrayBuffer, | ||
| Uint8ClampedArray: options.arrayBuffer, | ||
| Uint16Array: options.arrayBuffer, | ||
| Uint32Array: options.arrayBuffer, | ||
| Uint64Array: options.arrayBuffer, | ||
| }; | ||
| } | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| */ | ||
| function createCopier(options) { | ||
| var normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options); | ||
| var tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions); | ||
| var array = tagSpecificCopiers.Array, object = tagSpecificCopiers.Object; | ||
| function copier(value, state) { | ||
@@ -315,8 +395,3 @@ state.prototype = state.Constructor = undefined; | ||
| function createStrictCopier(options) { | ||
| return createCopier(Object.assign({ | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }, options)); | ||
| return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options)); | ||
| } | ||
@@ -323,0 +398,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.mjs","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["import type { CreateCopierOptions } from './index';\n\nexport interface Cache {\n _keys?: any[];\n _values?: any[];\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\nclass LegacyCache {\n _keys: any[] = [];\n _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value = any> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\nfunction copyOwnPropertiesStrict<Value extends any>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n const { copier } = state;\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n const { cache, copier } = state;\n\n cache.set(array, clone);\n\n for (let index: number = 0, length = array.length; index < length; ++index) {\n clone[index] = copier(array[index], state);\n }\n\n return clone;\n}\n\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, copier(value, state));\n });\n\n return clone;\n}\n\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n const symbols: symbol[] = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Get a copy of the object based on loose rules, meaning all enumerable keys\n * and symbols are copied, but property descriptors are not considered.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Get a copy of the object based on strict rules, meaning all keys and symbols\n * are copied based on the original property descriptors.\n */\nexport function copyObjectStrict<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(copier(value, state));\n });\n\n return clone;\n}\n\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const {\n array = copyArrayLoose,\n arrayBuffer = copyArrayBuffer,\n blob = copyBlob,\n dataView = copyDataView,\n date = copyDate,\n error = copySelf,\n map = copyMapLoose,\n object = copyObjectLoose,\n regExp = copyRegExp,\n set = copySetLoose,\n } = options;\n\n const tagSpecificCopiers: Record<string, InternalCopier> = {\n Array: array,\n ArrayBuffer: arrayBuffer,\n Blob: blob,\n DataView: dataView,\n Date: date,\n Error: error,\n Float32Array: arrayBuffer,\n Float64Array: arrayBuffer,\n Int8Array: arrayBuffer,\n Int16Array: arrayBuffer,\n Int32Array: arrayBuffer,\n Map: map,\n Object: object,\n Promise: copySelf,\n RegExp: regExp,\n Set: set,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: arrayBuffer,\n Uint8ClampedArray: arrayBuffer,\n Uint16Array: arrayBuffer,\n Uint32Array: arrayBuffer,\n Uint64Array: arrayBuffer,\n };\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(\n Object.assign(\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n },\n options\n )\n );\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":"AAUQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;AAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,CAAY;AAClB,IAAU,cAAc,GAAK,MAAM,CAAC,SAAS,SAArB,CAAsB;AAEtD,IAAA,WAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,WAAA,GAAA;QACE,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;QAClB,IAAO,CAAA,OAAA,GAAU,EAAE,CAAC;KAcrB;IAZC,WAAG,CAAA,SAAA,CAAA,GAAA,GAAH,UAAI,GAAQ,EAAA;QACV,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KACnC,CAAA;IAED,WAAG,CAAA,SAAA,CAAA,GAAA,GAAH,UAAI,GAAQ,EAAA;AACV,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KAC9C,CAAA;AAED,IAAA,WAAA,CAAA,SAAA,CAAA,GAAG,GAAH,UAAI,GAAQ,EAAE,KAAU,EAAA;AACtB,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC1B,CAAA;IACH,OAAC,WAAA,CAAA;AAAD,CAAC,EAAA,CAAA,CAAA;AAED,SAAS,iBAAiB,GAAA;IACxB,OAAO,IAAI,WAAW,EAAE,CAAC;AA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AK,EAAE,KAAK,CAAC,CAAC;AAC7B,SAAA;;AAGD,QAAA,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;AAClB,YAAA,OAAO,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5B,SAAA;QAED,IAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAE5D,QAAA,IAAI,iBAAiB,EAAE;AACrB,YAAA,OAAO,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxC,SAAA;AAED,QAAA,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACxE;IAED,OAAO,SAAS,IAAI,CAAQ,KAAY,EAAA;QACtC,OAAO,MAAM,CAAC,KAAK,EAAE;AACnB,YAAA,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,WAAW,EAAE;AACpB,YAAA,MAAM,EAAA,MAAA;AACN,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC,CAAC;AACL,KAAC,CAAC;AACJ,CAAC;AAED;;;AAGG;AACG,SAAU,kBAAkB,CAAC,OAA4B,EAAA;AAC7D,IAAA,OAAO,YAAY,CACjB,MAAM,CAAC,MAAM,CACX;AACE,QAAA,KAAK,EAAE,eAAe;AACtB,QAAA,GAAG,EAAE,aAAa;AAClB,QAAA,MAAM,EAAE,gBAAgB;AACxB,QAAA,GAAG,EAAE,aAAa;KACnB,EACD,OAAO,CACR,CACF,CAAC;AACJ,CAAC;AAED;;;;AAIG;IACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;AAEjD;;AAEG;AACH,YAAe,YAAY,CAAC,EAAE,CAAC;;;;"} | ||
| {"version":3,"file":"index.mjs","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\n/**\n * @classdesc Fallback cache for when WeakMap is not natively supported\n */\nclass LegacyCache {\n private _keys: any[] = [];\n private _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier<any>;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\n/**\n * Get the properites used when copying objects strictly. This includes both keys and symbols.\n */\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\n/**\n * Striclty copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = state.copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = state.copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0, length = array.length; index < length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer.\n */\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n const symbols = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/ban-types\n Value extends Boolean | Number | String\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { assign, getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\nconst DEFAULT_LOOSE_OPTIONS: Required<CreateCopierOptions> = {\n array: copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n blob: copyBlob,\n dataView: copyDataView,\n date: copyDate,\n error: copySelf,\n map: copyMapLoose,\n object: copyObjectLoose,\n regExp: copyRegExp,\n set: copySetLoose,\n};\nconst DEFAULT_STRICT_OPTIONS: Required<CreateCopierOptions> = assign(\n {},\n DEFAULT_LOOSE_OPTIONS,\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n }\n);\n\n/**\n * Get the copiers used for each specific object tag.\n */\nfunction getTagSpecificCopiers(\n options: Required<CreateCopierOptions>\n): Record<string, InternalCopier<any>> {\n return {\n Arguments: options.object,\n Array: options.array,\n ArrayBuffer: options.arrayBuffer,\n Blob: options.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: options.dataView,\n Date: options.date,\n Error: options.error,\n Float32Array: options.arrayBuffer,\n Float64Array: options.arrayBuffer,\n Int8Array: options.arrayBuffer,\n Int16Array: options.arrayBuffer,\n Int32Array: options.arrayBuffer,\n Map: options.map,\n Number: copyPrimitiveWrapper,\n Object: options.object,\n Promise: copySelf,\n RegExp: options.regExp,\n Set: options.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: options.arrayBuffer,\n Uint8ClampedArray: options.arrayBuffer,\n Uint16Array: options.arrayBuffer,\n Uint32Array: options.arrayBuffer,\n Uint64Array: options.arrayBuffer,\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);\n const tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);\n const { Array: array, Object: object } = tagSpecificCopiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":"AAMQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;AAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,CAAY;AAClB,IAAU,cAAc,GAAK,MAAM,CAAC,SAAS,SAArB,CAAsB;AAEtD;;AAEG;AACH,IAAA,WAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,WAAA,GAAA;QACU,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;QAClB,IAAO,CAAA,OAAA,GAAU,EAAE,CAAC;KAc7B;IAZC,WAAG,CAAA,SAAA,CAAA,GAAA,GAAH,UAAI,GAAQ,EAAA;QACV,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;KACnC,CAAA;IAED,WAAG,CAAA,SAAA,CAAA,GAAA,GAAH,UAAI,GAAQ,EAAA;AACV,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KAC9C,CAAA;AAED,IAAA,WAAA,CAAA,SAAA,CAAA,GAAG,GAAH,UAAI,GAAQ,EAAE,KAAU,EAAA;AACtB,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,C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C,EAAE,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;AAIG;IACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;AAEjD;;AAEG;AACH,YAAe,YAAY,CAAC,EAAE,CAAC;;;;"} |
| import type { Cache } from './utils'; | ||
| export declare type InternalCopier<Value = any> = (value: Value, state: State) => Value; | ||
| export declare type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
| export interface State { | ||
| Constructor: any; | ||
| cache: Cache; | ||
| copier: InternalCopier; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| export declare function copyArrayLoose(array: any[], state: State): any; | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| export declare function copyArrayStrict<Value extends any[]>(array: Value, state: State): Value; | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| export declare function copyArrayBuffer<Value extends ArrayBuffer>(arrayBuffer: Value, _state: State): Value; | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| export declare function copyBlob<Value extends Blob>(blob: Value, _state: State): Value; | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| export declare function copyDataView<Value extends DataView>(dataView: Value, state: State): Value; | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| export declare function copyDate<Value extends Date>(date: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| export declare function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends {}>(object: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
| export declare const copyObjectLoose: typeof copyObjectLooseModern; | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
| export declare function copyObjectStrict<Value extends {}>(object: Value, state: State): Value; | ||
| export declare function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| export declare function copyPrimitiveWrapper<Value extends Boolean | Number | String>(primitiveObject: Value, state: State): Value; | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| export declare function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value; | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| export declare function copySelf<Value>(value: Value, _state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| export declare function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value; | ||
| export {}; |
| export interface Cache { | ||
| _keys?: any[]; | ||
| _values?: any[]; | ||
| has: (value: any) => boolean; | ||
@@ -22,7 +20,7 @@ set: (key: any, value: any) => void; | ||
| export declare const getRegExpFlags: typeof getRegExpFlagsModern; | ||
| declare function getTagModern(value: any): string; | ||
| declare function getTagLegacy(value: any): string; | ||
| /** | ||
| * Get the tag of the value passed, so that the correct copier can be used. | ||
| */ | ||
| export declare const getTag: typeof getTagModern; | ||
| export declare const getTag: typeof getTagLegacy; | ||
| export {}; |
@@ -1,2 +0,2 @@ | ||
| !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self)["fast-copy"]={})}(this,(function(t){"use strict";var r=Function.prototype.toString,e=Object.create,n=Object.prototype.toString,o=function(){function t(){this._keys=[],this._values=[]}return t.prototype.has=function(t){return!!~this._keys.indexOf(t)},t.prototype.get=function(t){return this._values[this._keys.indexOf(t)]},t.prototype.set=function(t,r){this._keys.push(t),this._values.push(r)},t}();var c="undefined"!=typeof WeakMap?function(){return new WeakMap}:function(){return new o};function i(t){if(!t)return e(null);var n=t.constructor;if(n===Object)return t===Object.prototype?{}:e(t);if(~r.call(n).indexOf("[native code]"))try{return new n}catch(t){}return e(t)}var u="g"===/test/g.flags?function(t){return t.flags}:function(t){var r="";return t.global&&(r+="g"),t.ignoreCase&&(r+="i"),t.multiline&&(r+="m"),t.unicode&&(r+="u"),t.sticky&&(r+="y"),r};function a(t){var r=n.call(t);return r.substring(8,r.length-1)}var f="undefined"!=typeof Symbol?function(t){return t[Symbol.toStringTag]||a(t)}:a,s=Object.defineProperty,p=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,l=Object.getOwnPropertySymbols,v=Object.prototype,d=v.hasOwnProperty,h=v.propertyIsEnumerable,b="function"==typeof l;var g=b?function(t){return y(t).concat(l(t))}:y;function O(t,r,e){for(var n=g(t),o=e.copier,c=0,i=n.length,u=void 0,a=void 0;c<i;++c)if("callee"!==(u=n[c])&&"caller"!==u)if(a=p(t,u)){a.get||a.set||(a.value=o(a.value,e));try{s(r,u,a)}catch(t){r[u]=a.value}}else r[u]=o(t[u],e);return r}function j(t,r){var e=new r.Constructor,n=r.cache,o=r.copier;n.set(t,e);for(var c=0,i=t.length;c<i;++c)e[c]=o(t[c],r);return e}function w(t,r){var e=new r.Constructor;return r.cache.set(t,e),O(t,e,r)}function C(t,r){return t.slice(0)}function m(t,r){return t.slice(0,t.size,t.type)}function A(t,r){return new r.Constructor(C(t.buffer))}function _(t,r){return new r.Constructor(t.getTime())}function x(t,r){var e=new r.Constructor,n=r.cache,o=r.copier;return n.set(t,e),t.forEach((function(t,n){e.set(n,o(t,r))})),e}function S(t,r){return O(t,x(t,r),r)}var k=b?function(t,r){var e=i(r.prototype),n=r.cache,o=r.copier;for(var c in n.set(t,e),t)d.call(t,c)&&(e[c]=o(t[c],r));for(var u=l(t),a=0,f=u.length,s=void 0;a<f;++a)s=u[a],h.call(t,s)&&(e[s]=o(t[s],r));return e}:function(t,r){var e=i(r.prototype),n=r.cache,o=r.copier;for(var c in n.set(t,e),t)d.call(t,c)&&(e[c]=o(t[c],r));return e};function P(t,r){var e=i(r.prototype);return r.cache.set(t,e),O(t,e,r)}function E(t,r){var e=new r.Constructor(t.source,u(t));return e.lastIndex=t.lastIndex,e}function I(t,r){return t}function M(t,r){var e=new r.Constructor,n=r.cache,o=r.copier;return n.set(t,e),t.forEach((function(t){e.add(o(t,r))})),e}function U(t,r){return O(t,M(t,r),r)}var T=Array.isArray,W=Object.getPrototypeOf;function B(t){var r=t.array,e=void 0===r?j:r,n=t.arrayBuffer,o=void 0===n?C:n,i=t.blob,u=void 0===i?m:i,a=t.dataView,s=void 0===a?A:a,p=t.date,y=void 0===p?_:p,l=t.error,v=void 0===l?I:l,d=t.map,h=void 0===d?x:d,b=t.object,g=void 0===b?k:b,O=t.regExp,w=void 0===O?E:O,S=t.set,P={Array:e,ArrayBuffer:o,Blob:u,DataView:s,Date:y,Error:v,Float32Array:o,Float64Array:o,Int8Array:o,Int16Array:o,Int32Array:o,Map:h,Object:g,Promise:I,RegExp:w,Set:void 0===S?M:S,WeakMap:I,WeakSet:I,Uint8Array:o,Uint8ClampedArray:o,Uint16Array:o,Uint32Array:o,Uint64Array:o};function U(t,r){if(r.prototype=r.Constructor=void 0,!t||"object"!=typeof t)return t;if(r.cache.has(t))return r.cache.get(t);if(r.prototype=t.__proto__||W(t),r.Constructor=r.prototype&&r.prototype.constructor,!r.Constructor||r.Constructor===Object)return g(t,r);if(T(t))return e(t,r);var n=P[f(t)];return n?n(t,r):"function"==typeof t.then?t:g(t,r)}return function(t){return U(t,{Constructor:void 0,cache:c(),copier:U,prototype:void 0})}}function D(t){return B(Object.assign({array:w,map:S,object:P,set:U},t))}var F=D({}),V=B({});t.copyStrict=F,t.createCopier=B,t.createStrictCopier=D,t.default=V,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
| !function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r="undefined"!=typeof globalThis?globalThis:r||self)["fast-copy"]={})}(this,(function(r){"use strict";var t=Function.prototype.toString,e=Object.create,n=Object.prototype.toString,o=function(){function r(){this._keys=[],this._values=[]}return r.prototype.has=function(r){return!!~this._keys.indexOf(r)},r.prototype.get=function(r){return this._values[this._keys.indexOf(r)]},r.prototype.set=function(r,t){this._keys.push(r),this._values.push(t)},r}();var a="undefined"!=typeof WeakMap?function(){return new WeakMap}:function(){return new o};function c(r){if(!r)return e(null);var n=r.constructor;if(n===Object)return r===Object.prototype?{}:e(r);if(~t.call(n).indexOf("[native code]"))try{return new n}catch(r){}return e(r)}var u="g"===/test/g.flags?function(r){return r.flags}:function(r){var t="";return r.global&&(t+="g"),r.ignoreCase&&(t+="i"),r.multiline&&(t+="m"),r.unicode&&(t+="u"),r.sticky&&(t+="y"),t};function i(r){var t=n.call(r);return t.substring(8,t.length-1)}var f="undefined"!=typeof Symbol?function(r){return r[Symbol.toStringTag]||i(r)}:i,s=Object.defineProperty,p=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,l=Object.getOwnPropertySymbols,v=Object.prototype,d=v.hasOwnProperty,b=v.propertyIsEnumerable,h="function"==typeof l;var g=h?function(r){return y(r).concat(l(r))}:y;function O(r,t,e){for(var n=g(r),o=0,a=n.length,c=void 0,u=void 0;o<a;++o)if("callee"!==(c=n[o])&&"caller"!==c)if(u=p(r,c)){u.get||u.set||(u.value=e.copier(u.value,e));try{s(t,c,u)}catch(r){t[c]=u.value}}else t[c]=e.copier(r[c],e);return t}function j(r,t){return r.slice(0)}function w(r,t){var e=new t.Constructor;return t.cache.set(r,e),r.forEach((function(r,n){e.set(n,t.copier(r,t))})),e}var m=h?function(r,t){var e=c(t.prototype);for(var n in t.cache.set(r,e),r)d.call(r,n)&&(e[n]=t.copier(r[n],t));for(var o=l(r),a=0,u=o.length,i=void 0;a<u;++a)i=o[a],b.call(r,i)&&(e[i]=t.copier(r[i],t));return e}:function(r,t){var e=c(t.prototype);for(var n in t.cache.set(r,e),r)d.call(r,n)&&(e[n]=t.copier(r[n],t));return e};function C(r,t){return new t.Constructor(r.valueOf())}function A(r,t){return r}function B(r,t){var e=new t.Constructor;return t.cache.set(r,e),r.forEach((function(r){e.add(t.copier(r,t))})),e}var _=Array.isArray,x=Object.assign,S=Object.getPrototypeOf,k={array:function(r,t){var e=new t.Constructor;t.cache.set(r,e);for(var n=0,o=r.length;n<o;++n)e[n]=t.copier(r[n],t);return e},arrayBuffer:j,blob:function(r,t){return r.slice(0,r.size,r.type)},dataView:function(r,t){return new t.Constructor(j(r.buffer))},date:function(r,t){return new t.Constructor(r.getTime())},error:A,map:w,object:m,regExp:function(r,t){var e=new t.Constructor(r.source,u(r));return e.lastIndex=r.lastIndex,e},set:B},P=x({},k,{array:function(r,t){var e=new t.Constructor;return t.cache.set(r,e),O(r,e,t)},map:function(r,t){return O(r,w(r,t),t)},object:function(r,t){var e=c(t.prototype);return t.cache.set(r,e),O(r,e,t)},set:function(r,t){return O(r,B(r,t),t)}});function E(r){var t=function(r){return{Arguments:r.object,Array:r.array,ArrayBuffer:r.arrayBuffer,Blob:r.blob,Boolean:C,DataView:r.dataView,Date:r.date,Error:r.error,Float32Array:r.arrayBuffer,Float64Array:r.arrayBuffer,Int8Array:r.arrayBuffer,Int16Array:r.arrayBuffer,Int32Array:r.arrayBuffer,Map:r.map,Number:C,Object:r.object,Promise:A,RegExp:r.regExp,Set:r.set,String:C,WeakMap:A,WeakSet:A,Uint8Array:r.arrayBuffer,Uint8ClampedArray:r.arrayBuffer,Uint16Array:r.arrayBuffer,Uint32Array:r.arrayBuffer,Uint64Array:r.arrayBuffer}}(x({},k,r)),e=t.Array,n=t.Object;function o(r,o){if(o.prototype=o.Constructor=void 0,!r||"object"!=typeof r)return r;if(o.cache.has(r))return o.cache.get(r);if(o.prototype=r.__proto__||S(r),o.Constructor=o.prototype&&o.prototype.constructor,!o.Constructor||o.Constructor===Object)return n(r,o);if(_(r))return e(r,o);var a=t[f(r)];return a?a(r,o):"function"==typeof r.then?r:n(r,o)}return function(r){return o(r,{Constructor:void 0,cache:a(),copier:o,prototype:void 0})}}function I(r){return E(x({},P,r))}var M=I({}),U=E({});r.copyStrict=M,r.createCopier=E,r.createStrictCopier=I,r.default=U,Object.defineProperty(r,"__esModule",{value:!0})})); | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["import type { CreateCopierOptions } from './index';\n\nexport interface Cache {\n _keys?: any[];\n _values?: any[];\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\nclass LegacyCache {\n _keys: any[] = [];\n _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value = any> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\nfunction copyOwnPropertiesStrict<Value extends any>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n const { copier } = state;\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n const { cache, copier } = state;\n\n cache.set(array, clone);\n\n for (let index: number = 0, length = array.length; index < length; ++index) {\n clone[index] = copier(array[index], state);\n }\n\n return clone;\n}\n\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, copier(value, state));\n });\n\n return clone;\n}\n\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n const symbols: symbol[] = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Get a copy of the object based on loose rules, meaning all enumerable keys\n * and symbols are copied, but property descriptors are not considered.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Get a copy of the object based on strict rules, meaning all keys and symbols\n * are copied based on the original property descriptors.\n */\nexport function copyObjectStrict<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(copier(value, state));\n });\n\n return clone;\n}\n\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const {\n array = copyArrayLoose,\n arrayBuffer = copyArrayBuffer,\n blob = copyBlob,\n dataView = copyDataView,\n date = copyDate,\n error = copySelf,\n map = copyMapLoose,\n object = copyObjectLoose,\n regExp = copyRegExp,\n set = copySetLoose,\n } = options;\n\n const tagSpecificCopiers: Record<string, InternalCopier> = {\n Array: array,\n ArrayBuffer: arrayBuffer,\n Blob: blob,\n DataView: dataView,\n Date: date,\n Error: error,\n Float32Array: arrayBuffer,\n Float64Array: arrayBuffer,\n Int8Array: arrayBuffer,\n Int16Array: arrayBuffer,\n Int32Array: arrayBuffer,\n Map: map,\n Object: object,\n Promise: copySelf,\n RegExp: regExp,\n Set: set,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: arrayBuffer,\n Uint8ClampedArray: arrayBuffer,\n Uint16Array: arrayBuffer,\n Uint32Array: arrayBuffer,\n Uint64Array: arrayBuffer,\n };\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(\n Object.assign(\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n },\n options\n )\n );\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":["toStringFunction","Function","prototype","create","Object","toStringObject","LegacyCache","this","_keys","_values","has","key","indexOf","get","set","value","push","createCache","WeakMap","getCleanClone","Constructor","constructor","call","_a","getRegExpFlags","flags","regExp","global","ignoreCase","multiline","unicode","sticky","getTagLegacy","type","substring","length","getTag","Symbol","toStringTag","defineProperty","getOwnPropertyDescriptor","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","propertyIsEnumerable","SUPPORTS_SYMBOL","getStrictProperties","object","concat","copyOwnPropertiesStrict","clone","state","properties","copier","index","length_1","property","descriptor","error","copyArrayLoose","array","cache","length_2","copyArrayStrict","copyArrayBuffer","arrayBuffer","_state","slice","copyBlob","blob","size","copyDataView","dataView","buffer","copyDate","date","getTime","copyMapLoose","map","forEach","copyMapStrict","copyObjectLoose","symbols","length_3","symbol","copyObjectStrict","copyRegExp","source","lastIndex","copySelf","copySetLoose","add","copySetStrict","isArray","Array","getPrototypeOf","createCopier","options","_b","_c","_d","_e","_f","_g","_h","_j","_k","tagSpecificCopiers","ArrayBuffer","Blob","DataView","Date","Error","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Map","Promise","RegExp","Set","WeakSet","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Uint64Array","undefined","__proto__","tagSpecificCopier","then","createStrictCopier","assign","copyStrict"],"mappings":"oPAUQ,IAAUA,EAAqBC,SAASC,mBACxCC,EAAWC,OAAMD,OACPE,EAAmBD,OAAOF,mBAE5CI,EAAA,WAAA,SAAAA,IACEC,KAAKC,MAAU,GACfD,KAAOE,QAAU,EAclB,CAAD,OAZEH,EAAGJ,UAAAQ,IAAH,SAAIC,GACF,SAAUJ,KAAKC,MAAMI,QAAQD,IAG/BL,EAAGJ,UAAAW,IAAH,SAAIF,GACF,OAAOJ,KAAKE,QAAQF,KAAKC,MAAMI,QAAQD,KAGzCL,EAAAJ,UAAAY,IAAA,SAAIH,EAAUI,GACZR,KAAKC,MAAMQ,KAAKL,GAChBJ,KAAKE,QAAQO,KAAKD,IAErBT,CAAD,IAaO,IAAMW,EACQ,o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AWlD,EACXmD,WAAYnD,EACZoD,WAAYpD,EACZqD,IAAKxC,EACL1E,OAAQ2C,EACRwE,QAAS9B,EACT+B,OAAQ9F,EACR+F,SAnBM,IAAAf,EAAAhB,IAoBNxE,QAASuE,EACTiC,QAASjC,EACTkC,WAAY1D,EACZ2D,kBAAmB3D,EACnB4D,YAAa5D,EACb6D,YAAa7D,EACb8D,YAAa9D,GAGf,SAASZ,EAAOtC,EAAYoC,GAG1B,GAFAA,EAAMjD,UAAYiD,EAAM/B,iBAAc4G,GAEjCjH,GAA0B,iBAAVA,EACnB,OAAOA,EAGT,GAAIoC,EAAMU,MAAMnD,IAAIK,GAClB,OAAOoC,EAAMU,MAAMhD,IAAIE,GAOzB,GAJAoC,EAAMjD,UAAYa,EAAMkH,WAAalC,EAAehF,GACpDoC,EAAM/B,YAAc+B,EAAMjD,WAAaiD,EAAMjD,UAAUmB,aAGlD8B,EAAM/B,aAAe+B,EAAM/B,cAAgBhB,OAC9C,OAAO2C,EAAOhC,EAAOoC,GAIvB,GAAI0C,EAAQ9E,GACV,OAAO6C,EAAM7C,EAAOoC,GAGtB,IAAM+E,EAAoBvB,EAAmBvE,EAAOrB,IAEpD,OAAImH,EACKA,EAAkBnH,EAAOoC,GAGL,mBAAfpC,EAAMoH,KAAsBpH,EAAQgC,EAAOhC,EAAOoC,EACjE,CAED,OAAO,SAAqBpC,GAC1B,OAAOsC,EAAOtC,EAAO,CACnBK,iBAAa4G,EACbnE,MAAO5C,IACPoC,OAAMA,EACNnD,eAAW8H,GAEf,CACF,CAMM,SAAUI,EAAmBnC,GACjC,OAAOD,EACL5F,OAAOiI,OACL,CACEzE,MAAOG,EACPe,IAAKE,EACLjC,OAAQsC,EACRvE,IAAK8E,GAEPK,GAGN,KAOaqC,EAAaF,EAAmB,IAK9B9E,EAAA0C,EAAa,CAAA"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\n/**\n * @classdesc Fallback cache for when WeakMap is not natively supported\n */\nclass LegacyCache {\n private _keys: any[] = [];\n private _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier<any>;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\n/**\n * Get the properites used when copying objects strictly. This includes both keys and symbols.\n */\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\n/**\n * Striclty copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = state.copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = state.copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0, length = array.length; index < length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer.\n */\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n const symbols = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/ban-types\n Value extends Boolean | Number | String\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { assign, getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\nconst DEFAULT_LOOSE_OPTIONS: Required<CreateCopierOptions> = {\n array: copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n blob: copyBlob,\n dataView: copyDataView,\n date: copyDate,\n error: copySelf,\n map: copyMapLoose,\n object: copyObjectLoose,\n regExp: copyRegExp,\n set: copySetLoose,\n};\nconst DEFAULT_STRICT_OPTIONS: Required<CreateCopierOptions> = assign(\n {},\n DEFAULT_LOOSE_OPTIONS,\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n }\n);\n\n/**\n * Get the copiers used for each specific object tag.\n */\nfunction getTagSpecificCopiers(\n options: Required<CreateCopierOptions>\n): Record<string, InternalCopier<any>> {\n return {\n Arguments: options.object,\n Array: options.array,\n ArrayBuffer: options.arrayBuffer,\n Blob: options.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: options.dataView,\n Date: options.date,\n Error: options.error,\n Float32Array: options.arrayBuffer,\n Float64Array: options.arrayBuffer,\n Int8Array: options.arrayBuffer,\n Int16Array: options.arrayBuffer,\n Int32Array: options.arrayBuffer,\n Map: options.map,\n Number: copyPrimitiveWrapper,\n Object: options.object,\n Promise: copySelf,\n RegExp: options.regExp,\n Set: options.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: options.arrayBuffer,\n Uint8ClampedArray: options.arrayBuffer,\n Uint16Array: options.arrayBuffer,\n Uint32Array: options.arrayBuffer,\n Uint64Array: options.arrayBuffer,\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);\n const tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);\n const { Array: array, Object: object } = tagSpecificCopiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":["toStringFunction","Function","prototype","create","Object","toStringObject","LegacyCache","this","_keys","_values","has","key","indexOf","get","set","value","push","createCache","WeakMap","getCleanClone","Constructor","constructor","call","_a","getRegExpFlags","flags","regExp","global","ignoreCase","multiline","unicode","sticky","getTagLegacy","type","substring","length","getTag","Symbol","toStringTag","defineProperty","getOwnPropertyDescriptor","getOwnPropertyNames","getOwnPropertySymbols","hasOwnProperty","propertyIsEnumerable","SUPPORTS_SYMBOL","getStrictProperties","object","concat","copyOwnPropertiesStrict","clone","state","properties","index","length_1","property","descriptor","copier","error","copyArrayBuffer","arrayBuffer","_state","slice","copyMapLoose","map","cache","forEach","copyObjectLoose","symbols","length_3","symbol","copyPrimitiveWrapper","primitiveObject","valueOf","copySelf","copySetLoose","add","isArray","Array","assign","getPrototypeOf","DEFAULT_LOOSE_OPTIONS","array","length_2","blob","size","dataView","buffer","date","getTime","source","lastIndex","DEFAULT_STRICT_OPTIONS","createCopier","options","tagSpecificCopiers","Arguments","ArrayBuffer","Blob","Boolean","DataView","Date","Error","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Map","Number","Promise","RegExp","Set","String","WeakSet","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Uint64Array","getTagSpecificCopiers","undefined","__proto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AAM6G,KAAsB7G,EAAQgC,EAAOhC,EAAOoC,EACjE,CAED,OAAO,SAAqBpC,GAC1B,OAAO0C,EAAO1C,EAAO,CACnBK,iBAAaqG,EACbxD,MAAOhD,IACPwC,OAAMA,EACNvD,eAAWuH,GAEf,CACF,CAMM,SAAUI,EAAmB/B,GACjC,OAAOD,EAAad,EAAO,CAAA,EAAIa,EAAwBE,GACzD,KAOagC,EAAaD,EAAmB,IAK9BxE,EAAAwC,EAAa,CAAA"} |
| import type { Cache } from './utils'; | ||
| export declare type InternalCopier<Value = any> = (value: Value, state: State) => Value; | ||
| export declare type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
| export interface State { | ||
| Constructor: any; | ||
| cache: Cache; | ||
| copier: InternalCopier; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| export declare function copyArrayLoose(array: any[], state: State): any; | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| export declare function copyArrayStrict<Value extends any[]>(array: Value, state: State): Value; | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| export declare function copyArrayBuffer<Value extends ArrayBuffer>(arrayBuffer: Value, _state: State): Value; | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| export declare function copyBlob<Value extends Blob>(blob: Value, _state: State): Value; | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| export declare function copyDataView<Value extends DataView>(dataView: Value, state: State): Value; | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| export declare function copyDate<Value extends Date>(date: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| export declare function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends {}>(object: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
| export declare const copyObjectLoose: typeof copyObjectLooseModern; | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
| export declare function copyObjectStrict<Value extends {}>(object: Value, state: State): Value; | ||
| export declare function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| export declare function copyPrimitiveWrapper<Value extends Boolean | Number | String>(primitiveObject: Value, state: State): Value; | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| export declare function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value; | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| export declare function copySelf<Value>(value: Value, _state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| export declare function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value; | ||
| export {}; |
| export interface Cache { | ||
| _keys?: any[]; | ||
| _values?: any[]; | ||
| has: (value: any) => boolean; | ||
@@ -22,7 +20,7 @@ set: (key: any, value: any) => void; | ||
| export declare const getRegExpFlags: typeof getRegExpFlagsModern; | ||
| declare function getTagModern(value: any): string; | ||
| declare function getTagLegacy(value: any): string; | ||
| /** | ||
| * Get the tag of the value passed, so that the correct copier can be used. | ||
| */ | ||
| export declare const getTag: typeof getTagModern; | ||
| export declare const getTag: typeof getTagLegacy; | ||
| export {}; |
+129
-54
@@ -10,2 +10,5 @@ (function (global, factory) { | ||
| var toStringObject = Object.prototype.toString; | ||
| /** | ||
| * @classdesc Fallback cache for when WeakMap is not natively supported | ||
| */ | ||
| var LegacyCache = /** @class */ (function () { | ||
@@ -101,8 +104,13 @@ function LegacyCache() { | ||
| } | ||
| /** | ||
| * Get the properites used when copying objects strictly. This includes both keys and symbols. | ||
| */ | ||
| var getStrictProperties = SUPPORTS_SYMBOL | ||
| ? getStrictPropertiesModern | ||
| : getOwnPropertyNames; | ||
| /** | ||
| * Striclty copy all properties contained on the object. | ||
| */ | ||
| function copyOwnPropertiesStrict(value, clone, state) { | ||
| var properties = getStrictProperties(value); | ||
| var copier = state.copier; | ||
| for (var index = 0, length_1 = properties.length, property = void 0, descriptor = void 0; index < length_1; ++index) { | ||
@@ -117,3 +125,3 @@ property = properties[index]; | ||
| // the loose assignment. | ||
| clone[property] = copier(value[property], state); | ||
| clone[property] = state.copier(value[property], state); | ||
| continue; | ||
@@ -123,3 +131,3 @@ } | ||
| if (!descriptor.get && !descriptor.set) { | ||
| descriptor.value = copier(descriptor.value, state); | ||
| descriptor.value = state.copier(descriptor.value, state); | ||
| } | ||
@@ -136,37 +144,62 @@ try { | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| function copyArrayLoose(array, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(array, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| for (var index = 0, length_2 = array.length; index < length_2; ++index) { | ||
| clone[index] = copier(array[index], state); | ||
| clone[index] = state.copier(array[index], state); | ||
| } | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| function copyArrayStrict(array, state) { | ||
| var clone = new state.Constructor(); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(array, clone); | ||
| return copyOwnPropertiesStrict(array, clone, state); | ||
| } | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| function copyArrayBuffer(arrayBuffer, _state) { | ||
| return arrayBuffer.slice(0); | ||
| } | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| function copyBlob(blob, _state) { | ||
| return blob.slice(0, blob.size, blob.type); | ||
| } | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| function copyDataView(dataView, state) { | ||
| return new state.Constructor(copyArrayBuffer(dataView.buffer)); | ||
| } | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| function copyDate(date, state) { | ||
| return new state.Constructor(date.getTime()); | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| function copyMapLoose(map, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(map, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(map, clone); | ||
| map.forEach(function (value, key) { | ||
| clone.set(key, copier(value, state)); | ||
| clone.set(key, state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| function copyMapStrict(map, state) { | ||
@@ -177,8 +210,7 @@ return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state); | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -190,8 +222,7 @@ } | ||
| var clone = getCleanClone(state.prototype); | ||
| var cache = state.cache, copier = state.copier; | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| cache.set(object, clone); | ||
| state.cache.set(object, clone); | ||
| for (var key in object) { | ||
| if (hasOwnProperty.call(object, key)) { | ||
| clone[key] = copier(object[key], state); | ||
| clone[key] = state.copier(object[key], state); | ||
| } | ||
@@ -203,3 +234,3 @@ } | ||
| if (propertyIsEnumerable.call(object, symbol)) { | ||
| clone[symbol] = copier(object[symbol], state); | ||
| clone[symbol] = state.copier(object[symbol], state); | ||
| } | ||
@@ -210,4 +241,3 @@ } | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
@@ -218,4 +248,4 @@ var copyObjectLoose = SUPPORTS_SYMBOL | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
@@ -228,2 +258,11 @@ function copyObjectStrict(object, state) { | ||
| } | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| function copyPrimitiveWrapper(primitiveObject, state) { | ||
| return new state.Constructor(primitiveObject.valueOf()); | ||
| } | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| function copyRegExp(regExp, state) { | ||
@@ -234,14 +273,26 @@ var clone = new state.Constructor(regExp.source, getRegExpFlags(regExp)); | ||
| } | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| function copySelf(value, _state) { | ||
| return value; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| function copySetLoose(set, state) { | ||
| var clone = new state.Constructor(); | ||
| var cache = state.cache, copier = state.copier; | ||
| cache.set(set, clone); | ||
| // set in the cache immediately to be able to reuse the object recursively | ||
| state.cache.set(set, clone); | ||
| set.forEach(function (value) { | ||
| clone.add(copier(value, state)); | ||
| clone.add(state.copier(value, state)); | ||
| }); | ||
| return clone; | ||
| } | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| function copySetStrict(set, state) { | ||
@@ -252,33 +303,62 @@ return copyOwnPropertiesStrict(set, copySetLoose(set, state), state); | ||
| var isArray = Array.isArray; | ||
| var getPrototypeOf = Object.getPrototypeOf; | ||
| var assign = Object.assign, getPrototypeOf = Object.getPrototypeOf; | ||
| var DEFAULT_LOOSE_OPTIONS = { | ||
| array: copyArrayLoose, | ||
| arrayBuffer: copyArrayBuffer, | ||
| blob: copyBlob, | ||
| dataView: copyDataView, | ||
| date: copyDate, | ||
| error: copySelf, | ||
| map: copyMapLoose, | ||
| object: copyObjectLoose, | ||
| regExp: copyRegExp, | ||
| set: copySetLoose, | ||
| }; | ||
| var DEFAULT_STRICT_OPTIONS = assign({}, DEFAULT_LOOSE_OPTIONS, { | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }); | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| * Get the copiers used for each specific object tag. | ||
| */ | ||
| function createCopier(options) { | ||
| var _a = options.array, array = _a === void 0 ? copyArrayLoose : _a, _b = options.arrayBuffer, arrayBuffer = _b === void 0 ? copyArrayBuffer : _b, _c = options.blob, blob = _c === void 0 ? copyBlob : _c, _d = options.dataView, dataView = _d === void 0 ? copyDataView : _d, _e = options.date, date = _e === void 0 ? copyDate : _e, _f = options.error, error = _f === void 0 ? copySelf : _f, _g = options.map, map = _g === void 0 ? copyMapLoose : _g, _h = options.object, object = _h === void 0 ? copyObjectLoose : _h, _j = options.regExp, regExp = _j === void 0 ? copyRegExp : _j, _k = options.set, set = _k === void 0 ? copySetLoose : _k; | ||
| var tagSpecificCopiers = { | ||
| Array: array, | ||
| ArrayBuffer: arrayBuffer, | ||
| Blob: blob, | ||
| DataView: dataView, | ||
| Date: date, | ||
| Error: error, | ||
| Float32Array: arrayBuffer, | ||
| Float64Array: arrayBuffer, | ||
| Int8Array: arrayBuffer, | ||
| Int16Array: arrayBuffer, | ||
| Int32Array: arrayBuffer, | ||
| Map: map, | ||
| Object: object, | ||
| function getTagSpecificCopiers(options) { | ||
| return { | ||
| Arguments: options.object, | ||
| Array: options.array, | ||
| ArrayBuffer: options.arrayBuffer, | ||
| Blob: options.blob, | ||
| Boolean: copyPrimitiveWrapper, | ||
| DataView: options.dataView, | ||
| Date: options.date, | ||
| Error: options.error, | ||
| Float32Array: options.arrayBuffer, | ||
| Float64Array: options.arrayBuffer, | ||
| Int8Array: options.arrayBuffer, | ||
| Int16Array: options.arrayBuffer, | ||
| Int32Array: options.arrayBuffer, | ||
| Map: options.map, | ||
| Number: copyPrimitiveWrapper, | ||
| Object: options.object, | ||
| Promise: copySelf, | ||
| RegExp: regExp, | ||
| Set: set, | ||
| RegExp: options.regExp, | ||
| Set: options.set, | ||
| String: copyPrimitiveWrapper, | ||
| WeakMap: copySelf, | ||
| WeakSet: copySelf, | ||
| Uint8Array: arrayBuffer, | ||
| Uint8ClampedArray: arrayBuffer, | ||
| Uint16Array: arrayBuffer, | ||
| Uint32Array: arrayBuffer, | ||
| Uint64Array: arrayBuffer, | ||
| Uint8Array: options.arrayBuffer, | ||
| Uint8ClampedArray: options.arrayBuffer, | ||
| Uint16Array: options.arrayBuffer, | ||
| Uint32Array: options.arrayBuffer, | ||
| Uint64Array: options.arrayBuffer, | ||
| }; | ||
| } | ||
| /** | ||
| * Create a custom copier based on the object-specific copy methods passed. | ||
| */ | ||
| function createCopier(options) { | ||
| var normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options); | ||
| var tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions); | ||
| var array = tagSpecificCopiers.Array, object = tagSpecificCopiers.Object; | ||
| function copier(value, state) { | ||
@@ -322,8 +402,3 @@ state.prototype = state.Constructor = undefined; | ||
| function createStrictCopier(options) { | ||
| return createCopier(Object.assign({ | ||
| array: copyArrayStrict, | ||
| map: copyMapStrict, | ||
| object: copyObjectStrict, | ||
| set: copySetStrict, | ||
| }, options)); | ||
| return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options)); | ||
| } | ||
@@ -330,0 +405,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["import type { CreateCopierOptions } from './index';\n\nexport interface Cache {\n _keys?: any[];\n _values?: any[];\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\nclass LegacyCache {\n _keys: any[] = [];\n _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value = any> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\nfunction copyOwnPropertiesStrict<Value extends any>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n const { copier } = state;\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n const { cache, copier } = state;\n\n cache.set(array, clone);\n\n for (let index: number = 0, length = array.length; index < length; ++index) {\n clone[index] = copier(array[index], state);\n }\n\n return clone;\n}\n\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, copier(value, state));\n });\n\n return clone;\n}\n\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n const { cache, copier } = state;\n\n // set in the cache immediately to be able to reuse the object recursively\n cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = copier(object[key], state);\n }\n }\n\n const symbols: symbol[] = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Get a copy of the object based on loose rules, meaning all enumerable keys\n * and symbols are copied, but property descriptors are not considered.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Get a copy of the object based on strict rules, meaning all keys and symbols\n * are copied based on the original property descriptors.\n */\nexport function copyObjectStrict<Value extends {}>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n const { cache, copier } = state;\n\n cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(copier(value, state));\n });\n\n return clone;\n}\n\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const {\n array = copyArrayLoose,\n arrayBuffer = copyArrayBuffer,\n blob = copyBlob,\n dataView = copyDataView,\n date = copyDate,\n error = copySelf,\n map = copyMapLoose,\n object = copyObjectLoose,\n regExp = copyRegExp,\n set = copySetLoose,\n } = options;\n\n const tagSpecificCopiers: Record<string, InternalCopier> = {\n Array: array,\n ArrayBuffer: arrayBuffer,\n Blob: blob,\n DataView: dataView,\n Date: date,\n Error: error,\n Float32Array: arrayBuffer,\n Float64Array: arrayBuffer,\n Int8Array: arrayBuffer,\n Int16Array: arrayBuffer,\n Int32Array: arrayBuffer,\n Map: map,\n Object: object,\n Promise: copySelf,\n RegExp: regExp,\n Set: set,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: arrayBuffer,\n Uint8ClampedArray: arrayBuffer,\n Uint16Array: arrayBuffer,\n Uint32Array: arrayBuffer,\n Uint64Array: arrayBuffer,\n };\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(\n Object.assign(\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n },\n options\n )\n );\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":";;;;;;IAUQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;IAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,CAAY;IAClB,IAAU,cAAc,GAAK,MAAM,CAAC,SAAS,SAArB,CAAsB;IAEtD,IAAA,WAAA,kBAAA,YAAA;IAAA,IAAA,SAAA,WAAA,GAAA;YACE,IAAK,CAAA,KAAA,GAAU,EAAE,CAAC;YAClB,IAAO,CAAA,OAAA,GAAU,EAAE,CAAC;SAcrB;QAZC,WAAG,CAAA,SAA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BACtB,KAAK,EAAE,WAAW,EAAE;IACpB,YAAA,MAAM,EAAA,MAAA;IACN,YAAA,SAAS,EAAE,SAAS;IACrB,SAAA,CAAC,CAAC;IACL,KAAC,CAAC;IACJ,CAAC;IAED;;;IAGG;IACG,SAAU,kBAAkB,CAAC,OAA4B,EAAA;IAC7D,IAAA,OAAO,YAAY,CACjB,MAAM,CAAC,MAAM,CACX;IACE,QAAA,KAAK,EAAE,eAAe;IACtB,QAAA,GAAG,EAAE,aAAa;IAClB,QAAA,MAAM,EAAE,gBAAgB;IACxB,QAAA,GAAG,EAAE,aAAa;SACnB,EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;;;IAIG;QACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;IAEjD;;IAEG;AACH,gBAAe,YAAY,CAAC,EAAE,CAAC;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../src/utils.ts","../../../../src/copier.ts","../../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\nconst { toString: toStringFunction } = Function.prototype;\nconst { create } = Object;\nconst { toString: toStringObject } = Object.prototype;\n\n/**\n * @classdesc Fallback cache for when WeakMap is not natively supported\n */\nclass LegacyCache {\n private _keys: any[] = [];\n private _values: any[] = [];\n\n has(key: any) {\n return !!~this._keys.indexOf(key);\n }\n\n get(key: any) {\n return this._values[this._keys.indexOf(key)];\n }\n\n set(key: any, value: any) {\n this._keys.push(key);\n this._values.push(value);\n }\n}\n\nfunction createCacheLegacy(): Cache {\n return new LegacyCache();\n}\n\nfunction createCacheModern(): Cache {\n return new WeakMap();\n}\n\n/**\n * Get a new cache object to prevent circular references.\n */\nexport const createCache =\n typeof WeakMap !== 'undefined' ? createCacheModern : createCacheLegacy;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : create(prototype);\n }\n\n if (~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {}\n }\n\n return create(prototype);\n}\n\nfunction getRegExpFlagsLegacy(regExp: RegExp): string {\n let flags = '';\n\n if (regExp.global) {\n flags += 'g';\n }\n\n if (regExp.ignoreCase) {\n flags += 'i';\n }\n\n if (regExp.multiline) {\n flags += 'm';\n }\n\n if (regExp.unicode) {\n flags += 'u';\n }\n\n if (regExp.sticky) {\n flags += 'y';\n }\n\n return flags;\n}\n\nfunction getRegExpFlagsModern(regExp: RegExp): string {\n return regExp.flags;\n}\n\n/**\n * Get the flags to apply to the copied regexp.\n */\nexport const getRegExpFlags =\n /test/g.flags === 'g' ? getRegExpFlagsModern : getRegExpFlagsLegacy;\n\nfunction getTagLegacy(value: any): string {\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n\nfunction getTagModern(value: any): string {\n return value[Symbol.toStringTag] || getTagLegacy(value);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport const getTag =\n typeof Symbol !== 'undefined' ? getTagModern : getTagLegacy;\n","import { getCleanClone, getRegExpFlags } from './utils';\n\nimport type { Cache } from './utils';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n Constructor: any;\n cache: Cache;\n copier: InternalCopier<any>;\n prototype: any;\n}\n\nconst {\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n} = Object;\nconst { hasOwnProperty, propertyIsEnumerable } = Object.prototype;\n\nconst SUPPORTS_SYMBOL = typeof getOwnPropertySymbols === 'function';\n\nfunction getStrictPropertiesModern(object: any): Array<string | symbol> {\n return (getOwnPropertyNames(object) as Array<string | symbol>).concat(\n getOwnPropertySymbols(object)\n );\n}\n\n/**\n * Get the properites used when copying objects strictly. This includes both keys and symbols.\n */\nconst getStrictProperties = SUPPORTS_SYMBOL\n ? getStrictPropertiesModern\n : getOwnPropertyNames;\n\n/**\n * Striclty copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value>(\n value: Value,\n clone: Value,\n state: State\n): Value {\n const properties = getStrictProperties(value);\n\n for (\n let index = 0, length = properties.length, property, descriptor;\n index < length;\n ++index\n ) {\n property = properties[index];\n\n if (property === 'callee' || property === 'caller') {\n continue;\n }\n\n descriptor = getOwnPropertyDescriptor(value, property);\n\n if (!descriptor) {\n // In extra edge cases where the property descriptor cannot be retrived, fall back to\n // the loose assignment.\n (clone as any)[property] = state.copier((value as any)[property], state);\n continue;\n }\n\n // Only clone the value if actually a value, not a getter / setter.\n if (!descriptor.get && !descriptor.set) {\n descriptor.value = state.copier(descriptor.value, state);\n }\n\n try {\n defineProperty(clone, property, descriptor);\n } catch (error) {\n // Tee above can fail on node in edge cases, so fall back to the loose assignment.\n (clone as any)[property] = descriptor.value;\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0, length = array.length; index < length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(\n array: Value,\n state: State\n) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer.\n */\nexport function copyArrayBuffer<Value extends ArrayBuffer>(\n arrayBuffer: Value,\n _state: State\n): Value {\n return arrayBuffer.slice(0) as Value;\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(\n blob: Value,\n _state: State\n): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(\n dataView: Value,\n state: State\n): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state));\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(\n map: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n map.forEach((value, key) => {\n clone.set(key, state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(\n map: Value,\n state: State\n) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\nfunction copyObjectLooseLegacy<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone: any = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n return clone;\n}\n\nfunction copyObjectLooseModern<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key in object) {\n if (hasOwnProperty.call(object, key)) {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n const symbols = getOwnPropertySymbols(object);\n\n for (\n let index = 0, length = symbols.length, symbol;\n index < length;\n ++index\n ) {\n symbol = symbols[index];\n\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport const copyObjectLoose = SUPPORTS_SYMBOL\n ? copyObjectLooseModern\n : copyObjectLooseLegacy;\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(\n object: Value,\n state: State\n): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/ban-types\n Value extends Boolean | Number | String\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(\n regExp: Value,\n state: State\n): Value {\n const clone = new state.Constructor(\n regExp.source,\n getRegExpFlags(regExp)\n ) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n set.forEach((value) => {\n clone.add(state.copier(value, state));\n });\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(\n set: Value,\n state: State\n): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier';\nimport { createCache, getTag } from './utils';\n\nimport type { InternalCopier, State } from './copier';\n\nexport type { State } from './copier';\n\nconst { isArray } = Array;\nconst { assign, getPrototypeOf } = Object;\n\nexport interface CreateCopierOptions {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<any>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\nconst DEFAULT_LOOSE_OPTIONS: Required<CreateCopierOptions> = {\n array: copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n blob: copyBlob,\n dataView: copyDataView,\n date: copyDate,\n error: copySelf,\n map: copyMapLoose,\n object: copyObjectLoose,\n regExp: copyRegExp,\n set: copySetLoose,\n};\nconst DEFAULT_STRICT_OPTIONS: Required<CreateCopierOptions> = assign(\n {},\n DEFAULT_LOOSE_OPTIONS,\n {\n array: copyArrayStrict,\n map: copyMapStrict,\n object: copyObjectStrict,\n set: copySetStrict,\n }\n);\n\n/**\n * Get the copiers used for each specific object tag.\n */\nfunction getTagSpecificCopiers(\n options: Required<CreateCopierOptions>\n): Record<string, InternalCopier<any>> {\n return {\n Arguments: options.object,\n Array: options.array,\n ArrayBuffer: options.arrayBuffer,\n Blob: options.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: options.dataView,\n Date: options.date,\n Error: options.error,\n Float32Array: options.arrayBuffer,\n Float64Array: options.arrayBuffer,\n Int8Array: options.arrayBuffer,\n Int16Array: options.arrayBuffer,\n Int32Array: options.arrayBuffer,\n Map: options.map,\n Number: copyPrimitiveWrapper,\n Object: options.object,\n Promise: copySelf,\n RegExp: options.regExp,\n Set: options.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: options.arrayBuffer,\n Uint8ClampedArray: options.arrayBuffer,\n Uint16Array: options.arrayBuffer,\n Uint32Array: options.arrayBuffer,\n Uint64Array: options.arrayBuffer,\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed.\n */\nexport function createCopier(options: CreateCopierOptions) {\n const normalizedOptions = assign({}, DEFAULT_LOOSE_OPTIONS, options);\n const tagSpecificCopiers = getTagSpecificCopiers(normalizedOptions);\n const { Array: array, Object: object } = tagSpecificCopiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n state.prototype = value.__proto__ || getPrototypeOf(value);\n state.Constructor = state.prototype && state.prototype.constructor;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n return object(value, state);\n }\n\n // arrays\n if (isArray(value)) {\n return array(value, state);\n }\n\n const tagSpecificCopier = tagSpecificCopiers[getTag(value)];\n\n if (tagSpecificCopier) {\n return tagSpecificCopier(value, state);\n }\n\n return typeof value.then === 'function' ? value : object(value, state);\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Create a custom copier based on the object-specific copy methods passed, defaulting to the\n * same internals as `copyStrict`.\n */\nexport function createStrictCopier(options: CreateCopierOptions) {\n return createCopier(assign({}, DEFAULT_STRICT_OPTIONS, options));\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createStrictCopier({});\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport default createCopier({});\n"],"names":[],"mappings":";;;;;;IAMQ,IAAU,gBAAgB,GAAK,QAAQ,CAAC,SAAS,SAAvB,CAAwB;IAClD,IAAA,MAAM,GAAK,MAAM,CAAA,MAAX,CAAY;IAClB,IAAU,cAAc,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EAAE,KAAK,CAAC,CAAC;IAC5B,SAAA;YAED,IAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAE5D,QAAA,IAAI,iBAAiB,EAAE;IACrB,YAAA,OAAO,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,SAAA;IAED,QAAA,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SACxE;QAED,OAAO,SAAS,IAAI,CAAQ,KAAY,EAAA;YACtC,OAAO,MAAM,CAAC,KAAK,EAAE;IACnB,YAAA,WAAW,EAAE,SAAS;gBACtB,KAAK,EAAE,WAAW,EAAE;IACpB,YAAA,MAAM,EAAA,MAAA;IACN,YAAA,SAAS,EAAE,SAAS;IACrB,SAAA,CAAC,CAAC;IACL,KAAC,CAAC;IACJ,CAAC;IAED;;;IAGG;IACG,SAAU,kBAAkB,CAAC,OAA4B,EAAA;QAC7D,OAAO,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;IAIG;QACU,UAAU,GAAG,kBAAkB,CAAC,EAAE,EAAE;IAEjD;;IAEG;AACH,gBAAe,YAAY,CAAC,EAAE,CAAC;;;;;;;;;;;;;"} |
| import type { Cache } from './utils'; | ||
| export declare type InternalCopier<Value = any> = (value: Value, state: State) => Value; | ||
| export declare type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
| export interface State { | ||
| Constructor: any; | ||
| cache: Cache; | ||
| copier: InternalCopier; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
| } | ||
| /** | ||
| * Deeply copy the indexed values in the array. | ||
| */ | ||
| export declare function copyArrayLoose(array: any[], state: State): any; | ||
| /** | ||
| * Deeply copy the indexed values in the array, as well as any custom properties. | ||
| */ | ||
| export declare function copyArrayStrict<Value extends any[]>(array: Value, state: State): Value; | ||
| /** | ||
| * Copy the contents of the ArrayBuffer. | ||
| */ | ||
| export declare function copyArrayBuffer<Value extends ArrayBuffer>(arrayBuffer: Value, _state: State): Value; | ||
| /** | ||
| * Create a new Blob with the contents of the original. | ||
| */ | ||
| export declare function copyBlob<Value extends Blob>(blob: Value, _state: State): Value; | ||
| /** | ||
| * Create a new DataView with the contents of the original. | ||
| */ | ||
| export declare function copyDataView<Value extends DataView>(dataView: Value, state: State): Value; | ||
| /** | ||
| * Create a new Date based on the time of the original. | ||
| */ | ||
| export declare function copyDate<Value extends Date>(date: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original. | ||
| */ | ||
| export declare function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the keys and values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends {}>(object: Value, state: State): Value; | ||
| declare function copyObjectLooseModern<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Get a copy of the object based on loose rules, meaning all enumerable keys | ||
| * and symbols are copied, but property descriptors are not considered. | ||
| * Deeply copy the properties (keys and symbols) and values of the original. | ||
| */ | ||
| export declare const copyObjectLoose: typeof copyObjectLooseModern; | ||
| /** | ||
| * Get a copy of the object based on strict rules, meaning all keys and symbols | ||
| * are copied based on the original property descriptors. | ||
| * Deeply copy the properties (keys and symbols) and values of the original, as well | ||
| * as any hidden or non-enumerable properties. | ||
| */ | ||
| export declare function copyObjectStrict<Value extends {}>(object: Value, state: State): Value; | ||
| export declare function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value; | ||
| /** | ||
| * Create a new primitive wrapper from the value of the original. | ||
| */ | ||
| export declare function copyPrimitiveWrapper<Value extends Boolean | Number | String>(primitiveObject: Value, state: State): Value; | ||
| /** | ||
| * Create a new RegExp based on the value and flags of the original. | ||
| */ | ||
| export declare function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value; | ||
| /** | ||
| * Return the original value (an identity function). | ||
| * | ||
| * @note | ||
| * THis is used for objects that cannot be copied, such as WeakMap. | ||
| */ | ||
| export declare function copySelf<Value>(value: Value, _state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original. | ||
| */ | ||
| export declare function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value; | ||
| /** | ||
| * Deeply copy the values of the original, as well as any custom properties. | ||
| */ | ||
| export declare function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value; | ||
| export {}; |
| export interface Cache { | ||
| _keys?: any[]; | ||
| _values?: any[]; | ||
| has: (value: any) => boolean; | ||
@@ -22,7 +20,7 @@ set: (key: any, value: any) => void; | ||
| export declare const getRegExpFlags: typeof getRegExpFlagsModern; | ||
| declare function getTagModern(value: any): string; | ||
| declare function getTagLegacy(value: any): string; | ||
| /** | ||
| * Get the tag of the value passed, so that the correct copier can be used. | ||
| */ | ||
| export declare const getTag: typeof getTagModern; | ||
| export declare const getTag: typeof getTagLegacy; | ||
| export {}; |
+2
-2
@@ -21,3 +21,3 @@ interface Cache { | ||
| type InternalCopier<Value = any> = (value: Value, state: State) => Value; | ||
| type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
@@ -27,3 +27,3 @@ export interface State { | ||
| cache: Cache; | ||
| copier: InternalCopier; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
@@ -30,0 +30,0 @@ } |
+3
-3
@@ -88,3 +88,3 @@ { | ||
| "dist": "npm run clean && npm run build", | ||
| "lint": "eslint 'src/*.ts'", | ||
| "lint": "eslint 'src/*.ts' '__tests__/*.ts' 'DEV_ONLY/*.ts'", | ||
| "lint:fix": "npm run lint -- --fix", | ||
@@ -99,7 +99,7 @@ "prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run dist", | ||
| "test:watch": "npm run test -- --watch", | ||
| "typecheck": "tsc src/*.ts --noEmit" | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "type": "module", | ||
| "types": "index.d.ts", | ||
| "version": "3.0.0-beta.7" | ||
| "version": "3.0.0-beta.8" | ||
| } |
+130
-36
@@ -18,2 +18,6 @@ # fast-copy | ||
| - [`createCopier`](#createcopier) | ||
| - [Copier state](#copier-state) | ||
| - [`cache`](#cache) | ||
| - [`copier`](#copier) | ||
| - [`Constructor` / `prototype`](#constructor--prototype) | ||
| - [`createStrictCopier`](#createstrictcopier) | ||
@@ -102,2 +106,89 @@ - [Copier methods](#copier-methods) | ||
| Each internal copier method has the following contract: | ||
| ```ts | ||
| type InternalCopier<Value> = (value: Value, state: State) => Value; | ||
| interface State { | ||
| Constructor: any; | ||
| cache: WeakMap; | ||
| copier: InternalCopier<any>; | ||
| prototype: any; | ||
| } | ||
| ``` | ||
| Any method overriding the defaults must maintain this contract. | ||
| #### Copier state | ||
| ##### `cache` | ||
| If you want to maintain circular reference handling, then you'll need the methods to handle cache population for future lookups: | ||
| ```ts | ||
| function shallowlyCloneArray<Value extends any[]>( | ||
| value: Value, | ||
| state: State | ||
| ): Value { | ||
| const clone = [...value]; | ||
| state.cache.set(value, clone); | ||
| return clone; | ||
| } | ||
| ``` | ||
| ##### `copier` | ||
| `copier` is provided for recursive calls with deeply-nested objects. | ||
| ```ts | ||
| function deeplyCloneArray<Value extends any[]>( | ||
| value: Value, | ||
| state: State | ||
| ): Value { | ||
| const clone = []; | ||
| state.cache.set(value, clone); | ||
| value.forEach((item) => state.copier(item, state)); | ||
| return clone; | ||
| } | ||
| ``` | ||
| Note above I am using `forEach` instead of a simple `map`. This is because it is highly recommended to store the clone in [`cache`](#cache) eagerly when deeply copying, so that nested circular references are handled correctly. | ||
| ##### `Constructor` / `prototype` | ||
| Both `Constructor` and `prototype` properties are only populated with complex objects that are not standard objects or arrays. This is mainly useful for custom subclasses of these globals, or maintaining custom prototypes of objects. | ||
| ```ts | ||
| function deeplyCloneSubclassArray<Value extends CustomArray>( | ||
| value: Value, | ||
| state: State | ||
| ): Value { | ||
| const clone = new state.Constructor(); | ||
| state.cache.set(value, clone); | ||
| value.forEach((item) => clone.push(item)); | ||
| return clone; | ||
| } | ||
| function deeplyCloneCustomObject<Value extends CustomObject>( | ||
| value: Value, | ||
| state: State | ||
| ): Value { | ||
| const clone = Object.create(state.prototype); | ||
| state.cache.set(value, clone); | ||
| Object.entries(value).forEach(([k, v]) => (clone[k] = v)); | ||
| return clone; | ||
| } | ||
| ``` | ||
| ### `createStrictCopier` | ||
@@ -211,9 +302,9 @@ | ||
| | ------------------ | ------------------- | | ||
| | **fast-copy** | **5,743,509** | | ||
| | lodash.cloneDeep | 2,614,035 | | ||
| | clone | 2,173,098 | | ||
| | fast-clone | 1,341,313 | | ||
| | deepclone | 1,238,167 | | ||
| | ramda | 1,115,519 | | ||
| | fast-copy (strict) | 845,093 | | ||
| | **fast-copy** | **5,880,312** | | ||
| | lodash.cloneDeep | 2,706,261 | | ||
| | clone | 2,207,231 | | ||
| | deepclone | 1,274,810 | | ||
| | fast-clone | 1,239,952 | | ||
| | ramda | 1,146,152 | | ||
| | fast-copy (strict) | 852,382 | | ||
@@ -226,9 +317,9 @@ #### Complex objects | ||
| | ------------------ | ------------------- | | ||
| | **fast-copy** | **160,060** | | ||
| | ramda | 134,873 | | ||
| | deepclone | 131,345 | | ||
| | fast-clone | 49,911 | | ||
| | clone | 75,780 | | ||
| | fast-copy (strict) | 61,556 | | ||
| | lodash.cloneDeep | 59,493 | | ||
| | **fast-copy** | **162,858** | | ||
| | ramda | 142,104 | | ||
| | deepclone | 133,607 | | ||
| | fast-clone | 101,143 | | ||
| | clone | 70,872 | | ||
| | fast-copy (strict) | 62,961 | | ||
| | lodash.cloneDeep | 62,060 | | ||
@@ -241,8 +332,8 @@ #### Big data | ||
| | ------------------ | ------------------- | | ||
| | **fast-copy** | 304 | | ||
| | fast-clone | 236 | | ||
| | **fast-copy** | 303 | | ||
| | fast-clone | 245 | | ||
| | deepclone | 151 | | ||
| | lodash.cloneDeep | 150 | | ||
| | deepclone | 148 | | ||
| | clone | 90 | | ||
| | fast-copy (strict) | 89 | | ||
| | clone | 93 | | ||
| | fast-copy (strict) | 90 | | ||
| | ramda | 42 | | ||
@@ -256,8 +347,8 @@ | ||
| | ------------------ | ------------------- | | ||
| | **fast-copy** | **2,273,405** | | ||
| | deepclone | 1,299,928 | | ||
| | ramda | 951,721 | | ||
| | clone | 945,585 | | ||
| | lodash.cloneDeep | 887,775 | | ||
| | fast-copy (strict) | 630,221 | | ||
| | **fast-copy** | **2,420,466** | | ||
| | deepclone | 1,386,896 | | ||
| | ramda | 1,024,108 | | ||
| | lodash.cloneDeep | 989,796 | | ||
| | clone | 987,721 | | ||
| | fast-copy (strict) | 617,602 | | ||
| | fast-clone | 0 (not supported) | | ||
@@ -271,9 +362,9 @@ | ||
| | ------------------ | ------------------- | | ||
| | **fast-copy** | **144,616** | | ||
| | clone | 68,880 | | ||
| | fast-clone | 66,233 | | ||
| | lodash.cloneDeep | 63,376 | | ||
| | ramda | 52,216 | | ||
| | deepclone | 28,394 | | ||
| | fast-copy (strict) | 21,033 | | ||
| | **fast-copy** | **152,792** | | ||
| | clone | 74,347 | | ||
| | fast-clone | 66,576 | | ||
| | lodash.cloneDeep | 64,760 | | ||
| | ramda | 53,542 | | ||
| | deepclone | 28,823 | | ||
| | fast-copy (strict) | 21,362 | | ||
@@ -285,8 +376,10 @@ ## Development | ||
| - benchmark => run benchmark tests against other equality libraries | ||
| - build => run `build:files` and `build:types` | ||
| - build:files => build dist files with `rollup` | ||
| - build:types => build TypeScript types for consumers | ||
| - build => run `build:esm`, `build:cjs`, `build:umd`, and `build:min` scripts | ||
| - build:cjs => build CJS files and types | ||
| - build:esm => build ESM files and types | ||
| - build:min => build minified files and types | ||
| - build:umd => build UMD files and types | ||
| - clean => run `rimraf` on the `dist` folder | ||
| - dev => start webpack playground App | ||
| - dist => run `build` and `build:minified` scripts | ||
| - dist => run `clean` and `build` scripts | ||
| - lint => run ESLint on all files in `src` folder (also runs on `dev` script) | ||
@@ -302,1 +395,2 @@ - lint:fix => run `lint` script, but with auto-fixer | ||
| - test:watch => run same script as `test` but keep persistent watcher | ||
| - typecheck => run `tsc` on the codebase |
195299
12.55%1951
24.43%388
31.97%