prelude
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");
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