hard-prop
Easy way to create properties with getter and/or setter.
Install
npm install hard-prop
Usage
var prop = object; ;;;;;;;
Creates function, that defines properties for given object.
First parameter name
must be string.
Second parameter can be object with properties get
and/or set
for getter and/or setter. In other way one or more functions can be given as parameters. Function with no arguments will be getter, and function with arguments will be setter (only first argument counts).
If only getter given - property will be read-only (error will thrown on write). If only setter given - property will be write-only (error will thrown on read). At least one getter or setter must be given.
Examples
Class way:
const P = ; { const _p = ; const _firstname _lastname = firstname lastname; ;}
Closure way:
const P = ; const Humanfirstname lastname => const _name = firstname lastname; const _p = ; ;
License
MIT