@expressots/boost-ts

中文文档
1.3.0发布于 2024/08/01MITTypeScriptESM + CJS近 30 天下载 31.9万

Expressots: Boost is a collection of libraries for the TypeScript programming language designed to enhance its capabilities across various domains. (@boost-ts)

原始使用文档
文档目录6 节
  1. Available Libraries
  2. Installation
  3. Match Pattern Usage
  4. Optional Pattern Usage
  5. Contributing
  6. License

Expresso TS Logo

Boost-TS

Boost is a collection of libraries for the TypeScript programming language designed to enhance its capabilities across various domains. These libraries provide a wide range of functionality, enabling developers to leverage the full potential of TypeScript and streamline their development process. With Boost, TypeScript developers can efficiently tackle complex tasks, improve code readability, and maintainability, while also benefiting from advanced features and best practices.

Available Libraries

  • Match Pattern
  • Optional Pattern

Installation

npm i @expressots/boost-ts

Match Pattern Usage

  • Using Match pattern with enums
import { match } from "./match-pattern";

const enum Coin {
    Penny,
    Nickel,
    Dime,
    Quarter
}

function valueInCents(coin: Coin): number {
    return match(coin, {
        [Coin.Penny]: () => 1,
        [Coin.Nickel]: () => 5,
        [Coin.Dime]: () => 10,
        [Coin.Quarter]: () => 25,
    })
}

console.log(valueInCents(Coin.Penny)); // 1
  • Using Match pattern with numbers
let isNumber: number = 1;

const result = match(isNUmber, {
  1: () => 1,
  2: () => 2,
  "_": () => "No number found"
});

console.log(result); // 1
  • Using Match pattern with boolean
let isOn: boolean = true;

const result = match(isOn, {
  true: () => "The light is on",
  false: () => "The light is off",
});

console.log(result); // The light is off
  • Using Match pattern with Optional pattern
import { Some, None, Optional, matchOptional } from "./optional-pattern";
import { match } from "./match-pattern";

const v1: Optional<number> = Some(1);
const v2: Optional<number> = None();

const result = match(v1, {
    Some: (x) => x + 1,
    None: 0,
});

console.log(result); // 2
  • Other possible combinations
    • "expressions..=expressions" -> numbers or characters
    • "isOr: this | that | other"
    • "Regex: "/[a-z]/"
const result = match("a", {
  "1..=13": () => "Between 1 and 13",
  "25 | 50 | 100": () => "A bill",
  "a..=d": () => "A letter",
  "/[a-z]/": () => "A lowercase letter",
  "_": () => "Default",
});
console.log(result); // A letter

Optional Pattern Usage

const someValue: Optional<number> = Some(1);

function plusOne(x: Optional<number>): number {
    return match(x, {
        Some: (x) => x + 3,
        None: 0,
    })
}

console.log(plusOne(None())); // 0

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

版本与发布记录

@expressots/boost-ts 共发布 6 个版本,首次发布于 2023/03/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.3.0latest2024/08/012 年前
1.2.02024/08/012 年前
1.1.22023/04/073 年前
1.1.12023/04/073 年前
1.1.02023/04/073 年前
1.0.02023/03/183 年前

关于 @expressots/boost-ts 的常见问题

@expressots/boost-ts 是什么?

Expressots: Boost is a collection of libraries for the TypeScript programming language designed to enhance its capabilities across various domains. (@boost-ts)

如何安装 @expressots/boost-ts?

在项目目录运行 npm install @expressots/boost-ts,或使用 pnpm add / yarn add / bun add。

@expressots/boost-ts 支持 TypeScript 吗?

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

@expressots/boost-ts 支持 ESM 还是 CommonJS?

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

@expressots/boost-ts 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@expressots/boost-ts 可以商用吗?

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

@expressots/boost-ts 的下载量有多少?

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

@expressots/boost-ts 还在维护吗?

最新版本 1.3.0 发布于 2024/08/01(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/03/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。