Skip to content

Commit 9a942bf

Browse files
committed
Document descriptor properties
1 parent f31c504 commit 9a942bf

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

lib/node_modules/@stdlib/utils/define-property/docs/repl.txt

+36
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
{{alias}}( obj, prop, descriptor )
33
Defines a property.
44

5+
Property descriptors come in two flavors: data descriptors and accessor
6+
descriptors. A data descriptor is a property that has a value, which may or
7+
may not be writable. An accessor descriptor is a property described by a
8+
getter-setter function pair. A descriptor must be one of these two flavors
9+
and cannot be both.
10+
511
Parameters
612
----------
713
obj: Object
@@ -13,6 +19,36 @@
1319
descriptor: Object
1420
Property descriptor.
1521

22+
descriptor.configurable: boolean (optional)
23+
Boolean indicating if property descriptor can be changed and if the
24+
property can be deleted from the provided object. Default: false.
25+
26+
descriptor.enumerable: boolean (optional)
27+
Boolean indicating if the property shows up when enumerating object
28+
properties. Default: false.
29+
30+
descriptor.writable: boolean (optional)
31+
Boolean indicating if the value associated with the property can be
32+
changed with an assignment operator. Default: false.
33+
34+
descriptor.value: any (optional)
35+
Property value.
36+
37+
descriptor.get: Function|void (optional)
38+
Function which serves as a getter for the property, or, if no getter,
39+
undefined. When the property is accessed, a getter function is called
40+
without arguments and with the `this` context set to the object through
41+
which the property is accessed (which may not be the object on which the
42+
property is defined due to inheritance). The return value will be used
43+
as the property value. Default: undefined.
44+
45+
descriptor.set: Function|void (optional)
46+
Function which serves as a setter for the property, or, if no setter,
47+
undefined. When assigning a property value, a setter function is called
48+
with one argument (the value being assigned to the property) and with
49+
the `this` context set to the object through which the property is
50+
assigned. Default: undefined.
51+
1652
Examples
1753
--------
1854
> var obj = {};

lib/node_modules/@stdlib/utils/define-property/lib/builtin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties
3737
* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator
3838
* @param {*} [descriptor.value] - property value
39-
* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the value of the property.
39+
* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.
4040
* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.
4141
* @throws {TypeError} first argument must be an object
4242
* @throws {TypeError} third argument must be an object

lib/node_modules/@stdlib/utils/define-property/lib/polyfill.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var lookupSetter = objectProtoype.__lookupSetter__;
5151
* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties
5252
* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator
5353
* @param {*} [descriptor.value] - property value
54-
* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the value of the property.
54+
* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.
5555
* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.
5656
* @throws {TypeError} first argument must be an object
5757
* @throws {TypeError} third argument must be an object

0 commit comments

Comments
 (0)