Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/froebel/mod.ts>forward

A strictly typed utility library.
Go to Latest
variable forward
import { forward } from "https://deno.land/x/froebel@v0.18.0/mod.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