@abhaydgarg/is

中文文档
1.1.0发布于 2018/07/31MITCommonJS零依赖近 30 天下载 2708

Javascript checking library

原始使用文档
文档目录8 节
  1. Installation
  2. Run test
  3. Usage
  4. API
  5. 1. Type check
  6. 2. Emptiness check
  7. 3. Value check
  8. License

is.js

Javascript checking library.

NPM

Installation

npm install --save @abhaydgarg/is

Run test

# all
npm run test

# single file
FILE=is-string.test.js npm run test:file

Usage

// commonJS - Destructuring
const { isEmpty, isString } = require('@abhaydgarg/is');

// ES6 - using webapack bundler
import { isEmpty, isString } from '@abhaydgarg/is';

API

1. Type check

isArray(value)

Check if value is of type Array.

isBoolean(value)

Check if value is of type boolean.

isDate(value)

Check if value is of type Date.

isError(value)

Check if value is of type Error.

isFunction(value)

Check if value is of type function.

isMap(value)

Check if value is of type Map.

isNumber(value)

Check if value is of type number.

isObject(value)

Check if value is of type object.

isRegEx(value)

Check if value is of type RegExp.

isSet(value)

Check if value is of type Set.

isString(value)

Check if value is of type string.

isSymbol(value)

Check if value is of type symbol.

isUndefined(value)

Check if value is undefined.

isNull(value)

Check if value is null.

isNullOrUndefined(value)

Check if value is either null or undefined.

2. Emptiness check

isEmpty(value)

Check if value is empty.

All below return true

isEmpty(null);
isEmpty(undefined);
isEmpty(function () { }); // empty function
isEmpty([]); // array length 0
isEmpty(new Error()); // without message
isEmpty(new Set()); // Set size 0
isEmpty(new Map()); // Map size 0
isEmpty({});
isEmpty(0);
isEmpty(''); // string length 0
isEmpty(' ') // whitespace string is consider empty

3. Value check

isNumeric(value)

Check if value is numeric.

isNumeric(1234567890); // true
isNumeric('1234567890'); // true
isNumeric('-123'); // true
isNumeric('1.23'); // true
isNumeric('Infinity'); // true
isNumeric('0xFF') // true
isNumeric('123e5');  // true

isInteger(value)

Check if value of type number is integer (whole number).

isFloat(value)

Check if value of type number is float (fractional number).

isUrl(value)

Check if value is url.

isEmail(value)

Check if value is email.

isWhitespace(value)

Check if value of type string is whitespace.

License

MIT

版本与发布记录

@abhaydgarg/is 共发布 3 个版本,首次发布于 2018/02/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2018/07/318 年前
1.0.02018/02/158 年前
0.1.02018/02/138 年前

关于 @abhaydgarg/is 的常见问题

@abhaydgarg/is 是什么?

Javascript checking library

如何安装 @abhaydgarg/is?

在项目目录运行 npm install @abhaydgarg/is,或使用 pnpm add / yarn add / bun add。

@abhaydgarg/is 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/abhaydgarg__is 是否存在。

@abhaydgarg/is 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@abhaydgarg/is 可以商用吗?

@abhaydgarg/is 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@abhaydgarg/is 的下载量有多少?

根据 npm 官方下载统计,@abhaydgarg/is 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,708 次,日均约 90 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@abhaydgarg/is 还在维护吗?

最新版本 1.1.0 发布于 2018/07/31(8 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/02/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。