Core

Core
Static Members
converge
forEach
i
map
mapMatrix
pipe
read
reduce
same
write

Array

bottom

Get all but first element from array

bottom
Parameters
params (...any)
limit (integer) How many elements from the bottom
source (Array) The source
Returns
mixed:
Example
bottom([1, 2, 3])
// => [1, 2]

bottom([1]), bottom([])
// => []

bottom(2, [2, 3])
// => [2, 3]

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

count

Count the number of elements that satisfies a function

count
Parameters
fn (Function) Match function
source (Array<Object>) Source array
Returns
number:
Example
const scores = [{
 name   : "Bob",
 score  : 1,
 subject: "Math"
}, {
 name   : "Alice",
 score  : 10,
 subject: "Math"
}, {
 name   : "Hatter",
 score  : 10,
 subject: "Math"
}]

count(element => element.score === 10)(scores)
// => 2

countWith

Count elements that match a predicate

countWith
Parameters
subset (Function) Match function
source (Array<Object>) Source array
Returns
number:
Example
const scores = [{
 name   : "Bob",
 score  : 1,
 subject: "Math"
}, {
 name   : "Alice",
 score  : 10,
 subject: "Math"
}, {
 name   : "Hatter",
 score  : 10,
 subject: "Math"
}]

countWith({ score: gt(5) })(scores)
// => 2

distinct

Remove repeating values

distinct
Parameters
source (Array) Source input array
Returns
Array:
Example
distinct([1, 1, 2])
// => [1, 2]

filter

Filter elements matching a predicate

filter
Parameters
fn (Function) Predicate functions
Returns
Array:

filterWith

Filter elements matching an object

filterWith
Parameters
subset (Object) The function
Returns
Array:

find

Find the first element that matches a predicate

find
Parameters
fn ((Fn | Array<Fn>)) Match function applied to each element
notFoundDefault (Any) Return if no item found
source (Array) Source array to iterate over
Returns
Any: First element found or undefined
Related
findWith
Example
const comments = [{id: 1, body: ""}, {id: 2, body: "dolor"}]

find(item => item.body === "dolor")(comments)
// => {id: 2, body: "dolor"}

find([get("body"), equals("dolor")], null, comments)
// => {id: 2, boby: "dolor" }

findWith

Find the first element that matches an object

findWith
Parameters
subset (Object) Match object
notFoundDefault (Any) Return if no item found
source (Array) Source array to iterate over
Returns
Any: First element found or undefined
Related
find isMatch
Example
const comments = [{id: 1, body: ""}, {id: 2, body: "dolor"}]

findWith({id: 2})(comments)
// => {id: 2, body: "dolor"}

find({id: "404"}, {default: "value"}, comments)
// => {default: "value"}

first

Get left most element of array

first
Parameters
source (Array) The source
Returns
mixed:
Example
first([1, 2, 3])
// => 1

first([])
// => undefined

flatten

Recursively concat all arrays intro a single array

flatten
Parameters
source ((Array | Object)) Array or Object to flatten
Returns
Array: 1 level deep array
Example
flatten([1, [2], [3, [4]]])
// => [1, 2, 3, 4]

flatten({test: {a: 1, b: {c: 2}}})
// => {
 test__a: 1,
 test__b__c: 2
}

last

Get right most element of array

last
Parameters
source (Array) The source
Returns
mixed:
Example
last([1, 2, 3])
// => 3
last([])
// => undefined

partition

Split a list based on a predicate function

partition
Parameters
fn (Function) A predicate function.
Returns
[[], []]: A function taking a A[] and returning a two-tuple of A[] s. The first element of the tuple consists of elements for which the predicate returned true , the second of elements for which it returned false .
Example
partition(x => x % 2 === 0)([1, 2, 3, 4, 5])
// => [[2, 4], [1, 3, 5]]

partitionWith

Split a list based on object matching

partitionWith
Parameters
subset (Object) A predicate function.
Returns
[[], []]: A function taking a A[] and returning a two-tuple of A[] s. The first element of the tuple consists of elements for which the predicate returned true , the second of elements for which it returned false .
Example
partitionWith({comments: is}, [{id: 1}, {id: 2, comments: []}])
// => [[{id: 1}], [{id: 2, comments: []}]]

pluck

Returns a new list by extracting the same named property off all objects in the source list

pluck
Parameters
field (string) Field name to extract values from
source (Array<Object>) Array of objects
Returns
number:
Example
pluck("position")([{id: 1, position: 3}, {id:2, position: -1}])
// => [3, -1]

remove

Remove element(s) from array by value or by predicate

remove
Parameters
fn ((Function | mixed)) Value to remove or predicate to match
source (Array) Source array
Returns
Array:
Example
remove(3)([1, 2, 3])
// => [1, 2]

remove(_ => _ === 3)([1, 2, 3])
// => [1, 2]

removeWith

Remove element(s) by matching object

removeWith
Parameters
subset (Object) Match object
source (Array) Source array
Returns
Array:
Example
remove(3)([1, 2, 3])
// => [1, 2]

remove(_ => _ === 3)([1, 2, 3])
// => [1, 2]

top

Get all but last element from array

top
Parameters
params (...any)
limit (integer) How many elements from the top
source (Array) The source
Returns
mixed:
Example
top([1, 2, 3])
// => [1, 2]

top([1]), top([])
// => []

top(2, [2, 3])
// => [2, 3]

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

Boolean

all

Test if all elements of array satisfy a function

all
Parameters
fn ((Function | Array<Function>)) Test function called on each elements
source (Array) Source array to iterate over
Returns
Boolean: True if all elements pass, otherwise false
Related
allWith any anyWith
Example
all(isNumber)([1, 2, 3])
// => true

all(is, [1, "asd", null])
// => false

allWith

Test if all elements in array match object

allWith
Parameters
subset (Object) Match object
source (Array) Source array to iterate over
Returns
Boolean: True if all elements match, otherwise false
Related
all any anyWith isMatch
Example
allWith(isNumber)([1, 2, 3])
// => true

allWith(is, [1, "asd", null])
// => false

any

Test if at least one element in array matches predicate

any
Parameters
fn ((Fn | Array<Fn>)) Predicate function
source (Array) Source array to iterate over
Returns
Boolean: True if at least one element passes, otherwise false
Related
anyWith all allWith
Example
any(isNumber)([1, "string", NaN])
// => true

any([get("id"), is], [{title: ""}, {}])
// => false

anyWith

Test if at least one element in array matches object

anyWith
Parameters
subset (Object) Match object
source (Array) Source array to iterate over
Returns
Boolean: True if at least one element pass, otherwise false
Related
any all allWith isMatch
Example
anyWith({ comments: is })([{id: 1}, {id: 2, comments: []}])
// => true

anyWith({ tags: is })([{id: 1}, {id: 2, comments: []}])
// => false

is

Test if something is not null or undefined

is
Parameters
source (any) Source variable
Returns
boolean:
Example
is(null)      // => false
is(0)         // => true
is(undefined) // => false
is("")        // => true
is(false)     // => true
is(NaN)       // => false

isBetween

Check if value is inside open or closed interval

isBetween
Parameters
left (number) Left limit
right (number) Right limit
arg3 (Object = {}) Props
Name Description
arg3.closed boolean (default false) If intervals is closed or not
Returns
boolean:
Example
between(2, 5)(5)
// => false

between(2, 5, {closed: true})(5)
// => true

isEmpty

Check if variable is considered empty

isEmpty
Parameters
source (Any) Source input
Returns
boolean: True if empty, False otherwise
Example
isEmpty({})               // true
isEmpty(1)                // false
isEmpty(false)            // false
isEmpty("")               // true
isEmpty(null)             // true
isEmpty(undefined)        // true
isEmpty([])               // true
isEmpty(NaN)              // true
isEmpty(/[A-z]/)          // false
isEmpty(new Date())       // false
isEmpty(() => {})         // false
isEmpty(Promise.resolve() // false

isEqual

Check if a is equal to b (strict equality)

isEqual
Parameters
one (mixed) First value
two (mixed) Second value
Returns
boolean:
Example
equal(2)(2)
// => true

equal("2")(2)
// => false

equal(NaN)(NaN)
// => true

equal([1])([1])
// => false

isMatch

Determines if one object's properties are equal to another

isMatch
Parameters
subset (Object) Set of properties that should match
source (Object) Object matching against
Returns
boolean: True if all "subset" properties are of equal (shallow compare) value to properties in "source" object, otherwise false
Example
isMatch({
 id: 2,
 parentId: null,
})({
 id: 2,
 parentId: null
 name: "John",
})
// true

isMatch({
 "!parentId": null,
 "name": "John",
})({
 id: 2,
 parentId: null,
 name: "John",
})
// false

when

Functional if-then-else

when
Parameters
ifFn (Function) Condition
thenFn (Function) Then function
elseFn (Function) Else function, if not specified will return source
Returns
mixed:
Example
when(isEven, increment, decrement)(5)
// => 6

when(isOdd, increment)(6)
// => 6

Object

keys

Get list with names of all own properties

keys
Parameters
source ((Array | Object)) Array or Object to extract keys from
Returns
Array<string>: List of property names
Example
keys(["lorem", "ipsum"])
// => ["0", "1"]

keys({ foo: "bar", lorem: "ipsum"})
// => ["foo", "lorem"]

keys("foo"), keys(12), keys(null), etc
// => []

merge

Combine from left to right, 2 or more objects into a new single one. Properties will be shallow copied. Those with the same name will be overwriten by right most object.

merge
Parameters
sources (...any)
source (Array<Object>) Array of objects
Returns
Object:
Example
merge({a: "lorem"}, {b: "ipsum", c: 41}, {c: 42, b: undefined})
// => { a: "lorem", b: "ipsum", c: 42 }

pick

Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.

pick
Parameters
keys (Array<string>) The properties to be filtered out
source (Object) The source object
Returns
Object:
Example
pick(["id", "name"])({id: 2, name: "lorem", description: "lorem ipsum"})
// => {id: 2, name: lorem}

zipToObj

Create an object from two arrays, one containing keys, the other values. Bost arrays will be trimmed to the smallest length.

zipToObj
Parameters
keys (Array) Array with keys
values (Array) Array with values
Returns
Object:
Example
zipToObj( [ a, b ] )( [ 1, 2 ] ) // => { a: 1, b: 2 }
zipToObj( [ a ] )( [ 1, 2 ] ) // => { a: 1 }

isDeepEqual

Determine if two variables are structurally equal

isDeepEqual
Parameters
a (Any) Source input
b (Any) Other source input
Returns
Boolean: True if inputs are structurally equal, false otherwise
Related
clone
Example
deepEqual(
  {b: 3, a: 2},
  {a: 2, b: 3}
)
// => true

deepEqual(
  {a :[1, 2]}
)(
  {a: [2, 1]}
)
// => false

elapsedTime

Calculate elapsed time between to dates. In days, hours, minutes and seconds

elapsedTime
Parameters
startDate (Data) Start date
endDate (Data) End date
Returns
Object:
Example
elapsedTime(
  new Date("June 1, 2018 00:00:00")
)(
  new Date("June 1, 2018 03:24:00")
)
// => { days: 0, hours: 3, minutes: 24, seconds: 0 }

groupBy

Group an array of objects by field.

groupBy
Parameters
field (string) The field to index by. Value will be cast to string before indexing.
source (Array) Input array
Returns
Array<Array>:
Example
groupBy("user_id")([
  {id: 1, user_id: 2},
  {id: 2, user_id: 3},
  {id: 3, user_id: 2},
  {id: 4, user_id: null},
] )
// => [
//   [{id: 1, user_id: 2}, {id: 3, user_id: 2}],
//   [{id: 2, user_id: 3}],
//   [{id: 4, user_id: null}],
// ]

indexBy

Index an array of objects by field. Only truthy fields will be indexed.

indexBy
Parameters
field (string) The field to index by
array (Array) Input
Returns
Object:
Example
indexBy("id")([
  {id: 1, user_id: 2},
  {id: 2, user_id: 3},
])
// => {
//   1: {id: 1, user_id: 2},
//   2: {id: 2, user_id: 3},
// }

byArray

Count the number of occurances of each element

byArray
Parameters
source (Array) Source input
Returns
Object:

byKey

Count the number of occurances of each object by a field

byKey
Parameters
field (string) The field
Returns
Object:

hist

Determine the count of all field's distinct values in a list of objects (aka histogram)

hist
Parameters
field (string) Field name to count
source (Array<Object>) Array of objects
Returns
Object:
Example
const scores = [{
 name   : "Bob",
 score  : 1,
 subject: "Math"
}, {
 name   : "Alice",
 score  : 10,
 subject: "Math"
}, {
 name   : "Hatter",
 score  : 10,
 subject: "Math"
}]

hist( "score" )( scores )
// => { "1": 1, "10": 2 }

protoChain

Return an array of constructor function names based on the prototype chain

protoChain
Parameters
source (Object) Source input
acc (Array<string> = []) Accumulator array
Returns
Array<string>:

renameFile

Rename a file

renameFile
Parameters
newName (string) New file name
filePath (string) Absolute file path
Returns
string:

tryCatch

Replicate try/catch using a tryer and catcher function

tryCatch
Parameters
tryer (Function) Try to do something with source input
catcher (Function) Run if tryer throws exception
Returns
any:
Example
tryCatch(inc)(10)
// => 11

tryCatch(
  () => { throw new Error("Tryer error") },
  (error, source) => inc(source)
)(10)
// => 11

type

From ramda: Gives a single-word string description of the (native) type of a value, returning such answers as "Object", "Number", "Array", or "Null".

Does not attempt to distinguish user Object types any further, reporting them all as "Object".

type
Parameters
input (mixed) Something to check type on
Returns
string:
Example
type({})                // "Object"
type(1)                 // "Number"
type(false)             // "Boolean"
type("s")               // "String"
type(null)              // "Null"
type(undefined)         // "Undefined"
type([])                // "Array"
type(/[A-z]/)           // "RegExp"
type(new Date())        // "Date"
type(() => {})          // "Function"
type(Promise.resolve()) // "Promise"

throttle

Call a function only if it hasn't been called in the last timeWindow ms.

throttle
Parameters
fn (function) Function to be ran
timeWindow (integer = {}) Time between each fn call
Name Description
timeWindow.timeWindow any (default 50)
timeWindow.bind any (default null)
timeWindow.hasLastCall any (default false)
Returns
function: Either return fn if you've passed the timeWindow or return a timer that will run the fn in timeWindow ms

debounce

Call function after wait milliseconds have elapsed

debounce
Parameters
fn (Function) Source function
props (Object?) Properties
Name Description
props.wait number (default 50) Time in milliseconds to wait without calling until invoke
props.bind Object (default null) this provided for the call to fn
Returns
Function: Wrapper function that calls fn after wait passed without calling
Example
// constructor
this.debouncedAutocomplete = debounce(autocompleteFromAPI, {
  wait: 100,
  bind: this
})

// render
<input onChange={this.debouncedAutocomplete} ... />

pipeP

Performs left-to-right function composition. The leftmost function may have any arity, the remaining functions must be unary.

Functions can return a Promise, behaving like Promise.sequence.

pipeP
Parameters
first (Function) First function in chain
rest (Array<Function>) Remaining bottom functions
source (Array) First function arguments
Returns
Promise<any>:
Related
pipe
Example
const inc = input => input + 1
const incP = input => Promise.resolve(input + 1)

pipeP(incP, inc)(2).then(result => {
  // => result = 4
})

clone

Creates a new instance of the object with same properties than original. Will not inherit prototype, only own enumerable properties.

clone
Parameters
source (Any) Source input value
Returns
Any: New instance of source
Related
deepEqual
Example
let x = {a: [1]}

clone(x)
// => {a: [1]}

close(x) === x
// => false

repeat

Return an array of fixed size containing a specified value or function result

repeat
Parameters
fn ((Function | mixed)) Function or value to repeat
count (number) Number of times
Returns
Array:
Example
repeat(2)(3)
// => [2, 2, 2]

repeat(index=>index+1)(3)
// => [1, 2, 3]

curry

Partially apply a function

curry
Parameters
fn (Function) The function to apply
args (any) The arguments to apply, in order
Returns
(Function | mixed): If the number of arguments provided is sufficient to call the function, call the function and return the result. Otherwise, return a new function which takes additional parameters, returning the result of calling curry on the function with the provided parameters.
Example
const sum = (a, b) => a + b

curry(sum)(1)(2) = 3

cases

Functional case statement.

cases
Parameters
conditions (Array<[ifFn, thenFn]>) List of 2-tuples of functions (if, then)
otherwise (Function) Function to call if no condition matches Defaults to identity.
source (any) Value to check
Returns
any: The result of calling the first matching then function or the otherwise function on the input.
Related
when
Example
cases([
 [x === 0, x => x * 2],
 [x === 1, x => x],
], x => x + 1)(2)
// => 3

page

Get a subset array using offset and limit

page
Parameters
$0 (Object = {})
Name Description
$0.offset any (default 0)
$0.limit any (default 10)
offset (number) Start position
limit (number) How many items
source (Array) Input array
Returns
Array:
Example
page({
  offset: 1,
  limit: 5
})([1, 2, 3, 4, 5, 6, 7, 8])
// => [2, 3, 4, 5, 6]

push

Add element at end of array

push
Parameters
elements (...any)
element (mixed) Element to be added
input (Array) Array to add to
Returns
Array:
Example
push(2)([1]) // => [1, 2]
push(2, 4)([1]) // => [1, 2, 4]

maxByValue

Find max value using language operator

maxByValue
Parameters
source (Array) Source input
Returns
mixed:

maxByFunction

Find max value using function to transform element into numeric

maxByFunction
Parameters
fn (Function) Transform function
source (Array) Source input
Returns
mixed:

max

Find the maximum value in a source array

max
Parameters
arg1 ((Array | Function)) Custom transform function or source array
source (Array<number>) Array of numbers
Returns
number:
Example
max([-1, 1, 10, 3])
// => 10

const fn = element => ( new Date( element.time ) )
const source = [
  { time: "2018-05-15T11:20:07.754110Z" },
  { time: "2018-06-11T09:01:54.337344Z" },
  { time: "2018-06-08T08:26:12.711071Z" },
]
max(fn)(source)
// => {time: "2018-06-11T09:01:54.337344Z"}

minByValue

Find min value using language operator

minByValue
Parameters
source (Array) Source input
Returns
mixed:

minByFunction

Find min value using function to transform element into numeric

minByFunction
Parameters
fn (Function) Transform function
source (Array) Source input
Returns
mixed:

min

Find the minimum value in a source array

min
Parameters
arg1 ((Array | Function)) Custom transform function or source array
source (Array<number>) Array of numbers
Returns
number:
Example
min([-1, 1, 10, 3])
// => -1

const fn = element => ( new Date( element.time ) )
const source = [
  { time: "2018-05-15T11:20:07.754110Z" },
  { time: "2018-06-11T09:01:54.337344Z" },
  { time: "2018-06-08T08:26:12.711071Z" },
]
min(fn)(source)
// => {time: "2018-05-15T11:20:07.754110Z"}

drop

{ lambda_description }

drop
Parameters
count (number) The count
Returns
Array: { description_of_the_return_value }

dropLast

Remove elements from end of array

dropLast
Parameters
count ((number | Array)) Number of element to remove
source (Array) Source array
Returns
Array:

concat

Merge two or more arrays into one

concat
Parameters
source1 (Array) First array
source2 (Array) Second array
Returns
Array:
Example
concat([1])([4, 5])
// => [1, 4, 5]

toggle

Add element if not exists, remove otherwise

toggle
Parameters
element (mixed) Toggable value
Returns
Array:
Example
toggle(1)([1, 2])
// => [2]

toggle(1)([2])
// => [1, 2]

replaceString

Replace substring in string

replaceString
Parameters
oldString (string) The old string
newString (string) The new string
Returns
string:

replaceArray

Replace element in array (shallow equal)

replaceArray
Parameters
oldElm (mixed) The old elm
newElm (mixed) The new elm
Returns
Array:

replace

Replace substring if source is string, replace element (shallow equal) if source is Array

replace
Parameters
oldElm ((string | mixed)) To be cloned
newElm ((string | mixed)) Copy of this object.
source ((string | Array)) Source array
Returns
(string | Array):

replaceWith

Replace object element in array using filter object

replaceWith
Parameters
filter (Object) Filter object to match against each element
newValue (Object) Object to replace matching elements
source (Array<Object>) Source array
Returns
Array:
Example
replaceWith(
 {id: 2},
 {id: 2, title: "boss", isBoss: true}
 )([
   {id: 2, title:"minion"}
   {id: 3, title:"minion"}
 ])
// => [
//   {id: 2, title:"boss", isBoss: true},
//   {id: 3, title:"minion"}
// ]

replaceWith({ id: 2 }, item => ({
  ...item,
  content: ["new", "updated", "field"],
}))([
  { id: 1, name: "foo", content: [] },
  { id: 2, name: "bar", content: [] },
])
// [
//   { id: 1, name: "foo", content: [] },
//   { id: 2, name: "bar", content: ["new", "updated", "field"] },
// ],

sort

Sort array using custom function

sort
Parameters
fn (Function) Sort function
source (Array) Array
Returns
Array:
Example
sort((a,b) => a.id-b.id)([{id:2}, {id: 1}])
// => [{id:1}, {id: 2}]

sortWith

Sort an array of objects by a custom field

sortWith
Parameters
field (string) Sort field name
direction (string = "asc") Sort direction
source (Array) Input array
Returns
Array:
Example
sortWith( "position" )( [
  { id: 1, position: 3 },
  { id: 2, position: 2 },
  { id: 3 },
  { id: 4, position: 5 },
  { id: 5, position: null },
] )
// [
//  { id: 2, position: 2 },
//  { id: 1, position: 3 },
//  { id: 4, position: 5 },
//  { id: 5, position: null },
//  { id: 3 },
//]

findIndex

Find the position the first element that satisfies a predicate function

findIndex
Parameters
fn ((Fn | Array<Fn>)) Predicate applied to each element
source (Array<Object>) Source array to iterate over
Returns
Number: Position of found element or -1 if not found
Example
const comments = [{id: 1, body: ""}, {id: 2, body: "dolor"}]

findIndex(item => item.body === "lorem")(comments)
// => -1

findIndex([get("body"), equals("dolor")], null, comments)
// => 1

dec

Substract one

dec
Parameters
source (number) Source input
Returns
number:
Example
dec(2)
// => 1

inc

Add one

inc
Parameters
source (number) Source input
Returns
number:
Example
inc(2)
// => 3

gt

Grater compare.

Since this will mostly be used in pipe, the first param in the curry chain is the second operand.

gt
Parameters
second (number) Second number
first (number) First number
Returns
boolean:
Example
gt(10)(4)
// => false
gt(10)(14)
// => true

lt

Less compare.

Since this will mostly be used in pipe, the first param in the curry chain is the second operand.

lt
Parameters
second (number) Second number
first (number) First number
Returns
boolean:
Example
lt(10)(4)
// => true
lt(10)(14)
// => false

random

Generate random number between interval

random
Parameters
arg1 (Object) Props
Name Description
arg1.min number The minimum
arg1.max number The maximum
Returns
integer:

split

Splits a String object into an array of strings by separating the string into substrings, using a specified separator string to determine where to make each split.

split
Parameters
separator ((string | RegExp)) Points where each split should occur
source (string) Source string
Returns
Array:
Example
split( "," )( "lorem,ipsum" )
// [ "lorem", "ipsum" ]

startsWith

Test if string starts with substring

startsWith
Parameters
search (string) Search string
source (string) Source string
Returns
boolean:
Example
startsWith("lorem")("lorem ipsum")
// => true

endsWith

Test if string ends with substring

endsWith
Parameters
search (string) Search string
source (string) Source string
Returns
boolean:
Example
endWith("ipsum")("lorem ipsum")
// => true

toLower

Convert string to lower case

toLower
Parameters
source (string) Source string
Returns
string:
Example
toLower("Lorem Ipsum")
// "lorem ipsum"

trim

Remove char from beginning and end of string

trim
Parameters
char (string = " ") Character to be removed
source (string) Source string
Returns
string:
Example
trim()(" lorem  ")
// => "lorem"
trim("-")("-- lorem  --")
// => " lorem  "

contains

Test if string contains substring

contains
Parameters
search (string) Search string
source (string) Source string
Returns
boolean:
Example
contains("ipsum")("lorem ipsum")
// => true

join

Join all elements of an array into a string

join
Parameters
separator (String) Separator between each adjacent elements
rest (...any)
source ([]) Source array
Returns
String:
Example
join(",")(["lorem", "ipsum"])
// => "lorem,ipsum"

escapeRegExp

Make safe for RegExp'ing

escapeRegExp
Parameters
source (string) Source string
Returns
string:
Example
{ example }

escapeRegExp( "lorem. ipsum [dolor]" )
// => "lorem \\. ipsum \\[dolor\\]"