@art-suite/art-core-ts-types

中文文档
0.4.1发布于 2026/06/19MITTypeScriptESM + CJS零依赖近 30 天下载 3234

A TypeScript string utility library

原始使用文档
文档目录5 节
  1. Why This Module?
  2. Example Installation and Use (Required)
  3. Functional Overview
  4. Type Checking Functions
  5. API Documentation Reference

@art-suite/art-core-ts-types

A simple, consistent library for runtime identification of JavaScript types.

Why This Module?

The Why: JavaScript's type system is famously inconsistent at runtime. Developers often struggle with the many different, sometimes unreliable, ways to check if a value is a string, array, date, or other type—leading to bugs, confusion, and duplicated code.

The How: This library unifies and standardizes type checks by providing a set of highly-performant, well-tested isFoo functions. Each function implements the most reliable and efficient strategy for identifying its respective type, abstracting away JavaScript's quirks.

The What: A comprehensive set of isFoo functions (like isString, isDate, isPlainObject, etc.) for robust, readable, and consistent runtime type checking.

Example Installation and Use (Required)

Install with npm:

npm install @art-suite/art-core-ts-types

Basic usage:

import {
  isString,
  isPlainObject,
  isDate,
  isNull,
  isNotNull,
  isNullish,
  isNotNullish,
  exists,
  present,
} from "@art-suite/art-core-ts-types";

isString("hello"); // true
isPlainObject({ a: 1 }); // true
isDate(new Date()); // true
isDate("2020-01-01"); // false
isNull(null); // true
isNotNull(undefined); // false
isNullish(undefined); // true
isNotNullish(0); // true
exists(0); // true
present(""); // false
present("something"); // true

Functional Overview

Type Checking Functions

  • Primitives:

    • isString(value) — Checks for string values.
    • isNumber(value) — Checks for numbers.
    • isBoolean(value) — Checks for booleans.
    • isFunction(value) — Checks for functions.
  • Objects and Collections:

    • isObject(value) — Checks for any object (excluding null, primitives, and functions).
    • isPlainObject(value) — Checks for plain objects (i.e., {}).
    • isArray(value) — Checks for arrays.
    • isArrayBuffer(value) — Checks for ArrayBuffer instances.
    • isTypedArray(value) — Checks for any TypedArray.
  • Special Types:

    • isDate(value) — Checks for Date objects.
    • isRegExp(value) — Checks for regular expressions.
    • isError(value) — Checks for Error objects.
    • isPromise(value) — Checks for Promise-like objects.
  • Other Utilities:

    • isEmptyObject(value) — Checks if an object has no own properties.
    • isNonNegativeInt(value) — Checks for non-negative integers.
    • stringIsPresent(value) — Checks for non-empty, non-whitespace strings.
  • Null/Undefined/Exists Utilities:

    • isNull(value) — Checks for null or undefined values.
    • isNotNull(value) — Checks for values that are not null or undefined.
    • isNullish(value) — Checks for null or undefined (alias for isNull).
    • isNotNullish(value) — Checks for values that are not null or undefined (alias for isNotNull).
    • exists(value) — Checks for non-null, non-undefined values.
    • present(value) — Checks for values that are present (non-null, non-undefined, non-empty string, or custom present-ness).

API Documentation Reference

For detailed information on all exported functions and their parameters, please refer to the TypeScript typings and JSDoc comments within the source code.

版本与发布记录

@art-suite/art-core-ts-types 共发布 23 个版本,首次发布于 2025/05/12;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.4.1latest2026/06/194 个月前
0.4.02026/03/277 个月前
0.3.112025/12/0511 个月前
0.3.102025/12/0511 个月前
0.3.92025/12/0411 个月前
0.3.82025/10/301 年前

关于 @art-suite/art-core-ts-types 的常见问题

@art-suite/art-core-ts-types 是什么?

A TypeScript string utility library

如何安装 @art-suite/art-core-ts-types?

在项目目录运行 npm install @art-suite/art-core-ts-types,或使用 pnpm add / yarn add / bun add。

@art-suite/art-core-ts-types 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@art-suite/art-core-ts-types 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@art-suite/art-core-ts-types 可以商用吗?

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

@art-suite/art-core-ts-types 的下载量有多少?

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

@art-suite/art-core-ts-types 还在维护吗?

最新版本 0.4.1 发布于 2026/06/19(4 个月前);至今共发布 23 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/05/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。