2.0.2 • Published 6 years ago

oassign v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

oassign

Yes, it is just another Object.assign.

Build Status NPM version

FAQ

Why not Object.assign by itself?

Mostly because Object.assign changes first of merged objects.

// So it is boring to write everytime something like that:
const newObj = Object.assign({}, firstObj, secondObj);
// instead of something like that:
const newObj = oassign(ofirstObj, secondObj);

Why not destructuring assignment?

Mostly because destructuring assignment treats strings as arrays of chars. Also because for some people destructuring assignment is not readable enough (for example sometime they can forget ellipsis). But destructuring assignment is not bad too if you prefer it.

Features

  • don't changes source objects
  • ignores all parameters except objects and arrays

Install

npm i oassign

Usage

const oassign = require('oassign');
console.log(oassign({a: 1}, [2], 'bad', null));
// {a: 1, 0: 2}
console.log(oassign('bad'));
// {}

License

MIT