def-prop
v2.0.2
Published
def(prop())
Downloads
5
Readme
def-prop
Simple and easy API around Object.defineProperty.
def
—Object.defineProperty
.val
— const value, not enumerable, writable or configurable. Append:enum
,:write
and:config
string literals to enable corresponding traits.getset
— getter-setter pair. If no setter then it is disabled. Append:enum
,:write
and:config
string literals to enable corresponding traits.:enum
— enumerable.:write
— writable.:config
— configurable.
npm i def-prop
import def from 'def-prop'
import val from 'def-prop/val'
import getset from 'def-prop/getset'
var object = {}
def(object,'prop', val(5))
def(object,'prop', val(5, ':enum'))
def(object,'prop', val(5, ':config', ':enum'))
def(object, 'prop', getset(() => 'getter'))
def(object, 'prop', getset(() => 'getter', v => { 'setter' }))
def(object, 'prop', getset(() => 'getter', ':enum'))
def(object, 'prop', getset(() => 'getter', v => { 'setter' }, ':enum'))
Vanilla CJS package, available both in ESM/CJS. Typings included.
license
MIT. © Strider, 2023.