JSPM

reconstruct-descriptors

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

Deeply reconstruct any object iterating over its property descriptors.

Package Exports

  • reconstruct-descriptors

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

Readme

reconstruct-descriptors

Build Status

Deeply reconstruct any object iterating over its property descriptors.

Install

reconstruct-descriptors is published on NPM Registry, so you can install it using any node package manager.

npm install reconstruct-descriptors

# If you're using Yarn.
yarn add reconstruct-descriptors

Usage

This module exports a function that receives an object and a function to iterate over property descriptors.

import reconstruct from 'reconstruct-descriptors'

const immutable = (object) => reconstruct(object, (descriptor, property) => ({
  [property]: {
    ...descriptor,
    writable: false,
    configurable: false
  }
}))

const user = immutable({ name: 'Ryan' })

user.name = 'Bruno'
console.log(user.name) // 'Ryan'

delete user.name
console.log(user.name) // 'Ryan'

License

Released under MIT license. You can see it here.