npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lazy-assert/check-basic

v1.0.14

Published

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

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)

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

使用方式 (Usage)

基本使用 (Basic Usage)

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)

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