@1791-labs/object-utilities

Some utility functions for JavaScript objects.

Usage no npm install needed!

<script type="module">
  import 1791LabsObjectUtilities from 'https://cdn.skypack.dev/@1791-labs/object-utilities';
</script>

README

Project: ObjectUtilities

Some utility functions for JavaScript objects.

npm (latest version) David David (dev) npm (license)

Travis CI (branch: master) Travis CI (branch: develop)

Coveralls (branch: master) Coveralls (branch: develop)

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

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.


ObjectUtilities.createDataPropertyDescriptor([value], [isWritable]) ⇒ PropertyDescriptor

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.


ObjectUtilities.createDescribedFrozenObject([propertyDescriptors]) ⇒ Object

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.


ObjectUtilities.createDescribedSealedObject([propertyDescriptors]) ⇒ Object

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.


ObjectUtilities.createEmptyObject() ⇒ Object

Creates a null-prototyped empty object.

Kind: static method of ObjectUtilities
Returns: Object -

The object.


ObjectUtilities.createEnumerableAccessorPropertyDescriptor([getter], [setter]) ⇒ PropertyDescriptor

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.


ObjectUtilities.createEnumerableDataPropertyDescriptor([value], [isWritable]) ⇒ PropertyDescriptor

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.


ObjectUtilities.createFrozenObject([properties]) ⇒ Object

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.


ObjectUtilities.createObject([properties]) ⇒ Object

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.


ObjectUtilities.createSealedObject([properties]) ⇒ Object

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