An open API service indexing awesome lists of open source software.

https://github.com/writetome51/error-if-not-object

Function triggers error is passed argument is not an object. Arrays are considered objects. Nulls are not
https://github.com/writetome51/error-if-not-object

error javascript message not object

Last synced: 11 months ago
JSON representation

Function triggers error is passed argument is not an object. Arrays are considered objects. Nulls are not

Awesome Lists containing this project

README

          

# errorIfNotObject(arg): void

Triggers error if `arg` is not an object. Arrays are considered objects. Null is not.

## Examples
```
errorIfNotObject({}); // no error.
errorIfNotObject([]); // no error.

errorIfNotObject(null); // Error: "Input must be object"

// If you try to create a primitive with a constructor function,
// it becomes an object:
let str = new String('string');
errorIfNotObject(str); // no error.
```

## Installation
`npm i error-if-not-object`

## Loading
```js
import { errorIfNotObject} from 'error-if-not-object';
```