@bitty/pipe
用于在 LTR (Left- to- Right) 方向中执行函数组成的管函数 .
-
无害环境管理、共同司法系统、城市监测网和城市监测网的分布情况 已修改 格式.
-
轻量级:
- 维格小于0.3KB(min + gzip).
- 3个小于
ramda.pipe。 。 。 . - 树可摇.
- 副相无相.
-
电池包括:
- 无依取相.
- 它没有基于更新型浏览器的API或es2015+功能.
-
- 安全点:
- JSDocs和IDEs和编辑器自动完成/智能的类型声明.
- 尽可能严格地使用 TypeScript 制作 .
- 单位测试与AVA.
安装
这个库发布在国家预防机制登记册上,可以使用任何兼容的软件包管理器来安装.
npm install @bitty/pipe --save
# For Yarn, use the command below.
yarn add @bitty/pipe
从 CDN 安装
这个模块有一个通过JSDelivr和Unpkg CDNs提供的UMD捆绑.
<!-- 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>
开始
导入 pipe 从软件包开始,然后用它来编写功能.
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
第一个管子参数是一个ality N函数,因此在组成中可以收到多个参数.
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"
许可证
释放 MIT 许可证。 。 。 .