Skip to main content
Module

x/froebel/forward.ts>default

A strictly typed utility library.
Go to Latest
variable default
import { default } from "https://deno.land/x/froebel@v0.23.1/forward.ts";

Given a function and its nth..last arguments, return a function accepting arguments 0..n-1.

Examples

Example 1

const divide = (dividend: number, divisor: number) => dividend / divisor

// (dividend: number) => number
const divideBy2 = forward(divide, 2)

// prints: 0.5
console.log(divideBy2(1))

Example 2

const fetchUrl = async (protocol: string, domain: string, path: string) =>
  await fetch(`${protocol}://${domain}/${path}`)

const fetchRepo = forward(fetchUrl, 'github.com', 'MathisBullinger/froebel')

const viaHTTPS = await fetchRepo('https')

type

<T extends λ, PR extends any[]>(fun: T, ...argsRight: PR) => unknown