Skip to content

Commit 03b840c

Browse files
committed
Document property descriptors
1 parent ed88529 commit 03b840c

File tree

1 file changed

+20
-1
lines changed
  • lib/node_modules/@stdlib/utils/define-properties

1 file changed

+20
-1
lines changed

lib/node_modules/@stdlib/utils/define-properties/README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ limitations under the License.
3030
var defineProperties = require( '@stdlib/utils/define-properties' );
3131
```
3232

33-
#### defineProperties( obj, props )
33+
#### defineProperties( obj, properties )
3434

3535
[Defines][mdn-define-properties] (and/or modifies) object properties.
3636

@@ -56,10 +56,29 @@ var keys = objectKeys( obj );
5656
// returns [...]
5757
```
5858

59+
The `properties` parameter is an `object` whose own enumerable property values are descriptors for the properties to be defined or modified. A property descriptor has the following optional properties:
60+
61+
- **configurable**: `boolean` indicating if property descriptor can be changed and if the property can be deleted from the provided object. Default: `false`.
62+
- **enumerable**: `boolean` indicating if the property shows up when enumerating object properties. Default: `false`.
63+
- **writable**: `boolean` indicating if the value associated with the property can be changed with an assignment operator. Default: `false`.
64+
- **value**: property value.
65+
- **get**: `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. Default: `undefined`.
66+
- **set**: `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. Default: `undefined`.
67+
5968
</section>
6069

6170
<!-- /.usage -->
6271

72+
<section class="notes">
73+
74+
## Notes
75+
76+
- Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be **one** of these two flavors and **cannot** be both.
77+
78+
</section>
79+
80+
<!-- /.notes -->
81+
6382
<section class="examples">
6483

6584
## Examples

0 commit comments

Comments
 (0)