prototype-stringify

1.0.2 • Public • Published

prototype-stringify

stringify simple object, including data in prototypes.

Install

npm install prototype-stringify

Usage

var a = { b: 1, c: { d: 2 }, e: { f: 3 } };
var aa = Object.create(a);

aa.bb = 11;
aa.c.dd = 22;
aa.e = Object.create(a.e);
aa.e.ff = 33;

var s1 = JSON.stringify(aa);		//JSON.stringify() exclude data in prototype
console.log("JSON.stringify():\n\t" + s1);
//{"bb":11,"e":{"ff":33}}

var s2 = prototype_stringify(aa);		//to include data in prototypes
console.log("prototype_stringify():\n\t" + s2);
//{"b":1,"bb":11,"c":{"d":2,"dd":22},"e":{"f":3,"ff":33}}

/*
var expect = {
    b: 1,
    bb: 11,
    c: {
        d: 2,
        dd: 22
    },
    e: {
        f: 3,
        ff: 33
    }
};
*/

Readme

Keywords

Package Sidebar

Install

npm i prototype-stringify

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

8.94 kB

Total Files

6

Last publish

Collaborators

  • adf0001