-
Notifications
You must be signed in to change notification settings - Fork 135
moxie.core.utils.Basic
Important! This page is auto-generated from the comments in the source files. All changes will be overwritten! If you are looking to contribute, modify the comment in the corresponding source file instead.
-
Methods
-
typeOf(o)
static
-
extend(target, [obj])
static
-
extendIf(target, [obj])
static
-
inherit(child, parent)
static
-
each(obj, callback)
static
-
isEmptyObj(o)
static
-
inSeries(queue, cb)
static
-
inParallel(queue, cb)
static
-
inArray(needle, array)
static
-
toArray(obj)
static
-
guid(prefix)
static
-
trim(str)
static
-
parseSizeStr(size)
static
-
typeOf(o)
typeOf(o) static
Gets the true type of the built-in object (better version of typeof).
Arguments
-
o
Object
Object to check.
extend(target, [obj]) static
Extends the specified object with another object(s).
Arguments
-
target
Object
Object to extend. -
[obj]
Object
Multiple objects to extend with.
extendIf(target, [obj]) static
Extends the specified object with another object(s), but only if the property exists in the target.
Arguments
-
target
Object
Object to extend. -
[obj]
Object
Multiple objects to extend with.
inherit(child, parent) static
A way to inherit one class
from another in a consisstent way (more or less)
Arguments
-
child
Function
-
parent
Function
each(obj, callback) static
Executes the callback function for each item in array/object. If you return false in the callback it will break the loop.
Arguments
-
obj
Object
Object to iterate. -
callback
Function
Callback function to execute for each item.
isEmptyObj(o) static
Checks if object is empty.
Arguments
-
o
Object
Object to check.
inSeries(queue, cb) static
Recieve an array of functions (usually async) to call in sequence, each function receives a callback as first argument that it should call, when it completes. Finally, after everything is complete, main callback is called. Passing truthy value to the callback as a first argument will interrupt the sequence and invoke main callback immediately.
Arguments
-
queue
Array
Array of functions to call in sequence -
cb
Function
Main callback that is called in the end, or in case of error
inParallel(queue, cb) static
Recieve an array of functions (usually async) to call in parallel, each function receives a callback as first argument that it should call, when it completes. After everything is complete, main callback is called. Passing truthy value to the callback as a first argument will interrupt the process and invoke main callback immediately.
Arguments
-
queue
Array
Array of functions to call in sequence -
cb
Function
Main callback that is called in the end, or in case of erro
inArray(needle, array) static
Find an element in array and return it's index if present, otherwise return -1.
Arguments
-
needle
Mixed
Element to find -
array
Array
toArray(obj) static
Forces anything into an array.
Arguments
-
obj
Object
Object with length field.
guid(prefix) static
Generates an unique ID. The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth to be hit with an asteroid.
Arguments
-
prefix
String
to prepend (by default 'o' will be prepended).
trim(str) static
Trims white spaces around the string
Arguments
-
str
String
parseSizeStr(size) static
Parses the specified size string into a byte value. For example 10kb becomes 10240.
Arguments
-
size
String/Number
String to parse or number to just pass through.