Augmented Next Core - Utilities and Functions.
npm install next-core-utilitiesAugmented Next Core - Utilities and Functions
- isString
- Parameters
- isFunction
- Parameters
- has
- Parameters
- isObject
- Parameters
- allKeys
- Parameters
- create
- Parameters
- result
- arrayhas
- Parameters
- exec
- Parameters
- isDefined
- Parameters
- prettyPrint
- Parameters
- prettyPrintHTML
- Parameters
- shuffle
- Parameters
- binarySearch
- Parameters
- TransformerType
- Properties
- Transformer
- transform
- Parameters
- transform
- Parameters
- isType
- Parameters
- wrap
- Parameters
- filterObject
- Parameters
- findByMatchingProperties
- Parameters
- sortObjects
- Parameters
- mergeSort
- Parameters
- mergeSort
- Parameters
- mergeSort
- Parameters
- QuickSort
- Parameters
- formatBinary
- Parameters
- binaryToHex
- Parameters
- formatDate
- Parameters
- filter
- Parameters
- sizeOf
- formatByteSize
- memorySizeOf
- hammingDistance
- Parameters
- isEqual
- Parameters
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
- obj object The input object
- key object The test key
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
- prototype object The input prototype
- props object The properties (optional)
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)
- arr array Source array
- key object Key to test for
Returns any true if property is included in an array
exec method - Execute a function by name
- functionName string The name of the function
- context object The context to call from
- args 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 print
- spaces boolean Use spaces instead of tabs (optional, default false)
- number number Number spaces to use (if spaces is true) (optional, default 2)
Returns string formatted JSON string
Prints an object nicely in HTML
- obj object The object to print
- indent (optional, default 0)
- array (optional, default false)
- last (optional, default true)
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 String
- Integer Symbol Integer
- Number Symbol Any number
- Boolean Symbol True/False
- Array Symbol Stanrdard Array
- Object Symbol Any Object
- Null 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
#### Parameters
- source
- type
Transform an object, primitive, or array to another object, primitive, or array
#### Parameters
- source object Source primitive to transform
- type Augmented.Utility.TransformerType Type to transform to
Returns object returns a transformed object or primitive
Returns a Augmented.Utility.TransformerType of a passed object
#### Parameters
- 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
- object object Object to filter
- keys array keys to filter from the object
Returns object returns a new object with only these keys
find an oject from matching properties
- set Array array/set of objects
- properties object properties to find by
Returns array returns a the objects that matched
Sorts an array of objects by propery in object
- array array The object array to sort
- key object The property to sort by
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 format
- pres 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 characters
- pad 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
- date date The date to format
- noTime boolean Exclude the time
Returns string The formatted date
Filter a string by removing a char
- str string The string
- char string The 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.
- num1 (number \| string) First number
- num2 (number \| string) Second number
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 item
- second any The second item
Returns boolean Returns true if equal