npm package: @osmium/is
Description: Osmium project - Type detector
Author: Vasiliy Isaichkin
Latest version: 0.2.0

# is

A comprehensive JavaScript/TypeScript utility library for type and value checking. It provides a wide range of functions to check types, structures, and properties of values in a consistent and reliable way.

## Features

- **Type Checks**: `null`, `undefined`, `array`, `object`, `string`, `boolean`, `number`, `symbol`, `function`, `async function`, etc.
- **Structure Checks**: `empty`, `iterable`, `plain object`, `native object`, etc.
- **Special Checks**: `JSON`, `GUID`, `RegExp`, `Map`, `Set`, `WeakMap`, `WeakSet`, `Date`, `Error`, `Promise`, `TypedArray`, etc.
- Works in both JavaScript and TypeScript projects.
- Well-tested and fast.

## Installation

```bash
npm install @osmium/is
```

or

```bash
yarn add @osmium/is
```

## API Reference

### `isNull(value)`
Checks if `value` is `null`.

```typescript
import { isNull } from '@osmium/is';

isNull(null); // true
isNull(undefined); // false
```

### `isUndefined(value)`
Checks if `value` is `undefined`.

```typescript
import { isUndefined } from '@osmium/is';

isUndefined(undefined); // true
isUndefined(null); // false
```

### `isFunction(value)`
Checks if `value` is a function (including async functions).

```typescript
import { isFunction } from '@osmium/is';

isFunction(() => {}); // true
isFunction(async () => {}); // true
```

### `isAsyncFunction(value, [pattern])`
Checks if `value` is an async function. Optionally accepts a RegExp or string pattern for custom detection (e.g., for transpiled async functions).

```typescript
import { isAsyncFunction } from '@osmium/is';

isAsyncFunction(async () => {}); // true
isAsyncFunction(() => {}); // false
```

### `isArray(value)`
Checks if `value` is an array.

```typescript
import { isArray } from '@osmium/is';

isArray([1, 2, 3]); // true
isArray({}); // false
```

### `isArrayEmpty(value)`
Checks if `value` is an empty array.

```typescript
import { isArrayEmpty } from '@osmium/is';

isArrayEmpty([]); // true
isArrayEmpty([1]); // false
```

### `isObject(value)`
Checks if `value` is a plain object.

```typescript
import { isObject } from '@osmium/is';

isObject({ a: 1 }); // true
isObject(new Date()); // false
```

### `isObjectEmpty(value)`
Checks if `value` is an empty object.

```typescript
import { isObjectEmpty } from '@osmium/is';

isObjectEmpty({}); // true
isObjectEmpty({ a: 1 }); // false
```

### `isString(value)`
Checks if `value` is a string.

```typescript
import { isString } from '@osmium/is';

isString('hello'); // true
isString(123); // false
```

### `isBoolean(value)`
Checks if `value` is a boolean.

```typescript
import { isBoolean } from '@osmium/is';

isBoolean(true); // true
isBoolean(0); // false
```

### `isNumber(value)`
Checks if `value` is a finite number (not `NaN`, not `Infinity`).

```typescript
import { isNumber } from '@osmium/is';

isNumber(42); // true
isNumber(Infinity); // false
```

### `isNumeric(value)`
Checks if `value` is a number (including `Infinity`, `-Infinity`).

```typescript
import { isNumeric } from '@osmium/is';

isNumeric(42); // true
isNumeric(Infinity); // true
```

### `isInteger(value)`
Checks if `value` is a safe integer.

```typescript
import { isInteger } from '@osmium/is';

isInteger(10); // true
isInteger(10.5); // false
```

### `isFloat(value)`
Checks if `value` is a float (not an integer).

```typescript
import { isFloat } from '@osmium/is';

isFloat(3.14); // true
isFloat(10); // false
```

### `isPositiveInteger(value)`
Checks if `value` is a positive integer (`>= 0`).

```typescript
import { isPositiveInteger } from '@osmium/is';

isPositiveInteger(5); // true
isPositiveInteger(-5); // false
```

### `isPositiveNumber(value)`
Checks if `value` is a positive number (`>= 0`).

```typescript
import { isPositiveNumber } from '@osmium/is';

isPositiveNumber(0.1); // true
isPositiveNumber(-1); // false
```

### `isSymbol(value, [description])`
Checks if `value` is a symbol, optionally with a specific description.

```typescript
import { isSymbol } from '@osmium/is';

isSymbol(Symbol('x')); // true
isSymbol(Symbol('x'), 'x'); // true
```

### `isRegExp(value)`
Checks if `value` is a regular expression.

```typescript
import { isRegExp } from '@osmium/is';

isRegExp(/abc/); // true
isRegExp('/abc/'); // false
```

### `isMap(value)`
Checks if `value` is a `Map`.

```typescript
import { isMap } from '@osmium/is';

isMap(new Map()); // true
```

### `isSet(value)`
Checks if `value` is a `Set`.

```typescript
import { isSet } from '@osmium/is';

isSet(new Set()); // true
```

### `isWeakMap(value)`
Checks if `value` is a `WeakMap`.

```typescript
import { isWeakMap } from '@osmium/is';

isWeakMap(new WeakMap()); // true
```

### `isWeakSet(value)`
Checks if `value` is a `WeakSet`.

```typescript
import { isWeakSet } from '@osmium/is';

isWeakSet(new WeakSet()); // true
```

### `isPromise(value)`
Checks if `value` is a `Promise`.

```typescript
import { isPromise } from '@osmium/is';

isPromise(Promise.resolve()); // true
```

### `isDate(value)`
Checks if `value` is a valid `Date` object.

```typescript
import { isDate } from '@osmium/is';

isDate(new Date()); // true
```

### `isError(value)`
Checks if `value` is an `Error` object.

```typescript
import { isError } from '@osmium/is';

isError(new Error('fail')); // true
```

### `isPlainObject(value)`
Checks if `value` is a plain object (its prototype is `Object` or `null`).

```typescript
import { isPlainObject } from '@osmium/is';

isPlainObject({}); // true
isPlainObject(Object.create(null)); // true
```

### `isTypedArray(value)`
Checks if `value` is a `TypedArray`.

```typescript
import { isTypedArray } from '@osmium/is';

isTypedArray(new Uint8Array()); // true
```

### `isNilOrEmpty(value)`
Checks if `value` is `null`, `undefined`, or an empty string.

```typescript
import { isNilOrEmpty } from '@osmium/is';

isNilOrEmpty(null); // true
isNilOrEmpty(''); // true
```

### `isEmpty(value)`
Checks if `value` is empty (array, string, object, `Map`, or `Set`).

```typescript
import { isEmpty } from '@osmium/is';

isEmpty([]); // true
isEmpty({}); // true
isEmpty(''); // true
```

### `isIterable(value)`
Checks if `value` is iterable (a non-empty array, `Map`, `Set`, or an object with keys).

```typescript
import { isIterable } from '@osmium/is';

isIterable([1, 2, 3]); // true
isIterable([]); // false
```

### `isAsyncIterable(value)`
Checks if `value` is async iterable.

```typescript
import { isAsyncIterable } from '@osmium/is';

isAsyncIterable({ async *[Symbol.asyncIterator]() {} }); // true
```

### `isJSON(value)`
Checks if `value` is a valid JSON string.

```typescript
import { isJSON } from '@osmium/is';

isJSON('{"a":1}'); // true
isJSON('not json'); // false
```

### `isGUID(value)`
Checks if `value` is a valid GUID.

```typescript
import { isGUID } from '@osmium/is';

isGUID('123e4567-e89b-12d3-a456-426614174000'); // true
```

### `isGUIDv4(value)`
Checks if `value` is a valid GUID v4.

```typescript
import { isGUIDv4 } from '@osmium/is';

isGUIDv4('123e4567-e89b-42d3-a456-426614174000'); // true
```

### `isNativeObject(value)`
Checks if `value` is a native object (not an array, function, or other special objects).

```typescript
import { isNativeObject } from '@osmium/is';

isNativeObject({}); // true
isNativeObject([]); // false
```

## Testing

To run all tests, use your favorite package manager:

```bash
npm test
```

or

```bash
yarn test
```

## Contributing

Pull requests and issues are welcome! Please write tests for new features and bug fixes.

## License

MIT

## Author

Maintained by Vasiliy Isaichkin.