Package Exports
- normalize-object-inheritance
- normalize-object-inheritance/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (normalize-object-inheritance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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.