Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

copy-anything

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-anything - npm Package Compare versions

Comparing version 1.5.4 to 1.6.0

test/index.ts

1

.eslintrc.js

@@ -0,1 +1,2 @@

// npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-tree-shaking
module.exports = {

@@ -2,0 +3,0 @@ root: true,

23

build/rollup.js

@@ -5,4 +5,2 @@ /* eslint-disable */

import typescript from 'rollup-plugin-typescript2'
// import { terser } from 'rollup-plugin-terser'
// import resolve from 'rollup-plugin-node-resolve'

@@ -26,5 +24,3 @@ // ------------------------------------------------------------------------------------------

const external = Object.keys(pkg.dependencies || [])
const plugins = [
typescript({useTsconfigDeclarationDir: true}),
]
const plugins = [typescript({ useTsconfigDeclarationDir: true })]

@@ -38,10 +34,13 @@ // ------------------------------------------------------------------------------------------

plugins,
external
external,
}
// defaults.output
config.output = config.output.map(output => {
return Object.assign({
sourcemap: false,
name: className,
}, output)
return Object.assign(
{
sourcemap: false,
name: className,
},
output
)
})

@@ -55,6 +54,6 @@ return Object.assign(defaults, config)

output: [
{file: 'dist/index.cjs.js', format: 'cjs'},
{file: 'dist/index.esm.js', format: 'esm'},
{ file: 'dist/index.cjs.js', format: 'cjs' },
{ file: 'dist/index.esm.js', format: 'esm' },
],
}),
]

@@ -28,3 +28,3 @@ 'use strict';

function assignProp(carry, key, newVal, originalObject, nonenumerable) {
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
var propType = {}.propertyIsEnumerable.call(originalObject, key)

@@ -35,3 +35,3 @@ ? 'enumerable'

carry[key] = newVal;
if (nonenumerable && propType === 'nonenumerable') {
if (includeNonenumerable && propType === 'nonenumerable') {
Object.defineProperty(carry, key, {

@@ -49,8 +49,10 @@ value: newVal,

* @export
* @param {*} target Target can be anything
* @param {*} options Options can be `props` or `nonenumerable`.
* @returns {*} the target with replaced values
* @template T
* @param {T} target Target can be anything
* @param {Options} [options={}] Options can be `props` or `nonenumerable`
* @returns {T} the target with replaced values
* @export
*/
function copy(target, options) {
if (options === void 0) { options = { props: null, nonenumerable: false }; }
if (options === void 0) { options = {}; }
if (isWhat.isArray(target))

@@ -66,3 +68,2 @@ return target.map(function (i) { return copy(i, options); });

}
// @ts-ignore
var val = target[key];

@@ -69,0 +70,0 @@ var newVal = copy(val, options);

@@ -26,3 +26,3 @@ import { isArray, isPlainObject } from 'is-what';

function assignProp(carry, key, newVal, originalObject, nonenumerable) {
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
var propType = {}.propertyIsEnumerable.call(originalObject, key)

@@ -33,3 +33,3 @@ ? 'enumerable'

carry[key] = newVal;
if (nonenumerable && propType === 'nonenumerable') {
if (includeNonenumerable && propType === 'nonenumerable') {
Object.defineProperty(carry, key, {

@@ -47,8 +47,10 @@ value: newVal,

* @export
* @param {*} target Target can be anything
* @param {*} options Options can be `props` or `nonenumerable`.
* @returns {*} the target with replaced values
* @template T
* @param {T} target Target can be anything
* @param {Options} [options={}] Options can be `props` or `nonenumerable`
* @returns {T} the target with replaced values
* @export
*/
function copy(target, options) {
if (options === void 0) { options = { props: null, nonenumerable: false }; }
if (options === void 0) { options = {}; }
if (isArray(target))

@@ -64,3 +66,2 @@ return target.map(function (i) { return copy(i, options); });

}
// @ts-ignore
var val = target[key];

@@ -67,0 +68,0 @@ var newVal = copy(val, options);

{
"name": "copy-anything",
"sideEffects": false,
"version": "1.5.4",
"version": "1.6.0",
"description": "An optimised way to copy'ing an object. A small and simple integration",

@@ -13,3 +13,3 @@ "main": "dist/index.cjs.js",

"rollup": "rollup -c build/rollup.js",
"build": "npm run lint && npm run rollup && npm run test"
"build": "npm run lint && npm run test && npm run rollup"
},

@@ -38,16 +38,25 @@ "repository": {

"homepage": "https://github.com/mesqueeb/copy-anything#readme",
"dependencies": {
"is-what": "^3.6.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.16.0",
"@typescript-eslint/parser": "^2.16.0",
"ava": "^2.4.0",
"@typescript-eslint/eslint-plugin": "^2.19.2",
"@typescript-eslint/parser": "^2.19.2",
"ava": "^3.3.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-tree-shaking": "^1.8.0",
"rollup": "^1.29.0",
"rollup": "^1.31.0",
"rollup-plugin-typescript2": "^0.25.3",
"ts-node": "^8.6.2",
"typescript": "^3.7.5"
},
"dependencies": {
"is-what": "^3.5.1"
"ava": {
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}
}
import { isPlainObject, isArray } from 'is-what'
function assignProp (carry, key, newVal, originalObject, nonenumerable): void {
// @ts-ignore
type PlainObject = { [key: string | symbol]: any }
function assignProp (
carry: PlainObject,
key: string | symbol,
newVal: any,
originalObject: PlainObject,
includeNonenumerable: boolean
): void {
const propType = {}.propertyIsEnumerable.call(originalObject, key)

@@ -8,3 +17,3 @@ ? 'enumerable'

if (propType === 'enumerable') carry[key] = newVal
if (nonenumerable && propType === 'nonenumerable') {
if (includeNonenumerable && propType === 'nonenumerable') {
Object.defineProperty(carry, key, {

@@ -19,3 +28,3 @@ value: newVal,

export type Options = { props: any[]; nonenumerable: boolean }
export type Options = { props?: (string | symbol)[]; nonenumerable?: boolean }

@@ -26,11 +35,10 @@ /**

* @export
* @param {*} target Target can be anything
* @param {*} options Options can be `props` or `nonenumerable`.
* @returns {*} the target with replaced values
* @template T
* @param {T} target Target can be anything
* @param {Options} [options={}] Options can be `props` or `nonenumerable`
* @returns {T} the target with replaced values
* @export
*/
export default function copy (
target: any,
options: Options = { props: null, nonenumerable: false }
): any {
if (isArray(target)) return target.map(i => copy(i, options))
export default function copy<T extends any> (target: T, options: Options = {}): T {
if (isArray(target)) return target.map((i: any) => copy(i, options))
if (!isPlainObject(target)) return target

@@ -43,3 +51,2 @@ const props = Object.getOwnPropertyNames(target)

}
// @ts-ignore
const val = target[key]

@@ -49,3 +56,3 @@ const newVal = copy(val, options)

return carry
}, {})
}, {} as T)
}
export declare type Options = {
props: any[];
nonenumerable: boolean;
props?: (string | symbol)[];
nonenumerable?: boolean;
};

@@ -9,6 +9,8 @@ /**

* @export
* @param {*} target Target can be anything
* @param {*} options Options can be `props` or `nonenumerable`.
* @returns {*} the target with replaced values
* @template T
* @param {T} target Target can be anything
* @param {Options} [options={}] Options can be `props` or `nonenumerable`
* @returns {T} the target with replaced values
* @export
*/
export default function copy(target: any, options?: Options): any;
export default function copy<T extends any>(target: T, options?: Options): T;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc