JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 30
  • Score
    100M100P100Q52991F
  • License MIT

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

Package Exports

  • collapse-prototypes

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 (collapse-prototypes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

collapse-prototypes

npm version Build Status 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'
});