The main namespace.
Classes
Namespaces
Methods
-
<static> bool(str)
-
Pass in a string and it will be returned as a boolean. If the string is not
true
orfalse
, the string passed will be returned.Parameters:
Name Type Description str
String The string to convert into a boolean.
Returns:
- Type
- Boolean
-
<static> extend(defaults, options)
-
Merge defaults with user options.
Parameters:
Name Type Description defaults
Object Default settings.
options
Object User options.
Returns:
Merged values of defaults and options.
- Type
- Object
-
<static> isBool(val)
-
Returns
true
orfalse
if value is a boolean.Parameters:
Name Type Description val
* Test value.
Returns:
- Type
- Boolean
-
<static> isNum(val)
-
Returns
true
orfalse
if value is a number.Parameters:
Name Type Description val
* Test value.
Returns:
- Type
- Boolean
-
<static> isString(val)
-
Returns
true
orfalse
if value is a string.Parameters:
Name Type Description val
* Test value.
Returns:
- Type
- Boolean
-
<static> isUndef(val [, empty])
-
Returns
true
orfalse
if a value is undefined.Parameters:
Name Type Argument Default Description val
* Test value.
empty
Boolean <optional>
false Checks if the value is empty, i.e. "". If a value is empty and parameter is not set,
false
is returned.Returns:
- Type
- Boolean
-
<static> loop(arr, cb)
-
Loop through an array with callback.
Parameters:
Name Type Description arr
Arrays The array.
cb
function Callback function.
Properties
Name Type Description element
* The value of the array.
index
Number The index of the array.
Example
var arr = ['apple', 'orange', 'blueberry', 'strawberry']; ML.loop(arr, function(element, index) { console.log(element); // Will console out: apple, orange, etc... console.log(index); // Will console out the array item's index: 0, 1, etc... })
-
<static> parObj(str, base, sep)
-
Parses a string into an object.
Parameters:
Name Type Description str
String String to be parse.
base
String Base of the string to be removed.
sep
String Used to separate each property.
Returns:
- Type
- Object
-
<static> trim(str)
-
Returns a string with whitespace removed.
Parameters:
Name Type Description str
String String to remove whitespace.
Returns:
- Type
- String
-
<static> urlParams(arg)
-
Returns query paramaters.
Parameters:
Name Type Description arg
String | Object Query parameter.
Returns:
- Type
- String
Example
var str = 'animal=cat&fruit=apple'; // 'animal=cat&fruit=apple' is returned. var obj = {animal: 'cat', fruit: 'apple'}; // 'animal=cat&fruit=apple' is returned.
-
<static> windowDimen()
-
Returns the width and height of the window. credit
Returns:
- Type
- Object