# objects-made-easy

> Node.js utility functions to handle objects

Latest version **1.1.0** (published 2020-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install objects-made-easy
pnpm add objects-made-easy
yarn add objects-made-easy
bun add objects-made-easy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-04-06 |
| First published | 2018-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Roger Mori |
| Maintainers | rogermori |
| Keywords | object, validate, intersection, difference, pick |

## Links

- npm: https://www.npmjs.com/package/objects-made-easy
- Repository: https://github.com/rogermori/objects-made-easy
- Homepage: https://github.com/rogermori/objects-made-easy#readme
- Issues: https://github.com/rogermori/objects-made-easy/issues
- npm.io page: https://npm.io/package/objects-made-easy

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-04-06
- 1.0.9 — 2019-08-10
- 1.0.8 — 2019-08-10
- 1.0.7 — 2018-11-13
- 1.0.6 — 2018-11-07
- 1.0.5 — 2018-10-18
- 1.0.4 — 2018-10-17
- 1.0.3 — 2018-10-16
- 1.0.2 — 2018-10-10
- 1.0.1 — 2018-09-29
- 1.0.0 — 2018-09-29

## README

# objects-made-easy
A set of Node.js utility functions to handle objects.
## Supported Language Features
This module uses JavaScript [ES6](https://github.com/lukehoban/es6features)

#### Install
```
> npm install --save objects-made-easy 
```
#### Run tests
```
> npm run test 
```
#### Run example
```
> node example 
```

### Usage

#### NoU: Check if a variable is null or undefined.
````
const NoU = require('objects-made-easy').NoU;
console.log(NoU(null));  //true
console.log(NoU(null));  //true
console.log(NoU({}));    //false
````
### isObject: Check if a variable is an object.
````
const isObject = require('objects-made-easy').isObject;

console.log(isObject(null)); // false
console.log(isObject(undefined)); // false
console.log(isObject([])); // true
console.log(isObject(new Date())); // true
console.log(isObject(new Set())); // true
console.log(isObject('hello')); // false
console.log(isObject(()=>{})); // true
console.log(isObject({})); // true
```` 
#### coalesce: returns the first non null argument ; otherwise returns null
````
const coalesce = require('objects-made-easy').coalesce;

console.log(coalesce());           // null
console.log(coalesce(null));       // null
console.log(coalesce(undefined));  // null
console.log(null,null,1,null);     // 1
````

#### isEmpty: Check if an object is logically empty. 
````
const isEmpty = require('objects-made-easy').isEmpty;
const array = [
  {},
  {first: null, last: undefined},
  {retail: {}, wholesale: {}},
  ' ',
  [],
  1,
  false,
  new Set(),
  new Date(),
  {a: 1},
];
````
#### project: fetch an object's attribute (field or key's value) by path. 
````
const project = require('objects-made-easy').project
const a = {
      b: {
        c: {
          d: 'deal',
          e: 'elephant',
          f: null,
        },
      },
    };
console.log(project(a, ''))                //a
console.log(project(undefined,''))         //a
console.log(project(a, 'k.p5'))            //undefined
console.log(project(a, 'b.c.l'))           //undefined
console.log(project(a, 'b.c.f'))           //null
console.log(project(a, 'b.c.f','default')) //default
console.log(project(a, 'b.c'))             //{d: 'deal', e: 'elephant', f: null}    
````


#### hasEmpty: Check if an array of object contains any logically empty element. 
````
const hasEmpty = require('objects-made-easy').haEmpty;
console.log(hasEmpty([{}, ' ', null, 1])); // true
console.log(hasEmpty(['a', 1])); // false
```` 
#### emptyKeys: returns the key names of the logically empty values of an object.
````
const emptyKeys = require('objects-made-easy').emptyKeys;
const instance = {
  hello: 'world',
  address: {},
  phone: null,
  fax: undefined,
  role: '',
  rights: [],
};
console.log(emptyKeys(instance));
/*
    { success: true,
      keys: [ 'address', 'phone', 'fax', 'role', 'rights' ],
      hasEmptyKeys: true
    }
 */
````

---
_Source: https://npm.io/package/objects-made-easy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
