normalize-object-inheritance

1.0.1 • Public • Published

Normalize object

A small recursive library which makes sure that all objects are an instance of the Object class.

Some libraries do not provide interoperability by returning arrays with completely empty objects (no toString() or keys() or hasOwnProperty() functions) which most libraries cannot deal with.

You do not need this library

The following line fixes this problem as well: obj = JSON.parse(JSON.stringify(obj)) However this is ~20% slower than this library because it does not work in place and take cpu to serialize the object, which is not actually what we want.

Usage

import normalizeObject from 'normalizeObject';

obj = normalizeObject(obj);

To be able to normalize the root object, in case it is a null type object, it is needed to reassign the value to the output of the function. If you are 100% sure the root object will not be a null type object this is not needed.

Package Sidebar

Install

npm i normalize-object-inheritance

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

4.12 kB

Total Files

4

Last publish

Collaborators

  • amicopo