copy-anything
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -29,3 +29,3 @@ 'use strict'; | ||
function assignProp(carry, key, newVal, originalObject, nonenumerable) { | ||
var propType = originalObject.propertyIsEnumerable(key) | ||
var propType = {}.propertyIsEnumerable.call(originalObject, key) | ||
? 'enumerable' | ||
@@ -40,3 +40,3 @@ : 'nonenumerable'; | ||
writable: true, | ||
configurable: true | ||
configurable: true, | ||
}); | ||
@@ -43,0 +43,0 @@ } |
@@ -27,3 +27,3 @@ import { isArray, isPlainObject } from 'is-what'; | ||
function assignProp(carry, key, newVal, originalObject, nonenumerable) { | ||
var propType = originalObject.propertyIsEnumerable(key) | ||
var propType = {}.propertyIsEnumerable.call(originalObject, key) | ||
? 'enumerable' | ||
@@ -38,3 +38,3 @@ : 'nonenumerable'; | ||
writable: true, | ||
configurable: true | ||
configurable: true, | ||
}); | ||
@@ -41,0 +41,0 @@ } |
{ | ||
"name": "copy-anything", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "An optimised way to copy'ing an object. A small and simple integration", | ||
@@ -10,4 +10,5 @@ "main": "dist/index.cjs.js", | ||
"test": "ava", | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", | ||
"rollup": "rollup -c build/rollup.js", | ||
"build": "npm run rollup && npm run test" | ||
"build": "npm run lint && npm run rollup && npm run test" | ||
}, | ||
@@ -37,10 +38,15 @@ "repository": { | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.16.0", | ||
"@typescript-eslint/parser": "^2.16.0", | ||
"ava": "^2.4.0", | ||
"rollup": "^1.27.3", | ||
"rollup-plugin-typescript2": "^0.25.2", | ||
"typescript": "^3.7.2" | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-plugin-tree-shaking": "^1.8.0", | ||
"rollup": "^1.29.0", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"typescript": "^3.7.5" | ||
}, | ||
"dependencies": { | ||
"is-what": "^3.3.1" | ||
"is-what": "^3.5.0" | ||
} | ||
} |
import { isPlainObject, isArray } from 'is-what' | ||
function assignProp (carry, key, newVal, originalObject, nonenumerable) { | ||
const propType = originalObject.propertyIsEnumerable(key) | ||
function assignProp (carry, key, newVal, originalObject, nonenumerable): void { | ||
const propType = {}.propertyIsEnumerable.call(originalObject, key) | ||
? 'enumerable' | ||
@@ -13,3 +13,3 @@ : 'nonenumerable' | ||
writable: true, | ||
configurable: true | ||
configurable: true, | ||
}) | ||
@@ -19,3 +19,3 @@ } | ||
export type Options = {props: any[], nonenumerable: boolean} | ||
export type Options = { props: any[]; nonenumerable: boolean } | ||
@@ -32,3 +32,3 @@ /** | ||
target: any, | ||
options: Options = {props: null, nonenumerable: false} | ||
options: Options = { props: null, nonenumerable: false } | ||
): any { | ||
@@ -39,13 +39,12 @@ if (isArray(target)) return target.map(i => copy(i, options)) | ||
const symbols = Object.getOwnPropertySymbols(target) | ||
return [...props, ...symbols] | ||
.reduce((carry, key) => { | ||
if (isArray(options.props) && !options.props.includes(key)) { | ||
return carry | ||
} | ||
// @ts-ignore | ||
const val = target[key] | ||
const newVal = copy(val, options) | ||
assignProp(carry, key, newVal, target, options.nonenumerable) | ||
return [...props, ...symbols].reduce((carry, key) => { | ||
if (isArray(options.props) && !options.props.includes(key)) { | ||
return carry | ||
}, {}) | ||
} | ||
// @ts-ignore | ||
const val = target[key] | ||
const newVal = copy(val, options) | ||
assignProp(carry, key, newVal, target, options.nonenumerable) | ||
return carry | ||
}, {}) | ||
} |
25657
15
538
9
Updatedis-what@^3.5.0