@caiogondim/pipeline

中文文档
1.0.6发布于 2016/10/18MITCommonJS零依赖近 30 天下载 1830

您的功能( 同步/ 同步) 管道 QQ 运算符

此软件包已被标记为弃用

This package was renamed to *tubo*

中文使用文档
文档目录11 节
  1. 使用量
  2. 同步
  3. 自动同步
  4. 混合
  5. 安装
  6. 实例
  7. 验证(同步和同步)
  8. 直发案件
  9. 与 const 用法
  10. 功能更新
  11. 参考资料和贷项

输油管.js

Travis CI codecov

管道像管道操作器在功能编程中更为常见 语言,如埃克西尔语.

这个 lib 支持 同步 财务报告和审定财务报表 自动同步 参数.

如果所有参数都是同步函数或字面的,则管道将正常运行 函数返回最后计算值。 如果其中一个论点是 函数返回一个承诺或承诺实例(当时可以使用的对象),a 承诺会在最后归还.

使用量

同步

function double(x) {
  return x * 2
}

function square(x) {
  return x * x
}

var output = pipeline(
  2,
  double,
  square
)
console.log(output) // => 16

自动同步

pipeline(
  bookingDetails.userId,
  fetchUserById, // async
  JSON.parse
)
  .then(function(result) {
    console.log(result)
  })
  .catch(function(error) {
    console.log(error)
  })

混合

也可以混合同步和同步参数. 只要发现一个能产生承诺或承诺的功能, lib 切换到 async 模式,然后返回 a Promise。 。 。 .

安装

要使用库,请通过 npm 安装

npm install @caiogondim/pipeline --save

要将其移植到浏览器或任何其他(非 CJS) 环境, 请使用您最喜欢的 CJS bundle. 没有最喜欢的吗? 尝试: 浏览器, (中文(简体) ), 网络制作 或者说 网络软件包。 。 。 .

实例

验证(同步和同步)

// Before
function validateEmail(email) {
  email = trim(email)
  validateEmailTld(email)
  validateEmailFormat(email)
}

// After
function validateEmail(email) {
  return pipeline(
    email,
    trim,
    validateEmailTld,
    validateEmailFormat
  )
}

try {
  validateEmail('[email protected]')
} catch (error) {
  console.log(error)
}

直发案件

// Before
if (cache && localStorage.getItem(endpoint)) {
  return m.prop( JSON.parse( localStorage.get(endpoint) ) )
}

// After
if (cache && localStorage.getItem(endpoint)) {
  return pipeline(
    localStorage.get(endpoint),
    JSON.parse,
    m.prop
  )
}

与 const 用法

// Before
let items = base64ToJSON(response.data.content)
items = Array.isArray(items) ? items : [items]

// After
const items = pipeline(
  base64ToJSON(response.data.content),
  x => Array.isArray(x) ? x : [x]
)

功能更新

// Before
return Event.create(
  Object.assign(attrs, { parent_id: parentId, status: 'draft' })
)

// After
return pipeline(
  Object.assign(attrs, { parent_id: parentId, status: 'draft' }),
  Event.create
)

参考资料和贷项


cariogondim.com 互联网档案馆的存檔,存档日期2013-12-02  • 妇女  GitHub 图像 @caiogondim (英语)  • 妇女  微博 @caio gondim (英语)

版本与发布记录

@caiogondim/pipeline 共发布 7 个版本,首次发布于 2016/09/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.6latest2016/10/1810 年前
1.0.52016/10/1810 年前
1.0.42016/09/2510 年前
1.0.32016/09/2510 年前
1.0.22016/09/2510 年前
1.0.12016/09/2310 年前

关于 @caiogondim/pipeline 的常见问题

@caiogondim/pipeline 是什么?

您的功能( 同步/ 同步) 管道 QQ 运算符注意:该包已被作者标记为弃用——This package was renamed to *tubo*

如何安装 @caiogondim/pipeline?

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

@caiogondim/pipeline 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/caiogondim__pipeline 是否存在。

@caiogondim/pipeline 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@caiogondim/pipeline 可以商用吗?

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

@caiogondim/pipeline 的下载量有多少?

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

@caiogondim/pipeline 还在维护吗?

最新版本 1.0.6 发布于 2016/10/18(10 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2016/09/23。作者已将其标记为弃用,新项目建议寻找替代方案。