npm

Check out our latest tech talk, "JavaScript Supply Chain Security" presented by VP of Security, Adam Baldwin.Watch it here »

app.let

0.1.6 • Public • Published

app.let

"app.let" polyfills 'let' for Object props. Additionally, it also provides a 'private' Map for Objects

applet = require('app.let')()

By default trying to reset an Object's property that is a 'let' property does not throw errors. To throw errors:

applet = require('app.let')({strict:true})

The 'app.let' Symbol('@let') can also be customized:

applet = require('app.let')({ symbol:'custom-symbol' })

app.let is class Leter

class Leter extends Map
get symbol() => Symbol
get name() => Symbol string value
get privates() => Leter private map
get isLeter() => true

def(obj) => obj w/ let defined
priv(obj) => obj w/ private Map defined
sudo(obj) => get or set if not defined obj's private Map

app.let use:

applet=require('app.let')()
obj=applet.def( { hello:'world' } )


obj.let('hello')
obj.hello = 'saturn'
obj.hello // returns 'world' or if strict throws Error

applet.sudo(obj).set('hello','private world')
applet.sudo(obj).get('hello') // 'private world'

Notes:

- app.let uses Object.watch or watch (sans unwatch) polyfill from https://gist.github.com/eligrey/384583

install

npm i app.let

Downloadsweekly downloads

6

version

0.1.6

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability