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';

    Install

    npm i error-if-not-object

    DownloadsWeekly Downloads

    4

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.69 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar