Reduction for Object.defineProperty method for define accessors (getters and setters)
import { define } from '@biorate/tools';
const obj = {
_value: 0,
};
define.accessor(
obj,
'value',
{
get() {
return this._value;
},
set(value: number) {
this._value = value;
},
},
'cw',
);
console.log(obj); // { _value: 0 }
console.log(Object.getOwnPropertyDescriptor(obj, 'value'));
// {
// get: [Function: get],
// set: [Function: set],
// enumerable: false,
// configurable: true
// }
Generated using TypeDoc
Object to define property