StartToolsJSPure Utilities

Pure Utilities

Library with helper methods.

Installation

npm install pure-utilities
bash

array


average(array)

Returns the average of the array elements.

average(100, 200)
<= 150
js

comma(array, number)

Returns a string created by joining array elements with comma and optional spaces.

comma([1, 2, 3], 2)
<= "1, 2, 3"
js

compact(array, strict)

Returns an array with truthy values.

compact([0, 1, false, null, 2, "", 3])
<= [1,2,3]
js
compact([0, 1, null, 2, undefined, 3], false)
<= [0,1,2,3]
js

difference(array, arrays)

Returns an array containing elements that do not occur in other arrays.

difference([1, 2, 3, 4, 5, 100], [100, 2, 3, 10, 31])
<= [1,4,5]
js

drop(array, digit)

Removes elements of the array.

drop([1, 2, 3], 2)
<= [3]
js

duplicates(array)

Returns an array containing repeated elements.

duplicates([1, 1, 2, 3, 5, 5])
<= [1,5]
js

eigth(array)

Returns the eigth element of the array.

eigth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 8
js

fifth(array)

Returns the fifth element of the array.

fifth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 5
js

first(array)

Returns the first element of the array.

first([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 1
js

fourth(array)

Returns the fourth element of the array.

fourth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 4
js

Returns the first element of the array.

head([1, 2, 3, 4, 5, 6])
<= 1
js

identifier(array)

Returns a new unique identifier based on passed in identifiers.

identifier(["a"])
<= "b"
js

intersection(arrays)

Returns an array containing elements common to all arrays that have been passed to the function.

intersection([1, 2, 3, 4, 5, 100], [100, 2, 3, 10, 31])
<= [2,3,100]
js

last(array)

Returns the last element of the array.

last([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 10
js

median(array)

Returns the median of the array elements.

median([6, 4, 2, 4, 4])
<= 4
js

ninth(array)

Returns the ninth element of the array.

ninth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 9
js

nth(array, position)

Returns the element located at the passed position. When position is negative it searches from the end of the array.

nth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3)
<= 3
js

partition(array, predicate)

Returns an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsey for. The predicate has one argument.

partition([{ user: "barney", active: false }, { user: "fred", active: true }, { user: "pebbles", active: false }], item => item.active)
<= [[{"user":"fred","active":true}],[{"user":"barney","active":false},{"user":"pebbles","active":false}]]
js

pluck(array)

Returns a list of property values from an array of objects.

pluck([{ foo: "bar"}, { name: "baz"}], "name")
<= ["baz"]
js

range(number, number)

Returns an array of numbers within the range.

range(1, 5)
<= [1,2,3,4,5]
js

rotate(array, digit)

Rotates the elements on the array. When second parameter is negative, shifting starts from the end of the array.

rotate([1, 2, 3], 2)
<= [3,1,2]
js

sample()

Returns random element of the array.

sample([[1, 2, 3]])
<= 1
js

second(array)

Returns the second element of the array.

second([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 2
js

seventh(array)

Returns the seventh element of the array.

seventh([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 7
js

sixth(array)

Returns the sixth element of the array.

sixth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 6
js

slice(array, start, end)

Extracts a fragment of the array.

slice([1, 2, 3, 4,5, 6], 3, 5)
<= [4,5]
js

sum(array)

Returns the sum of the array elements.

sum([3, 10, 2])
<= 15
js

symdifference(arrays)

Returns an array of elements that are not part of intersection.

symdifference([1, 3, 4, 6, 7, 9], [3, 5, 6, 7, 8, 9])
<= [1,4,5,8]
js

take(array, digit)

Takes elements from the array based on the second parameter, starting from the beginning of the array.

take([1, 2, 3, 4, 5, 6], 2)
<= [1,2]
js

tenth(array)

Returns the tenth element of the array.

tenth([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 10
js

third(array)

Returns the third element of the array.

third([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
<= 3
js

union(arrays)

Returns an array of unique values.

union([2], [1, 2])
<= [2,1]
js

unique(array, iteratee)

Returns an array with unique elements.

unique([1, 1, 2, 10, 2, 33])
<= [1,2,10,33]
js

collection


append(collection, indefinite, amount, of, arguments)

Adds arguments at the end of the collecion.

append("foo", "bar")
<= "foobar"
js
append([1, 2, 3], 4, 5, 6)
<= [1,2,3,4,5,6]
js

flatten(collection)

Flattens n-dimensional array or n-depth object to a single depth array or object.

flatten([1, [2], [ [3, [ 4, [5] ] ] ] ])
<= [1,2,3,4,5]
js
flatten({"titles":{"index":"Buxus - Plants, seedlings, producer"}})
<= {"titles.index":"Buxus - Plants, seedlings, producer"}
js

occurences(collection, string)

Returns the count of occurences of the string in the collection or string.

occurences(["foo", "foo", "bar"], "foo")
<= 2
js
occurences("foo foo bar", "foo")
<= 2
js

prepend(collection, indefinite, amount, of, arguments)

Adds arguments at the beginning of the collection.

prepend("foo", "bar")
<= "barfoo"
js
prepend([1, 2, 3], 4, 5, 6)
<= [4,5,6,1,2,3]
js

reverse(collection)

Reverses the elements of the collection.

reverse([1, 2, 3, 4])
<= [4,3,2,1]
js
reverse("foo")
<= "oof"
js

size(collection)

Returns the size of the collection.

size(1, 2, 3, 4, 5)
<= 5
js
size({ a: 1, b: 2 })
<= 2
js

unflatten(collection)

Converts properties of the object, which contain in the name dots(.), to multi-depth object.

unflatten({"errors.404.title":"Page not found"})
<= {"errors":{"404":{"title":"Page not found"}}}
js

date


day(date)

Returns the day of the month (from 1 to 31) of the passed date.

day(new Date(2018, 4, 28)
<= 28
js

format(date, format)

Formats the date. First argument can be a Date object or a date string. By default date is parsed to the YYYY-MM-DD format.

format(new Date("2013/06/13"))
<= "13-06-2013"
js
format(new Date(2018, 4, 23), "MM")
<= "05"
js
format(new Date(2018, 4, 23), "DD/MM/YYYY")
<= "23/05/2018"
js
format(new Date("2013/06/09"))
<= "09-06-2013"
js

hours(date)

Returns the hours of the day (from 0 to 23) of the passed date.

hours(new Date(2018, 4, 28, 10))
<= 10
js

isostring(value)

Returns a string in simplified extended ISO format.

isostring("1460303444338")
<= "2016-04-10T15:50:44.338Z"
js

minutes(date)

Returns the minutes of the hour (from 0 to 59) of the passed date.

minutes(new Date(2018, 4, 28, 10, 11))
<= 11
js

month(date)

Returns the month (from 0 to 11) of the passed date.

month(new Date(2018, 4, 28))
<= 4
js

prettydate(date, localization)

Returns a string, that contains: the name of weekday, day of the month (from 1 to 31), name of the month, and year (four digits for dates between year 1000 and 9999). Localization can be "en-En" or "pl-Pl", in other case function throws error. By default localization equals "en-En".

prettydate(new Date(2043, 9, 25))
<= "Sunday, 25th of October 2043"
js
prettydate(new Date(2018, 2, 21)
<= "Wednesday, 21st of March 2018"
js
prettydate(new Date(2018, 2, 21)
<= "środa, 21 marca 2018"
js

seconds(date)

Returns the seconds of the minute (from 0 to 59) of the passed date.

seconds(new Date(2018, 4, 28, 10, 11, 12))
<= 12
js

timestamp(date, pattern)

Returns a formatted date, based on the passed pattern.

timestamp(new Date(2018, 4, 28), "YYYY")
<= "2018"
js
timestamp(new Date(2018, 4, 28), "YYYY/MM")
<= "2018/05"
js
timestamp(new Date(2018, 4, 28), "YYYY/MM/DD")
<= "2018/05/28"
js

weekday(date)

Returns the day of the week (from 0 to 6) of the specified date.

weekday(new Date(2017, 1, 11))
<= 6
js

year(date)

Returns the year of the passed date.

year(new Date (2018, 4, 2))
<= 2018
js

json


prettify(value, indent)

Converts a value to JSON string. When the passed value is not a string, returns the value.

prettify({"foo":"bar"})
<= "{\n \"foo\": \"bar\"\n}"
js

math


abs(number)

Returns the absolute value of the number.

abs(-1)
<= 1
js

acos(number)

Returns the arccosine of the number, in radians.

acos(0.5)
<= 1.0471975511965979
js

acosh(number)

Returns the hyperbolic arccosine of the number, in radians.

acosh(2)
<= 1.3169578969248166
js

add(number1, number2)

Adds two parameters.

add(10, 5)
<= 15
js

asin(number)

Returns the arcsine of the number, in radians.

asin(1)
<= 1.5707963267948966
js

asinh(number)

Returns the hyperbolic arcsine of the number.

asinh(1)
<= 0.881373587019543
js

atan(number)

Returns the hyperbolic arctangent of the number.

atan(1)
<= 0.7853981633974483
js

atan2(number1, number2)

Returns the arctangent of the quotient of its arguments.

atan2(5, 5)
<= 0.7853981633974483
js

atanh(number)

Returns the hyperbolic arctangent of the number.

atanh(0.5)
<= 0.5493061443340548
js

cbrt(number)

Returns the cubic root of the number.

cbrt(1)
<= 1
js

ceil(number)

Returns the number, rounded upwards to the nearest integer.

ceil(100.2)
<= 101
js

clamp(number, min, max)

Returns the highest possible value from range min to max of the number.

clamp(25, 20, 30)
<= 25
js
clamp(30, 20, 30)
<= 30
js

cos(number)

Returns the cosine of the number (number is in radians).

cos(1)
<= 0.5403023058681398
js

cosh(number)

Returns the hyperbolic cosine of the number.

cosh(0)
<= 1
js

cube(number)

Returns the third power of the number.

cube(-4)
<= -64
js

decrement(number)

Decrements the number.

decrement(1)
<= 0
js

degrees(number, precision)

Converts radians to degrees and rounds received result by default precision equals 2.

degrees(5)
<= 286.48
js

distance(a, b)

Calculates the distance between points a and b in space.

distance([1,2,3], [1,2,4])
<= 1
js

divide(number1, number2)

Divides two parameters.

divide(10, 5)
<= 2
js

exp(number)

Returns the value of E^number, where E is Euler's number.

exp(0)
<= 1
js

factorial(number)

Returns factorial of the number.

factorial(5)
<= 120
js

feet(number, precision, decimal)

Converts inches to feets. By default precision equals 2. When decimal flag is set to false, returns result with prim (′) symbol.

feet(1)
<= 0.08
js

fixed(number, digit)

Formats the number using fixed-point notation. By default digit equals 0.

fixed(25.32)
<= "25"
js

float(number)

Parses the number to the float.

float("4.25")
<= 4.25
js

floor(number)

Returns the number, rounded downwards to the nearest integer.

floor(300.91)
<= 300
js

inches(number, precision, decimal)

Converts feets to inches. By default precision equals 2. When decimal flag is set to false, returns result with bis (″) symbol.

inches(1)
<= 12
js

increment(number)

Increments the number.

increment(1)
<= 2
js

int(number)

Parses the number to the integer.

int("4.25")
<= 4
js

kmeans(k, data, maxIterations)

Computes centroids of k clusters, which are the average values of those points.

kmeans(3, [[1,2],[2,3],[2,5],[1,6],[4,6],[3,5],[2,4],[4,3],[5,2],[6,9],[4,4],[3,3],[8,6],[7,5],[9,6],[9,7],[8,8],[7,9],[11,3],[11,2],[9,9],[7,8],[6,8],[12,2],[14,3],[15,1],[15,4],[14,2],[13,1],[16,4]])
<= {"centroids":[[11.75,2],[14.8,2.8],[5.095238095238095,5.619047619047619]],"iteration":2,"complete":true}
js

log(number)

Returns the natural logarithm (base E) of the number.

log(2, 8)
<= 0.6931471805599453
js

max(numbers)

Returns the number with the highest value.

max([2,5,1])
<= 5
js

mean(array)

Computes the mean of the values in array.

mean([1,2,3,4])
<= 2.5
js

min(numbers)

Returns the number with the lowest value.

min([2,5,1])
<= 1
js

modulo(number1, number2)

Divides two parameters and returns the remainder.

modulo(7, 2)
<= 1
js

monetize(number, options)

Formats the number to currency format options is an object that accepts the following parameters: - digits: Number of digits after comma. By default equals 2. - separator: Separator separating the decimal part. By default equals ','. - symbol: The symbol of currency. By default equals 'zł'. - ending: Boolean flag, that specifies position of currency symbol. By default set to true. - space: Boolean flag, that specifies if space should exist before currency symbol. By default set to true. - hyphen: The symbol between groups of integer part. By default set to empty space. - size: The number of integers, that should be grouped. By default set to 3.

monetize(100)
<= "100,00 zł"
js
monetize(100.5, {"symbol":"€","separator":"."})
<= "100.50 €"
js

multiply(number1, number2)

Multiplies two parametrs.

multiply(10, 5)
<= 50
js

percentage(number)

Converts the number to percentage format.

percentage(0.25)
<= "25%"
js

pow(number1, number2)

Returns the value of first parameter to the power of the second parameter.

pow(2, 5)
<= 32
js

radians(number, precision)

Converts degrees to radians and rounds received result by default precision equals 2.

radians(12)
<= 0.21
js

random()

Returns a floating-point, pseudo-random number in the range 0–1.

random()
<= 0.75800265935387
js

round(number)

Rounds the number, to the nearest integer.

round(20.49)
<= 20
js

sin(number)

Returns the sine of the number.

sin(2)
<= 0.9092974268256817
js

sinh(number)

Returns the hyperbolic sine of the number.

sinh(1)
<= 1.1752011936438014
js

sqrt(number)

Returns the square root of the number.

sqrt(4)
<= 2
js

square(number)

Returns square of the number.

square(5)
<= 25
js

subtract(number1, number2)

Subtracts two parameters.

subtract(10, 5)
<= 5
js

tan(number)

Returns the tangent of the number.

tan(1)
<= 1.5574077246549023
js

tanh(number)

Returns the hyperbolic tangent of the number.

tanh(-1)
<= -0.7615941559557649
js

trunc(number)

Returns the integer part of the number.

trunc(42.84)
<= 42
js

object


camelcase(object)

Converts object keys to camelCase.

camelcase({"created_at":"2000-01-01"})
<= {"createdAt":"2000-01-01"}
js

clone(object)

Creates shallow copy of the passed object (objects are clone as reference).

clone({"a":0,"b":{"c":0}})
<= {"a":0,"b":{"c":0}}
js

deepclone(object)

Creates deep copy of the passed object (objects are clone as value).

deepclone({"a":0,"b":{"c":0}})
<= {"a":0,"b":{"c":0}}
js

dig(object, string)

Returns the value of any object property, which the name has been passed in the string.

dig({"foo":{"bar":"baz"}}, "foo.bar")
<= "baz"
js

keys(object)

Returns an array of a given object's property names.

keys({"foo":"bar","baz":[1,2,3]})
<= ["foo","baz"]
js

merge(object, sources)

Merges properties of sources into the destination object.

merge({"foo":{"a":1,"b":1,"c":1},"baz":{"b":2,"c":2}})
<= {"foo":{"a":1,"b":1,"c":1},"baz":{"b":2,"c":2}}
js
merge({"foo":{"a":1,"b":1,"c":1},"baz":{"b":2,"c":2},"bar":{"c":3}})
<= {"foo":{"a":1,"b":1,"c":1},"baz":{"b":2,"c":2},"bar":{"c":3}}
js

pat(object, string, value)

Overrides the value of any object property, which the name has been passed in the string with the value.

pat({"foo":"bar"}, "foo", "baz")
<= {"foo":"baz"}
js

recsort(object)

Sorts keys of an object.

recsort({"b":2,"a":1})
<= {"a":1,"b":2}
js

rename(object, keys)

Changes names of the object properties to responds values from the keys object.

rename({"created_at":"2000-01-01"}, {"created_at":"createdAt"})
<= {"createdAt":"2000-01-01"}
js

values(object)

Returns an array of a given object's own enumerable property values.

values({"foo":"bar","baz":[1,2,3]})
<= ["bar",[1,2,3]]
js

string


bytes(string)

Converts string with specific unit to bytes.

bytes("400KB")
<= 409600
js

camelize(string, lowercased)

Converts string to camelcase notation. Second parameter sets the first letter to lowercase or uppercase.

camelize("foo_bar")
<= "fooBar"
js
camelize("FooBar")
<= "fooBar"
js

capitalize(string)

Converts first letter of the string to uppercase.

capitalize("foo")
<= "Foo"
js
capitalize("foo bar and baz")
<= "Foo bar and baz"
js

celsius(string)

Converts temperature in Fahrenheit and Kelvin notation to Celsius degree. When passed string is a number, appends °C to the string.

celsius("25")
<= "25°C"
js
celsius("0°F")
<= "-18°C"
js
celsius("0K")
<= "-273°C"
js

chomp(string, pattern)

Removes from the end of the string passed pattern.

chomp("foo bar", "ar")
<= "foo b"
js

chop(string)

Returns string with last character removed. If the string ends with line ending characters then both will be removed.

chop("foo bar baz")
<= "foo bar ba"
js

classify(string)

Creates a class name based on the string.

classify("cars")
<= "Car"
js

constantize(string)

Converts string to constant notation.

constantize("foo")
<= "FOO"
js

crop(string, length, append)

Truncates string at full words. Adds ... if the string is longer than the second parameter.

crop("foo bar baz ban bar", 10)
<= "foo bar..."
js

dasherize(string)

Replaces _ with -.

dasherize("foo_bar__baz")
<= "foo-bar--baz"
js

dot(string)

Returns string with dot at the end.

dot("foo bar")
<= "foo bar."
js

fahrenheit(string)

Converts temperature in Celsius and Kelvin notation to Fahrenheit degree. When passed string is a number, appends °F to the string.

fahrenheit("50")
<= "50°F"
js
fahrenheit("30°C")
<= "86°F"
js

htmlstrip(string)

Removes HTML tags from a string. Warning: user input might include malicious content, htmlstrip is not a silver bullet against xss.

htmlstrip("<div>foo</div>")
<= "foo"
js
htmlstrip("Hello <b><i>world!</i></b>")
<= "Hello world!"
js

humanize(string, capitalize = true)

Replaces _ with singlespaces. When capitalize is truthy, converts first char of the string to uppercase.

humanize("foo bar")
<= "Foo bar"
js
humanize("foo_bar")
<= "Foo bar"
js

hyphenate(string)

Replaces spaces with hyphens, splits camelcase text, remove non-word chars and converts string to lowercase.

hyphenate("%# lorem ipsum ? $ dolor")
<= "lorem-ipsum-dolor"
js
hyphenate("loremIpsum")
<= "lorem-ipsum"
js

index(string, pattern, start = 0)

Returns index of searched pattern.

index("hello", "e")
<= 1
js
index("hello", "lo")
<= 3
js

initials(string, separator = "")

Returns initials separated by the separator.

initials("Foo Bar")
<= "FB"
js
initials("Foo Barin-Bar", ".")
<= "F.B.B"
js

kelvin(string)

Converts temperature in Celsius and Fahrenheit notation to Kelvin scale. When passed string is a number, appends K to the string.

kelvin("100")
<= "100K"
js
kelvin("26°C")
<= "299K"
js

lowercase(string)

Lowercases the string.

lowercase("Foo BAR and baZ")
<= "foo bar and baz"
js

lowerfirst(string)

Converts first letter of the string to lowercase.

lowerfirst("Foo bar baz")
<= "foo bar baz"
js

ltrim(string, characters = " ")

Removes white space characters or other specified in parameter characters from the beginning of the string.

ltrim(" foo")
<= "foo"
js

pad(string, pad, left = true)

Returns string with added pad from left side or right side.

pad("hello world", 5)
<= " hello world"
js
pad("Hello world", 5, false)
<= "Hello world "
js
pad("hello world", "** ")
<= "** hello world"
js

pluralize(string)

Returns plural form of the string.

pluralize("car")
<= "cars"
js
pluralize("dress")
<= "dresses"
js
pluralize("wife")
<= "wives"
js

quote(string, lang = "en")

Puts the string inside quotations marks.

quote("foo bar baz")
<= "\"foo bar baz\""
js
quote("foo bar baz", "pl")
<= "„foo bar baz”"
js

repeat(string, count)

Repeats the string n times.

repeat("foo", 2)
<= "foofoo"
js

replace(string, pattern, replace)

Replaces searched pattern by the last parameter.

replace("foo bar baz ban", "baz", "qux")
<= "foo bar qux ban"
js

rtrim(string, characters = " ")

Removes white space characters or other specified in parameter characters from the end of the string.

rtrim("foo ")
<= "foo"
js

singlespace(string)

Replaces in the string multiple spaces to single spaces.

singlespace("foo bar baz")
<= "foo bar baz"
js

singularize(string, appendix = "")

Returns singular form of the string.

singularize("cars")
<= "car"
js
singularize("watches")
<= "watch"
js
singularize("shelves", "f")
<= "shelf"
js

slugify(string, separator = "-")

Converts string to lower case, remove non-word chars and replace spaces with the separator.

slugify("LoremIpsum dolor special chars")
<= "loremipsum-dolor-special-chars"
js

split(string, separator = "")

Splits string into an array by separating the string into substrings.

split("foo,bar,bazz", ",")
<= ["foo","bar","bazz"]
js

squeeze(string, pattern = "a-zA-Z")

Replaces multiple occurances of the same characters to the one character.

squeeze("yellow moon")
<= "yelow mon"
js

strip(string, pattern)

Removes the passed pattern from the string.

strip(" foo ")
<= "foo"
js
strip("foo bar baz ban", ["o","r","a"])
<= "f b bz bn"
js

summarize(string, length = 100)

Adds three dots at the end of the string, when the string is longer than the passed length.

summarize("foo bar baz ban", 10)
<= "foo bar baz ban..."
js

swapcase(string)

Replaces in string lowercased letters to uppercase and uppercased letters to lowercase.

swapcase("foo")
<= "FOO"
js
swapcase("fOo Bar BAZ")
<= "FoO bAR baz"
js

tail(string, length = 30, ending = "...")

Truncates the tail of a given string.

tail("Once upon a time in a world far far away", 15)
<= "...far far away"
js

titleize(string)

Converts to 'uppercase' first letter of each word in string.

titleize("foo bar")
<= "Foo Bar"
js

trim(string)

Removes whitespace from the start and the end of the string.

trim(" foo ")
<= "foo"
js

truncate(string, length = 30, ending = "...")

Truncates a given string if it longer than the passed length and replaces last chars of new string with the passed ending.

truncate("Once upon a time in a world far far away")
<= "Once upon a time in a world..."
js
truncate("Once upon a time in a world far far away", 15)
<= "Once upon a ..."
js

uid(length = 32)

Returns an unique identifier.

uid(10)
<= "dp0VOfYq4f"
js

underscore(string)

Returns new string with words separated by _. All letters are lowercased.

underscore("fooBar")
<= "foo_bar"
js

unescape(string)

Converts the HTML entities to their corresponding characters.

unescape("&amp;")
<= "&"
js

unquote(string)

Removes "" or „” from the string.

unquote("„foo bar baz”")
<= "foo bar baz"
js
unquote("\"foo bar baz\"")
<= "foo bar baz"
js

unwrap(string, first, last = first)

Removes characters from the start and end of the string based on the passed values.

unwrap("\"foo bar baz ban\"", "\"")
<= "foo bar baz ban"
js
unwrap("„foo bar baz”", "„", "”")
<= "foo bar baz"
js

uppercase(string)

Converts string to uppercase.

uppercase("foo")
<= "FOO"
js

whitespacestrip(string)

Removes whitespaces from the string.

whitespacestrip(" f o o")
<= "foo"
js

wrap(string, first, last = first)

Wraps string between the first and last parameters.

wrap("foo bar baz ban", "„", "”")
<= "„foo bar baz ban”"
js