@typescript-package/descriptor
Version:
A lightweight TypeScript library for property descriptor.
547 lines (539 loc) • 29.4 kB
JavaScript
/**
* @description The common properties for descriptors.
* @export
* @abstract
* @class CommonDescriptor
* @template {boolean} [C=boolean] The type of configurable property.
* @template {boolean} [E=boolean] The type of enumerable property.
* @implements {Pick<PropertyDescriptor, 'configurable' | 'enumerable'>}
*/
class CommonDescriptor {
/**
* @description The default value for configurable.
* @public
* @static
* @type {?boolean}
*/
static configurable;
//
/**
* @description The default value for enumerable.
* @public
* @static
* @type {?boolean}
*/
static enumerable;
//#region Property descriptor
/**
* @description The configurable property.
* @public
* @type {?C}
*/
configurable;
/**
* @description The enumerable property.
* @public
* @type {?E}
*/
enumerable;
//#endregion
/**
* Creates an instance of `CommonDescriptor` child class.
* @constructor
* @param {CommonPropertyDescriptor<C, E>} [param0={}] Object containing configurable and enumerable properties.
* @param {CommonPropertyDescriptor<C, E>} param0.configurable The configurable property. Defaults to static configurable value.
* @param {CommonPropertyDescriptor<C, E>} param0.enumerable The enumerable property. Defaults to static enumerable value.
*/
constructor({ configurable, enumerable } = {}) {
delete this.configurable, delete this.enumerable;
typeof configurable === 'boolean'
? (this.configurable = configurable)
: typeof CommonDescriptor.configurable === 'boolean' && (this.configurable = CommonDescriptor.configurable);
typeof enumerable === 'boolean'
? (this.enumerable = enumerable)
: typeof CommonDescriptor.enumerable === 'boolean' && (this.enumerable = CommonDescriptor.enumerable);
}
}
// Abstract,
/**
* @description The `AccessorDescriptor` class is a concrete implementation of the `CommonDescriptor` class that represents an accessor property descriptor.
* @export
* @class AccessorDescriptor
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of property key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of value captured from the object.
* @template {boolean} [C=boolean] The type of the configurable property.
* @template {boolean} [E=boolean] The type of the enumerable property.
* @extends {CommonDescriptor<C, E>} Common descriptor properties.
*/
class AccessorDescriptor extends CommonDescriptor {
/**
* @description Creates an instance of `AccessorDescriptor`.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of property key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of value captured from the object.
* @template {boolean} [C=boolean] The type of the configurable property.
* @template {boolean} [E=boolean] The type of the enumerable property.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0 Accessor descriptor properties.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.configurable The type of configurable of `C`.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.enumerable The type of enumerable of `E`.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.get The type of the getter function.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.set The type of the setter function.
* @param {?O} [object] The object (non-stored) to define the descriptor on and capture the `this` context.
* @param {?K} [key] The (non-stored) key to define the descriptor on.
* @param {?ValidationCallback<ThisAccessorPropertyDescriptor<V, O, C, E>>} [onValidate]
* @returns {AccessorDescriptor<O, K, V, C, E>}
*/
static create({ configurable, enumerable, get, set }, object, key, onValidate) {
return new AccessorDescriptor({ configurable, enumerable, get, set }, object, key, onValidate);
}
/**
* @description Returns strictly defined accessor descriptor of a `ThisAccessorPropertyDescriptor<V, O, C, E>` type on `get` or `set` property detected.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the object key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of the object value.
* @template {boolean} [C=boolean] The type of the configurable property.
* @template {boolean} [E=boolean] The type of the enumerable property.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0 The accessor descriptor attributes.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.configurable The configurable of `C` type.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.enumerable The configurable of `E` type.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.get The getter.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.set The setter.
* @param {?O} [object] The object (non-stored) to define the descriptor on and capture the `this` context.
* @param {?K} [key] The (non-stored) key to define the descriptor on and capture the type of value.
* @param {?ValidationCallback<ThisAccessorPropertyDescriptor<V, O, C, E>>} [onValidate] A `ValidationCallback` function to handle the result of the check whether the `descriptor` is an `object` with `get` or `set` property.
* @returns {(ThisAccessorPropertyDescriptor<V, O, C, E> | undefined)} The returned value is an `object` of a `ThisAccessorPropertyDescriptor<V, O, C, E>` type.
*/
static define({ configurable, enumerable, get, set }, object, key, onValidate) {
return this.guard({ configurable, enumerable, get, set }, onValidate)
? {
...(configurable || AccessorDescriptor.configurable) && { configurable: configurable || AccessorDescriptor.configurable },
...(enumerable || AccessorDescriptor.enumerable) && { enumerable: enumerable || AccessorDescriptor.enumerable },
...set && { set },
...get && { get },
}
: undefined;
}
/**
* @description Guards the `descriptor` to be an `object` of a `ThisAccessorPropertyDescriptor<V, O, C, E>` type.
* @public
* @static
* @template V The type of the value.
* @template O The type of the object.
* @template {boolean} [C=boolean] The type of the configurable.
* @template {boolean} [E=boolean] The type of the enumerable.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} descriptor The object of a `ThisAccessorPropertyDescriptor<V, O, C, E>` type to guard.
* @param {?ValidationCallback<ThisAccessorPropertyDescriptor<V, O, C, E>>} [callbackFn] A `ValidationCallback` function to handle the result of the check whether or not the descriptor is an `object` containing the `get` or `set` property.
* @returns {descriptor is ThisAccessorPropertyDescriptor<V, O, C, E>} The return value is a boolean indicating whether the `descriptor` is an `object` with the `get` or `set` property.
*/
static guard(descriptor, callbackFn) {
const result = typeof descriptor === 'object'
&& (('get' in descriptor && typeof descriptor.get === 'function')
||
('set' in descriptor && typeof descriptor.set === 'function'))
&& !('value' in descriptor || 'writable' in descriptor);
return callbackFn?.(result, descriptor) || result;
}
//#region Accessor descriptor.
/**
* @description The getter function.
* @public
* @type {?() => V}
*/
get;
/**
* @description The setter function.
* @public
* @type {?(value: V) => void}
*/
set;
//#endregion
/**
* Creates an instance of `AccessorDescriptor`.
* @constructor
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0 The properties of the accessor descriptor.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.configurable The configurable of generic type variable `C`.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.enumerable The enumerable of generic type variable `E`.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.get The getter function.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.set The setter function.
* @param {?O} [object] The object (non-stored) to define the descriptor on.
* @param {?K} [key] The (non-stored) key to define the descriptor on.
* @param {?ValidationCallback<ThisAccessorPropertyDescriptor<V, O, C, E>>} [onValidate]
*/
constructor({ configurable, enumerable, get, set }, object, key, onValidate) {
onValidate && AccessorDescriptor.guard({ configurable, enumerable, get, set }, onValidate);
super({ configurable, enumerable });
delete this.get, delete this.set;
'get' in arguments[0] && (this.get = get);
'set' in arguments[0] && (this.set = set);
}
}
// Abstract.
/**
* @description The `DataDescriptor` class is a concrete implementation of the `CommonDescriptor` class that represents a data property descriptor.
* @export
* @class DataDescriptor
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of property key.
* @template [V=K extends keyof O ? O[K] : any] The type of value captured from the object.
* @template {boolean} [C=boolean] The type of the configurable property.
* @template {boolean} [E=boolean] The type of the enumerable property.
* @template {boolean} [W=boolean] The type of the writable property.
* @extends {CommonDescriptor<C, E>}
*/
class DataDescriptor extends CommonDescriptor {
/**
* @description Creates an instance of `DataDescriptor`.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the property key.
* @template [V=K extends keyof O ? O[K] : any] The type of the value captured from the object.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @template {boolean} [W=boolean] The type of writable.
* @param {DataPropertyDescriptor<V, C, E, W>} param0 Data descriptor properties.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.configurable The configurable property.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.enumerable The enumerable property.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.value The value for data descriptor.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.writable The writable property.
* @param {?O} [object] The object (non-stored) to define the descriptor on. The object is optional, if not provided the descriptor will be created without an object.
* @param {?K} [key] The property key to define the descriptor on. The key is optional, if not provided the descriptor will be created without a key.
* @param {?ValidationCallback<DataPropertyDescriptor<V, C, E, W>>} [onValidate] An optional validation callback to validate the descriptor.
* @returns {(DataDescriptor<O, K, V, C, E, W> | undefined)} The returned
*/
static create({ configurable, enumerable, value, writable }, object, key, onValidate) {
return new DataDescriptor({ configurable, enumerable, value, writable }, object, key, onValidate);
}
/**
* @description Returns strictly defined data descriptor of a `DataPropertyDescriptor<V, C, E, W>` interface on `writable` or `value` property detected.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the object key.
* @template [V=K extends keyof O ? O[K] : any] The type of value.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @template {boolean} [W=boolean] The type of writable.
* @param {DataPropertyDescriptor<V, C, E, W>} param0 An `object` of a `DataPropertyDescriptor<V, C, E, W>` interface, to set with the default values of the `CommonDescriptor`.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.configurable The descriptor configurable.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.enumerable The descriptor enumerable.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.value The descriptor value.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.writable The descriptor writable.
* @param {?O} [object] The object (non-stored) to define the descriptor on. The object is optional, if not provided the descriptor will be created without an object.
* @param {?K} [key] The (non-stored) key to define the descriptor on.
* @param {?ValidationCallback<DataPropertyDescriptor<V, C, E, W>>} [onValidate] An optional `ResultCallback` function to handle the result of the check whether or not the `descriptor` is an `object` with the `writable` or `value` property, by default it uses `dataCallback()` function from the static `guard()` method.
* @returns {(DataPropertyDescriptor<V, C, E, W> | undefined)} The return value is an `object` of a `DataPropertyDescriptor<V, C, E, W>` interface.
*/
static define({ configurable, enumerable, value, writable }, object, key, onValidate) {
return this.guard({ configurable, enumerable, value, writable }, onValidate)
? {
...{
configurable: CommonDescriptor.configurable,
enumerable: DataDescriptor.enumerable,
writable: DataDescriptor.writable,
},
...{ configurable, enumerable, value, writable }
}
: undefined;
}
/**
* @description Guards the `descriptor` to be an `object` of a `DataPropertyDescriptor<Value>` interface.
* @public
* @static
* @template V The type of the value.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @template {boolean} [W=boolean] The type of writable.
* @param {DataPropertyDescriptor<V, C, E, W>} descriptor Object of a `DataPropertyDescriptor<Value>` interface to guard.
* @param {?ValidationCallback<DataPropertyDescriptor<V, C, E, W>>} [callbackFn] A `ResultCallback` function to handle the result of the check whether or not the `descriptor` is an `object` with the `writable` or `value` property, by default it uses `dataCallback()` function.
* @returns {descriptor is DataPropertyDescriptor<V, C, E, W>} The return value is a `boolean` indicating whether the `descriptor` is an `object` with the `writable` or `value` property.
*/
static guard(descriptor, callbackFn) {
return typeof callbackFn === 'function'
? callbackFn(typeof descriptor === 'object'
&& 'value' in descriptor
&& !('get' in descriptor || 'set' in descriptor), descriptor)
: false;
}
/**
* @description Defaults to writable.
* @public
* @static
* @type {?boolean}
*/
static writable;
/**
* @description The value of the descriptor.
* @public
* @type {?V}
*/
value;
/**
* @description The writable of the descriptor.
* @public
* @type {?W}
*/
writable;
/**
* Creates an instance of `DataDescriptor`.
* @constructor
* @param {DataPropertyDescriptor<V, C, E, W>} param0 Data descriptor properties.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.configurable The configurable of the descriptor.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.enumerable Enumerable of the descriptor.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.value The value for data descriptor.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.writable The writable for data descriptor.
* @param {?O} [object] The object (non-stored) to define the descriptor on. The object is optional, if not provided the descriptor will be created without an object.
* @param {?K} [key] The (non-stored) key to define the descriptor on.
* @param {?ValidationCallback<DataPropertyDescriptor<V, C, E, W>>} [onValidate] Optional callback function to determine the validity of the descriptor.
*/
constructor({ configurable, enumerable, value, writable }, object, key, onValidate) {
onValidate && DataDescriptor.guard({ configurable, enumerable, value, writable }, onValidate);
super({ configurable, enumerable });
delete this.writable;
'writable' in arguments[0] && (this.writable = writable);
this.value = value;
}
}
// Abstract.
/**
* @description The `Descriptor` class is a concrete implementation of the `CommonDescriptor` class that represents a property descriptor.
* @export
* @class Descriptor
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of the value.
* @template {boolean} [C=boolean] The type of the configurable flag.
* @template {boolean} [E=boolean] The type of the enumerable flag.
* @template {boolean} [W=boolean] The type of the writable flag.
* @extends {CommonDescriptor<C, E>}
*/
class Descriptor extends CommonDescriptor {
/**
* @description Creates an instance of `Descriptor`.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of the value.
* @template {boolean} [C=boolean] The type of the configurable flag.
* @template {boolean} [E=boolean] The type of the enumerable flag.
* @template {boolean} [W=boolean] The type of the writable flag.
* @param {StrictPropertyDescriptor<V, O, C, E>} [attributes={}] The type of the descriptor.
* @param {?O} [object] The object (non-stored) to define the descriptor on. The object is optional, if not provided the descriptor will be created without an object.
* @param {?K} [key] The key (non-stored) to define the descriptor on. The key is optional, if not provided the descriptor will be created without a key.
* @returns {Descriptor<O, K, V, C, E, W>}
*/
static create(attributes = {}, object, key) {
return new Descriptor(attributes, object, key);
}
/**
* @description Creates an instance of `Descriptor`.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of the value.
* @template {boolean} [C=boolean] The type of the configurable.
* @template {boolean} [E=boolean] The type of the enumerable.
* @template {boolean} [W=boolean] The type of the writable.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} [attributes={}] Data descriptor properties.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} attributes.configurable The configurable property.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} attributes.enumerable The enumerable property.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} attributes.value The value for data descriptor.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} attributes.writable The writable property.
* @param {?O} [object] The object (non-stored) to define the descriptor on.
* @param {?K} [key] The key (non-stored) to define the descriptor on.
* @returns {StrictPropertyDescriptor<V, O, C, E, W>}
*/
static define(attributes = {}, object, key) {
return {
...this.create(attributes, object, key)
};
}
/**
* @description Returns accessor descriptor of a `ThisAccessorPropertyDescriptor<V, O, C, E>` type, on `get` or `set` property detected.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the object key.
* @template {K extends keyof O ? O[K] : any} [V=K extends keyof O ? O[K] : any] The type of the value.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0 The accessor descriptor attributes.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.configurable The configurable property.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.enumerable The enumerable property.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.get The getter function.
* @param {ThisAccessorPropertyDescriptor<V, O, C, E>} param0.set The setter function.
* @param {?O} [object] The object (non-stored) to define the descriptor on.
* @param {?K} [key] The key (non-stored) to define the descriptor on.
* @param {?ValidationCallback<ThisAccessorPropertyDescriptor<V, O, C, E>>} [onValidate]
* @returns {(ThisAccessorPropertyDescriptor<V, O, C, E> | undefined)}
*/
static defineAccessor({ configurable, enumerable, get, set }, object, key, onValidate) {
return AccessorDescriptor.define({ configurable, enumerable, get, set }, object, key, onValidate);
}
/**
* @description Returns data descriptor of a `DataPropertyDescriptor<Value>` interface, on `writable` or `value` property detected.
* @public
* @static
* @template [O=any] The type of the object.
* @template {PropertyKey | keyof O} [K=keyof O] The type of the object key.
* @template [V=K extends keyof O ? O[K] : any] The type of the value.
* @template {boolean} [C=boolean] The type of configurable.
* @template {boolean} [E=boolean] The type of enumerable.
* @template {boolean} [W=boolean] The type of writable.
* @param {DataPropertyDescriptor<V, C, E, W>} param0 An `object` of a `DataPropertyDescriptor<Value>` interface, to set with the default values of the `CommonDescriptor`.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.configurable The configurable property.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.enumerable The enumerable property.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.value The value property.
* @param {DataPropertyDescriptor<V, C, E, W>} param0.writable The writable property.
* @param {?O} [object] The object (non-stored) to define the descriptor on.
* @param {?K} [key] The key (non-stored) to define the descriptor on.
* @param {?ValidationCallback<DataPropertyDescriptor<V, C, E, W>>} [onValidate] An optional `ValidationCallback` function to handle the result of the check whether or not the `descriptor` is an `object` with the `writable` or `value` property.
* @returns {(DataPropertyDescriptor<V, C, E, W> | undefined)}
*/
static defineData({ configurable, enumerable, value, writable }, object, key, onValidate) {
return DataDescriptor.define({ configurable, enumerable, writable, value }, object, key, onValidate);
}
/**
* @description Returns property descriptors from the specified object and its prototype.
* @public
* @static
* @template O The type of the object.
* @param {O} object An `object` of a generic `Obj` type to get property descriptors.
* @returns {(ObjectPropertyDescriptors<O> | undefined)} The return value is an `object` of a `ObjectPropertyDescriptors<O> | undefined` type.
*/
static fromObject(object) {
return {
...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(object)) || {}, // ['__proto__'] equivalent to getPrototypeOf()
...Object.getOwnPropertyDescriptors(object) || {},
};
}
/**
* @description Returns property descriptor from the `object` or `class` prototype.
* Wrapper function for the `getOwnPropertyDescriptor`, which "Gets the own property descriptor of the specified object."
* @param object An `object` of a generic `Obj` type or a class to get own property descriptor with the specified `key`.
* If `class` is provided then it uses its prototype to get the property descriptor.
* @param key A `keyof Obj` value to get property descriptor from the `object`.
* @returns The return value is an `object` of a `PropertyDescriptor` interface or an `undefined`.
* @example
* // Useful here.
* class A {
* get foo() { return "foo"; }
* }
* const a = new A();
* Descriptor.fromProperty(a, 'foo'); // {set: undefined, enumerable: false, configurable: true, get: ƒ}
*/
static fromProperty(object, key) {
return (Object.getOwnPropertyDescriptor(object, key) ||
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), key));
}
/**
* @alias fromProperty()
*/
static get(object, key) {
return this.fromProperty(object, key);
}
/**
* @alias fromObject()
*/
static getAll(object) {
return this.fromObject(object);
}
/**
* @description Picks the descriptors of the specified keys from the `object`.
* @public
* @static
* @template O The type of object.
* @template {keyof O} K The type of object key.
* @param {O} object The object to pick the descriptors from.
* @param {...K[]} keys The keys of the descriptors to pick.
* @returns {Pick<ObjectPropertyDescriptors<O>, K>} The picked descriptors.
*/
static pick(object, ...keys) {
// Prepare constant to assign descriptors of picked keys.
const result = {};
// Get all descriptors.
const descriptors = this.getAll(object);
// If descriptors exists then set picked descriptor into the map storage.
typeof descriptors === 'object' &&
Object.keys(descriptors)
.filter(key => keys.includes(key))
.forEach(key => Object.assign(result, {
[key]: descriptors[key],
}));
return result;
}
/**
* The static getter accessor to get descriptors from property or object.
* @returns The returned value is an `object` with `object` and `property` properties.
*/
static get from() {
return {
object: this.fromObject,
property: this.fromProperty,
};
}
//#region Property descriptor
/**
* @description The configurable property.
* @public
* @type {?() => V}
*/
get;
/**
* @description
* @public
* @type {?(value: V) => void}
*/
set;
/**
* @description The value property.
* @public
* @type {?V}
*/
value;
/**
* @description The writable property.
* @public
* @type {?W}
*/
writable;
//#endregion
/**
* Creates an instance of `Descriptor`.
* @constructor
* @param {StrictPropertyDescriptor<V, O, C, E, W>} [param0={}] The attributes of the descriptor.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.configurable The configurable property.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.enumerable The enumerable property.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.get The getter function.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.set The setter function.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.writable The writable property.
* @param {StrictPropertyDescriptor<V, O, C, E, W>} param0.value The value property.
* @param {?O} [object] The object (non-stored) to define the descriptor on. The object is optional, if not provided the descriptor will be created without an object.
* @param {?K} [key] The key (non-stored) of the property to define the descriptor on.
*/
constructor({ configurable, enumerable, get, set, value, writable } = {}, object, key) {
super({ configurable, enumerable });
// Deletes the PropertyDescriptor properties.
delete this.get, delete this.set, delete this.value, delete this.writable;
'get' in arguments[0] && (this.get = get);
'set' in arguments[0] && (this.set = set);
'value' in arguments[0] && (this.value = value);
'writable' in arguments[0] && (this.writable = writable);
}
}
// Abstract.
/*
* Public API Surface of descriptor
*/
/**
* Generated bundle index. Do not edit.
*/
export { AccessorDescriptor, CommonDescriptor, DataDescriptor, Descriptor };
//# sourceMappingURL=typescript-package-descriptor.mjs.map