Socket
Socket
Sign inDemoInstall

keyu

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    keyu

Key utilities for everyday use


Version published
Weekly downloads
547
decreased by-16.36%
Maintainers
1
Install size
4.20 kB
Created
Weekly downloads
 

Readme

Source

Keyu

Key utilities you will need when you work in any javascript project.

Utilities

Functional programming

Compose

Composes N functions into another one, also accept functions that a return Promise.

const {compose} = require('keyu');

const sum1 = x => x+1;
const mult2 = x => x*2;
const dbSum = x => Promise.resolve(x+1);

const sumAndMult = compose(mult2,sum1);
const sumAndMultDB = compose(dbSum,mult2,sum1);

sumAndMult(1) // 4
sumAndMultDB(1) // Promise(5)
Pipe

Pipe N functions into another one, also accept functions that a return Promise.

const {pipe} = require('keyu');

const sum1 = x => x+1;
const mult2 = x => x*2;
const dbSum = x => Promise.resolve(x+1);

const sumAndMult = pipe(sum1,mult2);
const sumAndMultDB = pipe(sum1, mult2, dbSum);

sumAndMult(1) // 4
sumAndMultDB(1) // Promise(5)

Objects

Map

Maps over every key of an object

let obj = {a:1,b:2,c:3};

console.log(obj.map(value => value+1)) // {a:2}
console.log(obj.map((value, key) => `${key}:${value+1}`)) // {a:'a:2'}
Filter

Filters an object for each single key

let obj = {a:1,b:2,c:3};

console.log(obj.filter(value => value > 2)) // {c:3}

console.log(obj.filter((value, key) => value > 1 && key === 'c')) // {c:3}

Keywords

FAQs

Last updated on 21 Mar 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc