isxx

TypeScript-first is functions collection

Usage no npm install needed!

<script type="module">
  import isxx from 'https://cdn.skypack.dev/isxx';
</script>

README

farray

TypeScript-first functional array utility

test GitHub release npm download

GitHub (Pre-)Release Date dependencies Status codecov Codacy Badge npm type definitions Commitizen friendly Gitmoji semantic-release License: MIT

Install

Node.js

npm i farray
yarn add farray
pnpm add farray

Deno

import { head } from 'https://esm.sh/farray'

API

head

Take first element or list safety

types

declare const head: <T extends string | readonly unknown[]>(val: T) => Head<T>

examples

// String
head('') // ''
head('hello') // 'h'
// Array
head<[]> // undefined
head<['hello', 'world']> // 'hello'

last

Take last element of list safety

types

declare const last: <T extends string | readonly unknown[]>(val: T) => Last<T>

examples

// String
last('') // ''
last('hello') // 'o'
// Array
last('hello', 'new', 'world') // 'world'
last([]) // undefined
last(['one', 2, 3, 4]) // 4

take

Return a slice of string or array with n elements taken from the beginning.

types

declare const take: <T extends string | readonly unknown[]>(
  howMany: number,
  val: T
) => T

examples

// String
take(3, 'hello') // 'hel'
// Array
take(3, [1, 2, 3, 4]) // [1, 2, 3]

takeLast

Return a slice of string or array with n elements taken from the end

types

declare const takeLast: <T extends string | readonly unknown[]>(
  howMany: number,
  val: T
) => T

examples

// String
takeLast(3, 'hello') // 'llo'
// Array
takeLast(3, [1, 2, 3, 4]) // [2, 3, 4]

:handshake: Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues.

:seedling: Show your support

Give a ⭐️ if this project helped you!

:bulb: License

Copyright © 2021-present TomokiMiyauci.

Released under the MIT license