Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mirror-own Version Badge

github actions coverage License Downloads

npm badge

Mirror (copy) the own property descriptors from one object, onto another.

Getting started

npm install --save mirror-own

Usage/Examples

const assert = require('assert');
const mirrorOwn = require('mirror-own');

const a = { a: 1, b: 2, [Symbol.toStringTag]: 'foo' };
const b = { c: 3 };

mirrorOwn(a, b);

assert.deepEqual(a, { a: 1, b: 2, [Symbol.toStringTag]: 'foo' }, 'source object unchanged');
assert.deepEqual(b, { a: 1, b: 2, c: 3, [Symbol.toStringTag]: 'foo' }, 'target object changed');

Options

You may pass an optional options object as the third argument. The available options are:

skipFailures

Must be a boolean, if present. If true, then non-configurable keys on to will be silently skipped.

omit

Must be a predicate function, if present. It will be invoked once per key of from, and if it returns a truthy value, that key will not be mirrored onto to.

Tests

Clone the repo, npm install, and run npm test

About

Mirror (copy) the own property descriptors from one object, onto another.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages