Skip to main content
Module

x/froebel/mod.ts

A strictly typed utility library.
Go to Latest
import * as froebel from "https://deno.land/x/froebel@v0.23.0/mod.ts";

Classes

Behaves like a regular JavaScript Map, but its iteration order is dependant on the compare function supplied in the constructor.

Variables

Like pipe but takes an argument as its first parameter and invokes the pipe with it.

Same as nullishChain but accept asynchronous functions too.

Access list at i % length. Negative indexes start indexing the last element as [-1] and wrap around to the back.

Takes a list and returns it in multiple smaller lists of the size batchSize. The last batch may be smaller than batchSize depending on if list size is divisible by batchSize.

Given a list of functions that accept the same parameters, returns a function that takes these parameters and invokes all of the given functions.

Same as bundle, but return synchronously.

Take a list of functions that accept the same parameters and call them all with the provided arguments.

Transforms a variable name to camel case.

Upper-case first letter of string.

Clamp num between min and max inclusively.

Returns a copied version of value.

Creates a queue function that accepts a function as it's only parameter. When queue is invoked, the passed in function is executed after the last function passed to queue has finished executing. The queue function returns the result of the passed in function asynchronously.

Creates a debounced function that delays invoking fun until ms milliseconds have passed since the last invocation of the debounced function.

Checks if value is falsy. Literal types are narrowed accordingly.

Given a function and its nth..last arguments, return a function accepting arguments 0..n-1.

Identity function.

Checks if result (returned from Promise.allSettled) is fulfilled.

Checks if value is not a promise.

Checks if value looks like a promise.

Checks if result (returned from Promise.allSettled) is rejected.

Transforms a variable name to kebab case.

Returns a version of the function fun that can only be invoked limit times. An optional except function will be called with the same parameters on any additional invocations.

Strictly typed String.toLowerCase().

Map over data. data can be a regular object, a Map, a Set, or an array.

Returns a copy of fun that remembers its result for any given arguments and only invokes fun for unknown arguments.

Recursively merges A and B. If a property in A and B is of a different type (i.e. it's not an array, Set, Map, or plain object in both, the value from B will be used in the result).

Checks if value is not nullish. Literal types are narrowed accordingly.

Checks if value is nullish. Literal types are narrowed accordingly.

Given a list of functions that accept the same parameters, returns a function that given these arguments returns the result of the first function whose result is not nullish.

From obj, create a new object that does not include keys.

Special case of limitInvocations. fun can only be invoked once.

Checks if v is one of cmps.

Partially apply a function.

Takes a list and returns a pair of lists containing: the elements that match the predicate and those that don't, respectively.

Transforms a variable name to pascal case.

From obj, create a new object that only includes keys.

Given a list of functions returns a function that will execute the given functions one after another, always passing the result of the previous function as an argument to the next function.

Returns str prefixed with prefix. Optionally, allows prefxing in camel case, i.e. prefix('foo', 'bar', 'camel') => 'fooBar', or snake case, i.e. prefix('foo', 'bar', 'snake') => 'foo_bar'.

Turns a function accepting a callback into a function returning a promise. You can specify in which parameter (if any) the callback expects to receive a result and in which it expects an error. Pass null to resultIndex or errorIndex if no result or errors are passed to the callback. By default the first argument passed to the callback is interpreted as result and none of the arguments as error (if the function accepting the callback throws or rejects, that will still result in the promisified function rejecting).

Creates a range between two values.

Transforms a variable name to screaming snake case.

Returns the value in obj at path. If the given path does not exist, the symbol none is returned.

Shuffles list using the Fisher-Yates shuffle algorithm. The original list is not modified and the shuffled list is returned.

Same as shuffle but shuffles list in place.

Transforms a variable name to snake case.

Returns str suffixed with suffix. Same case and type behavior as prefix.

Surrounds the str with surrounding. surrounding must have an even length.

Takes n elements from the iterable list and returns them as an array.

Create a throttled function that invokes fun at most every ms milliseconds.

Transform a variable name to targetCase

Checks if value is truthy. Literal types are narrowed accordingly.

Turns fun into a unary function (a function that only accepts one argument).

Lower-case first letter of string

Reverse of zip. Takes a list of tuples and deconstructs them into an array (of length of the tuples length) of lists each containing all the elements in all tuples at the lists index.

Same as unzip but accepts an unzipper function for each tuple index. The unzipper's return value is used as the value in the list at that index returned from unzipWith.

Strictly typed String.toUpperCase().

Takes multiple lists and returns a list of tuples containing the value in each list at the current index. If the lists are of different lengths, the returned list of tuples has the length of the shortest passed in list.

Same as zip but also takes a zipper function, that is called for each index with the element at current index in each list as arguments. The result of zipper is the element at current index in the list returned from zipWith.

Functions

Constructs a range between characters.

Checks if a and b are structurally equal using the following algorithm:

Constructs a numeric between start and end inclusively.

Returns a generator that repeats sequence.

Takes n elements from the iterable list and returns them as a generator.