This is all about generating strings in one form or another. Yo.
- Source:
Methods
-
<static> compose(one) → {String}
-
create a string from a bunch of substrings
Parameters:
Name Type Description one
String or more strings as arguments
- Source:
Returns:
the resulting string
- Type
- String
-
<static> random(len, mode)
-
creates a random string (numbers and chars)
Parameters:
Name Type Description len
Number length of key
mode
Number determines which letters to use. null or 0 = all letters; 1 = skip 0, 1, l and o which can easily be mixed with numbers; 2 = use numbers only
- Source:
Returns:
random string
-
<static> repeat(string, num, sep) → {String}
-
function repeats a string passed as argument
Parameters:
Name Type Argument Description string
String the string to reproduce
num
Number amount of repetitions
sep
string <optional>
Separate the strings with this
- Source:
Returns:
resulting string
- Type
- String
Example
var strings = require("ink-strings"); strings.repeat( "there's no place line home", 3, " " ) -> "there's no place line home there's no place line home there's no place line home"
-
<static> sorter(field, order) → {Function}
-
factory to create functions for sorting objects in an array
Parameters:
Name Type Description field
String name of the field each object is compared with
order
Number (ascending or descending)
- Source:
Returns:
ready for use in Array.prototype.sort
- Type
- Function
Example
var characters = [{name:"rory", age:30}, {name: "amy", age:30}, {"mr weasley": age:60}]; var strings = require("ink-strings"); characters.sort(string.sorter("name")); -> [{name:"amy", age:30}, {name: "mr weasley", age:60}, {"rory": age:30}];
-
<static> tempKey() → {string}
-
Creates a random string, in this case a UUID-like thingy. I call it a Uniquely Interesting ID. It is not globally unique or even really unique. Just random and with a known format. Also available as uiid
- Source:
Returns:
- Type
- string