Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/degjs/objectutils
A utility library for working with JavaScript objects.
https://github.com/degjs/objectutils
utility
Last synced: about 1 month ago
JSON representation
A utility library for working with JavaScript objects.
- Host: GitHub
- URL: https://github.com/degjs/objectutils
- Owner: DEGJS
- Created: 2015-08-21T20:34:58.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T17:40:42.000Z (about 2 years ago)
- Last Synced: 2024-11-19T11:09:58.676Z (about 1 month ago)
- Topics: utility
- Language: JavaScript
- Homepage:
- Size: 1.04 MB
- Stars: 0
- Watchers: 12
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# objectUtils
A utility library for working with JavaScript objects.## Install
![Run Tests](https://github.com/DEGJS/objectUtils/workflows/Run%20Tests/badge.svg)objectUtils is an ES6 module. Consequently, you'll need an ES6 transpiler ([Babel](https://babeljs.io) is a nice one) as part of your Javascript workflow.
If you're already using NPM for your project, you can install objectUtils with the following command:
```
$ npm install @degjs/object-utils
```## Usage
### Importing individual objectUtils methods:
```js
import { ensureArray } from "@degjs/object-utils";let guaranteedArray = ensureArray(possibleArray);
```### Importing all objectUtils methods:
```js
import * as objectUtils from "@degjs/object-utils";let guaranteedArray = objectUtils.ensureArray(possibleArray);
```## Methods
### ensureArray(obj)
The ensureArray method returns a guaranteed array, regardless of the paramater passed into it.#### obj
Type: `Array` or `String`
The potential array to test.### assignDeep(target, source)
The assignDeep method copies the values of a source object to a target object. Unlike [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign), assignDeep does a proper deep clone of nested objects.#### target
Type: `Object`
The source object to copy.#### source
Type: `Object`
The target object to copy to.## Browser Support
objectUtils depends on the following browser APIs:
+ isArray: [Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) | [Polyfill](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#Polyfill)To support legacy browsers, you'll need to include polyfills for the above APIs.