Comparing version 1.2.3 to 1.2.4
# fast-copy CHANGELOG | ||
## 1.2.4 | ||
- Ensure `Date` copy uses realm-specific constructor | ||
## 1.2.3 | ||
@@ -4,0 +8,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.fastCopy = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = global || self, factory(global['fast-copy'] = {})); | ||
}(this, function (exports) { 'use strict'; | ||
var create = Object.create, | ||
getSymbols = Object.getOwnPropertySymbols, | ||
getPrototypeOf = Object.getPrototypeOf; | ||
var _Object$prototype = Object.prototype, | ||
hasOwnProperty = _Object$prototype.hasOwnProperty, | ||
propertyIsEnumerable = _Object$prototype.propertyIsEnumerable; | ||
/** | ||
* @constant {boolean} HAS_FLAGS_SUPPORT | ||
* @constant {Object} SUPPORTS cache of values supported | ||
*/ | ||
var HAS_FLAGS_SUPPORT = typeof /foo/g.flags === 'string'; | ||
/** | ||
* @constant {boolean} HAS_PROPERTY_SYMBOL_SUPPORT | ||
*/ | ||
var HAS_PROPERTY_SYMBOL_SUPPORT = typeof global.Object.getOwnPropertySymbols === 'function'; | ||
var SUPPORTS = { | ||
FLAGS: typeof /foo/g.flags === 'string', | ||
SYMBOL_PROPERTIES: typeof global.Object.getOwnPropertySymbols === 'function', | ||
WEAKSET: typeof global.WeakSet === 'function' | ||
}; | ||
/** | ||
* @constant {boolean} HAS_WEAKSET_SUPPORT | ||
*/ | ||
var HAS_WEAKSET_SUPPORT = typeof global.WeakSet === 'function'; | ||
// constants | ||
var create = Object.create, | ||
getKeys = Object.keys, | ||
getSymbols = Object.getOwnPropertySymbols, | ||
getPrototypeOf = Object.getPrototypeOf; | ||
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
/** | ||
* @function getNewCache | ||
@@ -38,3 +32,3 @@ * | ||
var getNewCache = function getNewCache() { | ||
return HAS_WEAKSET_SUPPORT ? new WeakSet() : create({ | ||
return SUPPORTS.WEAKSET ? new WeakSet() : create({ | ||
_values: [], | ||
@@ -50,21 +44,2 @@ add: function add(value) { | ||
/** | ||
* @function getPrototype | ||
* | ||
* @description | ||
* get the prototype of the object passed, using __proto__ when supported and | ||
* falling back to getPrototypeOf | ||
* | ||
* @param {any} object the object to get the prototype of | ||
* @returns {Object} the object's prototype | ||
*/ | ||
var getPrototype = function () { | ||
try { | ||
throw new Error(); | ||
} catch (error) { | ||
return getPrototypeOf; | ||
} | ||
}(); | ||
/** | ||
* @function getObjectToCopy | ||
@@ -76,3 +51,3 @@ * | ||
* @param {Object} object the object to copy | ||
* @param {any} realm the realm to base the object prototype on | ||
* @param {function} RealmObject the realm-specific Object constructor | ||
* @param {boolean} isPlainObject is the object a plain object | ||
@@ -82,6 +57,6 @@ * @returns {Object} an empty version of the object to copy | ||
var getObjectToCopy = function getObjectToCopy(object, realm, isPlainObject) { | ||
var getObjectToCopy = function getObjectToCopy(object, RealmObject, isPlainObject) { | ||
if (isPlainObject) { | ||
var prototype = getPrototype(object); | ||
return prototype === realm.Object.prototype ? {} : create(prototype); | ||
var prototype = object.__proto__ || getPrototypeOf(object); | ||
return prototype === RealmObject.prototype ? {} : create(prototype); | ||
} | ||
@@ -200,3 +175,4 @@ | ||
var copyBuffer = function copyBuffer(buffer, realm) { | ||
var newBuffer = realm.Buffer.allocUnsafe ? realm.Buffer.allocUnsafe(buffer.length) : new realm.Buffer(buffer.length); | ||
var RealmBuffer = realm.Buffer; | ||
var newBuffer = RealmBuffer.allocUnsafe ? RealmBuffer.allocUnsafe(buffer.length) : new RealmBuffer(buffer.length); | ||
buffer.copy(newBuffer); | ||
@@ -206,29 +182,40 @@ return newBuffer; | ||
/** | ||
* @function copyIterable | ||
* @function copyMap | ||
* | ||
* @description | ||
* copy the iterable values into a new iterable of the same type | ||
* copy the map values into a new map | ||
* | ||
* @param {function} assignmentHandler the handler for assigning the values to the new iterable | ||
* @returns {function((Map|Set), function, any): (Map|Set)} the copied iterable | ||
* @param {Map} map the map to copy | ||
* @param {function} copy the copy object method | ||
* @param {Object} realm the realm the constructor resides in | ||
* @returns {Map} the copied map | ||
*/ | ||
var createCopyIterable = function createCopyIterable(assignmentHandler) { | ||
return function (iterable, copy, realm) { | ||
var newIterable = new iterable.constructor(); | ||
iterable.forEach(assignmentHandler(newIterable, copy, realm)); | ||
return newIterable; | ||
}; | ||
var copyMap = function copyMap(map, copy, realm) { | ||
var newMap = new map.constructor(); | ||
map.forEach(function (value, key) { | ||
return newMap.set(key, copy(value, realm)); | ||
}); | ||
return newMap; | ||
}; | ||
var copyMap = createCopyIterable(function (iterable, copy, realm) { | ||
return function (value, key) { | ||
return iterable.set(key, copy(value, realm)); | ||
}; | ||
}); | ||
var copySet = createCopyIterable(function (iterable, copy, realm) { | ||
return function (value) { | ||
return iterable.add(copy(value, realm)); | ||
}; | ||
}); | ||
/** | ||
* @function copySet | ||
* | ||
* @description | ||
* copy the set values into a new set | ||
* | ||
* @param {Set} set the set to copy | ||
* @param {function} copy the copy object method | ||
* @param {Object} realm the realm the constructor resides in | ||
* @returns {Set} the copied set | ||
*/ | ||
var copySet = function copySet(set, copy, realm) { | ||
var newSet = new set.constructor(); | ||
set.forEach(function (value) { | ||
return newSet.add(copy(value, realm)); | ||
}); | ||
return newSet; | ||
}; | ||
/** | ||
* @function copyObject | ||
@@ -247,10 +234,6 @@ * | ||
var copyObject = function copyObject(object, copy, realm, isPlainObject) { | ||
var newObject = getObjectToCopy(object, realm, isPlainObject); | ||
var keys = getKeys(object); | ||
var newObject = getObjectToCopy(object, realm.Object, isPlainObject); | ||
if (keys.length) { | ||
var key; | ||
for (var index = 0; index < keys.length; index++) { | ||
key = keys[index]; | ||
for (var key in object) { | ||
if (hasOwnProperty.call(object, key)) { | ||
newObject[key] = copy(object[key], realm); | ||
@@ -260,11 +243,9 @@ } | ||
if (HAS_PROPERTY_SYMBOL_SUPPORT) { | ||
if (SUPPORTS.SYMBOL_PROPERTIES) { | ||
var symbols = getSymbols(object); | ||
if (symbols.length) { | ||
var symbol; | ||
for (var index = 0, symbol; index < symbols.length; index++) { | ||
symbol = symbols[index]; | ||
for (var _index = 0; _index < symbols.length; _index++) { | ||
symbol = symbols[_index]; | ||
if (propertyIsEnumerable.call(object, symbol)) { | ||
@@ -286,8 +267,8 @@ newObject[symbol] = copy(object[symbol], realm); | ||
* @param {RegExp} regExp the RegExp to copy | ||
* @param {any} realm the realm to check instanceof in | ||
* @param {function} RealmRegExp the realm-specific RegExp constructor | ||
* @returns {RegExp} the copied RegExp | ||
*/ | ||
var copyRegExp = function copyRegExp(regExp, realm) { | ||
var newRegExp = new realm.RegExp(regExp.source, HAS_FLAGS_SUPPORT ? regExp.flags : getRegExpFlags(regExp)); | ||
var copyRegExp = function copyRegExp(regExp, RealmRegExp) { | ||
var newRegExp = new RealmRegExp(regExp.source, SUPPORTS.FLAGS ? regExp.flags : getRegExpFlags(regExp)); | ||
newRegExp.lastIndex = regExp.lastIndex; | ||
@@ -311,2 +292,3 @@ return newRegExp; | ||
// utils | ||
var isArray = Array.isArray; | ||
/** | ||
@@ -328,2 +310,10 @@ * @function copy | ||
var _realm = realm, | ||
RealmArrayBuffer = _realm.ArrayBuffer, | ||
RealmBuffer = _realm.Buffer, | ||
RealmDate = _realm.Date, | ||
RealmMap = _realm.Map, | ||
RealmObject = _realm.Object, | ||
RealmRegExp = _realm.RegExp, | ||
RealmSet = _realm.Set; | ||
var cache = getNewCache(); | ||
@@ -336,3 +326,3 @@ | ||
if (Array.isArray(object)) { | ||
if (isArray(object)) { | ||
cache.add(object); | ||
@@ -342,3 +332,3 @@ return copyArray(object, handleCopy, realm); | ||
if (object.constructor === realm.Object) { | ||
if (object.constructor === RealmObject) { | ||
cache.add(object); | ||
@@ -348,11 +338,11 @@ return copyObject(object, handleCopy, realm, true); | ||
if (object instanceof realm.Date) { | ||
return new Date(object.getTime()); | ||
if (object instanceof RealmDate) { | ||
return new RealmDate(object.getTime()); | ||
} | ||
if (object instanceof realm.RegExp) { | ||
return copyRegExp(object, realm); | ||
if (object instanceof RealmRegExp) { | ||
return copyRegExp(object, RealmRegExp); | ||
} | ||
if (realm.Map && object instanceof realm.Map) { | ||
if (RealmMap && object instanceof RealmMap) { | ||
cache.add(object); | ||
@@ -362,3 +352,3 @@ return copyMap(object, handleCopy, realm); | ||
if (realm.Set && object instanceof realm.Set) { | ||
if (RealmSet && object instanceof RealmSet) { | ||
cache.add(object); | ||
@@ -368,12 +358,12 @@ return copySet(object, handleCopy, realm); | ||
if (realm.Buffer && realm.Buffer.isBuffer(object)) { | ||
if (RealmBuffer && RealmBuffer.isBuffer(object)) { | ||
return copyBuffer(object, realm); | ||
} | ||
if (realm.ArrayBuffer) { | ||
if (realm.ArrayBuffer.isView(object)) { | ||
if (RealmArrayBuffer) { | ||
if (RealmArrayBuffer.isView(object)) { | ||
return copyTypedArray(object); | ||
} | ||
if (object instanceof realm.ArrayBuffer) { | ||
if (object instanceof RealmArrayBuffer) { | ||
return copyArrayBuffer(object); | ||
@@ -398,3 +388,3 @@ } | ||
}))); | ||
})); | ||
//# sourceMappingURL=fast-copy.js.map |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.fastCopy={})}(this,function(e){"use strict";var b="string"==typeof/foo/g.flags,l="function"==typeof global.Object.getOwnPropertySymbols,t="function"==typeof global.WeakSet,p=Object.create,d=Object.keys,y=Object.getOwnPropertySymbols,n=Object.getPrototypeOf,g=Object.prototype.propertyIsEnumerable,h=function(){try{throw new Error}catch(e){return n}}(),v=function(e){return e.slice(0)},r=function(f){return function(e,t,n){var r=new e.constructor;return e.forEach(f(r,t,n)),r}},w=r(function(n,r,f){return function(e,t){return n.set(t,r(e,f))}}),O=r(function(t,n,r){return function(e){return t.add(n(e,r))}}),j=function(e,t,n,r){var f=function(e,t,n){if(n){var r=h(e);return r===t.Object.prototype?{}:p(r)}return e.constructor?new e.constructor:p(null)}(e,n,r),o=d(e);if(o.length)for(var u,a=0;a<o.length;a++)f[u=o[a]]=t(e[u],n);if(l){var i=y(e);if(i.length)for(var c,s=0;s<i.length;s++)c=i[s],g.call(e,c)&&(f[c]=t(e[c],n))}return f};e.default=function(e,y){void 0===y&&(y=global);var g=t?new WeakSet:p({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}});return function e(t){if(r=g,"object"!=typeof(n=t)||null===n||r.has(n))return t;var n,r,f,o,u,a,i,c,s,l,p,d;if(Array.isArray(t))return g.add(t),function(e,t,n){for(var r=new e.constructor,f=0;f<e.length;f++)r[f]=t(e[f],n);return r}(t,e,y);if(t.constructor===y.Object)return g.add(t),j(t,e,y,!0);if(t instanceof y.Date)return new Date(t.getTime());if(t instanceof y.RegExp)return f=t,(a=new y.RegExp(f.source,b?f.flags:(u="",(o=f).global&&(u+="g"),o.ignoreCase&&(u+="i"),o.multiline&&(u+="m"),o.unicode&&(u+="u"),o.sticky&&(u+="y"),u))).lastIndex=f.lastIndex,a;if(y.Map&&t instanceof y.Map)return g.add(t),w(t,e,y);if(y.Set&&t instanceof y.Set)return g.add(t),O(t,e,y);if(y.Buffer&&y.Buffer.isBuffer(t))return i=t,s=(c=y).Buffer.allocUnsafe?c.Buffer.allocUnsafe(i.length):new c.Buffer(i.length),i.copy(s),s;if(y.ArrayBuffer){if(y.ArrayBuffer.isView(t))return new(l=t).constructor(v(l.buffer));if(t instanceof y.ArrayBuffer)return v(t)}return d=y,"function"==typeof(p=t).then||p instanceof d.Error||d.WeakMap&&p instanceof d.WeakMap||d.WeakSet&&p instanceof d.WeakSet?t:(g.add(t),j(t,e,y))}(e)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self)["fast-copy"]={})}(this,function(e){"use strict";var n=Object.create,t=Object.getOwnPropertySymbols,r=Object.getPrototypeOf,o=Object.prototype,f=o.hasOwnProperty,u=o.propertyIsEnumerable,i="string"==typeof/foo/g.flags,c="function"==typeof global.Object.getOwnPropertySymbols,a="function"==typeof global.WeakSet,s=function(){return a?new WeakSet:n({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}})},l=function(e,n){return"object"==typeof e&&null!==e&&!n.has(e)},p=function(e,n){return!("function"==typeof e.then||e instanceof n.Error||n.WeakMap&&e instanceof n.WeakMap||n.WeakSet&&e instanceof n.WeakSet)},d=function(e,n,t){for(var r=new e.constructor,o=0;o<e.length;o++)r[o]=n(e[o],t);return r},y=function(e){return e.slice(0)},g=function(e,n){var t=n.Buffer,r=t.allocUnsafe?t.allocUnsafe(e.length):new t(e.length);return e.copy(r),r},b=function(e,n,t){var r=new e.constructor;return e.forEach(function(e,o){return r.set(o,n(e,t))}),r},v=function(e,n,t){var r=new e.constructor;return e.forEach(function(e){return r.add(n(e,t))}),r},h=function(e,o,i,a){var s=function(e,t,o){if(o){var f=e.__proto__||r(e);return f===t.prototype?{}:n(f)}return e.constructor?new e.constructor:n(null)}(e,i.Object,a);for(var l in e)f.call(e,l)&&(s[l]=o(e[l],i));if(c){var p=t(e);if(p.length)for(var d,y=0;y<p.length;y++)d=p[y],u.call(e,d)&&(s[d]=o(e[d],i))}return s},w=function(e,n){var t=new n(e.source,i?e.flags:function(e){var n="";return e.global&&(n+="g"),e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),e.sticky&&(n+="y"),n}(e));return t.lastIndex=e.lastIndex,t},O=function(e){return new e.constructor(y(e.buffer))},j=Array.isArray;e.default=function(e,n){void 0===n&&(n=global);var t=n,r=t.ArrayBuffer,o=t.Buffer,f=t.Date,u=t.Map,i=t.Object,c=t.RegExp,a=t.Set,_=s();return function e(t){if(!l(t,_))return t;if(j(t))return _.add(t),d(t,e,n);if(t.constructor===i)return _.add(t),h(t,e,n,!0);if(t instanceof f)return new f(t.getTime());if(t instanceof c)return w(t,c);if(u&&t instanceof u)return _.add(t),b(t,e,n);if(a&&t instanceof a)return _.add(t),v(t,e,n);if(o&&o.isBuffer(t))return g(t,n);if(r){if(r.isView(t))return O(t);if(t instanceof r)return y(t)}return p(t,n)?(_.add(t),h(t,e,n)):t}(e)},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -5,19 +5,7 @@ "use strict"; | ||
exports.HAS_WEAKSET_SUPPORT = exports.HAS_PROPERTY_SYMBOL_SUPPORT = exports.HAS_FLAGS_SUPPORT = void 0; | ||
/** | ||
* @constant {boolean} HAS_FLAGS_SUPPORT | ||
*/ | ||
var HAS_FLAGS_SUPPORT = typeof /foo/g.flags === 'string'; | ||
/** | ||
* @constant {boolean} HAS_PROPERTY_SYMBOL_SUPPORT | ||
*/ | ||
exports.HAS_FLAGS_SUPPORT = HAS_FLAGS_SUPPORT; | ||
var HAS_PROPERTY_SYMBOL_SUPPORT = typeof global.Object.getOwnPropertySymbols === 'function'; | ||
/** | ||
* @constant {boolean} HAS_WEAKSET_SUPPORT | ||
*/ | ||
exports.HAS_PROPERTY_SYMBOL_SUPPORT = HAS_PROPERTY_SYMBOL_SUPPORT; | ||
var HAS_WEAKSET_SUPPORT = typeof global.WeakSet === 'function'; | ||
exports.HAS_WEAKSET_SUPPORT = HAS_WEAKSET_SUPPORT; |
@@ -8,14 +8,2 @@ "use strict"; | ||
// utils | ||
/** | ||
* @function copy | ||
* | ||
* @description | ||
* deeply copy the object to a new object of the same type | ||
* | ||
* @param {any} object the object to copy | ||
* @param {any} [realm=global] the realm to check instanceof in | ||
* @returns {any} the copied object | ||
*/ | ||
function copy(object, realm) { | ||
@@ -22,0 +10,0 @@ if (realm === void 0) { |
151
lib/utils.js
@@ -8,3 +8,2 @@ "use strict"; | ||
// constants | ||
var create = Object.create, | ||
@@ -15,10 +14,2 @@ getKeys = Object.keys, | ||
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
/** | ||
* @function getNewCache | ||
* | ||
* @description | ||
* get a new cache object to prevent circular references | ||
* | ||
* @returns {Object|Weakset} the new cache object | ||
*/ | ||
@@ -36,13 +27,3 @@ var getNewCache = function getNewCache() { | ||
}; | ||
/** | ||
* @function getProto | ||
* | ||
* @description | ||
* get the __proto__ prototype property from the object | ||
* | ||
* @param {any} object the object to get the __proto__ from | ||
* @returns {Object} tthe prototype of the object | ||
*/ | ||
exports.getNewCache = getNewCache; | ||
@@ -53,14 +34,3 @@ | ||
}; | ||
/** | ||
* @function getPrototype | ||
* | ||
* @description | ||
* get the prototype of the object passed, using __proto__ when supported and | ||
* falling back to getPrototypeOf | ||
* | ||
* @param {any} object the object to get the prototype of | ||
* @returns {Object} the object's prototype | ||
*/ | ||
exports.getProto = getProto; | ||
@@ -81,15 +51,3 @@ | ||
}(); | ||
/** | ||
* @function getObjectToCopy | ||
* | ||
* @description | ||
* get the object to copy, including appropriate prototype | ||
* | ||
* @param {Object} object the object to copy | ||
* @param {any} realm the realm to base the object prototype on | ||
* @param {boolean} isPlainObject is the object a plain object | ||
* @returns {Object} an empty version of the object to copy | ||
*/ | ||
exports.getPrototype = getPrototype; | ||
@@ -105,13 +63,3 @@ | ||
}; | ||
/** | ||
* @function getRegExpFlags | ||
* | ||
* @description | ||
* get the flags to apply to the copied regexp | ||
* | ||
* @param {RegExp} regExp the regexp to get the flags of | ||
* @returns {string} the flags for the regexp | ||
*/ | ||
exports.getObjectToCopy = getObjectToCopy; | ||
@@ -144,14 +92,3 @@ | ||
}; | ||
/** | ||
* @function isObjectCopyable | ||
* | ||
* @description | ||
* is the object able to be copied | ||
* | ||
* @param {any} object the object to test | ||
* @param {Object|Weakset} cache the cache of copied values | ||
* @returns {boolean} can the object be copied | ||
*/ | ||
exports.getRegExpFlags = getRegExpFlags; | ||
@@ -162,14 +99,3 @@ | ||
}; | ||
/** | ||
* @function shouldObjectBeCopied | ||
* | ||
* @description | ||
* should the object be copied | ||
* | ||
* @param {any} object the object to test | ||
* @param {any} realm the realm to check instanceof in | ||
* @returns {boolean} should the object be copied | ||
*/ | ||
exports.isObjectCopyable = isObjectCopyable; | ||
@@ -180,15 +106,3 @@ | ||
}; | ||
/** | ||
* @function copyArray | ||
* | ||
* @description | ||
* copy the array, deeply copying the values | ||
* | ||
* @param {Array<any>} array the array to copy | ||
* @param {function} copy the function to copy values | ||
* @param {any} realm the realm to check instanceof in | ||
* @returns {Array<any>} the copied array | ||
*/ | ||
exports.shouldObjectBeCopied = shouldObjectBeCopied; | ||
@@ -205,13 +119,3 @@ | ||
}; | ||
/** | ||
* @function copyArrayBuffer | ||
* | ||
* @description | ||
* copy the arrayBuffer, deeply copying the values | ||
* | ||
* @param {ArrayBuffer} arrayBuffer the arrayBuffer to copy | ||
* @returns {ArrayBuffer} the copied bufarrayBufferfer | ||
*/ | ||
exports.copyArray = copyArray; | ||
@@ -222,14 +126,3 @@ | ||
}; | ||
/** | ||
* @function copyBuffer | ||
* | ||
* @description | ||
* copy the buffer, deeply copying the values | ||
* | ||
* @param {Buffer} buffer the buffer to copy | ||
* @param {any} realm the realm to check instanceof in | ||
* @returns {Buffer} the copied buffer | ||
*/ | ||
exports.copyArrayBuffer = copyArrayBuffer; | ||
@@ -242,13 +135,3 @@ | ||
}; | ||
/** | ||
* @function copyIterable | ||
* | ||
* @description | ||
* copy the iterable values into a new iterable of the same type | ||
* | ||
* @param {function} assignmentHandler the handler for assigning the values to the new iterable | ||
* @returns {function((Map|Set), function, any): (Map|Set)} the copied iterable | ||
*/ | ||
exports.copyBuffer = copyBuffer; | ||
@@ -276,15 +159,2 @@ | ||
}); | ||
/** | ||
* @function copyObject | ||
* | ||
* @description | ||
* copy the object values into a new object of the same type | ||
* | ||
* @param {Object} object the object to copy | ||
* @param {function} copy the copy method | ||
* @param {any} realm the realm to check instanceof in | ||
* @param {boolean} isPlainObject is the object to copy a plain object | ||
* @returns {Object} the copied object | ||
*/ | ||
exports.copySet = copySet; | ||
@@ -323,14 +193,3 @@ | ||
}; | ||
/** | ||
* @function copyRegExp | ||
* | ||
* @description | ||
* copy the RegExp to a new RegExp with the same properties | ||
* | ||
* @param {RegExp} regExp the RegExp to copy | ||
* @param {any} realm the realm to check instanceof in | ||
* @returns {RegExp} the copied RegExp | ||
*/ | ||
exports.copyObject = copyObject; | ||
@@ -343,13 +202,3 @@ | ||
}; | ||
/** | ||
* @function copyTypedArray | ||
* | ||
* @description | ||
* copy the typedArray, deeply copying the values | ||
* | ||
* @param {TypedArray} typedArray the typedArray to copy | ||
* @returns {TypedArray} the copied typedArray | ||
*/ | ||
exports.copyRegExp = copyRegExp; | ||
@@ -356,0 +205,0 @@ |
@@ -16,2 +16,3 @@ { | ||
}, | ||
"browser": "dist/fast-copy.js", | ||
"bugs": { | ||
@@ -34,3 +35,3 @@ "url": "https://github.com/planttheidea/fast-copy/issues" | ||
"deep-clone": "^3.0.3", | ||
"deep-eql": "^3.0.1", | ||
"deep-eql": "^4.0.0", | ||
"deep-equal": "^1.0.1", | ||
@@ -55,6 +56,6 @@ "deepclone": "^1.0.2", | ||
"react-fast-compare": "^2.0.2", | ||
"rollup": "^0.66.6", | ||
"rollup": "^1.1.2", | ||
"rollup-plugin-babel": "^4.0.1", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-terser": "^4.0.3", | ||
"shallow-equal-fuzzy": "^0.0.2", | ||
@@ -75,4 +76,4 @@ "sinon": "^7.0.0", | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
"main": "dist/fast-copy.cjs.js", | ||
"module": "dist/fast-copy.esm.js", | ||
"name": "fast-copy", | ||
@@ -84,23 +85,18 @@ "repository": { | ||
"scripts": { | ||
"benchmark": "NODE_ENV=production BABEL_ENV=test babel src --out-dir lib --no-comments && node benchmark/index.js", | ||
"benchmark": "npm run build && node benchmark/index.js", | ||
"build": "NODE_ENV=production rollup -c", | ||
"clean": "npm run clean:es && npm run clean:lib && npm run clean:dist", | ||
"clean:dist": "rimraf dist", | ||
"clean:es": "rimraf es", | ||
"clean:lib": "rimraf lib", | ||
"clean": "rimraf dist", | ||
"dev": "NODE_ENV=development webpack-dev-server --colors --progress --config=webpack/webpack.config.dev.js", | ||
"dist": "npm run clean:dist && npm run build", | ||
"dist": "npm run clean && npm run build", | ||
"lint": "NODE_ENV=test eslint src --max-warnings 0", | ||
"lint:fix": "NODE_ENV=test eslint src --fix", | ||
"prepublish": "if in-publish; then npm run prepublish:compile; fi", | ||
"prepublish:compile": "npm run lint && npm run test:coverage && npm run transpile:lib && npm run transpile:es && npm run dist", | ||
"prepublish:compile": "npm run lint && npm run test:coverage && npm run dist", | ||
"start": "npm run dev", | ||
"test": "NODE_PATH=. BABEL_ENV=test ava", | ||
"test:coverage": "nyc npm test", | ||
"test:watch": "npm test -- --watch", | ||
"transpile:es": "npm run clean:es && BABEL_ENV=es babel src --out-dir es", | ||
"transpile:lib": "npm run clean:lib && BABEL_ENV=lib babel src --out-dir lib" | ||
"test:watch": "npm test -- --watch" | ||
}, | ||
"types": "index.d.ts", | ||
"version": "1.2.3" | ||
"version": "1.2.4" | ||
} |
@@ -156,6 +156,3 @@ # fast-copy | ||
- build => build dist files with `rollup` | ||
- clean => run `clean:dist`, `clean:es`, and `clean:lib` scripts | ||
- clean:dist => run `rimraf` on the `dist` folder | ||
- clean:es => run `rimraf` on the `es` folder | ||
- clean:lib => run `rimraf` on the `lib` folder | ||
- clean => run `rimraf` on the `dist` folder | ||
- dev => start webpack playground App | ||
@@ -165,3 +162,3 @@ - dist => run `build` and `build:minified` scripts | ||
- lint:fix => run `lint` script, but with auto-fixer | ||
- prepublish:compile => run `lint`, `test:coverage`, `transpile:lib`, `transpile:es`, and `dist` scripts | ||
- prepublish:compile => run `lint`, `test:coverage`, and `dist` scripts | ||
- start => run `dev` | ||
@@ -171,3 +168,1 @@ - test => run AVA with NODE_ENV=test on all files in `test` folder | ||
- test:watch => run same script as `test` but keep persistent watcher | ||
- transpile:es => run Babel on all files in `src` folder (transpiled to `es` folder without transpilation of ES2015 export syntax) | ||
- transpile:lib => run Babel on all files in `src` folder (transpiled to `lib` folder) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100056
16
1184
166
1