[go: up one dir, main page]

@suc/chain
TypeScript icon, indicating that this package has built-in type declarations

1.1.10 • Public • Published

@suc/chain

在Object和Array的原型链上提供方便的链式操作方法.

const fruits = [
    {name: 'banana', amount: 2},
    {name: 'apple', amount: 4},
    {name: 'pineapple', amount: 2},
    {name: 'mango', amount: 1}
];
fruits
    .concat([{name: 'apple', amount: 100}])
    .sortedBy('name', 'amount')
    .reverse()
    .tap(arr => arr.unshift({name: 'pineapple', amount: 100}))
    .thru(arr => arr[0])

// 返回值可能为空 .xxxOrNull

Readme

Keywords

none

Package Sidebar

Install

npm i @suc/chain

Weekly Downloads

1

Version

1.1.10

License

MIT

Unpacked Size

78.4 kB

Total Files

166

Last publish

Collaborators

  • ylzc