Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utilities"

Index

Variables

Const fnRegex

fnRegex: RegExp = /^[\"|\'](.*)[\"|\']$/gmi

global

global: any

Const isAndroid

isAndroid: boolean = /Android/.test(ua)

Const isMSBrowser

isMSBrowser: boolean = ua.length === 0 ? false : ua.indexOf("MSIE ") > 0 || ua.indexOf("Trident/") > 0 || ua.indexOf("Edge/") > 0

Const isSafari

isSafari: boolean = ua.length === 0 ? false : (/^((?!chrome|android).)*safari/i.test(ua)) || (/iPad|iPhone|iPod/.test(ua) && !window["MSStream"])

Const objectPathCache

objectPathCache: object

Type declaration

  • [pathQuery: string]: string[]

Const setFast

setFast: (Anonymous function) = typeof Promise !== "undefined" ? (...args: any[]) => {Promise.resolve().then(() => {fastApply(args);})} : (...args: any[]) => {setTimeout(() => {fastApply(args);}, 0);}

Const ua

ua: string = typeof window === "undefined" ? "" : (navigator.userAgent || "")

Functions

Const adapterFilters

  • Parameters

    Returns object

    • addIndexValue: function
      • addIndexValue(table: string, indexName: string, key: any, value: any, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • key: any
        • value: any
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • connect: function
      • connect(id: string, complete: function, error: function): void
      • Parameters

        • id: string
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • createIndex: function
      • createIndex(table: string, indexName: string, type: string, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • type: string
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • createTable: function
      • createTable(table: string, tableData: InanoSQLTable, complete: function, error: function): void
      • Parameters

        • table: string
        • tableData: InanoSQLTable
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • delete: function
      • delete(table: string, pk: any, complete: function, error: function): void
      • Parameters

        • table: string
        • pk: any
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • deleteIndex: function
      • deleteIndex(table: string, indexName: string, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • deleteIndexValue: function
      • deleteIndexValue(table: string, indexName: string, key: any, value: any, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • key: any
        • value: any
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • disconnect: function
      • disconnect(complete: function, error: function): void
      • Parameters

        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • dropTable: function
      • dropTable(table: string, complete: function, error: function): void
      • Parameters

        • table: string
        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • getTableIndex: function
      • getTableIndex(table: string, complete: function, error: function): void
      • Parameters

        • table: string
        • complete: function
            • (index: any[]): void
            • Parameters

              • index: any[]

              Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • getTableIndexLength: function
      • getTableIndexLength(table: string, complete: function, error: function): void
      • Parameters

        • table: string
        • complete: function
            • (length: number): void
            • Parameters

              • length: number

              Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • read: function
      • read(table: string, pk: any, complete: function, error: function): void
      • Parameters

        • table: string
        • pk: any
        • complete: function
            • (row: object | undefined): void
            • Parameters

              • row: object | undefined

              Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • readIndexKey: function
      • readIndexKey(table: string, indexName: string, pk: any, onRowPK: function, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • pk: any
        • onRowPK: function
            • (key: any): void
            • Parameters

              • key: any

              Returns void

        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • readIndexKeys: function
      • readIndexKeys(table: string, indexName: string, type: "range" | "offset" | "all", offsetOrLow: any, limitOrHigh: any, reverse: boolean, onRowPK: function, complete: function, error: function): void
      • Parameters

        • table: string
        • indexName: string
        • type: "range" | "offset" | "all"
        • offsetOrLow: any
        • limitOrHigh: any
        • reverse: boolean
        • onRowPK: function
            • (key: any, id: any): void
            • Parameters

              • key: any
              • id: any

              Returns void

        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • readMulti: function
      • readMulti(table: string, type: "range" | "offset" | "all", offsetOrLow: any, limitOrHigh: any, reverse: boolean, onRow: function, complete: function, error: function): void
      • Parameters

        • table: string
        • type: "range" | "offset" | "all"
        • offsetOrLow: any
        • limitOrHigh: any
        • reverse: boolean
        • onRow: function
            • (row: object, i: number): void
            • Parameters

              • row: object
                • [key: string]: any
              • i: number

              Returns void

        • complete: function
            • (): void
            • Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

    • write: function
      • write(table: string, pk: any, row: object, complete: function, error: function): void
      • Parameters

        • table: string
        • pk: any
        • row: object
          • [key: string]: any
        • complete: function
            • (pk: any): void
            • Parameters

              • pk: any

              Returns void

        • error: function
            • (err: any): void
            • Parameters

              • err: any

              Returns void

        Returns void

Const allAsync

  • allAsync<T>(items: T[], callback: function): Promise<any[]>
  • Quickly and efficiently fire asynchronous operations in parallel, returns once all operations are complete.

    Type parameters

    • T

    Parameters

    • items: T[]
    • callback: function
        • (item: T, i: number, next: function, err: function): void
        • Parameters

          • item: T
          • i: number
          • next: function
              • (value?: any): void
              • Parameters

                • Optional value: any

                Returns void

          • err: function
              • (err: any): void
              • Parameters

                • err: any

                Returns void

          Returns void

    Returns Promise<any[]>

Const assign

  • assign(obj: any): any
  • Object.assign, but faster.

    Parameters

    • obj: any

    Returns any

Const binarySearch

  • binarySearch(arr: any[], value: any, indexOf: boolean, startVal?: undefined | number, endVal?: undefined | number): number
  • Searches a sorted array for a given value.

    Parameters

    • arr: any[]
    • value: any
    • indexOf: boolean
    • Optional startVal: undefined | number
    • Optional endVal: undefined | number

    Returns number

Const buildQuery

Const cast

  • cast(selectedDB: string | undefined, type: string, val: any, allowUknownTypes?: undefined | false | true, nSQL?: InanoSQLInstance): any
  • Cast a javascript variable to a given type. Supports typescript primitives and more specific types.

    Parameters

    • selectedDB: string | undefined
    • type: string
    • val: any
    • Optional allowUknownTypes: undefined | false | true
    • Optional nSQL: InanoSQLInstance

    Returns any

Const chainAsync

  • chainAsync<T>(items: T[], callback: function): Promise<any[]>
  • Quickly and efficiently fire asynchronous operations in sequence, returns once all operations complete.

    Type parameters

    • T

    Parameters

    • items: T[]
    • callback: function
        • (item: T, i: number, next: function, err: function): void
        • Parameters

          • item: T
          • i: number
          • next: function
              • (value?: any): void
              • Parameters

                • Optional value: any

                Returns void

          • err: function
              • (err?: any): void
              • Parameters

                • Optional err: any

                Returns void

          Returns void

    Returns Promise<any[]>

Const cleanArgs

  • cleanArgs(selectedDB: string, argDeclarations: string[], args: object, nSQL: InanoSQLInstance): object
  • Clean the arguments from an object given an array of arguments and their types.

    Parameters

    • selectedDB: string
    • argDeclarations: string[]
    • args: object
      • [key: string]: any
    • nSQL: InanoSQLInstance

    Returns object

    • [key: string]: any

Const cleanArgs2

  • cleanArgs2(selectedDB: string, args: any, dataModel: object | string, nSQL: InanoSQLInstance): any

Const crowDistance

  • crowDistance(lat1: number, lon1: number, lat2: number, lon2: number, radius?: number): number
  • "As the crow flies" or Haversine formula, used to calculate the distance between two points on a sphere.

    The unit used for the radius will determine the unit of the answer. If the radius is in km, distance provided will be in km.

    The radius is in km by default.

    Parameters

    • lat1: number
    • lon1: number
    • lat2: number
    • lon2: number
    • Default value radius: number = 6371

    Returns number

Const deepFreeze

  • deepFreeze(obj: any): any
  • Recursively freeze a javascript object to prevent it from being modified.

    Parameters

    • obj: any

    Returns any

Const deepGet

  • deepGet(pathQuery: string | string[], object: any): any
  • Take an object and a string describing a path like "value.length" or "val[length]" and safely get that value in the object.

    objQuery("hello", {hello: 2}) => 2 objQuery("hello.length", {hello: [0]}) => 1 objQuery("hello[0]", {hello: ["there"]}) => "there" objQuery("hello[0].length", {hello: ["there"]}) => 5 objQuery("hello.color.length", {"hello.color": "blue"}) => 4

    Parameters

    • pathQuery: string | string[]
    • object: any

    Returns any

Const deepSet

  • deepSet(pathQuery: string | string[], object: any, value: any): any
  • Parameters

    • pathQuery: string | string[]
    • object: any
    • value: any

    Returns any

Const deg2rad

  • deg2rad(deg: number): number

Const execFunction

  • Recursively resolve function values provided a string and row

    Parameters

    • query: InanoSQLQuery
    • fnString: string

      // TRIM(UPPER(column))

    • row: any

      // {column: " value "}

    • prev: any

      // aggregate previous value for aggregate functions

    Returns InanoSQLFunctionResult

Const fastApply

  • fastApply(args: any): any

Const fastID

  • fastID(): string

Const generateID

  • generateID(primaryKeyType: string, incrimentValue?: undefined | number): any
  • Generate a row ID given the primary key type.

    Parameters

    • primaryKeyType: string
    • Optional incrimentValue: undefined | number

    Returns any

Const getFnValue

  • getFnValue(row: any, valueOrPath: string): any

Const hash

  • hash(str: string): string

Const intersect

  • intersect(arr1: any[], arr2: any[]): boolean
  • See if two arrays intersect.

    Parameters

    • arr1: any[]
    • arr2: any[]

    Returns boolean

Const isObject

  • isObject(val: any): boolean
  • Determine if a given value is a javascript object or not. Exludes Arrays, Functions, Null, Undefined, etc.

    Parameters

    • val: any

    Returns boolean

Const keyToDate

Const levenshtein

  • levenshtein(word1: string, word2: string): number

Const maybeAssign

  • maybeAssign(obj: any): any

Const maybeDate

  • maybeDate(value: any): any

Const mutateRowTypes

  • mutateRowTypes(selectedDB: string | undefined, replaceObj: any, table: string, nSQL: InanoSQLInstance): any

Const nan

  • nan(input: any): number

Const noop

  • noop(): void

Const objSort

  • objSort(path?: undefined | string, rev?: undefined | false | true): (Anonymous function)
  • Parameters

    • Optional path: undefined | string
    • Optional rev: undefined | false | true

    Returns (Anonymous function)

Const objectsEqual

  • objectsEqual(obj1: any, obj2: any): boolean
  • Compare two javascript variables for equality. Works with primitives, arrays and objects recursively.

    Parameters

    • obj1: any
    • obj2: any

    Returns boolean

Const rad2deg

  • rad2deg(rad: number): number

Const random16Bits

  • random16Bits(): number
  • Generate a random 16 bit number using strongest entropy/crypto available.

    Returns number

Const resolvePath

  • resolvePath(pathQuery: string): string[]

Const slugify

  • slugify(str: string): string

Const throttle

  • throttle(scope: any, func: any, limit: number): (Anonymous function)
  • Parameters

    • scope: any
    • func: any
    • limit: number

    Returns (Anonymous function)

Const throwErr

  • throwErr(err: any): never

Const timeid

  • timeid(ms?: undefined | false | true): string
  • Generate a TimeID for use in the database.

    Parameters

    • Optional ms: undefined | false | true

    Returns string

Const titleCase

  • titleCase(str: string): string
  • Converts a word to title case.

    Parameters

    • str: string

    Returns string

Const uuid

  • uuid(): string
  • Generates a valid V4 UUID using the strongest crypto available.

    Returns string

Object literals

Const blankTableDefinition

blankTableDefinition: object

actions

actions: never[] = []

ai

ai: false = false

columns

columns: never[] = []

count

count: number = 0

id

id: string = ""

indexes

indexes: object

Type declaration

isPkNum

isPkNum: false = false

model

model: object

Type declaration

name

name: string = ""

pkCol

pkCol: never[] = []

pkType

pkType: string = "string"

queries

queries: object

Type declaration

rowLocks

rowLocks: object

Type declaration

views

views: never[] = []

Generated using TypeDoc