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
- Host: GitHub
- URL: https://github.com/writetome51/error-if-not-object
- Owner: writetome51
- License: mit
- Created: 2019-04-05T19:36:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-01T07:12:05.000Z (over 5 years ago)
- Last Synced: 2025-02-02T08:47:26.417Z (12 months ago)
- Topics: error, javascript, message, not, object
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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';
```