12.1.2 • Published 14 days ago

zeelib v12.1.2

Weekly downloads
39
License
MIT
Repository
github
Last release
14 days ago

zeelib / Exports

zeelib

Utility library in TypeScript, with a focus on Node and FP utils and emphasis on not rewriting builtin features.

npm version ko-fi Support with PayPal


Installation

npm i zeelib

Usage

See the docs below for details (generated from types and comments). Example:

import * as z from 'zeelib'

const answer = await z.prompt('Pick a letter')
if (z.isEmpty(answer)) process.exit(1)

zeelib

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

AnyFn

Ƭ AnyFn: (...args: any[]) => any

Type declaration

▸ (...args): any

Parameters
NameType
...argsany[]
Returns

any

Defined in

pipe.ts:3


AnyMap

Ƭ AnyMap: Record\<string, any>

Defined in

types.ts:1


Cb

Ƭ Cb: (error: c.ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void

Type declaration

▸ (error, stdout, stderr): void

Parameters
NameType
errorc.ExecFileException | null
stdoutstring | Buffer
stderrstring | Buffer
Returns

void

Defined in

open.ts:4


ColMap

Ƭ ColMap: Record\<string, (t: string) => string>

Defined in

colorize.ts:4


F

Ƭ F: (...args: any[]) => any

Type declaration

▸ (...args): any

Parameters
NameType
...argsany[]
Returns

any

Defined in

curry.ts:1


Listener

Ƭ Listener: (a: AnyMap, b: AnyMap) => any

Type declaration

▸ (a, b): any

Parameters
NameType
aAnyMap
bAnyMap
Returns

any

Defined in

store.ts:3


R

Ƭ R: Record\<string, number>

Defined in

count-items-in-array.ts:1


R

Ƭ R: (...args: any[]) => Timer

Type declaration

▸ (...args): Timer

Parameters
NameType
...argsany[]
Returns

Timer

Defined in

debounce.ts:2


R

Ƭ R: string | any[] | AnyMap

Defined in

keep.ts:4


Timer

Ƭ Timer: NodeJS.Timeout | number | null

Defined in

debounce.ts:1


Updater

Ƭ Updater: (a: AnyMap) => AnyMap

Type declaration

▸ (a): AnyMap

Parameters
NameType
aAnyMap
Returns

AnyMap

Defined in

store.ts:4

Variables

colorize

Const colorize: ColMap

Defined in

colorize.ts:34

Functions

and

and\<T>(a): boolean

Returns false if any in input array is false

Type parameters

Name
T

Parameters

NameType
aT[]

Returns

boolean

Example

and([ 1, 2, 3 ]) // => true
and([ 1, 2, 3, false ]) // => false

Defined in

and.ts:8


average

average(xs): number

Averages a list of numbers

Parameters

NameType
xsnumber[]

Returns

number

Example

average([ 2, 4, 6, 8 ]) // => 5

Defined in

average.ts:7


basename

basename(str?): string

basename for Node

Parameters

NameTypeDefault value
strstring''

Returns

string

Example

basename() // => string

Defined in

basename.ts:9


camelCaseToLispCase

camelCaseToLispCase(str): string

Takes a camelCase string and returns one in lisp-case

Parameters

NameType
strstring

Returns

string

Example

camelCaseToLispCase('fooBar') // => 'foo-bar'

Defined in

camel-case-to-lisp-case.ts:7


camelCaseToPascalCase

camelCaseToPascalCase(str): string

Takes a camelCase string and returns one in PascalCase

Parameters

NameType
strstring

Returns

string

Example

camelCaseToPascalCase('fooBar') // => 'FooBar'

Defined in

camel-case-to-pascal-case.ts:7


camelCaseToSnakeCase

camelCaseToSnakeCase(str): string

Takes a camelCase string and returns one in snake_case

Parameters

NameType
strstring

Returns

string

Example

camelCaseToSnakeCase('fooBar') // => 'foo_bar'

Defined in

camel-case-to-snake-case.ts:7


capitalizeFirstChar

capitalizeFirstChar(str): string

Capitalizes the first character of string

Parameters

NameType
strstring

Returns

string

Example

capitalizeFirstChar('things and stuff') // => 'Things and stuff'

Defined in

capitalize-first-char.ts:7


chunk

chunk\<T>(arr, n): T

Splits an array into chunks

Type parameters

Name
T

Parameters

NameType
arrT[]
nnumber

Returns

T

Example

chunk([1, 2, 3, 4 ], 2) // => [ [ 1, 2 ], [ 3, 4 ] ]

Defined in

chunk.ts:7


clamp

clamp(val, min, max): number

Takes a number, min, and max If number is between min and max, returns number Otherwise returns min or max

Parameters

NameType
valnumber
minnumber
maxnumber

Returns

number

Example

clamp(100, 0, 1000) // => 100
clamp(100, 101, 1000) // => 101
clamp(100, 0, 99) // => 00

Defined in

clamp.ts:11


collapseNewlines

collapseNewlines(str): string

Collapses multiple newlines to two

Parameters

NameType
strstring

Returns

string

Example

collapseNewlines('\n\n\n\n') // => '\n\n'

Defined in

collapse-newlines.ts:7


collapseWhitespace

collapseWhitespace(str): string

Collapses consecutive whitespace to a single space

Parameters

NameType
strstring

Returns

string

Example

collapseWhitespace('a\n\r\t\nb') // => 'a b'

Defined in

collapse-whitespace.ts:7


collectBy

collectBy(p): (a: any[]) => AnyMap

Collect an an array of objects by string key cred: gh:uniqname

Parameters

NameType
pstring

Returns

fn

▸ (a): AnyMap

Parameters
NameType
aany[]
Returns

AnyMap

Example

const data = [ { foo: 'a', bar: 'baz' }, { foo: 'b', bar: 'quux' }, { foo: 'a', bar: 'whatever' } ]
collectBy('foo')(data) // => { a: { foo: 'a', bar: 'whatever' }, b: { foo: 'b', bar: 'quux' } }

Defined in

collect-by.ts:11


combineRegex

combineRegex(rs, opts?): RegExp

Combines regular expressions

Parameters

NameTypeDefault value
rsRegExp[]undefined
optsstring''

Returns

RegExp

Example

combineRegex([/[a-z]/, /[0-9]], 'g') ==> /[a-z][0-9]/g

Defined in

combine-regex.ts:7


compose

compose\<T>(...fns): (t: T) => T

Right to left composition

Type parameters

Name
T

Parameters

NameType
...fns(t: T) => T[]

Returns

fn

▸ (t): T

Parameters
NameType
tT
Returns

T

Example

const addOne = (a) => a + 1
const timesTwo = (a) => a * 2
compose(addOne, timesTwo)(2) // => 5

Defined in

compose.ts:11


countIn

countIn\<T>(el, ls): number

Find out how many of a given element is in an array or string.

Type parameters

Name
T

Parameters

NameType
elT
lsstring | T[]

Returns

number

Example

countIn('a', 'abc') // => 1
countIn('a', [ 'a', 'b', 'c' ]) // => 1

Defined in

count-in.ts:9


countItemsInArray

countItemsInArray\<T>(arr): R

Get an object of items in an array with count

Type parameters

Name
T

Parameters

NameType
arrT[]

Returns

R

Example

countItemsInArray([ 1, 1, 2, 3, 4 ]) // => { '1': 2, '2': 1, '3': 1, '4': 1 }

Defined in

count-items-in-array.ts:9


curry

curry\<T>(fn): F

Takes a function and returns a function that takes any number of arguments

Produces a curried function

Type parameters

Name
T

Parameters

NameType
fnF

Returns

F

Example

const addThree = (a, b, c) => a + b + c
curry(addThree)(1)(1)(1) // => 3

Defined in

curry.ts:13


debounce

debounce(fn, ms): R

Simple debounce

Parameters

NameType
fn(...args: any) => any
msnumber

Returns

R

Example

debounce(() => console.log('hi'), 5000)

Defined in

debounce.ts:10


diff

diff\<T>(a, b): T[]

Diff two arrays

Type parameters

Name
T

Parameters

NameType
aT[]
bT[]

Returns

T[]

Example

diff([ 1, 2, 3 ], [ 2, 3 ]) // => [ 1 ]

Defined in

diff.ts:7


div

div(ns): number

Divide any amount of numbers

Parameters

NameType
nsnumber[]

Returns

number

Example

div([ 4, 2, 1 ]) // => 2

Defined in

div.ts:7


doubleUntil

doubleUntil(minSize?): \<T>(arr: T[]) => T[]

Double an array until it's n long

Parameters

NameTypeDefault value
minSizenumber0

Returns

fn

▸ \<T>(arr): T[]

Type parameters
Name
T
Parameters
NameType
arrT[]
Returns

T[]

Example

doubleUntil(2)([ 'hi' ]) // => [ 'hi', 'hi' ]

Defined in

double-until.ts:7


drop

drop\<A>(n, arr): A[]

Like Haskell's drop

Type parameters

Name
A

Parameters

NameType
nnumber
arrA[]

Returns

A[]

Example

drop(2, [ 1, 2, 3 ]) // => 3

Defined in

drop.ts:7


dropWhile

dropWhile\<T>(pred, arr): T[]

The opposite of takeWhile: takes a predicate and array and returns an array of the elements that didn't pass the predicate

Type parameters

Name
T

Parameters

NameType
pred(x: T) => boolean
arrT[]

Returns

T[]

Example

dropWhile(lessThanThree, [ 1, 2, 3, 4 ]) // => [ 3, 4 ]

Defined in

drop-while.ts:11


each

each\<T>(xs, fn): Record\<string, any> | T[]

Takes an array or object and a function, and runs the function on each element

Type parameters

Name
T

Parameters

NameType
xsstring | any[] | Record\<string, any>
fn(a: any, b: string | number) => T

Returns

Record\<string, any> | T[]

Example

each([ 'a', 'b', 'c' ], id) // => 'a'

Defined in

each.ts:33


elem

elem\<T>(el, ls): boolean

Check if a string or array contains an element

Type parameters

Name
T

Parameters

NameType
elstring & T
lsstring | T[]

Returns

boolean

Example

elem('a', 'asdf') // => true
elem('a', 'asdf'.split('')) // => true

Defined in

elem.ts:8


escapeForRegex

escapeForRegex(s?): string

Parameters

NameTypeDefault value
sstring''

Returns

string

Example

escapeForRegex('foo') // => foo
escapeForRegex('1 \\ {} []|') // => '1 \\\\ \{\} \\[\\]\\|'

Defined in

escape-for-regex.ts:7


execute

execute(cmd): void

Like a standalone npm run that obeys npm bin

Parameters

NameType
cmdstring

Returns

void

Example

execute('standard-format -w')

Defined in

execute.ts:15


fileExists

fileExists(filePath): Promise\<boolean>

Returns bool based on if passed path exists

Parameters

NameType
filePathstring

Returns

Promise\<boolean>

Example

await fileExists('./foo') // => Promise<true>

Defined in

file-exists.ts:10


filter

filter\<T>(fn, list): T[] | Record\<string, T>

filter for array and object

Type parameters

Name
T

Parameters

NameType
fn(x: T, y: string | number) => boolean
liststring | AnyMap | T[]

Returns

T[] | Record\<string, T>

Example

filter(id, [ 1, 2 ]) // => [ 1, 2 ]
filter(lessThanThree, [ 1, 2, 3, 4 ]) // => [ 1, 2 ]
filter(lessThanThree, { a: 1, b: 4 }) // =>  { a: 1 }

Defined in

filter.ts:14


findIndices

findIndices(el, arr): number[]

Find all indices of an item in an array

Parameters

NameType
elany
arrany[]

Returns

number[]

Example

findIndices(1, [ 1, 2, 1 ]) // => [ 0, 2 ]

Defined in

find-indices.ts:7


findPort

findPort(port, cb): void

Find next open port

Parameters

NameType
portnumber
cb(x: null | Error, y?: number) => void

Returns

void

Example

findPort(8000, (err, port) => console.log(`${port} is open`))

Defined in

find-port.ts:13


flattenAndUniq

flattenAndUniq\<T>(arr): T[]

Recursively flatten arrays then uniq what's left

Type parameters

Name
T

Parameters

NameType
arrT[]

Returns

T[]

Example

flattenAndUniq([ 1, 2, 3, [ 1, 2, 3 ]]) // =>  [ 1, 2, 3 ]

Defined in

flatten-and-uniq.ts:10


flip

flip(f): (...args: any[]) => any

Flips order of received arguments and calls f.

Parameters

NameType
f(...xs: any[]) => any

Returns

fn

▸ (...args): any

Parameters
NameType
...argsany[]
Returns

any

Example

const minus = (a, b) => a - b
minus(2, 1) // => 1
flip(minus)(2, 1) // => -1

Defined in

flip.ts:9


fold

fold\<T>(f, a): T

Applies f to first two items of list, then to next, etc.

Type parameters

Name
T

Parameters

NameType
f(x: T, y: T) => T
aT[]

Returns

T

Example

foldl1(increment, [ 1, 1, 1 ]) // => 3

Defined in

fold.ts:8


getFreeDisk

getFreeDisk(): number

Get free disk space

Returns

number

Example

getFreeDisk()

Defined in

get-free-disk.ts:9


getFreeMemory

getFreeMemory(): number

Get free memory

Returns

number

Example

getFreeMemory()

Defined in

get-free-memory.ts:9


getGlobal

getGlobal(): undefined | typeof globalThis

Gets the global for your current context.

Returns

undefined | typeof globalThis

Example

getGlobal() // => window, global, whatever

Defined in

get-global.ts:7


getHashFromDate

getHashFromDate(): string

Returns a hash based on current timestamp

Returns

string

Example

getHashFromDate()

Defined in

get-hash-from-date.ts:7


getHashFromSystem

getHashFromSystem(): string

Get a md5 hash based on hostname, process.ppid, and date

Returns

string

Example

getHashFromSystem()

Defined in

get-hash-from-system.ts:10


getKeyByValue

getKeyByValue(value, object): undefined | string

Get the key for a value

Parameters

NameType
valueany
objectAnyMap

Returns

undefined | string

Example

getKeyByValue('bar', { foo: 'bar' }) // => 'foo'

Defined in

get-key-by-value.ts:9


getLoadAverage

getLoadAverage(): number

Get load average

Returns

number

Example

getLoadAverage()

Defined in

get-load-average.ts:10


getMemoryUsage

getMemoryUsage(): number

Get memory usage

Returns

number

Example

getMemoryUsage()

Defined in

get-memory-usage.ts:9


getOrdinal

getOrdinal(n): string

Adds ordinal onto integer

Works up to 999

Parameters

NameType
nnumber

Returns

string

Example

getOrdinal(1) // => '1st'

Defined in

get-ordinal.ts:9


getProjectRoot

getProjectRoot(): string

Get project root

Returns

string

Example

getProjectRoot() // /path/to/project

Defined in

get-project-root.ts:10


getRandomString

getRandomString(n?): string

Returns random string of n length (defaults to 8)

Parameters

NameTypeDefault value
nnumber8

Returns

string

Example

getRandomString()
getRandomString(32)

Defined in

get-random-string.ts:8


getRegexFlags

getRegexFlags(r): string[]

Returns the flags for a given regular expression

Parameters

NameType
rRegExp

Returns

string[]

Example

getRegexFlags(/foo/ig) // => [ 'g', 'i' ]

Defined in

get-regex-flags.ts:7


getStdin

getStdin(f): void

Get stdin and do something with it.

Parameters

NameType
f(a: string) => void

Returns

void

Example

getStdin((str) => {
  console.log(str.split(''))
})

Defined in

get-stdin.ts:9


getTerminalColumns

getTerminalColumns(): number

Get columns of current terminal

Returns

number

Example

getTerminalColumns()

Defined in

get-terminal-columns.ts:7


getTerminalRows

getTerminalRows(): number

Get current terminal rows

Returns

number

Example

getTerminalRows()

Defined in

get-terminal-rows.ts:7


getTerminalSize

getTerminalSize(): Size

Returns size of the current terminal

Returns

Size

Example

getTerminalSize() // => { columns: number, rows: number }

Defined in

get-terminal-size.ts:9


getUserHome

getUserHome(): string

Get current user's home directory

Returns

string

Example

getUserHome() // => /home/z

Defined in

get-user-home.ts:11


getUserShell

getUserShell(): string

Get the current user's shell, or an empty string on shell-less platforms

Returns

string

Example

getUserShell()

Defined in

get-user-shell.ts:8


greater

greater(a, b): number

Get the greater of two numbers

Parameters

NameType
anumber
bnumber

Returns

number

Example

greater(1, 2) // => 2

Defined in

greater.ts:7


groupBy

groupBy(p): (a: any[]) => AnyMap

Collect an an array of objects by string key

Parameters

NameType
pstring

Returns

fn

▸ (a): AnyMap

Parameters
NameType
aany[]
Returns

AnyMap

Example

const data = [ { foo: 'a', bar: 'baz' }, { foo: 'b', bar: 'quux' }, { foo: 'a', bar: 'whatever' } ]
groupBy('foo')(data) // => { a: { foo: 'a', bar: 'whatever' }, b: { foo: 'b', bar: 'quux' } }

Defined in

group-by.ts:10


gt

gt(a, b): boolean

Returns true if first param is greater than second param

Parameters

NameType
anumber
bnumber

Returns

boolean

Example

gt(2, 1) // => true
gt(1, 2) // => false

Defined in

gt.ts:8


gte

gte(a, b): boolean

Returns true if first param is greater than or equal to second param

Parameters

NameType
anumber
bnumber

Returns

boolean

Example

gte(2, 2) // => true
gte(2, 1) // => true
gte(2, 3) // => false

Defined in

gte.ts:9


has

has(p, o): boolean

See if an object has a property

Parameters

NameType
pstring
oAnyMap

Returns

boolean

Example

has('a' { b: 'c' }) // => false

Defined in

has.ts:9


hasColor

hasColor(): boolean

Returns true if the current terminal supports color

Returns

boolean

Example

hasColor()

Defined in

has-color.ts:14


hasDuplicate

hasDuplicate\<T>(arr): boolean

Returns true if an array has any duplicate elements

Type parameters

Name
T

Parameters

NameType
arrT[]

Returns

boolean

Example

hasDuplicate([ 1, 1, 2 ]) // => true

Defined in

has-duplicate.ts:8


head

head\<T>(arr): T

First element

Type parameters

Name
T

Parameters

NameType
arrT[]

Returns

T

Example

head([ 1, 2, 3 ]) // => 1

Defined in

head.ts:7


id

id\<A>(a): A

id

Type parameters

Name
A

Parameters

NameType
aA

Returns

A

Example

id(1) // => 1
id() // => undefined

Defined in

id.ts:8


init

init(arr): any[]

Returns all but the last item of an array

Parameters

NameType
arrany[]

Returns

any[]

Example

init([ 1, 2, 3 ]) // => [ 1, 2 ]

Defined in

init.ts:7


initials

initials(str): string

Trims a string to just caps

Parameters

NameType
strstring

Returns

string

Example

initials('Zac Anger') // => 'ZA'

Defined in

initials.ts:7


intersection

intersection\<T>(xs, ys): T[]

Get the intersection of two arrays

Type parameters

Name
T

Parameters

NameType
xsT[]
ysT[]

Returns

T[]

Example

intersection([ 1, 2 ], []) // => []
intersection([ 1, 2, 3 ], [1, 2]) // => [ 1, 2 ]

Defined in

intersection.ts:8


is

is(t, val): boolean

Returns true if the value is of the type

Parameters

NameType
tstring
valany

Returns

boolean

Example

is('number', 2) // => true

Defined in

is.ts:7


isArrayLike

isArrayLike(v): boolean

Returns true if the passed value is array-like

Parameters

NameType
vany

Returns

boolean

Example

isArrayLike({}) // => false
isArrayLike([ 1, 2 ]) // => true

Defined in

is-array-like.ts:10


isBetween

isBetween(a, b, mid): boolean

Returns true if the last parameter is before the first and second parameters

Parameters

NameType
anumber
bnumber
midnumber

Returns

boolean

Example

isBetween(1, 3, 2) // => true
isBetween(2, 1, 2) // => false

Defined in

is-between.ts:13


isBoolean

isBoolean(v): boolean

Returns true if the value is a boolean

Parameters

NameType
vany

Returns

boolean

Example

isBoolean(true) // => true

Defined in

is-boolean.ts:7


isClass

isClass(fn): boolean

Returns true if passed fn is an ES2015 class

Parameters

NameType
fn() => any

Returns

boolean

Example

isClass(noop) // => false

Defined in

is-class.ts:12


isDate

isDate(v): boolean

Returns true if the value is a date

Parameters

NameType
vany

Returns

boolean

Example

isDate(new Date()) // => true

Defined in

is-date.ts:9


isDefined

isDefined(v): boolean

Returns true if the value is defined

Parameters

NameType
vany

Returns

boolean

Example

isDefined(null) // => true

Defined in

is-defined.ts:7


isDirectory

isDirectory(filePath): Promise\<boolean>

Returns true if the path is a directory

Parameters

NameType
filePathstring

Returns

Promise\<boolean>

Example

await isDirectory('.') // => true
await isDirectory('./fake-path') // => false

Defined in

is-directory.ts:11


isEmpty

isEmpty(v): boolean

Returns true if the value is empty

Parameters

NameType
vany

Returns

boolean

Example

isEmpty('') // => true
isEmpty({}) // => true
isEmpty([]) // => true
isEmpty(null) // => true

Defined in

is-empty.ts:14


isError

isError(a): boolean

Returns true if value is an error

Parameters

NameType
aany

Returns

boolean

Example

isError(new Error()) // => true

Defined in

is-error.ts:9


isEven

isEven(n): boolean

Returns true if the number is even

Parameters

NameType
nnumber

Returns

boolean

Example

isEven(2) // => true

Defined in

is-even.ts:7


isFile

isFile(filePath): Promise\<boolean>

Returns true if the path is a file

Parameters

NameType
filePathstring

Returns

Promise\<boolean>

Example

isFile('./README.md') // => true
isFile('.') // => false

Defined in

is-file.ts:11


isFloat

isFloat(n): boolean

Returns true if the number is a float

Parameters

NameType
nnumber

Returns

boolean

Example

isFloat(2) // => false
isFloat(2.2) // => true

Defined in

is-float.ts:8


isFunction

isFunction(v): boolean

Returns true if the value is a function

Parameters

NameType
vany

Returns

boolean

Example

const noop = () => {}
isFunction(2) // => false
isFunction(noop) // => true

Defined in

is-function.ts:9


isGenerator

isGenerator(v): boolean

Returns true if passed val is a generator

Parameters

NameType
vany

Returns

boolean

Example

isGenerator(2) // => false

Defined in

is-generator.ts:7


isGeneratorFunction

isGeneratorFunction(v): boolean

Returns true if val is a generator function

Parameters

NameType
vany

Returns

boolean

Example

isGeneratorFunction(2) // => false

Defined in

is-generator-function.ts:7


isInstalled

isInstalled(pkgName): boolean

Returns true if the passed node_module name is installed

Parameters

NameType
pkgNamestring

Returns

boolean

Example

isInstalled('zeelib') // => true

Defined in

is-installed.ts:7


isInteger

isInteger(v): boolean

Returns true if the value is an integer

Parameters

NameType
vany

Returns

boolean

Example

isInteger(2) // => true
isInteger(1.1) // => false

Defined in

is-integer.ts:8


isJson

isJson(str): boolean

Returns true if the string is valid JSON

Parameters

NameType
strstring

Returns

boolean

Example

isJson(JSON.stringify({ a: 'b' })) // => true

Defined in

is-json.ts:7


isMap

isMap(v): boolean

Returns true if value is a map

Parameters

NameType
vany

Returns

boolean

Example

isMap(new Map()) // => true

Defined in

is-map.ts:9


isNode

isNode(): boolean

Returns true if code is in Node

Returns

boolean

Example

isNode()

Defined in

is-node.ts:7


isNull

isNull(v): boolean

Returns true if the value is null

Parameters

NameType
vany

Returns

boolean

Example

isNull(null) // => true

Defined in

is-null.ts:7


isNullOrUndefined

isNullOrUndefined(v): boolean

Returns true if the value is null or undefined

Parameters

NameType
vany

Returns

boolean

Example

isNullOrUndefined(null) // => true

Defined in

is-null-or-undefined.ts:10


isNumber

isNumber(v): boolean

Returns true if the value is a number and is not NaN

Parameters

NameType
vany

Returns

boolean

Example

isNumber(2) // => true
isNumber(NaN) // => false

Defined in

is-number.ts:8


isObject

isObject(v): boolean

Returns true if the value is an object

Parameters

NameType
vany

Returns

boolean

Example

isObject('asdf') // => false

Defined in

is-object.ts:7


isOdd

isOdd(n): boolean

Returns true if the number is odd

Parameters

NameType
nnumber

Returns

boolean

Example

isOdd(1) // => true

Defined in

is-odd.ts:7


isPow2

isPow2(n): boolean

Returns true if number is a power of two

Parameters

NameType
nnumber

Returns

boolean

Example

isPow2(16) // => true

Defined in

is-pow-2.ts:7


isPrimitive

isPrimitive(v): boolean

Returns true if value is a primitive

Parameters

NameType
vany

Returns

boolean

Example

isPrimitive(1) // => true

Defined in

is-primitive.ts:7


isPromise

isPromise(a): boolean

Returns true if value is a promise

Parameters

NameType
aany

Returns

boolean

Example

isPromise(Promise.resolve())

Defined in

is-promise.ts:7


isRegExp

isRegExp(v): boolean

Returns true if value is a RegExp

Parameters

NameType
vany

Returns

boolean

Example

isRegExp(/a/) // => true

Defined in

is-reg-exp.ts:9


isRoot

isRoot(): boolean

Check if current process is running as root.

Returns

boolean

Example

isRoot() // => true

Defined in

is-root.ts:7


isSemver

isSemver(v): boolean

Returns true if the provided string is a valid semantic version

Parameters

NameType
vstring

Returns

boolean

Example

isSemver("0.0.0") // => true
isSemver("0.") // => false

Defined in

is-semver.ts:8


isSet

isSet(v): boolean

Returns true if value is a set

Parameters

NameType
vany

Returns

boolean

Example

isSet(new Set()) // => true

Defined in

is-set.ts:9


isString

isString(v): boolean

Returns true if value is a string

Parameters

NameType
vany

Returns

boolean

Example

isString('a') // => true

Defined in

is-string.ts:7


isSymLink

isSymLink(filePath): Promise\<boolean>

Returns true if path is a symlink

Parameters

NameType
filePathstring

Returns

Promise\<boolean>

Example

isSymLink('.') // => false

Defined in

is-sym-link.ts:10


isSymbol

isSymbol(a): boolean

Returns true if value is a symbol

Parameters

NameType
aany

Returns

boolean

Example

isSymbol(Symbol.for('foo')) // => true

Defined in

is-symbol.ts:7


isUndefined

isUndefined(v): boolean

Returns true if value is undefined

Parameters

NameType
vany

Returns

boolean

Example

isUndefined(undefined) // => true

Defined in

is-undefined.ts:7


isValidDate

isValidDate(d): boolean

Returns true if the passed object is a valid Date

Parameters

NameType
dDate

Returns

boolean

Example

isValidDate('1234') // => false

Defined in

is-valid-date.ts:9


keep

keep(x): R

Returns an array or object with all falsey values removed

Parameters

NameType
xR

Returns

R

Example

keep([ 'a', null, '', 2]) // => [ 'a', 2 ]
keep({ a: '', b: null, c: 2 }) // => { c: 2 }

Defined in

keep.ts:13


last

last\<A>(arr): A

Returns the last element of the array

Type parameters

Name
A

Parameters

NameType
arrA[]

Returns

A

Example

last([ 1, 2, 3 ]) // => 3

Defined in

last.ts:7


len

len(val): number

Get length of element

Works for array, object, string, set, map, and function

Parameters

NameType
valany

Returns

number

Example

len('foo') // => 3
len([ 1, 2 ]) => 2
len((a, b) => a + b) // => 2

Defined in

len.ts:19


lesser

lesser(a, b): number

Returns the lesser of two numbers

Parameters

NameType
anumber
bnumber

Returns

number

Example

lesser(1, 2) // => 1

Defined in

lesser.ts:7


lightenOrDarken

lightenOrDarken(col, amt): string

Lighten or darken a color

Parameters

NameType
colstring
amtnumber

Returns

string

Example

// lighten
const newCol = lightenOrDarken('#F06D06', 20)
// darken
const newCol = lightenOrDarken('#F06D06', -20)

Defined in

lighten-or-darken.ts:10


lines

lines(str): string[]

Split a string on lines

Parameters

NameType
strstring

Returns

string[]

Example

lines('foo\nbar') // => [ 'foo', 'bar' ]

Defined in

lines.ts:7


lispCaseToCamelCase

lispCaseToCamelCase(str): string

From lisp-case to camelCase

Parameters

NameType
strstring

Returns

string

Example

lispCaseToCamelCase('foo-bar') // => 'fooBar'

Defined in

lisp-case-to-camel-case.ts:7


lispCaseToPascalCase

lispCaseToPascalCase(str): string

From lisp-case to PascalCase

Parameters

NameType
strstring

Returns

string

Example

lispCaseToPascalCase('foo-bar') // => 'FooBar'

Defined in

lisp-case-to-pascal-case.ts:7


lispCaseToSnakeCase

lispCaseToSnakeCase(str): string

From lisp-case to snake_case

Parameters

NameType
strstring

Returns

string

Example

lispCaseToSnakeCase('foo-bar') // => 'foo_bar'

Defined in

lisp-case-to-snake-case.ts:7


lt

lt(a, b): boolean

Returns true if first param is less than second param

Parameters

NameType
anumber
bnumber

Returns

boolean

Example

lt(2, 1) // => false

Defined in

lt.ts:7


lte

lte(a, b): boolean

Returns true if first param is less than or equal to second param

Parameters

NameType
anumber
bnumber

Returns

boolean

Example

lte(2, 1) // => false
lte(1, 1) // => true

Defined in

lte.ts:8


mapObject

mapObject(f, o, ctx?): AnyMap

Map for objects

Parameters

NameType
f(a: any, b: string, c: any) => any
oAnyMap
ctxany

Returns

AnyMap

Example

const f = (a) => a + ' world'
const d = { a: 'hello', b: 'sup' }
mapObject(f, d) // => { a: 'hello world', b: 'sup world' }

Defined in

map-object.ts:11


memoize

memoize(fn): any

A simple memoizing util

Parameters

NameType
fnany

Returns

any

Example

memoize((a) => a) // => [Function]
memoize((a) => a)(1) // => 1

Defined in

memoize.ts:8


mzero

mzero(v?): any

Get monadic empty/zero value for a type

Parameters

NameType
v?any

Returns

any

Example

mzero(1) // =>
mzero([1]) // => []

Defined in

mzero.ts:10


nco

nco\<A, B>(variable, defaultValue): A | B

nco

Type parameters

Name
A
B

Parameters

NameType
variableA
defaultValueB

Returns

A | B

Example

nco(null, 1) // => 1
nco(1, 2) // => 1

Defined in

nco.ts:9


noop

noop(): void

noop

Returns

void

Example

noop() // => undefined

Defined in

noop.ts:8


notElem

notElem\<T>(el, ls): boolean

The opposite of elem

Returns true if the element is not in the string or array

Type parameters

Name
T

Parameters

NameType
elT & string
lsstring | T[]

Returns

boolean

Example

notElem('a', 'asdf') // => false
notElem('b', 'asdf') // => true

Defined in

not-elem.ts:12


objectToString

objectToString(v): string

toString

Parameters

NameType
vany

Returns

string

Example

objectToString({}) // => '[object Object]'

Defined in

object-to-string.ts:7


once

once\<U>(fn): (...args: U[]) => U

Only calls fn once; subsequent calls just return first val

Type parameters

Name
U

Parameters

NameType
fn\<T>(...args: T[]) => T

Returns

fn

▸ (...args): U

Parameters
NameType
...argsU[]
Returns

U

Example

const o = once(id)
o(1) // => 1
o() // => 1
o(2) // => 1

Defined in

once.ts:10


open

open(args, opts, cb): void

Opens things. Works on Linux, Mac, and Windows

Parameters

NameType
argsstring
optsAnyMap
cbCb

Returns

void

Example

open('http://zacanger.com')

Defined in

open.ts:12


pair

pair\<A, B>(first, second): A, B

Make a pair out of any two values

Type parameters

Name
A
B

Parameters

NameType
firstA
secondB

Returns

A, B

Example

pair('a', 'b') // => [ 'a', 'b' ]

Defined in

pair.ts:7


pairWith

pairWith\<T>(f, a, b): T[]

Returns an array made by calling f on a and b.

Type parameters

Name
T

Parameters

NameType
f(x: T) => T
aT
bT

Returns

T[]

Example

pairWith(increment, 1, 1) // => [ 2, 2 ]

Defined in

pair-with.ts:8


pascalCaseToCamelCase

pascalCaseToCamelCase(str): string

PascalCase to camelCase

Parameters

NameType
strstring

Returns

string

Example

pascalCaseToCamelCase('FooBar') // => 'fooBar'

Defined in

pascal-case-to-camel-case.ts:7


pascalCaseToLispCase

pascalCaseToLispCase(str): string

PascalCase to lisp-case

Parameters

NameType
strstring

Returns

string

Example

pascalCaseToLispCase('FooBar') // => 'foo-bar'

Defined in

pascal-case-to-lisp-case.ts:7


pascalCaseToSnakeCase

pascalCaseToSnakeCase(str): string

PascalCase to snake_case

Parameters

NameType
strstring

Returns

string

Example

pascalCaseToSnakeCase('FooBar') // => 'foo_bar'

Defined in

pascal-case-to-snake-case.ts:7


pick

pick(ks, o): AnyMap

pick as it is in rambda (not ramda)

Parameters

NameType
ksstring | string[]
oAnyMap

Returns

AnyMap

Example

pick('a', { a: 'a', b: 'b' }) // => { a: 'a' }
pick([ 'a', 'b' ], { a: 'a', b: 'b', c: 'c' }) // => { a: 'a', b: 'b' }

Defined in

pick.ts:11


pipe

pipe\<T>(...fns): (data: T) => T

Left to right composition

Type parameters

Name
T

Parameters

NameType
...fnsAnyFn[]

Returns

fn

▸ (data): T

Parameters
NameType
dataT
Returns

T

Example

const addOne = (a) => a + 1
const timesTwo = (a) => a * 2
pipe(addOne, timesTwo)(2) // => 6

Defined in

pipe.ts:13


pluck

pluck(key, arr): any[]

Simple pluck

Parameters

NameType
keystring
arrany[]

Returns

any[]

Example

pluck('a', [ { a: 'a' }, { a: 'b' } ]) // => [ 'a', 'b' ]

Defined in

pluck.ts:7


product

12.1.2

14 days ago

12.0.0

4 months ago

12.0.1

4 months ago

12.0.2

4 months ago

12.1.0

4 months ago

12.1.1

4 months ago

11.2.0

2 years ago

11.1.9

3 years ago

11.1.8

3 years ago

11.1.7

3 years ago

11.1.6

3 years ago

11.1.5

4 years ago

11.1.4

4 years ago

11.1.3

4 years ago

11.1.2

4 years ago

11.1.1

4 years ago

11.1.0

4 years ago

11.0.13

4 years ago

11.0.14

4 years ago

11.0.12

4 years ago

11.0.11

4 years ago

11.0.10

4 years ago

11.0.7

4 years ago

11.0.8

4 years ago

11.0.9

4 years ago

11.0.6

4 years ago

11.0.5

4 years ago

11.0.4

4 years ago

11.0.3

4 years ago

11.0.2

5 years ago

11.0.1

5 years ago

11.0.0

5 years ago

10.0.5

5 years ago

10.0.4

5 years ago

10.0.3

5 years ago

10.0.2

5 years ago

10.0.1

5 years ago

10.0.0

5 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.6.1

5 years ago

8.6.0

5 years ago

8.5.0

5 years ago

8.4.1

5 years ago

8.4.0

5 years ago

8.3.1

5 years ago

8.3.0

5 years ago

8.2.3

5 years ago

8.2.2

6 years ago

8.2.1

6 years ago

8.2.0

6 years ago

8.1.2

6 years ago

8.1.1

6 years ago

8.1.0

6 years ago

8.0.0

6 years ago

7.0.6

6 years ago

7.0.4

6 years ago

7.0.3

6 years ago

7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.2.5

6 years ago

6.2.4

6 years ago

6.2.3

6 years ago

6.2.2

6 years ago

6.2.1

6 years ago

6.2.0

6 years ago

6.1.11

6 years ago

6.1.10

6 years ago

6.1.9

6 years ago

6.1.8

6 years ago

6.1.7

6 years ago

6.1.6

6 years ago

6.1.5

6 years ago

6.1.4

6 years ago

6.1.3

6 years ago

6.1.2

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.4

6 years ago

6.0.3

6 years ago

6.0.2

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.0

6 years ago

4.0.8

6 years ago

4.0.7

6 years ago

4.0.6

6 years ago

4.0.5

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.1.10

7 years ago

3.1.9

7 years ago

3.1.8

7 years ago

3.1.7

7 years ago

3.1.6

7 years ago

3.1.5

7 years ago

3.1.4

7 years ago

3.1.3

7 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.14

7 years ago

3.0.13

7 years ago

3.0.12

7 years ago

3.0.10

7 years ago

3.0.9

7 years ago

3.0.8

7 years ago

3.0.7

7 years ago

3.0.6

7 years ago

3.0.5

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.9.21

7 years ago

0.9.20

7 years ago

0.9.19

7 years ago

0.9.18

7 years ago

0.9.17

7 years ago

0.9.16

7 years ago

0.9.15

7 years ago

0.9.14

7 years ago

0.9.13

7 years ago

0.9.12

7 years ago

0.9.11

7 years ago

0.9.10

7 years ago

0.9.9

7 years ago

0.9.8

7 years ago

0.9.7

7 years ago

0.9.6

7 years ago

0.9.5

7 years ago

0.9.4

7 years ago

0.9.3

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.51

7 years ago

0.7.50

7 years ago

0.7.49

7 years ago

0.7.48

7 years ago

0.7.47

7 years ago

0.7.46

7 years ago

0.7.45

7 years ago

0.7.44

7 years ago

0.7.43

7 years ago

0.7.42

7 years ago

0.7.41

7 years ago

0.7.40

7 years ago

0.7.39

7 years ago

0.7.38

7 years ago

0.7.37

7 years ago

0.7.36

7 years ago

0.7.35

7 years ago

0.7.34

7 years ago

0.7.33

7 years ago

0.7.32

7 years ago

0.7.31

7 years ago

0.7.30

7 years ago

0.7.29

7 years ago

0.7.28

7 years ago

0.7.27

7 years ago

0.7.26

7 years ago

0.7.25

7 years ago

0.7.24

7 years ago

0.7.23

7 years ago

0.7.22

7 years ago

0.7.21

7 years ago

0.7.20

7 years ago

0.7.19

7 years ago

0.7.18

7 years ago

0.7.17

7 years ago

0.7.16

7 years ago

0.7.15

7 years ago

0.7.14

7 years ago

0.7.13

7 years ago

0.7.12

7 years ago

0.7.11

7 years ago

0.7.10

7 years ago

0.7.9

7 years ago

0.7.8

7 years ago

0.7.7

7 years ago

0.7.6

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.30

7 years ago

0.6.29

7 years ago

0.6.28

7 years ago

0.6.27

7 years ago

0.6.26

7 years ago

0.6.25

7 years ago

0.6.24

7 years ago

0.6.23

7 years ago

0.6.22

7 years ago

0.6.21

7 years ago

0.6.20

7 years ago

0.6.19

7 years ago

0.6.18

7 years ago

0.6.17

7 years ago

0.6.16

7 years ago

0.6.15

7 years ago

0.6.14

7 years ago

0.6.13

7 years ago

0.6.12

7 years ago

0.6.11

7 years ago

0.6.10

7 years ago

0.6.9

7 years ago

0.6.8

7 years ago

0.6.7

7 years ago

0.6.6

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.6

7 years ago

0.5.5

7 years ago

0.5.4

7 years ago

0.5.3

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.35

7 years ago

0.4.34

7 years ago

0.4.33

7 years ago

0.4.32

7 years ago

0.4.31

7 years ago

0.4.30

7 years ago

0.4.29

7 years ago

0.4.28

7 years ago

0.4.27

7 years ago

0.4.26

7 years ago

0.4.25

7 years ago

0.4.24

7 years ago

0.4.23

7 years ago

0.4.22

7 years ago

0.4.21

7 years ago

0.4.20

7 years ago

0.4.19

7 years ago

0.4.18

7 years ago

0.4.17

7 years ago

0.4.16

7 years ago

0.4.15

7 years ago

0.4.14

7 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.19

7 years ago

0.3.18

7 years ago

0.3.17

7 years ago

0.3.16

7 years ago

0.3.15

7 years ago

0.3.14

7 years ago

0.3.13

7 years ago

0.3.12

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.29

7 years ago

0.0.28

7 years ago

0.0.27

7 years ago

0.0.26

7 years ago

0.0.25

7 years ago

0.0.24

7 years ago

0.0.23

7 years ago

0.0.22

7 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago