copy-anything
Advanced tools
Comparing version 2.0.1 to 2.0.3
@@ -23,3 +23,5 @@ /* eslint-disable */ | ||
const external = Object.keys(pkg.dependencies || []) | ||
const plugins = [typescript({ useTsconfigDeclarationDir: true })] | ||
const plugins = [ | ||
typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: { exclude: ['test/**/*'] } }), | ||
] | ||
@@ -26,0 +28,0 @@ // ------------------------------------------------------------------------------------------ |
@@ -8,14 +8,14 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -52,3 +52,3 @@ | ||
* @param {T} target Target can be anything | ||
* @param {Options} [options={}] Options can be `props` or `nonenumerable` | ||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable` | ||
* @returns {T} the target with replaced values | ||
@@ -60,3 +60,3 @@ * @export | ||
if (isWhat.isArray(target)) | ||
return target.map(function (i) { return copy(i, options); }); | ||
return target.map(function (item) { return copy(item, options); }); | ||
if (!isWhat.isPlainObject(target)) | ||
@@ -63,0 +63,0 @@ return target; |
import { isArray, isPlainObject } from 'is-what'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -47,3 +47,3 @@ | ||
* @param {T} target Target can be anything | ||
* @param {Options} [options={}] Options can be `props` or `nonenumerable` | ||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable` | ||
* @returns {T} the target with replaced values | ||
@@ -55,3 +55,3 @@ * @export | ||
if (isArray(target)) | ||
return target.map(function (i) { return copy(i, options); }); | ||
return target.map(function (item) { return copy(item, options); }); | ||
if (!isPlainObject(target)) | ||
@@ -58,0 +58,0 @@ return target; |
{ | ||
"name": "copy-anything", | ||
"sideEffects": false, | ||
"version": "2.0.1", | ||
"version": "2.0.3", | ||
"description": "An optimised way to copy'ing an object. A small and simple integration", | ||
@@ -16,15 +16,16 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"is-what": "^3.7.1" | ||
"is-what": "^3.12.0" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.23.0", | ||
"@typescript-eslint/parser": "^2.23.0", | ||
"ava": "^3.5.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.0", | ||
"@typescript-eslint/eslint-plugin": "^4.14.2", | ||
"@typescript-eslint/parser": "^4.14.2", | ||
"ava": "^3.15.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-tree-shaking": "^1.8.0", | ||
"rollup": "^1.32.1", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"ts-node": "^8.6.2", | ||
"typescript": "^3.8.3" | ||
"rollup": "^2.38.4", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"ts-node": "^9.1.1", | ||
"tsconfig-paths": "^3.9.0", | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -60,2 +61,3 @@ "keywords": [ | ||
"require": [ | ||
"tsconfig-paths/register", | ||
"ts-node/register" | ||
@@ -62,0 +64,0 @@ ] |
import { isPlainObject, isArray } from 'is-what' | ||
// @ts-ignore | ||
type PlainObject = { [key: string | symbol]: any } | ||
type PlainObject = { [key in string | symbol]: any } | ||
@@ -16,3 +15,3 @@ function assignProp ( | ||
: 'nonenumerable' | ||
if (propType === 'enumerable') carry[key] = newVal | ||
if (propType === 'enumerable') carry[key as any] = newVal | ||
if (includeNonenumerable && propType === 'nonenumerable') { | ||
@@ -36,3 +35,3 @@ Object.defineProperty(carry, key, { | ||
* @param {T} target Target can be anything | ||
* @param {Options} [options={}] Options can be `props` or `nonenumerable` | ||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable` | ||
* @returns {T} the target with replaced values | ||
@@ -42,3 +41,3 @@ * @export | ||
export function copy<T extends any> (target: T, options: Options = {}): T { | ||
if (isArray(target)) return target.map((i: any) => copy(i, options)) | ||
if (isArray(target)) return target.map((item) => copy(item, options)) as T | ||
if (!isPlainObject(target)) return target | ||
@@ -45,0 +44,0 @@ const props = Object.getOwnPropertyNames(target) |
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "./dist", | ||
@@ -10,4 +11,5 @@ "declaration": true, | ||
"include": [ | ||
"src/**/*" | ||
"src/**/*", | ||
"test/**/*" | ||
] | ||
} |
@@ -11,3 +11,3 @@ export declare type Options = { | ||
* @param {T} target Target can be anything | ||
* @param {Options} [options={}] Options can be `props` or `nonenumerable` | ||
* @param {Options} [options = {}] Options can be `props` or `nonenumerable` | ||
* @returns {T} the target with replaced values | ||
@@ -14,0 +14,0 @@ * @export |
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
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
25299
0
517
11
Updatedis-what@^3.12.0