Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fonction/common/init.ts>init

A modern practical functional library
Latest
variable init
import { init } from "https://deno.land/x/fonction@v2.1.0-beta.4/common/init.ts";

Returns all but the init element of the given list or string.

Examples

Example 1

// String
init('hello') // 'hell'
init('h') // ''
init('') // ''

Example 2

init([1, 2, 3]) // [1, 2]
init(['hello', 'world']) // ['hello']
init(['hello']) // []
init([]) // []

type

<T extends string | readonly unknown[]>(val: T) => Init<T>