# @lazy-assert/check-basic

> Basic number checking utilities with TypeScript type guards / 基本數字檢查工具，支援 TypeScript 類型守護

Latest version **1.0.14** (published 2026-09-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install @lazy-assert/check-basic
pnpm add @lazy-assert/check-basic
yarn add @lazy-assert/check-basic
bun add @lazy-assert/check-basic
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2026-09-12 |
| First published | 2021-12-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 69.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | assert, test, check, assertion, testing, create-by-yarn-tool, create-by-tsdx |

## Links

- npm: https://www.npmjs.com/package/@lazy-assert/check-basic
- Repository: https://github.com/bluelovers/ws-jest
- Homepage: https://github.com/bluelovers/ws-jest/tree/master/packages/@lazy-assert/check-basic#readme
- Issues: https://github.com/bluelovers/ws-jest/issues
- npm.io page: https://npm.io/package/@lazy-assert/check-basic

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.14 (latest) — 2026-09-12
- 1.0.13 — 2023-10-18
- 1.0.12 — 2022-11-15
- 1.0.11 — 2022-10-29
- 1.0.10 — 2022-10-15
- 1.0.9 — 2022-10-05
- 1.0.8 — 2022-09-19
- 1.0.7 — 2022-09-10
- 1.0.6 — 2022-07-30
- 1.0.5 — 2022-07-30
- 1.0.2 — 2021-12-20
- 1.0.1 — 2021-12-18

## README

# @lazy-assert/check-basic

基本的數字檢查工具，提供多種數字類型檢查功能，支援 TypeScript 類型守護（Type Guard）。

Basic number checking utilities providing various number type checking functions with TypeScript type guard support.

## 特色 (Features)

- 提供多種數字類型檢查函式 / Provides various number type checking functions
- 支援 TypeScript 類型守護 / Supports TypeScript type guards
- 包含安全數字檢查 / Includes safe number checking
- 支援數字字串檢查 / Supports numeric string checking
- 零依賴 / Zero dependencies

## 安裝 (Installation)

```bash
npm install @lazy-assert/check-basic
# or
yarn add @lazy-assert/check-basic
```

## 使用方式 (Usage)

### 基本使用 (Basic Usage)

```typescript
import { isNum, isInt, isFloat, isFiniteNum } from '@lazy-assert/check-basic';

console.log(isNum(123));           // true
console.log(isNum(NaN));           // false
console.log(isInt(123.45));        // false
console.log(isFloat(123.45));      // true
console.log(isFiniteNum(Infinity)); // false
```

### 類型守護使用 (Type Guard Usage)

```typescript
function processNumber(n: unknown) {
  if (isInt(n)) {
    // n 在這裡被推斷為 number 類型
    // n is inferred as number type here
    console.log('整數:', n);
  }
}
```

## API 參考 (API Reference)

### 數字檢查 (Number Checking)

| 函式 (Function) | 說明 (Description) |
|----------------|-------------------|
| `isNum(n)` | 檢查是否為有效數字（排除 NaN）/ Check if valid number (excludes NaN) |
| `isNaN(n)` | 檢查是否為 NaN / Check if NaN |
| `isInt(n)` | 檢查是否為整數 / Check if integer |
| `isFloat(n)` | 檢查是否為浮點數 / Check if float |
| `isFiniteNum(n)` | 檢查是否為有限數字 / Check if finite number |
| `isFiniteInt(n)` | 檢查是否為有限整數 / Check if finite integer |
| `isFiniteFloat(n)` | 檢查是否為有限浮點數 / Check if finite float |
| `isInfinity(n)` | 檢查是否為無限大 / Check if infinity |
| `isZero(n)` | 檢查是否為零（0 或 -0）/ Check if zero (0 or -0) |
| `isPositive(n)` | 檢查是否為正數 / Check if positive |
| `isNegative(n)` | 檢查是否為負數 / Check if negative |

### 字串檢查 (String Checking)

| 函式 (Function) | 說明 (Description) |
|----------------|-------------------|
| `isUnSafeNumString(n)` | 檢查字串是否可轉換為有效數字 / Check if string can convert to valid number |
| `isUnSafeNumLike(n)` | 檢查是否為類數字型別（數字或可轉換字串）/ Check if number-like (number or convertible string) |

## 授權 (License)

ISC

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