Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils"

Index

Variables

global

global: any = typeof global !== "undefined"? global: typeof globalThis !== "undefined"? globalThis: {}

Functions

displayComponent

  • displayComponent(options?: { componentLibraries?: defs.jsonxLibrary; debug?: undefined | false | true; jsonx?: defs.jsonx; props?: any; renderIndex?: undefined | number }): boolean
  • Used to evaluate whether or not to render a component

    example

    const sampleJSONX = { component: 'div', props: { id: 'generatedJSONX', className: 'jsonx', bigNum: 1430931039, smallNum: 0.425, falsey: false, truthy: true, }, children: 'some div', }; const testJSONX = Object.assign({}, sampleJSONX, { comparisonprops: [{ left: ['truthy',], operation:'==', right:['falsey',], }], }); displayComponent({ jsonx: testJSONX, props: testJSONX2.props, }) // => false

    Parameters

    • Default value options: { componentLibraries?: defs.jsonxLibrary; debug?: undefined | false | true; jsonx?: defs.jsonx; props?: any; renderIndex?: undefined | number } = {}
      • Optional componentLibraries?: defs.jsonxLibrary
      • Optional debug?: undefined | false | true
      • Optional jsonx?: defs.jsonx

        Valid JSONX JSON

      • Optional props?: any

        Props to test comparison values against, usually Object.assign(jsonx.props,jsonx.asyncprops,jsonx.thisprops,jsonx.windowprops)

      • Optional renderIndex?: undefined | number

    Returns boolean

    returns true if all comparisons are true or if using or comparisons, at least one condition is true

fetchJSON

  • fetchJSON(path?: string, options?: {}): Promise<any>
  • Fetches JSON from remote path

    Parameters

    • Default value path: string = ""

      fetch path url

    • Default value options: {} = {}

      fetch options

    Returns Promise<any>

    • returns fetched JSON data

getAdvancedBinding

  • Use to test if can bind components this context for react-redux-router

    Parameters

    Returns boolean

    true if browser is not IE or old android / chrome

getSimplifiedJSONX

  • Transforms Valid JSONX JSON to SimpleJSONX {component,props,children} => {[component]:{props,children}}

    Parameters

    • Default value jsonx: jsonx = {}

      Valid JSONX JSON object

    Returns jsonx

    • returns a simple JSONX JSON Object from a valid JSONX JSON Object

simpleJSONXSyntax

  • Transforms SimpleJSONX to Valid JSONX JSON {[component]:{props,children}} => {component,props,children}

    Parameters

    • Default value simpleJSONX: simpleJsonx = {}

      JSON Object

    Returns jsonx

    • returns a valid JSONX JSON Object from a simple JSONX JSON Object

traverse

  • take an object of array paths to traverse and resolve

    example

    const testObj = { user: { name: 'jsonx', description: 'react withouth javascript', }, stats: { logins: 102, comments: 3, }, authentication: 'OAuth2', }; const testVals = { auth: ['authentication', ], username: ['user', 'name', ], };

    traverse(testVals, testObj) // =>{ auth:'OAuth2', username:'jsonx', }

    throws

    {TypeError}

    Parameters

    • Default value paths: defs.traversePaths = {}

      an object to resolve array property paths

    • Default value data: {} = {}

      object to traverse

    Returns jsonxResourceProps

    resolved object with traversed properties

validSimpleJSONXSyntax

  • validSimpleJSONXSyntax(simpleJSONX?: any): boolean
  • validates simple JSONX Syntax {[component]:{props,children}}

    Parameters

    • Default value simpleJSONX: any = {}

      Any valid simple JSONX Syntax

    Returns boolean

    returns true if simpleJSONX is valid

validateJSONX

  • validateJSONX(jsonx?: jsonx, returnAllErrors?: boolean): boolean | string
  • Validates JSONX JSON Syntax

    example

    validateJSONX({component:'p',children:'hello world'})=>true validateJSONX({children:'hello world'})=>throw SyntaxError('[0001] Missing React Component')

    throws

    {SyntaxError|TypeError|ReferenceError}

    Parameters

    • Default value jsonx: jsonx = {}

      JSONX JSON to validate

    • Default value returnAllErrors: boolean = false

    Returns boolean | string

    either returns true if JSONX is valid, or throws validation error or returns list of errors in array