Skip to content

Latest commit

 

History

History
executable file
·
4833 lines (2861 loc) · 75.4 KB

readme.md

File metadata and controls

executable file
·
4833 lines (2861 loc) · 75.4 KB

Craydent 0.10.2

by Clark Inada

Craydent is all inclusive utility library. There are several ways to use the library in NodeJS. More detailed documentation on constants can be found at Craydent Properties. More detailed documentation on methods can be found at Craydent Methods

// require with prototypes - this require will add prototypes to extend classes and add two constants ($c, $g) to the global space.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent');
$c.logit($c.VERSION);
arr.prototypedMethod(args);
// require no conflict - this require is the fully modular version with no global constants, prototypes, or methods.
var $c = require('craydent/noConflict');
$c.logit($c.VERSION);
$c.prototypedMethod(arr, args);
// require global - this require constants and methods in the global space and add prototypes to extend classes.
// $g is an alias to global and $c is the constant containing all the utility methods and properties.
require('craydent/global');
logit($c.VERSION);
arr.prototypedMethod(args);

Categories

Constants

CONSOLE_COLORS (Object) LOCAL_IP (String) TEMPLATE_TAG_CONFIG (Object)
DEBUG_MODE (Boolean) MODULES_LOADED (Object) TEMPLATE_VARS (Array)
ERROR_TYPES (Array) PUBLIC_IP (String) VERSION (String)
HTTP_STATUS_TEMPLATE (Object) RESPONSES (Object)

Featured

Array


add


Info: Array class extension to perform push and update indexes if used

Return: (Bool) Value to indicate success or failure

Parameters:

  • value: (Object) value to add

Overloads:

None


aggregate


Info: Array class extension to perform mongo style aggregation

Return: (Documents) returns an array of aggregates

Parameters:

  • pipelines: (Array) Array of stages defined in mongodb. ($project, $match, $redact, $limit, $skip, $unwind, $group, $sample, $sort, $lookup, $out)

Overloads:

None


average


Info: Array class extension to perform average of all the values (any value which is not a number is skipped).

Return: (number)

Parameters:

None

Overloads:

None


find


Info: Array class extension to use mongo or sql queries (Alias of Where minus the limit argument)

Return: (Array)

Parameters:

  • condition: (WhereCondition | string) Query following find/where clause syntax

Overloads:

Parameters

  • condition: (WhereCondition | string) Query following find/where clause syntax
  • projection: (Fields | string) Indicate which properties to return

Parameters

  • condition: (WhereCondition | string) Query following find/where clause syntax
  • useReference: (Bool) Flag to make a copy instead of using references

findOne


Info: Array class extension to use mongo or sql queries returning the first item match

Return: (T)

Parameters:

  • condition: (WhereCondition | string) Query following find/where clause syntax

Overloads:

Parameters

  • condition: (WhereCondition | string) Query following find/where clause syntax
  • projection: (Fields | string) Indicate which properties to return

Parameters

  • condition: (WhereCondition | string) Query following find/where clause syntax
  • useReference: (Bool) Flag to make a copy instead of using references

parallelEach


Info: Array class extension to perform push and update indexes if used

Return: (Bool) Value to indicate success or failure

Parameters:

  • value: (Object) value to add

Overloads:

None


stdev


Info: Array class extension to perform standard deviation (any value which is not a number is 0).

Return: (number | NaN) returns the standard deviation of the array of numbers

Parameters:

None

Overloads:

None


sum


Info: Array class extension to perform summation of all the values (any value which is not a number is 0).

Return: (number | NaN) returns the sum of the array of numbers

Parameters:

None

Overloads:

None


where


Info: Array class extension to use mongo or sql queries

Return: (Array) returns a filtered subset of the array.

Parameters:

  • condition: (WhereCondition) Query following mongo find/where clause syntax

Overloads:

Parameters

  • condition: (WhereCondition) Query following mongo find/where clause syntax
  • limit: (number) Limit the number of the results returned.

Parameters

  • condition: (WhereCondition) Query following mongo find/where clause syntax
  • projection: (Object) Indicate which properties to return

Parameters

  • condition: (WhereCondition) Query following mongo find/where clause syntax
  • useReference: (Bool) Flag to make a copy instead of using references

Parameters

  • condition: (WhereCondition) Query following mongo find/where clause syntax
  • projection: (Object) Indicate which properties to return
  • limit: (Int) Limit the number of the results returned.

Parameters

  • condition: (WhereCondition) Query following mongo find/where clause syntax
  • useReference: (Bool) Flag to make a copy instead of using references
  • limit: (Int) Limit the number of the results returned.

Parameters

  • condition: (WhereIterator) The funciton invoked per iteration.
  • limit: (number) Limit the number of the results returned.

Parameters

  • condition: (WhereIterator) The funciton invoked per iteration.
  • projection: (Object) Indicate which properties to return

Parameters

  • condition: (WhereIterator) The funciton invoked per iteration.
  • useReference: (Bool) Flag to make a copy instead of using references

Parameters

  • condition: (WhereIterator) The funciton invoked per iteration.
  • projection: (Object) Indicate which properties to return
  • limit: (Int) Limit the number of the results returned.

Parameters

  • condition: (WhereIterator) The funciton invoked per iteration.
  • useReference: (Bool) Flag to make a copy instead of using references
  • limit: (Int) Limit the number of the results returned.

Date


format


Info: Date class extension to convert to formatted string

Return: (String)

Parameters:

  • format: (String) Format syntax to use to to format date

Overloads:

Parameters

  • format: (String) Format syntax to use to to format date
  • options: (Object) specs with optional properties:
    (Bool) gmt
    (Int) offset

HTTP


$COOKIE


Info: Get/set Cookies

Return: (String|Bool)

Parameters:

  • key: (String) Key for cookie value
  • option?: (CookieOptions) Specify delete

Overloads:

Parameters

  • keyValue: (Object) Specify the key value pair: key=>property, value=>object[key]
  • option?: (CookieOptions) Specify path, domain, and/or expiration of cookie

Parameters

  • key: (String) Key for cookie value
  • value: (any) Value to store
  • option?: (CookieOptions) Specify path and/or expiration of cookie

$DEL


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$DELETE


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$GET


Info: Retrieve all or specific variables in the url

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (GetOptions|VerbOptionsTypes|String) Options to defer, ignore case, etc

$HEADER


Info: Retrieve all or specific variables in the headers

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$PAYLOAD


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$POST


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

$PUT


Info: Retrieve all or specific variables in the Body

Return: (Bool|Object)

Parameters:

None

Overloads:

Parameters

  • key: (String) key for query value
  • options?: (VerbOptionsTypes|VerbOptions) Options to defer, ignore case, etc

Object


get


Info: Alias to getProperty; however, it can not be used as a protoype property.

Return: (any)

Parameters:

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • delimiter?: (Char) Separator used to parse path

Overloads:

Parameters

  • object: (Object) object to get the property of
  • path: (RegExp) Regex match for the property

Parameters

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Parameters

  • object: (Object) object to get the property of
  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

getProperty


Info: Object class extension to retrieve nested properties without error when property path does not exist

Return: (any)

Parameters:

  • path: (String) Path to nested property

Overloads:

Parameters

  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path

Parameters

  • path: (RegExp) Regex match for the property

Parameters

  • path: (String) Path to nested property
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Parameters

  • path: (String) Path to nested property
  • delimiter: (Char) Separator used to parse path
  • options: (GetPropertyOptions) Options for ignoring inheritance, validPath, etc

Template


fillTemplate


Info: Function for templetizing

Return: (String)

Parameters:

  • htmlTemplate: (String) Template to be used
  • objs: (Object[]) Objects to fill the template variables
  • options?: (HelperOptions) Options to use: max,offset,newlineToHtml,preserveNonMatching,removeNewLineFromLogicalSyntax,removeWhitespaceFromLogicalSyntax

Overloads:

Parameters

  • htmlTemplate: (String) Template to be used
  • objs: (Object[]) Objects to fill the template variables
  • max: (Int) The maximum number of records to process

Parameters

  • htmlTemplate: (String) Template to be used
  • objs: (Object[]) Objects to fill the template variables
  • offset?: (Int) The start index of the Object array
  • max?: (Int) The maximum number of records to process
  • newlineToHtml?: (Boolean) Flag to replace all new line chars () to the HTML
    tag. Default is true.
  • preserveNonMatching?: (Boolean) Flag to used to leave template variables that were not replaced.
  • removeNewLineFromLogicalSyntax?: (Boolean) Flag to used to remove new lines from logical syntax.
  • removeWhitespaceFromLogicalSyntax?: (Boolean) Flag to used to remove whitespace caused by line formatting from logical syntax.

Utility


catchAll


Info: Creates an catch all for exceptions in the current node service.

Return: (void)

Parameters:

  • callback: (ErrorCallback) Callback function to call when there is an uncaught exception
  • append?: (Boolean) Options to defer, ignore case, etc

Overloads:

None


zipit


Info: Download a zip of files from file contents

Return: (void)

Parameters:

  • files: (FileObject[]) Objects containing properties name for file name and content for file content

Overloads:

Parameters

  • filename: (String) Name of the file
  • content: (String) contents of the file

Methods

Array


buildTree


Info: Array class extension to create a parent/child hierarchy

Return: (Array) returns a hierarchical array.

Parameters:

  • parentFinder: (TreeParentFinder) Function to determine the parent. Should return a boolean value and is passed the current item as an argument.
  • childFinder: (String|TreeChildFinder) Property name of the object to use as a grouping.
  • options?: (TreeOptions) Options to customize properties, Valid property is:
    childProperty

Overloads:

None


condense


Info: Array class extension to reduce the size of the Array removing blank strings, undefined's, and nulls

Return: (Array) returns a condensed version of the array.

Parameters:

  • check_values?: (Bool) Set craydent_ctx flag to remove duplicates

Overloads:

None


createIndex


Info: Array class extension to create indexes for faster searches during where

Return: (Array | Bool) returns the Array if successfull otherwise false.

Parameters:

  • properties: (string) Property or comma delimited property list to index.

Overloads:

Parameters

  • indexes: (Array) Array of properties to index

delete


Info: Array class extension to delete records

Return: (Array) returns a list of the deleted objects.

Parameters:

  • condition: (WhereCondition) Query following find/where clause syntax
  • justOne?: (Bool) Flag for deleting just one records [Default is: true]

Overloads:

None


distinct


Info: Array class extension to get all unique records by fields specified

Return: (Array) returns an array with distinct values

Parameters:

  • fields: (String|Array) Fields to use as the projection and unique comparison (comma delimited) or array of fields
  • condition?: (String|WhereCondition) Query following SQL where clause syntax

Overloads:

None


emit


Info: Call the next function(s) in queue

Return: (Array)

Parameters:

  • event: (String) Event to trigger.
  • ...infinite: (any) any number of arguments can be passed and will be applied to listening functions as arguments.

Overloads:

None


filter


Info: Array class extension to implement filter

Return: (Array)

Parameters:

  • func: (ArrayIterator) Callback function used to determine if value should be returned. Callback will get the current item, index, context as arguments.
  • craydent_ctxs?: (any) Specify the context on callback function

Overloads:

None


group


Info: Array class extension to group records by fields

Return: (Array)

Parameters:

  • params: (GroupOptions) specs with common properties:
    (Object) key
    (Object | string) condition
    (Function) reduce
    (Object) initial
    (Array | Function) keyf
    (Function) finalize
  • removeProps?: (Bool) Flag to preserve property if the value is null or undefined.

Overloads:

None


indexOfAlt


Info: Array class extension to find index of a value based on a callback function & String class extension to find the index based on a regular expression

Return: (Integer)

Parameters:

  • value: (any) value to find
  • func: (ArrayIterator<T, TResult>) Callback function used to do the comparison

Overloads:

Parameters

  • regex: (RegExp) Regular expression to check value against
  • pos?: (Int) Index offset to start

innerJoin


Info: Array class extension to do an inner join on arrays

Return: (Array) resulting array of the join.

Parameters:

  • arr: (Array) Array to be joined with
  • on: (String) Condition to join on

Overloads:

None


insert


Info: Array class extension to add to the array

Return: (Bool)

Parameters:

  • value: (Mixed) value to add

Overloads:

None


insertAfter


Info: Array class extension to add to the array after a specific index

Return: (Bool) returns true for success and false for failure.

Parameters:

  • index: (Int) Index to add after
  • value: (any) Value to add

Overloads:

None


insertAt


Info: Array class extension to add to the array at a specific index and push the all indexes down

Return: (Bool) returns true for success and false for failure.

Parameters:

  • index: (Int) Index to add after
  • value: (any) Value to add

Overloads:

None


insertBefore


Info: Array class extension to add to the array before a specific index

Return: (Bool) returns true for success and false for failure.

Parameters:

  • index: (Int) Index to add before
  • value: (any) Value to add

Overloads:

None


joinLeft


Info: Array class extension to do an outer left join on arrays

Return: (Array) resulting array of the join.

Parameters:

  • arr: (Array) Secondary array to be joined with
  • on: (String) Condition to join on

Overloads:

None


joinRight


Info: Array class extension to do an outer right join on arrays

Return: (Array) resulting array of the join.

Parameters:

  • arr: (Array) Secondary array to be joined with
  • on: (String) Condition to join on

Overloads:

None


last


Info: Array class extension to retrieve the last item in the array.

Return: (T) returns the last item in the array.

Parameters:

None

Overloads:

None


limit


Info: Array class extension to return a limited amount of items

Return: (Array) returns the first n items in the array.

Parameters:

  • max: (Int) Maximum number of items to return
  • skip?: (Int) Number of items to skip

Overloads:

None


mapReduce


Info: Array class extension to run map-reduce aggregation over records

Return: (Array) returns the map reduced array.

Parameters:

  • map: (ArrayIterator<T, TResult>) Function to apply to each item
  • reduce: (MongoReducer) Function used to condense the items
  • options?: (MongoMapReduceOptions<T, TResult>) Options specified in the Mongo Doc

Overloads:

None


normalize


Info: Array class extension to normalize all properties in the object array

Return: (Array) returns a normalized version of the objects.

Parameters:

None

Overloads:

None


remove


Info: Array class extension to remove an item by value

Return: (T | undefined) returns the removed item.

Parameters:

  • value: (any) Value to remove
  • indexOf?: (ArrayIterator) Callback function to use to find the item based on the value

Overloads:

None


removeAll


Info: Array class extension to remove all items by value

Return: (Array) returns an array of all the removed items.

Parameters:

  • value?: (any) Value to remove
  • indexOf?: (IndexOf) Callback function to use to find the item based on the value

Overloads:

None


removeAt


Info: Array class extension to remove item at a specific index

Return: (T | undefined) returns the removed item.

Parameters:

  • index: (Int) Index of the item to remove

Overloads:

None


replaceAt


Info: Array class extension to replace item at a specific index

Return: (T | undefined) returns the item removed.

Parameters:

  • index: (Int) Index of the item to remove
  • value: (any) Value to replace with

Overloads:

None


scramble


Info: Array class extension to scramble the order.

Return: (Array)

Parameters:

None

Overloads:

None


sortBy


Info: Array class extension to sort the array

Return: (Array)

Parameters:

  • props: (string) Property/Comma delimited list of properties to sort by. If the first character is '!', the sort order is reversed

Overloads:

Parameters

  • props: (Array) Properties to sort by. If the first character is '!', the sort order is reversed

Parameters

  • props: (string) Property/Comma delimited list of properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort

Parameters

  • props: (Array) Properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort

Parameters

  • props: (string) Property/Comma delimited list of properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.

Parameters

  • props: (Array) Properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.

Parameters

  • props: (string) Property/Comma delimited list of properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.
  • lookup: (Object) Look up object to use as values instead of the array values.

Parameters

  • props: (Array) Properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.
  • lookup: (Object) Look up object to use as values instead of the array values.

Parameters

  • props: (string) Property/Comma delimited list of properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.
  • lookup: (Object) Look up object to use as values instead of the array values.
  • options: (Object) Options to pass. Valid options are:
    i
    ignoreCase

Parameters

  • props: (Array) Properties to sort by. If the first character is '!', the sort order is reversed
  • rev: (Bool) Flag to reverse the sort
  • primer: (SortPrimer|null|undefined) Function to apply to values in the array.
  • lookup: (Object) Look up object to use as values instead of the array values.
  • options: (Object) Options to pass. Valid options are:
    i
    ignoreCase

toSet


Info: Array class extension to convert the array to a set

Return: (Set) returns a Set from the array Values

Parameters:

None

Overloads:

None


update


Info: Array class extension to update records in the array

Return: (Array)

Parameters:

  • condition: (WhereCondition) Query following find/where clause syntax
  • setClause: (MongoSet) Set clause used to update the records
  • options?: (UpdateOptions) Options to specify if mulit update and/or upsert

Overloads:

None


upsert


Info: Array class extension to upsert records to array

Return: (UpsertResult) returns the information for resulting operation.

Parameters:

  • records: (Array|T) Record(s) to use to insert/update array

Overloads:

Parameters

  • records: (Array|T) Records to use to insert/update array
  • callback: (UpsertIterator) Method to use to determine if the records are equal

Parameters

  • records: (Array|T) Records to use to insert/update array
  • prop: (string) Property to use as the primary key
  • callback?: (UpsertIterator) Method to use to determine if the records are equal

Class


Benchmarker


Info: Class used to measure the run time of code

Return: (IBenchmarker)

Parameters:

None

Overloads:

None


Cursor


Info: Cursor class to facilitate iteration

Return: (ICursor)

Parameters:

  • records: (Array) Array used to create the iterator to iterate each item

Overloads:

Parameters

  • records: (Object) Object used to create the iterator to iterate each property

OrderedList


Info: Collection class that filters out duplicate values and maintains an ordered list

Return: (IOrderedList)

Parameters:

None

Overloads:

Parameters

  • records?: (Array) Array used to create the initial items in the ordered list
  • sorter?: (SortIterator) Function for sorting logic

Queue


Info: Collection class that follows FIFO

Return: (IQueue)

Parameters:

  • records: (Array) Array used to create the iterator to iterate each item

Overloads:

None


ServerManager


Info: Class used to create a new context for HTTP server

Return: (void)

Parameters:

  • request: (HTTPRequest) HTTP request object provided by createServer
  • response: (HTTPResponse) HTTP response object provided by createServer

Overloads:

None


Set


Info: Collection class that filters out duplicate values

Return: (ISet<T, TResult>)

Parameters:

  • records: (Array) Array used to create the iterator to iterate each item

Overloads:

None

CLI


CLI


Info: CLI parser for arguments and simplem method to execute shell commands

Return: (CLI)

Parameters:

None

Overloads:

Parameters

  • options: (CLIOption[]) Array of options having properties option(required:command option ex: -c), type(data type returned using typeof, ex:string), description, required(default:false).

Control Flow


awaitable


Info: Makes a value awaitable via a Promise.

Return: (Promise)

Parameters:

  • value: (AwaitableValue) Value to make awaitable

Overloads:

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.

Parameters

  • func: (Function) Function to make awaitable
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.
  • returnIndex: (Integer) Index of callback argument.

syncroit


Info: Generator/Async based control flow to allow for more "syncronous" programing structure

Return: (Promise)

Parameters:

  • func: (GeneratorFunction|AsyncFunction) function to execute

Overloads:

None


yieldable


Info: Makes a value yieldable via a Promise.

Return: (Promise)

Parameters:

  • value: (YieldableValue) Value to make yieldable

Overloads:

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.

Parameters

  • func: (Function) Function to make yieldable
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.
  • returnIndex: (Integer) Index of callback argument.

Date


getDayOfYear


Info: Date class extension to retrieve the day of the year

Return: (Int)

Parameters:

None

Overloads:

None


getWeek


Info: Date class extension to retrieve the week number in the year

Return: (Int)

Parameters:

None

Overloads:

None


isValidDate


Info: Date class extension to check if the date is valid

Return: (Bool)

Parameters:

None

Overloads:

None

FS


access


Info: A promisified version of access. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


appendFile


Info: A promisified version of appendFile. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


chmod


Info: A promisified version of chmod. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


chown


Info: A promisified version of chown. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


close


Info: A promisified version of close. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


copyFile


Info: A promisified version of copyFile. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


fchmod


Info: A promisified version of fchmod. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


fchown


Info: A promisified version of fchown. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


fdatasync


Info: A promisified version of fdatasync. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


fstat


Info: A promisified version of fstat. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


fsync


Info: A promisified version of fsync. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


ftruncate


Info: A promisified version of ftruncate. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


futimes


Info: A promisified version of futimes. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


lchmod


Info: A promisified version of lchmod. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


lchown


Info: A promisified version of lchown. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


link


Info: A promisified version of link. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


lstat


Info: A promisified version of lstat. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


mkdir


Info: A promisified version of mkdir. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


mkdtemp


Info: A promisified version of mkdtemp. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


open


Info: A promisified version of open. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


read


Info: A promisified version of read. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


readFile


Info: A promisified version of readFile. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


readdir


Info: A promisified version of readdir. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


readlink


Info: A promisified version of readlink. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


realpath


Info: A promisified version of realpath. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


rename


Info: A promisified version of rename. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


rmdir


Info: A promisified version of rmdir. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


stat


Info: A promisified version of stat. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


symlink


Info: A promisified version of symlink. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


truncate


Info: A promisified version of truncate. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


unlink


Info: A promisified version of unlink. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


utimes


Info: A promisified version of utimes. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


writeFile


Info: A promisified version of writeFile. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None


write


Info: A promisified version of write. The arguments are the same as the native fs methods minus the callback.

Return: (any)

Parameters:

None

Overloads:

None

Function


emit


Info: Call the next function(s) in queue

Return: (Array)

Parameters:

  • event: (String) Event to trigger.
  • ...infinite: (any) any number of arguments can be passed and will be applied to listening functions as arguments.

Overloads:

None


next


Info: Call the next function(s) in queue

Return: (void)

Parameters:

  • ...infinite: (any) any number of arguments can be passed.

Overloads:

None


on


Info: Function listener to register events

Return: (Function)

Parameters:

  • event: (String) Event to listen on and invoked on emit
  • func: (Function) Function to call on emit

Overloads:

None

HTTP


ChromeVersion


Info: Get Chrome version

Return: (Float)

Parameters:

None

Overloads:

None


FirefoxVersion


Info: Get Firefox version

Return: (Float)

Parameters:

None

Overloads:

None


IEVersion


Info: Get Internet Explorer version

Return: (Float)

Parameters:

None

Overloads:

None


OperaVersion


Info: Get Opera version

Return: (Float)

Parameters:

None

Overloads:

None


SafariVersion


Info: Get Safari version

Return: (Float)

Parameters:

None

Overloads:

None


createServer


Info: Create http server, ability to run middleware, and define routes.

Return: (HTTP)

Parameters:

  • callback: (HTTPCallback) Function to callback when a request is received
  • createServer?: (HTTPOptions) Options for creating the server (ex: {createServer:require('http').createServer})

Overloads:

Parameters

  • options: (HTTPOptions) Function to callback when a request is received

echo


Info: Echo to buffer and use in response

Return: (void)

Parameters:

  • output: (String) Data to send in response

Overloads:

None


end


Info: Call the next function(s) in queue

Return: (void)

Parameters:

None

Overloads:

Parameters

  • status?: (Integer) HTTP status code.
  • output?: (String) output to send as response.
  • encoding?: (String) encoding for the response.

getSession


Info: Asynchronous retrieval of the session object when used in conjunction with createServer

Return: (Promise)

Parameters:

  • sid: (String) Session id of the session object to retrieve syncronously.
  • callback?: (SessionCallback) callback function to invoke once the session object is retrieved.

Overloads:

None


getSessionID


Info: Retrieve the session id when used in conjunction with createServer

Return: (String)

Parameters:

None

Overloads:

None


getSessionSync


Info: Syncronously retrieve the session object when used in conjunction with createServer

Return: (Session)

Parameters:

  • sid: (String) Session id of the session object to retrieve syncronously.

Overloads:

None


header


Info: Set Http Headers to send

Return: (void)

Parameters:

  • header: (Header) Http header.
  • code?: (Integer) Http response code.

Overloads:

None


isAmaya


Info: Check if browser is Amaya

Return: (Bool)

Parameters:

None

Overloads:

None


isAndroid


Info: Check if device is Android

Return: (Bool)

Parameters:

None

Overloads:

None


isBlackBerry


Info: Check if device is BlackBerry

Return: (Bool)

Parameters:

None

Overloads:

None


isChrome


Info: Check if browser is Chrome

Return: (Bool)

Parameters:

None

Overloads:

None


isFirefox


Info: Check if browser is Firefox

Return: (Bool)

Parameters:

None

Overloads:

None


isGecko


Info: Check if engine is Gecko

Return: (Bool)

Parameters:

None

Overloads:

None


isIE


Info: Check if browser is Internet Explorer

Return: (Bool)

Parameters:

None

Overloads:

None


isIE6


Info: Check if browser is Internet Explorer 6

Return: (Bool)

Parameters:

None

Overloads:

None


isIPad


Info: Check if device is iPad

Return: (Bool)

Parameters:

None

Overloads:

None


isIPhone


Info: Check if device is IPhone

Return: (Bool)

Parameters:

None

Overloads:

None


isIPod


Info: Check if device is IPod

Return: (Bool)

Parameters:

None

Overloads:

None


isKHTML


Info: Check if engine is KHTML

Return: (Bool)

Parameters:

None

Overloads:

None


isLinux


Info: Check if OS is Linux

Return: (Bool)

Parameters:

None

Overloads:

None


isMac


Info: Check if OS is Mac Based

Return: (Bool)

Parameters:

None

Overloads:

None


isMobile


Info: Check if the device is a Mobile device

Return: (Bool)

Parameters:

None

Overloads:

None


isOpera


Info: Check if browser is Opera

Return: (Bool)

Parameters:

None

Overloads:

None


isPalmOS


Info: Check if OS is PalmOS

Return: (Bool)

Parameters:

None

Overloads:

None


isPresto


Info: Check if engine is Presto

Return: (Bool)

Parameters:

None

Overloads:

None


isPrince


Info: Check if engine is Prince

Return: (Bool)

Parameters:

None

Overloads:

None


isSafari


Info: Check if browser is Safari

Return: (Bool)

Parameters:

None

Overloads:

None


isSymbian


Info: Check if OS is Symbian

Return: (Bool)

Parameters:

None

Overloads:

None


isTrident


Info: Check if engine is Trident

Return: (Bool)

Parameters:

None

Overloads:

None


isWebkit


Info: Check if engine is Webkit

Return: (Bool)

Parameters:

None

Overloads:

None


isWindows


Info: Check if OS is Windows

Return: (Bool)

Parameters:

None

Overloads:

None


isWindowsMobile


Info: Check if device is Windows Mobile

Return: (Bool)

Parameters:

None

Overloads:

None


send


Info: Recursively require the entire directory and returns an object containing the required modules.

Return: (void)

Parameters:

  • data: (Object) Object to send in response.

Overloads:

Parameters

  • status: (Integer) Status code for response.
  • data: (Object) Object to send in response.

varDump


Info: Dump of variables to response.

Return: (void)

Parameters:

  • ...infinite: (any) any number of arguments can be passed.

Overloads:

None


writeSession


Info: Writes session to filesystem to be retrieved later.

Return: (void)

Parameters:

None

Overloads:

None

JSON Parser


parseAdvanced


Info: JSON Parser that can handle types and refs

Return: (Object)

Parameters:

  • text: (String) A valid JSON string.
  • reviver?: (Reviver) A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
  • values?: (Object) Key/value pairs to be used to replace template variables defined in the json.

Overloads:

None


stringifyAdvanced


Info: JSON Parser that can handle types and refs

Return: (String)

Parameters:

  • json: (Object) A JavaScript value, usually an object or array, to be converted.
  • replacer?: (Replacer) A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
  • space?: (String|Integer) Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

Overloads:

None

Number


aboutEqualTo


Info: Number class extension to check if values are approximately equal

Return: (Bool)

Parameters:

  • compare: (Number) Number to compare
  • giveOrTake: (Number) Plus/minus value

Overloads:

None


contains


Info: Object class extension to check if value exists

Return: (Bool)

Parameters:

  • val: (ContainsValue|ContainsObjectIterator<T, TValue>) Value to check or custom function to determine validity

Overloads:

Parameters

  • val: (ContainsValue) Value to check
  • func: (ContainsIterator) Callback function used to do the comparison

Parameters

  • val: (ContainsValue) Value to check
  • func: (ComparisonOperator) String indicating logical operator ("$lt"|"$lte"|"$gt"|"$gte"|"$mod"|"$type")

Parameters

  • arr: (Array) Array of values to return first matching value

equals


Info: Object class extension to check if object values are equal

Return: (Bool)

Parameters:

  • compare: (any) Object to compare against
  • props?: (String[]) Array of property values to compare against

Overloads:

None


isEven


Info: Number class extension to check if number is even

Return: (Bool)

Parameters:

None

Overloads:

None


isOdd


Info: Number class extension to check if number is odd

Return: (Bool)

Parameters:

None

Overloads:

None

Object


addObjectPrototype


Info: Method to extend the Object Class

Return: (void)

Parameters:

  • name: (String) name of the method to add
  • fn: (Function) method implementation
  • override?: (Bool) if true, override the previously defined prototype

Overloads:

None


changes


Info: Object class extension to compare properties that have changed

Return: (Object)

Parameters:

  • compare: (any) Object to compare against

Overloads:

None


contains


Info: Object class extension to check if value exists

Return: (Bool)

Parameters:

  • val: (ContainsValue|ContainsObjectIterator<T, TValue>) Value to check or custom function to determine validity

Overloads:

Parameters

  • val: (ContainsValue) Value to check
  • func: (ContainsIterator) Callback function used to do the comparison

Parameters

  • val: (ContainsValue) Value to check
  • func: (ComparisonOperator) String indicating logical operator ("$lt"|"$lte"|"$gt"|"$gte"|"$mod"|"$type")

Parameters

  • arr: (Array) Array of values to return first matching value

copyObject


Info: Object class extension to copy an object excluding constructor

Return: (Object)

Parameters:

None

Overloads:

None


count


Info: Object class extension to count the properties in the object/elements in arrays/characters in strings.

Return: (Int)

Parameters:

None

Overloads:

Parameters

  • option: (WhereCondition) Query used in Array.where when counting elements in an Array

Parameters

  • option: (String) Word or phrase to count in the String

Parameters

  • option: (RegExp) Word or phrase pattern to count in the String

duplicate


Info: Object class extension to copy an object including constructor

Return: (Object)

Parameters:

  • recursive?: (Boolean) Flag to copy all child objects recursively

Overloads:

None


eachProperty


Info: Object class extension to loop through all properties where hasOwnValue is true.

Return: (Object)

Parameters:

  • callback: (EachIterator) Function to call for each property. Callback will have two arguments (the value of the object and the property name) passed

Overloads:

None


every


Info: Object class extension to check property values against a function

Return: (Bool)

Parameters:

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value

Overloads:

Parameters

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value
  • craydent_ctxObject: (any) Context for the callback function

equals


Info: Object class extension to check if object values are equal

Return: (Bool)

Parameters:

  • compare: (any) Object to compare against
  • props?: (String[]) Array of property values to compare against

Overloads:

None


getClass


Info: Object class extension to get the constructor name

Return: (String)

Parameters:

None

Overloads:

None


getKeys


Info: Object class extension to get the keys of the object

Return: (Array)

Parameters:

None

Overloads:

None


has


Info: Alias to Object.prototype.hasOwnProperty

Return: (Boolean)

Parameters:

  • property: (String) Property name to check

Overloads:

None


isArray


Info: Object class extension to check if object is an array

Return: (Bool)

Parameters:

None

Overloads:

None


isAsync


Info: Object class extension to check if object is a async function

Return: (Bool)

Parameters:

None

Overloads:

None


isBetween


Info: Object class extension to check if object is between lower and upper bounds

Return: (Bool)

Parameters:

  • lowerBound: (any) Lower bound comparison
  • upperBound: (any) Upper bound comparison
  • inclusive?: (Bool) Flag to include give bounds

Overloads:

None


isBoolean


Info: Object class extension to check if object is a boolean

Return: (Bool)

Parameters:

None

Overloads:

None


isDate


Info: Object class extension to check if object is a date

Return: (Bool)

Parameters:

None

Overloads:

None


isDomElement


Info: Object class extension to check if object is a DOM element

Return: (Bool)

Parameters:

None

Overloads:

None


isEmpty


Info: Object class extension to check if it is empty

Return: (Bool)

Parameters:

None

Overloads:

None


isError


Info: Object class extension to check if object is an error object

Return: (Bool)

Parameters:

None

Overloads:

None


isFloat


Info: Object class extension to check if object is a float

Return: (Bool)

Parameters:

None

Overloads:

None


isFunction


Info: Object class extension to check if object is a function

Return: (Bool)

Parameters:

None

Overloads:

None


isGenerator


Info: Object class extension to check if object is a generator function

Return: (Bool)

Parameters:

None

Overloads:

None


isGeolocation


Info: Object class extension to check if object is a geolocation

Return: (Bool)

Parameters:

None

Overloads:

None


isInt


Info: Object class extension to check if object is an integer

Return: (Bool)

Parameters:

None

Overloads:

None


isNullOrEmpty


Info: Object class extension to check if object is a null or empty (object with no props, empty string, etc)

Return: (Bool)

Parameters:

None

Overloads:

None


isNumber


Info: Object class extension to check if object is a number

Return: (Bool)

Parameters:

None

Overloads:

None


isObject


Info: Object class extension to check if object is an object

Return: (Bool)

Parameters:

None

Overloads:

None


isPromise


Info: Object class extension to check if object is a promise object

Return: (Bool)

Parameters:

None

Overloads:

None


isRegExp


Info: Object class extension to check if object is a RegExp

Return: (Bool)

Parameters:

None

Overloads:

None


isString


Info: Object class extension to check if object is a string

Return: (Bool)

Parameters:

None

Overloads:

None


isSubset


Info: Object class extension to check if item is a subset

Return: (Bool)

Parameters:

  • compare: (any) Superset to compare against
  • sharesAny: (Boolean) Flag to check if any property is shared

Overloads:

None


itemCount


Info: Object class extension to count the properties in item

Return: (Int)

Parameters:

None

Overloads:

None


keyOf


Info: Object class extension to get the key of the give value

Return: (String)

Parameters:

  • value: (any) Value to compare against

Overloads:

None


map


Info: Object class extension to apply method to every value

Return: (void)

Parameters:

  • callback: (ObjectIterator<T, TValue>) Callback to apply to each value
  • craydent_ctxObject?: (any) Context for the callback function

Overloads:

None


merge


Info: Object class extension to merge objects

Return: (Object)

Parameters:

  • secondary: (Object) Object to merge with
  • condition?: (MergeEnums|MergeOptions|MergeIterator) Flags to recurse, merge only shared value, clone, intersect etc

Overloads:

None


set


Info: Alias to setProperty; however, it can not be used as a protoype property.

Return: (Bool)

Parameters:

  • object: (Object) object to add the property to
  • path: (String) Path to nested property
  • value: (any) Value to set
  • delimiter?: (Char) Separator used to parse path

Overloads:

None


setProperty


Info: Object class extension to set nested properties creating necessary property paths

Return: (Bool)

Parameters:

  • path: (String) Path to nested property
  • value: (any) Value to set
  • delimiter?: (Char) Separator used to parse path

Overloads:

None


toStringAlt


Info: Object class extension for an alternate way to stringify object to formatted string

Return: (String)

Parameters:

  • delimiter?: (Char) Character to separate the property from the value
  • prefix?: (Char) Character to prefix the property name
  • urlEncode?: (Bool) Flag to url encode the property and value

Overloads:

None

RegExp


addFlags


Info: RegExp class extension to add flags to regex

Return: (RegExp)

Parameters:

  • flags: (String) Flags to add

Overloads:

None

String


acronymize


Info: String class extension to create an acronym from the given string

Return: (String)

Parameters:

  • capsOnly: (Boolean) Flag to indicate to use capital letters only.

Overloads:

Parameters

  • match: (RegExp) Pattern to match to qualify the Acronym.

Parameters

  • capsOnly: (Boolean) Flag to indicate to use capital letters only.
  • delimiter: (String|RegExp) Character or RegExp pattern that delimits the string.

Parameters

  • match: (RegExp) Pattern to match to qualify the Acronym.
  • delimiter: (String|RegExp) Character or RegExp pattern that delimits the string.

capitalize


Info: String class extension to capitalize parts of the string

Return: (String)

Parameters:

  • pos?: (Int|Int[]) Index of the string to capitalize
  • everyWord?: (Bool) Flag to capital every word

Overloads:

None


convertUTCDate


Info: String class extension to convert date string to UTC format

Return: (String)

Parameters:

  • delimiter: (String) Character that delimits the date string

Overloads:

None


count


Info: Object class extension to count the properties in the object/elements in arrays/characters in strings.

Return: (Int)

Parameters:

None

Overloads:

Parameters

  • option: (WhereCondition) Query used in Array.where when counting elements in an Array

Parameters

  • option: (String) Word or phrase to count in the String

Parameters

  • option: (RegExp) Word or phrase pattern to count in the String

cut


Info: String class extension to remove between the provided indexes

Return: (String)

Parameters:

  • start_index: (Integer) Start index to cut
  • end_index: (Integer) End index to cut
  • replacement?: (String) String to put in place of the cut

Overloads:

None


ellipsis


Info: String class extension to shorten by ellipsis

Return: (String)

Parameters:

  • before: (Int) Number of characters to use before using ellipsis
  • after?: (Int) Number of characters to use after the ellipsis

Overloads:

None


highlight


Info: String class extension to surround search words with the given tag(default span) and class (default chighlight)

Return: (String)

Parameters:

  • search: (String|RegExp) String or Regular expression to search
  • cssClass?: (String) Class to add for highlighting
  • tag?: (String) Tag to use to surround the search

Overloads:

None


indexOfAlt


Info: Array class extension to find index of a value based on a callback function & String class extension to find the index based on a regular expression

Return: (Integer)

Parameters:

  • value: (any) value to find
  • func: (ArrayIterator<T, TResult>) Callback function used to do the comparison

Overloads:

Parameters

  • regex: (RegExp) Regular expression to check value against
  • pos?: (Int) Index offset to start

ireplaceAll


Info: String class extension to replace all substrings ignoring case

Return: (String)

Parameters:

  • replace: (String|String[]) String or Array of strings to replace
  • subject: (String|String[]) String or Array of strings to replace with

Overloads:

None


ireplace_all


Info: String class extension to replace all substrings ignoring case

Return: (String)

Parameters:

  • replace: (String|String[]) String or Array of strings to replace
  • subject: (String|String[]) String or Array of strings to replace with

Overloads:

None


isBlank


Info: String class extension to check if the string is empty

Return: (Bool)

Parameters:

None

Overloads:

None


isCuid


Info: String class extension to check if the string is a cuid

Return: (Bool)

Parameters:

  • msFormat?: (Bool) use microsoft format if true

Overloads:

None


isValidEmail


Info: String class extension to check if string is a valid email

Return: (Bool)

Parameters:

None

Overloads:

None


lastIndexOfAlt


Info: String class extension to find the last index based on a regular expression

Return: (Int)

Parameters:

  • regex: (RegExp) Regular expression to check value against
  • pos?: (Int) Max index to go up to in the search

Overloads:

None


ltrim


Info: String class extension to remove characters from the beginning of the string

Return: (String)

Parameters:

  • character?: (Char[]) Character to remove

Overloads:

None


pluralize


Info: String class extension to do a best guess pluralization of the string

Return: (String)

Parameters:

None

Overloads:

None


replaceAll


Info: String class extension to replace all substrings (case sensitive)

Return: (String)

Parameters:

  • replace: (String|String[]) String or Array of strings to replace
  • subject: (String|String[]) String or Array of strings to replace with

Overloads:

None


replace_all


Info: String class extension to replace all substrings (case sensitive)

Return: (String)

Parameters:

  • replace: (String|String[]) String or Array of strings to replace
  • subject: (String|String[]) String or Array of strings to replace with

Overloads:

None


reverse


Info: String class extension to reverse the string

Return: (String)

Parameters:

None

Overloads:

None


rtrim


Info: String class extension to remove characters from the end of the string

Return: (String)

Parameters:

  • character?: (Char[]) Character to remove

Overloads:

None


sanitize


Info: String class extension to remove potential XSS threats

Return: (String)

Parameters:

None

Overloads:

None


singularize


Info: String class extension to do a best guess singularization of the string

Return: (String)

Parameters:

None

Overloads:

None


startItWith


Info: String class extension to guarantee the original string starts with the passed string

Return: (String)

Parameters:

  • starting: (String) String to start with

Overloads:

None


strip


Info: String class extension to remove characters from the beginning and end of the string

Return: (String)

Parameters:

  • character?: (Char[]) Character to remove

Overloads:

None


substringBetween


Info: String class extension to substring by character instead of using indexes

Return: (String)

Parameters:

  • start?: (Char) Character to use for the starting index (required if end is not passed)
  • end?: (Char) Character to use for the ending index (required if start is null or undefined)

Overloads:

None


substringEndAt


Info: String class extension to substring by character instead of using indexes

Return: (String)

Parameters:

  • end: (Char) Character to use for the ending index

Overloads:

None


substringStartFrom


Info: String class extension to substring by character instead of using indexes

Return: (String)

Parameters:

  • start: (Char) Character to use for the starting index

Overloads:

None


toCurrencyNotation


Info: String class extension to change number to use separater character

Return: (String)

Parameters:

  • separator?: (Char) Character to use as delimiter

Overloads:

None


toDateTime


Info: String class extension to convert string to datetime

Return: (Date|String)

Parameters:

  • options?: (DateTimeOptions) specs with optional properties:
    (Bool) gmt
    (Int) offset
    (String) format

Overloads:

None


toObject


Info: String class extension to convert to JSON

Return: (Object)

Parameters:

  • assignmentChar?: (Char) Character to use as assignment delimiter. Defaults to '&'.
  • delimiter?: (Char) Character to use as pair delimiter

Overloads:

None


trim


Info: String class extension to remove characters from the beginning and end of the string.

Return: (Bool)

Parameters:

  • character?: (Char[]) Character to remove in the String

Overloads:

None

TypeOf


isArray


Info: Object class extension to check if object is an array

Return: (Bool)

Parameters:

None

Overloads:

None


isAsync


Info: Object class extension to check if object is a async function

Return: (Bool)

Parameters:

None

Overloads:

None


isBetween


Info: Object class extension to check if object is between lower and upper bounds

Return: (Bool)

Parameters:

  • lowerBound: (any) Lower bound comparison
  • upperBound: (any) Upper bound comparison
  • inclusive?: (Bool) Flag to include give bounds

Overloads:

None


isBoolean


Info: Object class extension to check if object is a boolean

Return: (Bool)

Parameters:

None

Overloads:

None


isDate


Info: Object class extension to check if object is a date

Return: (Bool)

Parameters:

None

Overloads:

None


isDomElement


Info: Object class extension to check if object is a DOM element

Return: (Bool)

Parameters:

None

Overloads:

None


isEmpty


Info: Object class extension to check if it is empty

Return: (Bool)

Parameters:

None

Overloads:

None


isError


Info: Object class extension to check if object is an error object

Return: (Bool)

Parameters:

None

Overloads:

None


isFloat


Info: Object class extension to check if object is a float

Return: (Bool)

Parameters:

None

Overloads:

None


isFunction


Info: Object class extension to check if object is a function

Return: (Bool)

Parameters:

None

Overloads:

None


isGenerator


Info: Object class extension to check if object is a generator function

Return: (Bool)

Parameters:

None

Overloads:

None


isGeolocation


Info: Object class extension to check if object is a geolocation

Return: (Bool)

Parameters:

None

Overloads:

None


isInt


Info: Object class extension to check if object is an integer

Return: (Bool)

Parameters:

None

Overloads:

None


isNull


Info: Check if a value is Null

Return: (Bool|any)

Parameters:

  • value: (any) Value to check

Overloads:

Parameters

  • value: (any) Value to check
  • defaultValue: (any) Value to return if null

isNullOrEmpty


Info: Object class extension to check if object is a null or empty (object with no props, empty string, etc)

Return: (Bool)

Parameters:

None

Overloads:

None


isNumber


Info: Object class extension to check if object is a number

Return: (Bool)

Parameters:

None

Overloads:

None


isObject


Info: Object class extension to check if object is an object

Return: (Bool)

Parameters:

None

Overloads:

None


isPromise


Info: Object class extension to check if object is a promise object

Return: (Bool)

Parameters:

None

Overloads:

None


isRegExp


Info: Object class extension to check if object is a RegExp

Return: (Bool)

Parameters:

None

Overloads:

None


isString


Info: Object class extension to check if object is a string

Return: (Bool)

Parameters:

None

Overloads:

None

Utility


absolutePath


Info: Method to make retrieve the absolute path of the provided path

Return: (String)

Parameters:

  • path: (String) Path to convert to the absolute path

Overloads:

None


addObjectPrototype


Info: Method to extend the Object Class

Return: (void)

Parameters:

  • name: (String) name of the method to add
  • fn: (Function) method implementation
  • override?: (Bool) if true, override the previously defined prototype

Overloads:

None


ajax


Info: Method to make ajax calls

Return: (Promise)

Parameters:

  • url: (String) End point url
  • returnData?: (AjaxReturnType) Specifies which data to return when using Promise pattern

Overloads:

Parameters

  • params: (AjaxOptions) specs with common properties:
    (String) url
    (String) dataType
    (Mixed) hitch
    (Function[]) onerror
    (Function[])onsuccess
  • returnData?: (AjaxReturnType) Specifies which data to return when using Promise pattern

awaitable


Info: Makes a value awaitable via a Promise.

Return: (Promise)

Parameters:

  • value: (AwaitableValue) Value to make awaitable

Overloads:

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.

Parameters

  • func: (Function) Function to make awaitable
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make awaitable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.
  • returnIndex: (Integer) Index of callback argument.

clearCache


Info: Clear a module from the require cache.

Return: (Bool)

Parameters:

  • module?: (String) Single module to remove.

Overloads:

None


clusterit


Info: Enable clustering

Return: (void)

Parameters:

  • callback: (ClusterCallback) Method to call for Workers. Callback is passed the cluster object as an argument.

Overloads:

None


cout


Info: Log to console when DEBUG_MODE is true and when the console is available

Return: (void)

Parameters:

  • ...infinite: (any) any number of arguments can be passed.

Overloads:

None


cuid


Info: Creates a Craydent/Global Unique Identifier

Return: (String)

Parameters:

  • msFormat?: (Bool) use microsoft format if true

Overloads:

None


exclude


Info: Exclude prototyping

Return: (void)

Parameters:

  • list: (String[]) Array of strings in containing the property to exclude from prototyping.

Overloads:

None


foo


Info: Place holder function for a blank function

Return: (void)

Parameters:

None

Overloads:

None


include


Info: Require without erroring when module does not exist.

Return: (any|false)

Parameters:

  • path: (String) Module or Path to module.
  • refresh?: (Bool) Flag to clear cache for the specific include.

Overloads:

None


isNull


Info: Check if a value is Null

Return: (Bool|any)

Parameters:

  • value: (any) Value to check

Overloads:

Parameters

  • value: (any) Value to check
  • defaultValue: (any) Value to return if null

logit


Info: Log to console when DEBUG_MODE is true and when the console is available

Return: (void)

Parameters:

  • ...infinite: (any) any number of arguments can be passed.

Overloads:

None


md5


Info: MD5 encode a string.

Return: (String)

Parameters:

  • str: (String) String to encode.

Overloads:

None


mkdirRecursive


Info: Recursively create folders.

Return: (void)

Parameters:

  • path: (String) Path to create.
  • callback: (Function) Method to call when directories are created (Gets passed error object as an argument and is null if there were no errors).

Overloads:

None


namespace


Info: Adds the class to a namespace instead of the global space

Return: (void)

Parameters:

  • name: (String) Name of the namespace to add to.
  • clazz: (Class) Class to add to the given namespace
  • fn: (Function) Method to call after the class has been added to the namespace

Overloads:

None


noop


Info: Place holder function for a blank function

Return: (void)

Parameters:

None

Overloads:

None


now


Info: Get the DateTime of now

Return: (Date|String)

Parameters:

  • format?: (String) Format syntax to return formatted string of now

Overloads:

None


parseBoolean


Info: Try to parse value to a Boolean (0, 1, '0', and '1' are valid unless strict is set to true).

Return: (Bool|undefined)

Parameters:

  • value: (any) value to parse as boolean.
  • strict?: (Boolean) Disable parsing of 0, 1, '0', and '1'.

Overloads:

None


parseRaw


Info: Creates an evaluable string

Return: (String)

Parameters:

  • value: (any) value to parse
  • skipQuotes?: (Bool) Flag to skip quotes for strings
  • saveCircular?: (Bool) Flag to save circular references

Overloads:

None


rand


Info: Create a random number between two numbers

Return: (Number)

Parameters:

  • num?1: (Number) Lower bound
  • num2?: (Number) Upper bound
  • inclusive?: (Bool) Flag to include the given numbers

Overloads:

None


requireDirectory


Info: Recursively require the entire directory and returns an object containing the required modules.

Return: (Promise|any)

Parameters:

  • path: (String) Path to directory.
  • options?: (Char) 'r' Flag to use to indicate recursively require, (Char) 's' Flag to indicate use syncronous instead of Promise Pattern

Overloads:

None


runFuncArray


Info: Executes array of methods

Return: (Bool)

Parameters:

  • funcs: (Function[]) Array of methods to execute
  • args: (any[]) Array of arguments to be passed to each method

Overloads:

None


suid


Info: Creates a short Craydent/Global Unique Identifier

Return: (String)

Parameters:

  • length?: (Integer) Custom length of the short unique identifier. Default is 10.

Overloads:

None


syncroit


Info: Generator/Async based control flow to allow for more "syncronous" programing structure

Return: (Promise)

Parameters:

  • func: (GeneratorFunction|AsyncFunction) function to execute

Overloads:

None


tryEval


Info: Evaluates an expression without throwing an error

Return: (any)

Parameters:

  • expression: (any) Expression to evaluate
  • evaluator?: (EvaluatorMethod) Method to use to evaluate the expression

Overloads:

None


wait


Info: Stops execution until the condition is satisfied

Return: (void)

Parameters:

  • condition: (Code) Condition equivalent to js true to resume execution

Overloads:

None


yieldable


Info: Makes a value yieldable via a Promise.

Return: (Promise)

Parameters:

  • value: (YieldableValue) Value to make yieldable

Overloads:

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.

Parameters

  • func: (Function) Function to make yieldable
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.

Parameters

  • func: (Function) Function to make yieldable
  • context: (any) Context to use to execute func.
  • callbackIndex: (Integer) Index of callback argument.
  • returnIndex: (Integer) Index of callback argument.

XML to JSON


xmlToJson


Info: Converts XML to JSON

Return: (Object)

Parameters:

  • xml: (String|XMLDocument) XML string or XML DOM
  • ignoreAttributes?: (Bool) Flag to ignore attributes

Overloads:

None

Download