error-if-not-object

2.0.0 • Public • Published

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

import { errorIfNotObject} from 'error-if-not-object';

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    2
  • 1.0.0
    0

Package Sidebar

Install

npm i error-if-not-object

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

2.69 kB

Total Files

4

Last publish

Collaborators

  • writetome51