JSPM

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

defines static object attributes using Object.defineProperties

Package Exports

  • static-props

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

Readme

static-props

defines static object attributes using Object.defineProperties

js-standard-style

Usage

'use strict'

var staticProps = require('static-props')

class Point2d {
  constructor (x, y) {
    this.x = x
    this.y = y

    // Suppose you have few static attributes in your class.
    const label = 'A'
    const color = 'red'

    // Add static attributes quickly.
    staticProps(this)({label, color})
  }
}

var p = new Point(1, 2)

// Trying to modify a static prop will throw as you expect.
p.label = 'B'
// TypeError: Cannot assign to read only property 'label' of #<Point2d>

License

MIT