GithubHelp home page GithubHelp logo

arity's Introduction

Arity

Functional helpers, with Typescript type propagation

Install

npm install @psxcode/arity

nullary

import { nullary } from '@psxcode/arity'

const f: (p0: number, p1: string) => boolean

typeof nullary(f)  // () => boolean

unary

import { unary } from '@psxcode/arity'

const f: (p0: number, p1: string) => boolean

typeof unary(f)  // (p0: number) => boolean

binary

import { binary } from '@psxcode/arity'

const f: (p0: number, p1: string, p2: number) => boolean

typeof binary(f)  // (p0: number, p1: string) => boolean

ternary

import { ternary } from '@psxcode/arity'

const f: (p0: number, p1: string, p2: number, p3: string) => boolean

typeof ternary(f)  // (p0: number, p1: string, p2: number) => boolean

voidify

import { voidify } from '@psxcode/arity'

const f: (p0: number, p1: string) => boolean

typeof voidify(f)  // (p0: number, p1: string) => void

bind

import { bind } from '@psxcode/arity'

const f: (p0: number, p1: string, p2: boolean) => boolean

typeof bind(10)(f)  // (p0: string, p1: boolean) => boolean

typeof bind(10, 'str')(f)  // (p1: boolean) => boolean

typeof bind(10, 'str', true)(f)  // () => boolean

bindCtx

import { bindCtx } from '@psxcode/arity'

const ctx: { [k: string]: any }
const f: (this: typeof ctx, p0: number) => boolean

typeof bindCtx(ctx)(f)  // (p0: number) => boolean

bindProps

import { bindProps } from '@psxcode/arity'

const props: {
  a: number,
  b: string
}
const f: (p: typeof props) => boolean

typeof bindProps({ a: 10 })(f)  // (p: { b: string }) => boolean

curry

import { curry } from '@psxcode/arity'

const f: (a: number, b: string) => boolean

typeof curry(f)  // (a: number) => (b: string) => boolean

gather

import { gather } from '@psxcode/arity'

const f: (p: [number, string, boolean]) => boolean

typeof gather(f)  // (p0: number, p1: string, p2: boolean) => boolean

spread

import { spread } from '@psxcode/arity'

const f: (a: number, b: string, c: boolean) => boolean

typeof spread(f)  // (args: [number, string, boolean]) => boolean

branch

import { branch } from '@psxcode/arity'

const f0: (a: number) => string
const f1: (a: number) => number
const pred = (a: number) => true

typeof branch(pred, f0)  // (a: number) => string | undefined

typeof branch(pred, f0, f1)  // (a: number) => string | number

and

import { and } from '@psxcode/arity'

const f0: (a: number) => boolean
const f1: (a: number) => boolean

typeof and(f0, f1)  // (a: number) => boolean

or

import { or } from '@psxcode/arity'

const f0: (a: number) => boolean
const f1: (a: number) => boolean

typeof or(f0, f1)  // (a: number) => boolean

noop

import { noop } from '@psxcode/arity'

typeof noop  // () => void

identity

import { identity } from '@psxcode/arity'

typeof identity  // <T> (a: T) => T

identityAsync

import { identityAsync } from '@psxcode/arity'

typeof identityAsync  // <T> (a: T) => Promise<T>

constant

import { constant } from '@psxcode/arity'

typeof constant  // <T> (a: T) => () => T

constantAsync

import { constantAsync } from '@psxcode/arity'

typeof constantAsync  // <T> (a: T) => () => Promise<T>

arity's People

Contributors

dependabot[bot] avatar psxcode avatar

Stargazers

 avatar

Watchers

 avatar  avatar

arity's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.