1-liners

中文文档
0.4.2发布于 2019/06/27MIT零依赖近 30 天下载 3983

Useful oneliners and shorthand functions

原始使用文档
文档目录8 节
  1. Our decalogue
  2. Usage
  3. Install
  4. Usage in ES5
  5. Usage in ES 2015 (formerly ES6)
  6. API
  7. Maintainers
  8. License

MADE IN SWITZERLAND

Coverage Status Build Status Dependency Status npm version Stability: unstable Join the chat at https://gitter.im/1-liners/1-liners




1-liners



Functional tools that couldn’t be simpler.

We’re proud to present 1-liners – a dead simple functional utility belt. 137 one-liner functions (and counting). Each hand-crafted with love and attention.










Our decalogue

You get a product of top-quality functional programming craftmanship. Each function follows the KISS principle, which we’ve broken down into ten strict rules.

We always follow them. You have our word.



1-liners


  1. Each function shall fit in one readable line of code
    – take a glimpse at the source and you know exactly what’s going on.
     

  2. Each function shall have no side-effects
    – you can use it with confidence.
     

  3. Each function shall have a fixed number of arguments
    – it’s dead easy to bind, curry and uncurry, apply partially, implode and explode.
     

  4. Each function shall deal with data in an immutable way
    – no more debugging nightmares.
     

  5. Each function shall take data as the last argument
    – this makes currying and composing new functions a breeze.
     

  6. Each function shall be in a separate micro-module
    – you only load/bundle the single 1-liner you need.
     

  7. Each function shall be thoroughly tested
    – 100% code coverage guaranteed. We even test if every function fits in one line!
     

  8. Each function shall have great documentation
    – the docs explain usage, present the source, and link to the specs.
     

  9. We shall provide functional versions of native object methods
    – like reduce(callback, array) for array.reduce(callback).
     

  10. We shall provide functional versions of language constructs
    – like plus(a, b) for a + b.
     

Usage

Install

$ npm install --save 1-liners

Usage in ES5

// The lightweight, recommended way:
var map = require('1-liners/map');

// Sometimes practical:
var map = require('1-liners').map;

Usage in ES 2015 (formerly ES6)

// The lightweight, recommended way:
import map from '1-liners/module/map';

// Sometimes practical:
import { map, filter } from '1-liners/module';

API

Checkout the documentation

Maintainers

stoeffeltomekwihemanth
stoeffeltomekwihemanth
davidchasetristaaan
davidchasetristaaan

created with gh-contributors-table

License

MIT © stoeffel tomekwi hemanth davidchase tristaaan

版本与发布记录

1-liners 共发布 31 个版本,首次发布于 2015/04/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.2latest2019/06/277 年前
0.4.02016/02/0410 年前
0.3.62015/08/2511 年前
0.3.52015/07/0211 年前
0.3.42015/06/2511 年前
0.3.32015/06/2411 年前

关于 1-liners 的常见问题

1-liners 是什么?

Useful oneliners and shorthand functions

如何安装 1-liners?

在项目目录运行 npm install 1-liners,或使用 pnpm add / yarn add / bun add。

1-liners 支持 TypeScript 吗?

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

1-liners 需要什么版本的 Node.js?

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

1-liners 可以商用吗?

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

1-liners 的下载量有多少?

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

1-liners 还在维护吗?

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