# @honeo/check

> 型・インスタンスなどの確認

Latest version **2.9.0** (published 2024-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @honeo/check
pnpm add @honeo/check
yarn add @honeo/check
bun add @honeo/check
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.9.0 |
| Published | 2024-07-05 |
| First published | 2017-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 49 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | honeo |
| Maintainers | honeo |
| Keywords | check, type, instance |

## Links

- npm: https://www.npmjs.com/package/@honeo/check
- Repository: https://github.com/honeo/check
- Homepage: https://github.com/honeo/check#readme
- Issues: https://github.com/honeo/check/issues
- npm.io page: https://npm.io/package/@honeo/check

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.9.0 (latest) — 2024-07-05
- 2.8.1 — 2021-10-12
- 2.8.0 — 2021-09-18
- 2.7.0 — 2021-08-21
- 2.6.0 — 2021-08-07
- 2.5.0 — 2021-06-11
- 2.4.0 — 2021-06-11
- 2.3.1 — 2020-11-18
- 2.3.0 — 2020-11-18
- 2.2.0 — 2020-11-08
- 2.1.0 — 2020-11-07
- 2.0.0 — 2020-11-07
- 1.9.2 — 2020-10-24
- 1.9.1 — 2020-07-19
- 1.9.0 — 2020-06-11
- … 14 more at https://npm.io/package/@honeo/check/versions

## README

# check
* [honeo/check](https://github.com/honeo/check)
* [@honeo/check](https://www.npmjs.com/package/@honeo/check)


## なにこれ
型・インスタンス等をチェックするやつ。


## 使い方
```bash
$ npm i @honeo/check
```
```js
import {is, not, any} from '@honeo/check';

is.arr([]); // true

is.arr([], {}); // false
not.arr([], {}); // false
any.arr([], {}); // true


// single
import is from '@honeo/check/is.mjs'; // or not.mjs, any.mjs

// default export
import check from '@honeo/check';
check.is.foobar();
```
```js
// webpack v4~ webpack.config.js
{
	node: {
		fs: 'empty'
	}
}
```


## API
is, not, any共用。

### Alias
```js
is.FooBar===is.foobar; // true
```


### Type, Instance
```js
is.array([]); // true
is.arr([], []); // true

is.boolean(false); // true
is.bool(true, false); // true

is.buffer(new Buffer('foobar')); // true
is.arraybuffer( new ArrayBuffer(0)); // true

is.error(new Error('hoge')); // true

is.function(function(){}); // true
is.func(()=>{}); // true
is.fn(_=>_); // true

is.asyncfunction(async()=>{}); // true
is.asyncgeneratorfunction(async function*(){}); // true
is.generatorfunction(function*(){}); // true

is.number(1); // true
is.num(0, 1); // true

is.regexp(/hoge/); // true
is.re(/foo/, /bar/); // true

is.string('hoge'); // true
is.str('fuga', 'piyo'); // true

is.undefined(undefined); // true
is.undef(null); // false

is.null(null); // true

is.nan(NaN); // true

is.date(new Date()); // true

is.object({}); // true
is.obj(null); // false

is.promise(new Promise(_=>_)); // true

is.stats( fs.statSync('./') ); // true

is.abortcontroller(new AbortController() ); // true
is.abortsignal(new AbortController().signal); // true
```

| name                                           | type | varargs | description                                                                                                         |
|:---------------------------------------------- |:---- |:-------:|:------------------------------------------------------------------------------------------------------------------- |
| Array, Arr, array, arr                         | any  |    ○    |                                                                                                                     |
| Boolean, Bool, boolean, bool                   | any  |    ○    |                                                                                                                     |
| Buffer, Buf, buffer, buf                       | any  |    ○    |                                                                                                                     |
| Error, Err, error, err                         | any  |    ○    |                                                                                                                     |
| Function, Func, Fn, function, func, fn         | any  |    ○    |                                                                                                                     |
| AsyncFunction, asyncfunction                   | any  |    ○    |                                                                                                                     |
| AsyncGeneratorFunction, asyncgeneratorfunction | any  |    ○    |                                                                                                                     |
| GeneratorFunction, generatorfunction           | any  |    ○    |                                                                                                                     |
| Number, Num, number, num                       | any  |    ○    |                                                                                                                     |
| RegExp, RE, regexp, re                         | any  |    ○    |                                                                                                                     |
| String, Str, string, str                       | any  |    ○    |                                                                                                                     |
| Undefined, Undef, undefined, undef             | any  |    ○    |                                                                                                                     |
| Null, null                                     | any  |    ○    |                                                                                                                     |
| NaN, nan                                       | any  |    ○    |                                                                                                                     |
| Date, date                                     | any  |    ○    |                                                                                                                     |
| Object, Obj, object, obj                       | any  |    ○    |                                                                                                                     |
| Promise, promise                               | any  |    ○    |                                                                                                                     |
| Stats, stats                                   | any  |    ○    |                                                                                                                     |
| ArrayBuffer, ArrBuf, arraybuffer, arrbuf       | any  |    ○    |                                                                                                                     |
| AbortController, abortcontroller               | any  |    ○    | [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)インスタンスか（Polyfill対応）。 |
| AbortSignal, abortsignal                       | any  |    ○    | [AbortSignal](https://developer.mozilla.org/ja/docs/Web/API/AbortSignal)インスタンスか（Polyfill対応）。            |



### Number

```js
is.even(2); // true

is.odd(3); // true

is.multiple(8080, 80); // true
```

| name               | type   | varargs | description            |
|:------------------ |:------ |:-------:|:---------------------- |
| Odd, odd           | number |    ○    | 引数がすべて奇数か。   |
| Even, even         | number |    ○    | 引数がすべて偶数か。   |
| Multiple, multiple | number |    ✗    | 引数1が引数2の倍数か。 |

### String
```js
is.ipv4('192.168.1.1'); // true

is.hostname('www.example.com'); // true

is.lowercase('hoge'); // true

is.uppercase('FOO', 'BAR'); // true
```

| name                 | type   | varargs | description    |
|:-------------------- |:------ |:-------:|:-------------- |
| IPv4, ipv4           | string |    ○    |                |
| Hostname, hostname   | string |    ○    | やっつけ実装。 |
| Lowercase, lowercase | string |    ○    |                |
| Uppercase, uppercase | string |    ○    |                |

### DOM

```js
is.node(document.body, document.createTextNode('hoge')); // true

is.textnode(document.createTextNode('hoge')); // true

is.element(document.head, document.body); // true

is.df(document.createDocumentFragment()); // true

is.event( new Event("hoge") ); // true

is.eventtarget(document, window); // true
```

| name                                       | type | varargs | description |
|:------------------------------------------ |:---- |:-------:|:----------- |
| Node, node                                 | any  |    ○    |             |
| TextNode, textnode                         | any  |    ○    |             |
| Element, Elm, element, elm                 | any  |    ○    |             |
| DocumentFragment, DF, documentfragment, df | any  |    ○    |             |
| Event, event                               | any  |    ○    |             |
| EventTarget, eventtarget                   | any  |    ○    |             |


### その他

```js
is.true(true, !0); // true

is.false(false !1); // true

is.truthy(true, "hoge", 1, [], {}); // true

is.falsy(null, undefined, "", 0, NaN); // true

is.instance([], {}); // true
is.instance("hoge"); // false

is.instanceof(new Date(), Date); //true

is.instanceOfClassName([], "Array"); // true

is.objectliteral({}); // true
not.objectliteral([], new function(){}); // true

is.arraylike([], 'hoge'); // true

is.comparisonoperator('<='); // true

is.sameDay(new Date(), new Date()); // true

is.semver('1.2.3'); // true
is.semver('1.0.0-foo.bar'); // true

is.version('7.7.4', '2.5.0.1') // true
is.version('1.2A', 1.0); // false

is.empty('', [], {}) // true
is.empty(0, null); // false

is.leapyear(2020, new Date('2024'));

is.validdate(2019, 4, 17); // true
is.validdate(2020, 12, 32); // false
```

| name                                         | type         | varargs | description                                       |
|:-------------------------------------------- |:------------ |:-------:|:------------------------------------------------- |
| ArrayLike(), arraylike()                     | any          |    ○    |                                                   |
| True(), true()                               | any          |    ○    |                                                   |
| False(), false()                             | any          |    ○    |                                                   |
| Truthy(), truthy()                           | any          |    ○    |                                                   |
| Falsy(), falsy()                             | any          |    ○    |                                                   |
| Empty(), empty()                             | any          |    ○    | 要素が空か。                                      |
| Instance(), instance()                       | any          |    ○    | 何らかのインスタンスであるオブジェクトか。        |
| Instanceof(), instanceof()                   | any          |    ✗    | 引数1が引数2のConstructor/Classのインスタンスか。 |
| InstanceOfClassName(), instanceofclassname() | instance, string     |    ✗    | 引数1が引数2の名称を持つClassのインスタンスか。 |
| Nullish(), nullish()                         | any          |    ○    | null or undefined                                 |
| ObjectLiteral(), objectliteral()             | any          |    ○    | 未継承の素のオブジェクトか。                      |
| ComparisonOperator(), comparisonoperator()   | any          |    ○    | 有効な比較演算子の文字列か。                      |
| SameDay(), sameday()                         | date         |    ○    | 同じ日か                                          |
| SemVer(), semver()                           | any          |    ○    | 有効なSemVer文字列か。                            |
| Version(), Ver(), versiom(), ver()           | any          |    ○    | 有効な数字, dotのバージョン文字列か。             |
| LeapYear(), leapyear()                       | number, date |    ○    | 閏年か。                                          |
| ValidDate(year, mon, day), validdate()       | number       |    ✗    | 存在する日付か。                                  |


## Breaking Changes

### v2.0.0

#### CommonJS => ES Modules
```js
// before CJS
const {is, not, any} = require('@honeo/check');


// after ESM
import {is, not, any} from '@honeo/check';
```


#### rename: instance() => instanceof()
```js
// before
is.instance([], Array);

// after
is.instanceof([], Array);
```

---
_Source: https://npm.io/package/@honeo/check · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
