assert-is-object-x
If IsObject(value) is false, throw a TypeError exception.
module.exports(value)
⇒ *
⏏
Tests value
to see if it is an object, throws a TypeError
if it is
not. Otherwise returns the value
.
Kind: Exported function
Returns: *
- Returns value
if it is an object.
Throws:
TypeError
Throws ifvalue
is not an object.
Param | Type | Description |
---|---|---|
value | * |
The argument to be tested. |
[message] | string |
Optional alternative message. |
Example
; const primitive = true;const mySymbol = Symbol'mySymbol';const symObj = ObjectmySymbol;const object = {};const fn = {}; ; // TypeError 'true is not an object'; // TypeError 'Symbol(mySymbol) is not an object'; // Returns symObj.; // Returns object.; // Returns fn.