@bitty/pipe

中文文档
0.4.0发布于 2025/07/07MITTypeScriptESM + CJS零依赖近 30 天下载 18.1万

A pipe function to perform function composition in LTR (Left To Right) direction.

原始使用文档
文档目录4 节
  1. Installation
  2. Installation from CDN
  3. Getting Started
  4. License

@bitty/pipe

Bundle minified size Bundle minified and gzipped size

A pipe function to perform function composition in LTR (Left-To-Right) direction.

  • 📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.

  • ⚡ Lightweight:

    • Weighs less than 0.3KB (min + gzip).
    • 3x smaller than ramda.pipe.
    • Tree-shakeable.
    • Side-effects free.
  • 🔋 Bateries included:

    • No dependencies.
    • Its not based on newer browser's APIs or es2015+ features.
  • 🏷 Safe:

    • JSDocs and type declarations for IDEs and editor's autocomplete/intellisense.
    • Made with TypeScript as strict as possible.
    • Unit tests with AVA.

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @bitty/pipe --save

# For Yarn, use the command below.
yarn add @bitty/pipe

Installation from CDN

This module has a UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/@bitty/pipe"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/@bitty/pipe"></script>

<script>
  // UMD module is exposed through the "pipe" global function.
  console.log(pipe);
  //=> "[Function: pipe]"
</script>

Getting Started

Import pipe from package and just compose your functions with it.

import pipe from '@bitty/pipe';

const resolveToNumber = pipe(
  (value: unknown) => typeof value === 'number' ? value : parseFloat(value),
  (value: number) => Number.isNaN(value) ? 0 : value,
);

resolveToNumber('12389');
//=> 12389

The first pipe argument is an arity N function, so you can receive more than one argument in the composition.

import pipe from '@bitty/pipe';

const fromTextToWords = (text: string, wordsToIgnore: string[] = []) =>
  text
    .trim()
    .split(/\s+/)
    .filter((word) => !wordsToIgnore.includes(word));

const formatToInitials = pipe(
  fromTextToWords,
  (words) => words.map((word) => word.charAt(0)),
  (initials) => initials.join('').toUpperCase(),
);

formatToInitials('abraão  william de santana ', ['de']);
//=> "AWS"

License

Released under MIT License.

版本与发布记录

@bitty/pipe 共发布 13 个版本,首次发布于 2020/04/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.0latest2025/07/071.3 年前
0.3.02022/01/104 年前
0.2.22021/11/194 年前
0.2.12021/01/245 年前
0.1.02020/11/036 年前
0.0.72020/10/206 年前

其他发布通道:pnpm-temp → 0.0.5。

关于 @bitty/pipe 的常见问题

@bitty/pipe 是什么?

A pipe function to perform function composition in LTR (Left To Right) direction.

如何安装 @bitty/pipe?

在项目目录运行 npm install @bitty/pipe,或使用 pnpm add / yarn add / bun add。

@bitty/pipe 支持 TypeScript 吗?

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

@bitty/pipe 支持 ESM 还是 CommonJS?

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

@bitty/pipe 可以商用吗?

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

@bitty/pipe 的下载量有多少?

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

@bitty/pipe 还在维护吗?

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