@expressots/boost-ts

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

Expressots: Boost是TypeScript编程语言的库库,旨在提升其跨越多个领域的能力. (@boost-ts) (韩语)

中文使用文档
文档目录6 节
  1. 可用的图书馆
  2. 安装
  3. 匹配模式使用
  4. 可选模式使用
  5. 捐款
  6. 许可证

Expresso TS Logo

助推键

Boost是TypeScript编程语言的库集,旨在增强它跨越多个领域的能力. 这些库提供了广泛的功能,使开发者能够充分利用TypeScript的全部潜力并精简他们的开发过程. 有了"Boost",TypeScript开发者可以高效地处理复杂的任务,改善代码可读性,以及可维护性,同时也能从先进特性和最佳做法中受益.

可用的图书馆

  • 匹配模式
  • 可选模式

安装

npm i @expressots/boost-ts

匹配模式使用

  • 使用 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
  • 使用数字匹配模式
let isNumber: number = 1;

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

console.log(result); // 1
  • 使用布尔匹配模式
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
  • 使用可选模式的匹配模式
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
  • 其他可能的组合
    • "表达..=表达" - > 数字或字符
    • "是:这个是另一个"
    • "礼":"/[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

可选模式使用

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

捐款

欢迎拉动请求。 对于重大变动,请先开出一个问题来讨论你想要改变什么.

请确保酌情更新测试.

许可证

麻省理工学院

版本与发布记录

@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是TypeScript编程语言的库库,旨在提升其跨越多个领域的能力. (@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 和提交记录判断。