Global

Members

# constant filter

filter values in an array

View Source index.js, line 150

Example
import { filter } from "@nextml/lodestar";

const nonZero = (x) => x !== 0
filter(notZero, [1, 0, 1, 1, 0, 2, 3])
// => [1, 1, 1, 2, 3]

TODO: add more examples...

# constant key

get value of key in object

View Source index.js, line 544

Example
import { Pick } from "@nextml/lodestar";

Pick.key("foo", { foo: 123 });
// => 123

# constant map

array mapping function

View Source index.js, line 251

Example
import { map } from "@nextml/lodestar";

map((x) => x + 1, [0, 1, 2])
// => [1, 2, 3]

TODO: add more examples...

# constant match

Takes an object with one (1) key value pair { key: value } and matches with functions mapped in the conditions argument.

View Source index.js, line 301

Example
import { match } from "@nextml/lodestar";

const apiResult = { ok: { name: "foo" } }

match({
  ok: success,
  error: popup,
})(apiResult)

// => success({ name: "foo" })

# constant Pick

Pick module. Fetch values from objects and arrays. See "first", "last", "key".

View Source index.js, line 554

Example
import { Pick } from "@nextml/lodestar";

# constant reduce

reduces array of values

View Source index.js, line 374

Example
import { reduce } from "@nextml/lodestar";

const add = (x, y) => x + y;
reduce(add, 0, [1, 2, 3]);
// => 6

TODO: add more examples...

# constant trace

Log a value and return the same value

View Source index.js, line 430

Examples
import { trace } from "@nextml/lodestar";

const sum = trace("foo"); // > "foo"
// => "foo"
import { trace } from "@nextml/lodestar";

fetch("/")
  .then(response => response.json())
  .then(trace) // log request body
  .then(handleData)

# constant update

upate array or object by key/index

View Source index.js, line 439

# constant updateIn

Update a nested structure by providing a "path" represented by an array of keys/indices.

View Source index.js, line 476

Methods

# camelCaseToSnakeCase(x) → {string}

Convert camelCase strings to snake_case.
Parameters:
Name Type Description
x string string to convert

View Source index.js, line 15

converted string
string
Example
import { camelCaseToSnakeCase } from "@nextml/lodestar";

camelCaseToSnakeCase("helloWorld"); // => "hello_world"

# capitalize(x) → {string}

Convert the first letter of a string to uppercase and the rest to lowercase.
Parameters:
Name Type Description
x string string to capitalize

View Source index.js, line 35

capitalized string
string
Example
import { capitalize } from "@nextml/lodestar";

capitalize("foo"); // => "Foo"
capitalize("FOO"); // => "Foo"
capitalize("foo bar"); // => "Foo bar"

# compose(…fns) → {function}

Function composition left to right (sequential reading order).
Parameters:
Name Type Attributes Description
fns function <repeatable>
functions to compose

View Source index.js, line 50

composed function
function
Example
import { compose } from "@nextml/lodestar";

compose(addOne, multiplyByTwo)(2); // => 6

# composeAsync(…fns) → {function}

Asynchronous function composition left to right (sequential reading order).
Parameters:
Name Type Attributes Description
fns function <repeatable>
functions to compose, including asynchronous

View Source index.js, line 72

composed asynchronous function
function
Example
import { composeAsync } from "@nextml/lodestar";

composeAsync(fetch, doSomething)(url); // => 6

# curry(fn) → {function}

Curry a function to enable partial application.
Parameters:
Name Type Description
fn function the function to curry

View Source index.js, line 109

curried function
function
Example

Importing

import { curry } from "@nextml/lodestar";

curry((a, b, c) => a + b + c)(2, 3)(5) // => 10
curry((a, b, c) => a + b + c)(2)(3, 5) // => 10
curry((a, b, c) => a + b + c)(2)(3)(5) // => 10
curry((a, b, c) => a + b + c)(2, 3, 5) // => 10

# defer(fn, …args) → {function}

Defer function execution.
Parameters:
Name Type Attributes Description
fn function the function to defer
args any <repeatable>
input arguments for the deferred function `fn`

View Source index.js, line 130

constructed function
function
Example
import { defer } from "@nextml/lodestar";

const add = (a, b) => a + b;
const addLater = defer(add, 2, 3);
addLater(); // => 5

# first(xs) → {any}

get first element in array
Parameters:
Name Type Description
xs array array to pick element from

View Source index.js, line 517

first element in xs
any
Example
import { Pick } from "@nextml/lodestar";

Pick.first([0, 1, 2])
// => 0

# identity(x) → {any}

Return input value.
Parameters:
Name Type Description
x any any input value

View Source index.js, line 164

input value
any
Example
import { identity } from "@nextml/lodestar";

identity(1); // => 1
identity("hello"); // => "hello"

# isDefined(…args) → {boolean}

Check if input arguments have a defined value e.g. is not null or undefined
Parameters:
Name Type Attributes Description
args * <repeatable>
checked values

View Source index.js, line 201

if all input values are defined
boolean
Example
import { isDefined } from "@nextml/lodestar";

isDefined(1); // => true
isDefined("foo", () => {}); // => true

isDefined(undefined); // => false
isDefined(null); // => false
isDefined("foo", null); // => false

# isError(x) → {boolean}

Check if input is instance of any built-in error type.
Parameters:
Name Type Description
x any checked value

View Source index.js, line 234

if checked value is error
boolean
Example
import { isError } from '@nextml/lodestar';

isError(new Error('foo')); // true
isError(new TypeError('bar')); // true

isError(1); // false
isError('foo'); // false
isError(false); // false

# isUnitType(x) → {boolean}

Check if input is bottom value.
Parameters:
Name Type Description
x any any input value

View Source index.js, line 183

if bottom value
boolean
Example
import { isUnitType } from "@nextml/lodestar";

isUnitType(undefined); // => true
isUnitType(null); // => true

isUnitType(1); // => false
isUnitType("foo"); // => false

# last(xs) → {any}

get last element in array
Parameters:
Name Type Description
xs array array to pick element from

View Source index.js, line 530

last element in xs
any
Example
import { Pick } from "@nextml/lodestar";

Pick.last([0, 1, 2])
// => 2

# noop(…_) → {undefined}

Function that ignores the function call
Parameters:
Name Type Attributes Description
_ * <repeatable>
Any input arguments will be ignored

View Source index.js, line 356

Returns undefined
undefined
Example
import { noop } from "@nextml/lodestar";

noop("foo") // => undefined

# sideEffect(x) → {any}

Take input, run effect, and return the same input.
Parameters:
Name Type Description
x any any value

View Source index.js, line 406

x
any
Example
import { sideEffect } from "@nextml/lodestar";

const logAndReturnName = sideEffect((name) => {
  console.log('Hello my name is', name))
};

# snakeCaseToCamelCase(x) → {string}

Convert snake_case strings to camelCase.
Parameters:
Name Type Description
x string string to convert

View Source index.js, line 388

converted string
string
Example
import { snakeCaseToCamelCase } from "@nextml/lodestar";

snakeCaseToCamelCase("hello_world"); // => "helloWorld"

# typeOf(x) → {string}

Check input type of defined value.
Parameters:
Name Type Description
x any any non unit type value

View Source index.js, line 269

name of type
string
Example
import { typeOf } from "@nextml/lodestar";

typeOf(1); // => "number"
typeOf("hello"); // => "string"
typeOf(false); // => "boolean"
typeOf(() => {}); // => "function"
typeOf([]); // => "array"
typeOf({}); // => "object"

# withEventTargetValue(fn) → {function}

Use event target value point free in event handlers.
Parameters:
Name Type Description
fn function arbitrary function that takes event target value

View Source index.js, line 503

that takes javascript event as parameter
function
Example
import { withEventTargetValue } from "@nextml/lodestar";

const SomeComponent = () => {
 const [inputValue, setInputValue] = useState('');
 return (<input onChange={withEventTargetValue(setInputValue)} />);
}