Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@miyauci/prelude

TomokiMiyauci1.1kMIT1.2.0TypeScript support: included

The standard module for functional programming

prelude, functional, utility, utilities, function

readme

prelude

deno land GitHub release (latest by date) codecov GitHub

test NPM

The standard module for functional programming.

What

A minimalist collection of functions to support functional programming.

For example, it includes the following:

  • Method as function

Method as function

If you wanted to apply trim to all elements of a string[], you would do something like this:

const runtime = [" deno ", " node.js"].map((v) => v.trim());

Use string#trim.

import { trim } from "https://deno.land/x/prelude_js@$VERSION/trim.ts";
const runtime = [" deno ", " node.js"].map(trim);

trim

Removes the leading and trailing white space and line terminator characters from a string.

import { trim } from "https://deno.land/x/prelude_js@$VERSION/trim.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(trim(" deno "), "deno");

trimStart

Removes the leading white space and line terminator characters from a string.

import { trimStart } from "https://deno.land/x/prelude_js@$VERSION/trim_start.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(trimStart(" deno "), "deno ");

trimEnd

Removes the trailing white space and line terminator characters from a string.

import { trimEnd } from "https://deno.land/x/prelude_js@$VERSION/trim_end.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(trimEnd(" deno "), " deno");

toUpperCase

Converts all the alphabetic characters in a string to uppercase.

import { toUpperCase } from "https://deno.land/x/prelude_js@$VERSION/to_upper_case.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(toUpperCase("deno"), "DENO");

toLowerCase

Converts all the alphabetic characters in a string to lowercase.

import { toLowerCase } from "https://deno.land/x/prelude_js@$VERSION/to_lower_case.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(toLowerCase("Deno"), "deno");

Returns the first element of the given Iterable.

import { head } from "https://deno.land/x/prelude_js@$VERSION/head.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(head(""), "");
assertEquals(head("abc"), "a");
assertEquals(head([]), undefined);
assertEquals(head([1, 2, 3]), 1);
assertEquals(head(new Set(["x", "y", "z"])), "x");

last

Returns the last element of the given Iterable.

import { last } from "https://deno.land/x/prelude_js@$VERSION/last.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(last(""), "");
assertEquals(last("abc"), "c");
assertEquals(last([]), undefined);
assertEquals(last([1, 2, 3]), 3);
assertEquals(last(new Set(["x", "y", "z"])), "z");

Where is mod?

There is no single entry point such as mod.

This prevents the inclusion of many unnecessary modules.

License

Copyright © 2023-present TomokiMiyauci.

Released under the MIT license

changelog

1.2.0 (2023-04-08)

Features

  • head: improve type inference (41d932d)
  • last: improve type inference for last (b1a6070)

1.2.0-beta.1 (2023-04-08)

Features

  • head: improve type inference (41d932d)
  • last: improve type inference for last (b1a6070)

1.1.0 (2023-04-06)

Features

1.1.0-beta.1 (2023-04-06)

Features

1.0.0 (2023-03-28)

Features

  • bigint: add bigint methods as functions (becc326)
  • lists: add head function (b7f3e98)
  • multiary: all functions are generics, export globally (3ac0f41)
  • number: add number methods as functions (2a63a6e)
  • object: add object methods as functions (6ecf27f)
  • records: add prop function (437e63f)
  • string: add string methods as functions (dff1613)
  • to_lower_case: add String#toLowerCase as function (c81f33a)
  • to_upper_case: add String#toUpperCase as function (3783140)
  • trim_end: add String#trimEnd as function (c8fc3f3)
  • trim_start: add String#trimStart as function (0fe964c)
  • trim: add String#trim as function (52712c2)

1.0.0-beta.4 (2023-03-28)

Features

  • to_lower_case: add String#toLowerCase as function (c81f33a)
  • to_upper_case: add String#toUpperCase as function (3783140)
  • trim_end: add String#trimEnd as function (c8fc3f3)
  • trim_start: add String#trimStart as function (0fe964c)
  • trim: add String#trim as function (52712c2)

1.0.0-beta.3 (2022-10-06)

Features

  • lists: add head function (b7f3e98)
  • records: add prop function (437e63f)

1.0.0-beta.2 (2022-09-28)

Features

  • multiary: all functions are generics, export globally (3ac0f41)

1.0.0-beta.1 (2022-09-27)

Features

  • bigint: add bigint methods as functions (becc326)
  • number: add number methods as functions (2a63a6e)
  • object: add object methods as functions (6ecf27f)
  • string: add string methods as functions (dff1613)