Augmented Next Core - Utilities and Functions
- isString
- isFunction
- has
- isObject
- allKeys
- create
- result
- arrayhas
- exec
- isDefined
- prettyPrint
- prettyPrintHTML
- shuffle
- binarySearch
- TransformerType
- Transformer
- wrap
- filterObject
- findByMatchingProperties
- sortObjects
- mergeSort
- mergeSort
- mergeSort
- QuickSort
- formatBinary
- binaryToHex
- formatDate
- filter
- sizeOf
- formatByteSize
- memorySizeOf
- hammingDistance
- isEqual
isString - checks if a value is a String
val
variable
string to check
Returns boolean true if value is a string
isFunction - returns true if called name is a function simular to jQuery .isFunction method
name
function The name of the function to test
Returns any true if called name is a function
has
Returns boolean Returns true of the key exists
isObject
obj
object The input object
Returns boolean Returns true of the param is an object
Augmented.allKeys
obj
object The input object
Returns array Returns the array of ALL keys including prototyped
Augmented.create
Returns object Returns the created object
Augmented.result - returns named property in an object simular to underscore .result method
Returns any named property in an object
Array.has - returns is a property is in the array (very fast return)
Returns any true if property is included in an array
exec method - Execute a function by name
functionName
string The name of the functioncontext
object The context to call fromargs
object Arguments
isDefined - Checks and returns if a passed variable is defined
val
variable
string to check
Returns boolean true if value is defined
Prints an object nicely
obj
object The object to printspaces
boolean Use spaces instead of tabs (optional, defaultfalse
)number
number Number spaces to use (if spaces is true) (optional, default2
)
Returns string formatted JSON string
Prints an object nicely in HTML
obj
object The object to printindent
(optional, default0
)array
(optional, defaultfalse
)last
(optional, defaulttrue
)
Returns string formatted JSON string in HTML
Shuffles an Array with Fisher-Yates Shuffle algorithm
array
array The array to shuffle
Returns array A new shuffled array
Performs a binary search on the host array. vs indexOf
Binary Search is a complexity of O(n log n) vs O(n) with indexOf
arr
Array The array.find
Any The item to search for within the array.comparator
function The comparator to use
Returns Number The index of the element which defaults to -1 when not found.
Augmented.Utility.TransformerType
Transformer type for use in the transformer
Type: Symbol
String
Symbol Standard StringInteger
Symbol IntegerNumber
Symbol Any numberBoolean
Symbol True/FalseArray
Symbol Stanrdard ArrayObject
Symbol Any ObjectNull
Symbol Null
Augmented.Utility.Transformer
Transform an object, type, or array to another type, object, or array
The transformer type enum
Type: Augmented.Utility.TransformerType
source
type
Transform an object, primitive, or array to another object, primitive, or array
source
object Source primitive to transformtype
Augmented.Utility.TransformerType Type to transform to
Returns object returns a transformed object or primitive
Returns a Augmented.Utility.TransformerType of a passed object
source
object The source primitive
Returns Augmented.Utility.TransformerType type of source as Augmented.Utility.TransformerType
Wrap method to handle wrapping functions (simular to _.wrap)
fn
wrap
filter an object from array of values
Returns object returns a new object with only these keys
find an oject from matching properties
Returns array returns a the objects that matched
Sorts an array of objects by propery in object
Returns array The sorted array
Split the array into halves and merge them recursively
array
array The array to sort
Returns array The sorted array
Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.
array
array The array to sort
Returns array The sorted array
Simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order.
array
array The array to sort
Returns array The sorted array
Quick Sort implimentation for Arrays -
arr
Array Array to Sort
Returns Array Returns a sorted array
Format a number into binary string at a set precision
num
num The number to formatpres
pres The bit precision
Returns string The formatted binary string
Format a binary string into a hex value (two characters)
binary
binary The 8-bit binary string to return as hex characterspad
pad Add a zero if under '10'
Returns string The hex value
Format a date to US format (MM/DD/YYYY HH:mm AM/PM) or (MM/DD/YYYY) only
Returns string The formatted date
Filter a string by removing a char
Returns string The filtered string
Returns the size in bytes of an object
Returns Number size in bytes
Returns the number (in bytes) as a human readable string
Returns String size in formated human readable string
Returns the object size as a human readable string
Returns String size in formated human readable string
The Hamming Distance is the number of different symbols between two strings/numbers (equal length). It can be also considered as the number of changes required to convert from one input to another.
Returns number the distance
Performs a deep comparison between two values to determine if they are
equivalent. This is a simular function to lodash isEquals.
Note: This method supports comparing arrays, array buffers,
booleans, dates, error objects, maps, numbers, objects, regexes, sets,
strings, symbols, and typed arrays.
Objects are compared by their own, not inherited, enumerable properties.
Functions are compared by strict equality, i.e. ===.
DOM nodes are considered objects and treaked as such as this library does
not assume browsers.
first
any The first itemsecond
any The second item
Returns boolean Returns true if equal