@hgargg-0710/one
Version:
A tiny npm library purposed for providing beautiful solutions to frequent miniature (one-line/one-expression) tasks for various JS datatypes.
28 lines (27 loc) • 1.13 kB
JavaScript
/**
* Returns a get-set `PropertyDescriptor`
*/
export const GetSetDescriptor = (get, set) => ({
get,
set
});
/**
* Returns a non-configurable, non-writable, non-enumerable constant property descriptor
*/
export const ConstDescriptor = (value) => ({ value });
/**
* Returns a new property descriptor using corresponding flags
*/
export const Descriptor = (value, configurable = false, writable = false, enumerable = false) => ({ value, configurable, writable, enumerable });
/**
* Returns an enumerable property descriptor, otherwise defined by corresponding flags
*/
export const EnumerableDescriptor = (value, configurable, writable) => Descriptor(value, configurable, writable, true);
/**
* Returns a configurable property descriptor, otherwise defined by corresponding flags
*/
export const ConfigurableDescriptor = (value, writable, enumerable) => Descriptor(value, true, writable, enumerable);
/**
* Returns a writable property descriptor, otherwise defined by the given flags.
*/
export const WritableDescriptor = (value, configurable, enumerable) => Descriptor(value, configurable, true, enumerable);