Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace default

Index

Functions

assign

  • assign<T>(obj: any, ...args: any[]): T
  • Uses Object.assign if available or falls back to polyfill.

    Type parameters

    • T

    Parameters

    • obj: any

      object to assign.

    • Rest ...args: any[]

      additional source object.

    Returns T

camelcase

  • camelcase(val: string): string
  • Camelcase Converts string to camelcase.

    Parameters

    • val: string

      the value to be transformed.

    Returns string

capitalize

  • capitalize(val: string): string
  • Capitalize Converts string to capitalize.

    Parameters

    • val: string

      the value to be transformed.

    Returns string

castType

  • castType<T>(val: any, type: any, def?: any): T
  • Cast Type Attempts to cast to specified type.

    Type parameters

    • T

    Parameters

    • val: any

      the value to be cast.

    • type: any

      the type to cast to.

    • Optional def: any

      optional default value to return on null.

    Returns T

clone

  • clone<T>(obj: any, json?: boolean): T
  • Clone Performs deep cloning of objects.

    Type parameters

    • T

    Parameters

    • obj: any

      object to be cloned.

    • Optional json: boolean

      performs quick shallow clone using JSON.

    Returns T

contains

  • contains(arr: string | any[], value: any, transform?: Transform): boolean
  • Contains Tests if array contains value.

    Parameters

    • arr: string | any[]

      the array to be inspected.

    • value: any

      the value to check if is contained in array.

    • Optional transform: Transform

    Returns boolean

containsAny

  • containsAny(arr: string | any[], compare: string | any[], transform?: Transform): boolean
  • Contains Any Tests array check if contains value.

    Parameters

    • arr: string | any[]

      the array to be inspected.

    • compare: string | any[]

      array of values to compare.

    • Optional transform: Transform

    Returns boolean

create

  • create<T>(obj?: any): any
  • Create is a convenience method that simply calls Object.create(). If no object is passed creates using null.

    Type parameters

    • T

    Parameters

    • Optional obj: any

      optional object to use with Object.create.

    Returns any

decamelcase

  • decamelcase(val: string, separator?: string): string
  • Decamelcase converts a camelcase string to --some-flag.

    Parameters

    • val: string

      the value to de-camelize.

    • separator: string = '-'

      the separator char once decamelized.

    Returns string

del

  • del<T>(obj: any, key: string | string[], immutable?: boolean): T
  • Del Removes a property within the supplied object.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to inspect.

    • key: string | string[]

      the dot notated key or array of keys.

    • Optional immutable: boolean

      when true original object NOT mutated.

    Returns T

duplicates

  • duplicates(arr: any[], value: any, breakable?: boolean): number
  • Duplicates Counts the number of duplicates in an array.

    Parameters

    • arr: any[]

      the array to check for duplicates.

    • value: any

      the value to match.

    • Optional breakable: boolean

      when true allows breaking at first duplicate.

    Returns number

extend

  • extend<T>(obj: any, ...args: any[]): T
  • extend<T>(shallow: boolean, obj: any, ...args: any[]): T
  • Extend properties between target/source objects. This is NOT a deep copy.

    NOTE: use Object.assign if available!!

    example

    extend({ name: 'Bob', active: true }, { active: undefined })

    Type parameters

    • T

    Parameters

    • obj: any

      primary target object.

    • Rest ...args: any[]

      additional source objects to merge with target.

    Returns T

  • Extend properties between target/source objects. This is NOT a deep copy.

    NOTE: use Object.assign if available!!

    example

    extend(true, { name: 'Bob' }, { nested: { key: 'value' } })

    Type parameters

    • T

    Parameters

    • shallow: boolean

      when true only extends top level.

    • obj: any

      primary target object.

    • Rest ...args: any[]

      additional source objects to merge with target.

    Returns T

first

  • first<T>(arr: any[]): T
  • First Simple method to get first element just a little less typing.

    Type parameters

    • T

    Parameters

    • arr: any[]

      the array to get first element from.

    Returns T

flatten

  • flatten<T>(...arr: any[]): T[]
  • Flatten Takes multiple arrays and flattens to single array. NOTE: this will NOT work for empty nested arrays but will work for 90 plus % of cases.

    Type parameters

    • T

    Parameters

    • Rest ...arr: any[]

    Returns T[]

fromEpoch

  • fromEpoch(val: number, def?: Date): Date
  • From Epoch Converts to a Date from an epoch.

    Parameters

    • val: number

      the epoch value to convert to date.

    • Optional def: Date

    Returns Date

fromJSON

  • fromJSON<T>(val: string, def?: T): T
  • From JSON Simple wrapper to parse json.

    alias

    tryParseJSON

    Type parameters

    • T

    Parameters

    • val: string

      the string to be parsed.

    • Optional def: T

      a default fallback value on failed parse.

    Returns T

get

  • get<T>(obj: any, key: string | string[], def?: any): T
  • Get Gets a property within the supplied object.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to inspect.

    • key: string | string[]

      the dot notated key or array of keys.

    • Optional def: any

      a default value to set if not exists.

    Returns T

getType

  • getType(val: any, strict?: boolean | string, def?: string): any
  • Get Type Gets the type of the provided value.

    Value Type Strict

    {} literal object true boolean boolean 'true' boolean string 25 integer number 25.5 float number new Date() date date '01/01/2017' date string RegExp regexp regexp '/^test/g' regexp string null null null function() {} function function [] array array 'some string' string string

    Parameters

    • val: any

      the object to get type from.

    • Optional strict: boolean | string

      when true returns the strict type see examples.

    • Optional def: string

      the optional string name for unknown types.

    Returns any

has

  • has(obj: any, key: string | string[]): boolean
  • Has Checks if property exists in object.

    Parameters

    • obj: any

      the object to be inpsected.

    • key: string | string[]

      the key to be found.

    Returns boolean

includes

  • includes(arr: string | any[], value: any, transform?: Transform): boolean
  • Includes Tests if array contains value.

    Parameters

    • arr: string | any[]

      the array to be inspected.

    • value: any

      the value to check if is contained in array.

    • Optional transform: Transform

    Returns boolean

includesAny

  • includesAny(arr: string | any[], compare: string | any[], transform?: Transform): boolean
  • Includes Any Tests if array contains any value.

    Parameters

    • arr: string | any[]

      the array to be inspected.

    • compare: string | any[]

      the array to compare.

    • Optional transform: Transform

    Returns boolean

isArray

  • isArray(val: any): boolean
  • Is Array Check if value is an array.

    Parameters

    • val: any

      the value to test if is array.

    Returns boolean

isBoolean

  • isBoolean(val: any): boolean

isBrowser

  • isBrowser(override?: string): boolean
  • Is Browser Checks if script is running in browser.

    Parameters

    • Optional override: string

      an optional key to inspect on process.env.

    Returns boolean

isBuffer

  • isBuffer(val: any): boolean
  • Is Buffer Checks if value is an instanceof Buffer.

    Parameters

    • val: any

      the value to inspect as Buffer.

    Returns boolean

isDate

  • isDate(val: any): boolean
  • Is Date Inspects if is Date, parses date string when parse flag is set to true.

    Parameters

    • val: any

      the value to inspect/test if is Date.

    Returns boolean

isDebug

  • isDebug(debugging?: boolean): any
  • Indicates if app is in debug mode.

    Parameters

    • Optional debugging: boolean

      a manual flag to denote debugging.

    Returns any

isDirectory

  • isDirectory(val: any): boolean
  • Is Directory Checks if value is path to directory in filesytem. NODE ONLY!

    Parameters

    • val: any

      the value to inspect as file.

    Returns boolean

isDocker

  • isDocker(): boolean

isEmpty

  • isEmpty(val: any): boolean
  • Is Empty Test if value provided is empty. Note 0 would be empty.

    Parameters

    • val: any

      value to be inspected.

    Returns boolean

isEqual

  • isEqual(val: any, comp: any, loose?: boolean): boolean
  • Is Equal Tests if two values are equal. Does not support "deep equal".

    Parameters

    • val: any

      the value to be compared.

    • comp: any

      the comparer value.

    • Optional loose: boolean

      when true == is used instead of ===.

    Returns boolean

isError

  • isError(val: any, prop?: string): boolean
  • Is Error Checks if value is an error. Allows custom error property which can be useful in certain scenarios to flag an object as an error.

    Parameters

    • val: any

      the value/object to be inspected.

    • Optional prop: string

      a custom property to check if exists indicating is error.

    Returns boolean

isFile

  • isFile(val: any): boolean
  • Is File Checks if value is path to file in filesytem. NODE ONLY!

    Parameters

    • val: any

      the value to inspect as file.

    Returns boolean

isFloat

  • isFloat(val: any): boolean
  • Is Float Checks if number is float.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isFunction

  • isFunction(val: any): boolean
  • Is Function Check if object provided is function.

    Parameters

    • val: any

      test object provided is function.

    Returns boolean

isInfinite

  • isInfinite(val: any): boolean
  • Is Infinite Checks if value is Infinity.

    Parameters

    • val: any

      the value to test if infinite.

    Returns boolean

isInspect

  • isInspect(inspecting?: boolean): any
  • Indicates if app is started with --inspect flag.

    Parameters

    • Optional inspecting: boolean

      a manual flag to denote inspecting.

    Returns any

isInteger

  • isInteger(val: any): boolean
  • Is Integer Checks if numbers is an integer.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isMoment

  • isMoment(val: any): boolean
  • Is Moment Inspects object to detect if is moment.

    Parameters

    • val: any

      the object to be inspected.

    Returns boolean

isNode

  • isNode(): boolean

isNull

  • isNull(val: any): boolean
  • Is Null Checks if value is null.

    Parameters

    • val: any

      the object to inspect for null.

    Returns boolean

isNumber

  • isNumber(val: any): boolean
  • Check if value provided is number.

    Parameters

    • val: any

      the value to be tested.

    Returns boolean

isObject

  • isObject(val: any): boolean
  • Is Object Checks if value is an object.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isPlainObject

  • isPlainObject(val: any): boolean
  • Is Plain Object Inspects value checking if is object literal.

    Parameters

    • val: any

      the value to inspect

    Returns boolean

isPromise

  • isPromise(val: any, name?: string): boolean
  • Is Promise Checks if value is a Promise.

    Parameters

    • val: any

      the value to inspect.

    • Optional name: string

      optional constructor name for promise defaults to Promise.

    Returns boolean

isRegExp

  • isRegExp(val: any): boolean
  • Is Reg Expression Tests if object is regular expression.

    Parameters

    • val: any

      the value to inspect as RegExp.

    Returns boolean

isRoot

  • isRoot(): boolean

isString

  • isString(val: any): boolean
  • Is String Inspect value provided testing if is string.

    Parameters

    • val: any

      the value to be tested.

    Returns boolean

isSymbol

  • isSymbol(val: any): boolean
  • Is Symbol Checks if value is of type Symbol.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isTruthy

  • isTruthy(val: any): boolean
  • Is Truthy Checks if value is truthy e.g. not false, 0, null, undefined, empty.

    Strings such as 'false', '0', '-' or 'no' will return true. If NOT desired call toBoolean on the value then pass to isTruthy.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isType

  • isType(val: any, Type: any): boolean
  • Is Type Tests if object is instanceof provided Type.

    Parameters

    • val: any

      the value to inspect.

    • Type: any

      the instance type to match.

    Returns boolean

isUndefined

  • isUndefined(val: any): boolean
  • Is Undefined Tests if value is undefined.

    Parameters

    • val: any

      the value to inspect

    Returns boolean

isUndefinedOrNull

  • isUndefinedOrNull(val: any): boolean
  • Checks if is undefined or null value.

    Parameters

    • val: any

      the value to inspect.

    Returns boolean

isUnique

  • isUnique(arr: any[], value: any): boolean
  • Is Unique Tests if the value is unique in the collection.

    Parameters

    • arr: any[]

      the array to be inspected.

    • value: any

      the value to be matched.

    Returns boolean

isValue

  • isValue(val?: any): boolean
  • Is Value Ensures is of some value, e.g. not null not undefined not isNaN & not Infinite.

    Parameters

    • Optional val: any

      the value to inspect.

    Returns boolean

isWindows

  • isWindows(): boolean
  • Is Windows Returns boolean if node is running in Windows.

    Returns boolean

keys

  • keys(obj: IMap<any>): string[]
  • Keys Takes an object then returns keys in array.

    Parameters

    • obj: IMap<any>

      the object to parse keys.

    Returns string[]

last

  • last<T>(arr: any[]): T
  • Last Simple method to get last element.

    Type parameters

    • T

    Parameters

    • arr: any[]

      the array to get last element.

    Returns T

lowercase

  • lowercase(val: string): string
  • Lowercase Converts string to lowercase.

    Parameters

    • val: string

      the value to be transformed.

    Returns string

noop

  • noop(...args: any[]): void

noopIf

  • noopIf(fn?: any): any
  • Noop If If function provided return no operation funciton.

    Parameters

    • Optional fn: any

      optional function.

    Returns any

omit

  • omit<T>(str: string, chars: string | string[]): T
  • omit<T>(arr: any[], elements: any | any[]): T
  • omit<T>(obj: Record<string, unknown>, props: string | string[], immutable?: boolean): T
  • Omits characters or words from strings, removes trailing whitespace before punctuation and also double spaces.

    Type parameters

    • T

    Parameters

    • str: string

      the string to omit chars from.

    • chars: string | string[]

      the characters or words to be omitted.

    Returns T

  • Omits a value from an array.

    Type parameters

    • T

    Parameters

    • arr: any[]

      the array to be filtered.

    • elements: any | any[]

      the elements to be removed.

    Returns T

  • Omits properties from an object, supports dot notation nested removals.

    example

    .omit({ name: 'bob', blogs: { blog1: 'Title }}, ['blogs.blog1']);

    Type parameters

    • T

    Parameters

    • obj: Record<string, unknown>

      the object to remove properties from.

    • props: string | string[]

      the properties to be removed.

    • Optional immutable: boolean

      when true object is first cloned to not mutated source.

    Returns T

orderBy

  • Orders arrays of objects by property, falls back to .sort() if not fields are specified.

    example

    const arr = [{ name: 'bob', age: 30 }, { name: 'john', age: 22 }]; chek.orderBy(arr, 'age', 'name'); check.orderBy(arr, { key: 'name', order: 'desc', primer: primerFunc }); chek.orderBy(arr, 'age', 'name', primerFunc);

    Order property: asc, ascending, desc, descending, 1, -1, 0 Primer property: a method that accepts single value and is run as a preprocessor before sorting.

    Type parameters

    • T

    Parameters

    • arr: any[]

      the collection to be sorted.

    • Rest ...fields: IComparatorField[]

      an array of field names or comparator field objects.

    Returns T[]

padLeft

  • padLeft(val: string, len: number, offset?: number | string, char?: string): string
  • Pad Left Pads a string on the left.

    Parameters

    • val: string

      the string to be padded.

    • len: number

      the length to pad.

    • Optional offset: number | string

      an offset number or string to be counted.

    • Optional char: string

      the character to pad with.

    Returns string

padRight

  • padRight(val: string, len: number, offset?: number | string, char?: string): string
  • Pad Right Pads a string to the right.

    Parameters

    • val: string

      the string to be padded.

    • len: number

      the length to pad.

    • Optional offset: number | string

      an offset value to add.

    • Optional char: string

      the character to pad with.

    Returns string

padValues

  • padValues(arr: string[], strategy?: string, offset?: number | string, char?: string): string[]
  • Pad Values

    Parameters

    • arr: string[]
    • Optional strategy: string
    • Optional offset: number | string

      an offset value to add.

    • Optional char: string

      the character to pad with.

    Returns string[]

pick

  • pick<T>(obj: any, props: string | string[]): T
  • Picks values from object by property name.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to pick from.

    • props: string | string[]

      the properties to be picked.

    Returns T

pop

  • pop(arr: any[]): { array: any[]; val: any }
  • Pop Pops/removes last element in array.

    Parameters

    • arr: any[]

      the array to pop value from.

    Returns { array: any[]; val: any }

    • array: any[]
    • val: any

push

  • push(arr: any[], ...args: any[]): { array: any[]; val: number }
  • Push Non mutating way to push to an array.

    Parameters

    • arr: any[]

      the array to push items to.

    • Rest ...args: any[]

      the items to be added.

    Returns { array: any[]; val: number }

    • array: any[]
    • val: number

put

  • put<T>(obj: any, key: string | string[], val: any, immutable?: boolean): T
  • Put a value to key. If the value is not currently an array it converts.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to push value to.

    • key: string | string[]

      the key or array of keys to be joined as dot notation.

    • val: any

      the value to be pushed.

    • Optional immutable: boolean

      when true update in immutable mode.

    Returns T

reverse

  • reverse<T>(obj: any): T
  • Reverse Reverses arrays, strings or objects. Only numbers, strings or booleans are supported when reverse mapping objects.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to reverse.

    Returns T

set

  • set<T>(obj: any, key: string | string[], val: any, immutable?: boolean): T
  • Set Sets a value on an object using dot notation or url path.

    todo

    need to refactor this method.

    Type parameters

    • T

    Parameters

    • obj: any

      the object to set the value on.

    • key: string | string[]

      the property used for setting the value.

    • val: any
    • Optional immutable: boolean

      when true the original object is NOT mutated.

    Returns T

shift

  • shift(arr: any[]): { array: any[]; val: any }
  • Shift Shifts/removes first element in array. As this is a non-mutating method returns an object with new array and shifted value.

    Parameters

    • arr: any[]

      the array to shift value from.

    Returns { array: any[]; val: any }

    • array: any[]
    • val: any

slugify

  • slugify(val: string): string
  • Slugify Slugifies string.

    Parameters

    • val: string

      the value to be transformed.

    Returns string

splice

  • splice(arr: any[], start?: number, remove?: number, ...items: any[]): { array: any[]; val: any[] }
  • Splice Non mutating way of splicing an array.

    Parameters

    • arr: any[]

      the array to be spliced.

    • Optional start: number

      the starting index (default: 0)

    • Optional remove: number

      the count to be spliced (default: 1)

    • Rest ...items: any[]

      additional items to be concatenated.

    Returns { array: any[]; val: any[] }

    • array: any[]
    • val: any[]

split

  • split(val: string | string[], chars?: string | string[] | boolean): string[]
  • Split Splits a string at character. Default possible chars to match: ['/', '.', ',', ';', '|'] Note accepts string[] to simplify external methods that call split In this case will simply return the array.

    Parameters

    • val: string | string[]

      the string to be split.

    • Optional chars: string | string[] | boolean

    Returns string[]

titlecase

  • titlecase(val: string, conjunctions?: boolean): string

toArray

  • toArray<T>(val: any, def?: T[]): T[]
  • toArray<T>(val: any, id: string, def?: T[]): T[]
  • To Array Converts value to array with optional default value.

    Type parameters

    • T

    Parameters

    • val: any

      the value to convert to array.

    • Optional def: T[]

      optional default value on null or error.

    Returns T[]

  • Converts object to array where a key will be inserted into the object as $id: 'your defined id'.

    Type parameters

    • T

    Parameters

    • val: any

      the value to convert to array.

    • id: string

      optional id for converting object to an array.

    • Optional def: T[]

      optional default value on null or error.

    Returns T[]

toBoolean

  • toBoolean(val: any, def?: boolean): boolean
  • To Boolean Converts value if not boolean to boolean. Will convert 'true', '1', 'yes' or '+' to true.

    Parameters

    • val: any

      the value to inspect.

    • Optional def: boolean

      optional default value on null.

    Returns boolean

toDate

  • toDate(val: any, format?: string | IDateFormat | Date, def?: Date): Date
  • To Date Converts value to date using Date.parse when string. Optionally you can pass a format object containing Intl.DateFormatOptions and locales. You may also pass the timezone ONLY as a string. In this case locale en-US is assumed.

    Parameters

    • val: any

      the value to be converted to date.

    • Optional format: string | IDateFormat | Date

      date locale format options.

    • Optional def: Date

      a default date when null.

    Returns Date

toDefault

  • toDefault(val: any, def?: any): any
  • To Default Returns a default value when provided if primary value is null or undefined. If neither then null is returned.

    Parameters

    • val: any

      the value to return if defined.

    • Optional def: any

      an optional default value to be returned.

    Returns any

toEpoch

  • toEpoch(val: Date, def?: number): number
  • To Epoch Converts a Date type to an epoch.

    Parameters

    • val: Date

      the date value to convert.

    • Optional def: number

      optional default value when null.

    Returns number

toFloat

  • toFloat(val: any, def?: number): number
  • To Float Converts value to a float.

    Parameters

    • val: any

      the value to convert to float.

    • Optional def: number

    Returns number

toInteger

  • toInteger(val: any, def?: number): number
  • To Integer Convert value to integer.

    Parameters

    • val: any

      the value to convert to integer.

    • Optional def: number

      optional default value on null or error.

    Returns number

toJSON

  • toJSON(obj: any, pretty?: number | boolean | string, def?: string): string
  • To JSON Simple wrapper to strinigy using JSON.

    Parameters

    • obj: any

      the object to be stringified.

    • Optional pretty: number | boolean | string

      an integer or true for tabs in JSON.

    • Optional def: string

      optional default value on null.

    Returns string

toMap

  • toMap<T>(val: any, id?: string | IMap<any>, def?: IMap<any>): T
  • To Map Converts arrays, strings, to an object literal.

    example

    Array: ['one', 'two', 'three'] Maps To: { 0: 'one', 1: 'two', 2: 'three' } String: 'Star Wars' Maps To: { 0: 'Star Wars' } String: 'Star Wars, Star Trek' Maps To { 0: 'Star Wars', 1: 'Star Trek' } Array: [{ id: '123', name: 'Joe' }] Maps To: { 123: { name: 'Joe' }} Array: [{ name: 'Joe' }, { name: 'Amy' }] Maps To: { 0: { name: 'Joe' }, 2: { name: 'Amy' }}

    NOTE: mixed content arrays not supported.

    Type parameters

    • T

    Parameters

    • val: any

      the value to be mapped.

    • Optional id: string | IMap<any>

      optional id key when iterating array of objects.

    • Optional def: IMap<any>

      optional default value on null or error.

    Returns T

toNested

  • toNested<T>(val: IMap<any>, def?: IMap<any>): T
  • To Nested Takes an object that was flattened by toUnnested and re-nests it.

    Type parameters

    • T

    Parameters

    • val: IMap<any>

      the flattened object to be nested.

    • Optional def: IMap<any>

    Returns T

toNumber

  • toNumber(val: any, def?: number): number
  • To Number Converts value to number.

    Parameters

    • val: any

      the value to convert to number.

    • Optional def: number

      optional default value on null.

    Returns number

toRegExp

  • toRegExp(val: any, def?: RegExp): any
  • To Regular Expression Attempts to convert to a regular expression from a string.

    Parameters

    • val: any

      the value to convert to RegExp.

    • Optional def: RegExp

      optional express as default on null.

    Returns any

Const toStr

  • toStr(): string

toString

  • toString(val: any, def?: string): string
  • To String When not null or undefined calls to string method on object.

    Parameters

    • val: any

      the value to convert to string.

    • Optional def: string

      optional default value on null.

    Returns string

toUnnested

  • toUnnested<T>(obj: IMap<any>, prefix?: boolean | IMap<any>, def?: IMap<any>): IMap<T>
  • To Unnested Takes a nested object and flattens it to a single level safely. To disable key prefixing set prefix to false.

    Type parameters

    • T

    Parameters

    • obj: IMap<any>
    • Optional prefix: boolean | IMap<any>

      when NOT false parent key is prefixed to children.

    • Optional def: IMap<any>

      optional default value on null.

    Returns IMap<T>

toWindow

  • toWindow(key: any, val?: any, exclude?: string | string[]): void
  • To Window Adds key to window object if is browser.

    Parameters

    • key: any

      the key or object to add to the window object.

    • Optional val: any

      the corresponding value to add to window object.

    • Optional exclude: string | string[]

      string or array of keys to exclude.

    Returns void

tryRequire

  • tryRequire(name: string, def?: any, isRoot?: boolean): any
  • Try Require Tries to require a module returns null if cannot require or empty object.

    Parameters

    • name: string

      the name of module to try and require.

    • Optional def: any

      optional default value on null.

    • Optional isRoot: boolean

      used internally by tryRootRequire to require root modules.

    Returns any

tryRootRequire

  • tryRootRequire(name: string, def?: any): any
  • Try Root Require Tries to require module relative from root module.

    Parameters

    • name: string

      the name of the module to try and require.

    • Optional def: any

      the default value if null.

    Returns any

tryWrap

  • tryWrap(fn: (...args: any[]) => any, ...args: any[]): (def?: any) => any
  • Try Wrap Generic helper for calling try catch on a method. If a default method is provided it will return in on error otherwise it will return null.

    example

    function func(val: any) { return isString(val); } const result = tryWrap(func)();

    With params tryWrap(JSON.stringify, { name: 'Adele', age: 30 }, null, 2)()

    With default tryWrap(Number, '30')(35); Where '35' is the default value on error.

    Parameters

    • fn: (...args: any[]) => any

      the parse method to be called in try/parse block.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Rest ...args: any[]

      arguments to pass to above method.

    Returns (def?: any) => any

      • (def?: any): any
      • Parameters

        • Optional def: any

        Returns any

unshift

  • Unshift Unshifts a value to an array in a non mutable way.

    Parameters

    • arr: any[]

      the array to be unshifted.

    • Rest ...items: any[]

    Returns IArrayResult

uppercase

  • uppercase(val: string): string
  • Uppercase Converts string to uppercase.

    Parameters

    • val: string

      the value to be transformed.

    Returns string

uuid

  • uuid(): string

Generated using TypeDoc