Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ziii

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ziii

Right-compose functions with a z() utility function

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
increased by2.7%
Maintainers
1
Weekly downloads
 
Created
Source

ziii

Chain function calls using a prototype function .z()

Very similar to zii but without polluting the Object prototype globally. This one allows you opt-in when should the z utility be applied on the target object, allowing you to right-compose functions together. This is like the proposed pipeline operator |>, but implemented in ES5.

z(value).z(first).z(second) is the same as second(first(value))

  • 250 bytes small
  • Works with functions, objects and arrays
  • Works with RxJS 6+
  • Works with Callbags
  • Does not work with numbers and strings, unlike zii
  • Supports TypeScript

Installation

npm install ziii

Usage

const z = require('ziii')

const result = z({age: 10})        // Call z() to wrap the input
  .z(({age}) => ({age: age * 3}))  // then .z() to continue the chain
  .z(({age}) => ({age: age / 4}))
  .z(({age}) => ({age: Math.ceil(age)}));

console.log(result) // {age: 8}

If you use TypeScript, then add this to your tsconfig.json file:

{
  ...
  "types": [
    "node_modules/ziii/index.d.ts"
  ]
  ...
}

Examples

RxJS

const z = require('ziii')
const {from} = require('rxjs')
const {map, filter} = require('rxjs/operators')

z(from([1, 2, 3, 4, 5]))
  .z(filter(x => x % 2 === 1))
  .z(map(x => x * 10))
  .subscribe({
    next: x => console.log(x)
  })

Callbags

const z = require('ziii')
const {fromIter, map, filter, forEach} = require('callbag-basics')

z(fromIter([1, 2, 3, 4, 5]))
  .z(filter(x => x % 2 === 1))
  .z(map(x => x * 10))
  .z(forEach(console.log))

License

MIT

Keywords

FAQs

Package last updated on 12 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc