README
ObjectUtilities
Project: Some utility functions for JavaScript objects.
Installation
To install ObjectUtilities
, run:
npm i --save '@1791-labs/object-utilities'
Usage
const ObjectUtilities = require('@1791-labs/object-utilities')
API
ObjectUtilities
Some utility functions for JavaScript objects.
Kind: global class
- ObjectUtilities
- .createAccessorPropertyDescriptor([getter], [setter]) ⇒
PropertyDescriptor
- .createDataPropertyDescriptor([value], [isWritable]) ⇒
PropertyDescriptor
- .createDescribedFrozenObject([propertyDescriptors]) ⇒
Object
- .createDescribedSealedObject([propertyDescriptors]) ⇒
Object
- .createEmptyObject() ⇒
Object
- .createEnumerableAccessorPropertyDescriptor([getter], [setter]) ⇒
PropertyDescriptor
- .createEnumerableDataPropertyDescriptor([value], [isWritable]) ⇒
PropertyDescriptor
- .createFrozenObject([properties]) ⇒
Object
- .createObject([properties]) ⇒
Object
- .createSealedObject([properties]) ⇒
Object
- .createAccessorPropertyDescriptor([getter], [setter]) ⇒
PropertyDescriptor
ObjectUtilities.createAccessorPropertyDescriptor([getter], [setter]) ⇒ Creates an accessor property descriptor using the provided getter
and setter
functions.
Kind: static method of ObjectUtilities
Returns: PropertyDescriptor
-
The accessor property descriptor.
Param | Type | Description |
---|---|---|
[getter] | function |
A function that serves as a getter for the property. |
[setter] | function |
A function that serves as a setter for the property. |
PropertyDescriptor
ObjectUtilities.createDataPropertyDescriptor([value], [isWritable]) ⇒ Creates a data property descriptor using the provided value
and isWritable
flag.
Kind: static method of ObjectUtilities
Returns: PropertyDescriptor
-
The data property descriptor.
Param | Type | Description |
---|---|---|
[value] | * |
The value associated with the property. |
[isWritable] | Boolean |
A boolean flag establishing whether or not the property's value may be changed with an assignment operator. |
Object
ObjectUtilities.createDescribedFrozenObject([propertyDescriptors]) ⇒ Creates a frozen object (via Object.freeze
) using the provided propertyDescriptors
to define the properties of the object.
Kind: static method of ObjectUtilities
Returns: Object
-
The frozen object.
Param | Type | Description |
---|---|---|
[propertyDescriptors] | Array.<PropertyDescriptor> |
A set of property descriptors defining each property of the object. |
Object
ObjectUtilities.createDescribedSealedObject([propertyDescriptors]) ⇒ Creates a sealed object (via Object.seal
) using the provided propertyDescriptors
to define the properties of the object.
Kind: static method of ObjectUtilities
Returns: Object
-
The sealed object.
Param | Type | Description |
---|---|---|
[propertyDescriptors] | Array.<PropertyDescriptor> |
A set of property descriptors defining each property of the object. |
Object
ObjectUtilities.createEmptyObject() ⇒ Creates a null-prototyped empty object.
Kind: static method of ObjectUtilities
Returns: Object
-
The object.
PropertyDescriptor
ObjectUtilities.createEnumerableAccessorPropertyDescriptor([getter], [setter]) ⇒ Creates an enumerable accessor property descriptor using the provided getter
and setter
functions.
Kind: static method of ObjectUtilities
Returns: PropertyDescriptor
-
The enumerable accessor property descriptor.
Param | Type | Description |
---|---|---|
[getter] | function |
A function that serves as a getter for the property. |
[setter] | function |
A function that serves as a setter for the property. |
PropertyDescriptor
ObjectUtilities.createEnumerableDataPropertyDescriptor([value], [isWritable]) ⇒ Creates an enumerable data property descriptor using the provided value
and isWritable
flag.
Kind: static method of ObjectUtilities
Returns: PropertyDescriptor
-
The enumerable data property descriptor.
Param | Type | Description |
---|---|---|
[value] | * |
The value associated with the property. |
[isWritable] | Boolean |
A boolean flag establishing whether or not the property's value may be changed with an assignment operator. |
Object
ObjectUtilities.createFrozenObject([properties]) ⇒ Creates a frozen object (via Object.freeze
) with the provided properties
.
Kind: static method of ObjectUtilities
Returns: Object
-
The frozen object.
Param | Type | Description |
---|---|---|
[properties] | Object |
The properties of the object. |
Object
ObjectUtilities.createObject([properties]) ⇒ Creates an object with the provided properties
.
Kind: static method of ObjectUtilities
Returns: Object
-
The object.
Param | Type | Description |
---|---|---|
[properties] | Object |
The properties of the object. |
Object
ObjectUtilities.createSealedObject([properties]) ⇒ Creates a sealed object (via Object.seal
) with the provided properties
.
Kind: static method of ObjectUtilities
Returns: Object
-
The sealed object.
Param | Type | Description |
---|---|---|
[properties] | Object |
The properties of the object. |
Author
Jay B. <j@1791.io>
License
Apache-2.0
, Apache License, Version 2.0