6.0.0 • Published 6 months ago

collapse-prototypes v6.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 months ago

collapse-prototypes

npm version Build status

Return an object with prototype properties included as own properties (for serialization purposes)

Example

import collapse from 'collapse-prototypes';

let parent = {
  foo: 1
};

let child = Object.create(parent);

child.bar = 2;

let collapsed = collapse(child);

console.log(collapsed); // { foo: 1, bar: 2 }

Installation

yarn add collapse-prototypes

API

collapse(obj, {
  // useful if you're going to serialize, because `toJSON` and getters
  // may not like the new prototype-less object
  // Default value (false)
  stripFunctions: true,

  // speeds up collapsing if you don't need them
  // Default value (false)
  excludeNonenumerable: true,

  // useful if you're going to stringify (uses `json-stringify-safe`)
  // Default value (false)
  dropCycles: true,

  // prepend the debug log to differentiate calls using the `debug` package
  // (DEBUG=collapse-prototypes)
  // Default value ('')
  debugLabel: 'obj'
});
6.0.0

6 months ago

5.0.0

10 months ago

4.0.0

1 year ago

3.0.0

3 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago