assert-is-object-x

If IsObject(value) is false, throw a TypeError exception.

MIT 42 个版本
安装
npm install assert-is-object-x
yarn add assert-is-object-x
pnpm add assert-is-object-x
bun add assert-is-object-x
README

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

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 if value is not an object.
Param Type Description
value * The argument to be tested.
[message] string Optional alternative message.

Example

import assertIsObject from 'assert-is-object-x';

const primitive = true;
const mySymbol = Symbol('mySymbol');
const symObj = Object(mySymbol);
const object = {};
const fn = function fn() {};

assertIsObject(primitive); // TypeError 'true is not an object'
assertIsObject(mySymbol); // TypeError 'Symbol(mySymbol) is not an object'
assertIsObject(symObj); // Returns symObj.
assertIsObject(object); // Returns object.
assertIsObject(fn); // Returns fn.
版本列表
3.1.2 2019-08-28
3.1.1 2019-08-20
3.1.0 2019-08-14
3.0.18 2019-07-31
3.0.17 2019-07-27
3.0.16 2019-07-27
3.0.15 2019-07-26
3.0.14 2019-07-25
3.0.13 2019-07-24
3.0.11 2019-07-24
3.0.10 2019-07-22
3.0.9 2019-07-21
3.0.8 2019-07-19
3.0.7 2019-07-18
3.0.6 2019-07-17
3.0.5 2019-07-17
3.0.4 2019-07-17
3.0.3 2019-07-16
3.0.2 2019-07-16
3.0.1 2019-07-15
3.0.0 2019-07-15
2.1.0 2017-10-18
2.0.1 2017-09-01
2.0.0 2017-08-30
1.3.0 2017-07-11
1.1.1 2017-03-27
1.1.0 2017-03-10
1.0.14 2016-02-15
1.0.13 2016-02-13
1.0.12 2016-02-03
1.0.11 2016-01-25
1.0.10 2016-01-25
1.0.9 2016-01-21
1.0.8 2016-01-12
1.0.7 2016-01-05
1.0.6 2016-01-04
1.0.5 2015-12-17
1.0.4 2015-12-01
1.0.3 2015-11-30
1.0.2 2015-11-30
1.0.1 2015-11-27
1.0.0 2015-11-26