Manual Reference Source Test

Function

Static Public Summary
public

aggregate(baseClass: Class, mixins: Class[]): *

Support for mixin-style inheritance by extending from expressions yielding function objects.

public

arrayToObject(_array: Array, options: Object): Object

Convert the Array to an object

public

Convert string from camel to snake case

public

evaluate(a: Any, operator: String, b: Any): Boolean

Evaluate where a operator b

public

Updates field names from the current case to snake case

public

Updates field names from the current case to snake case

public

Flattens the json api format to a normal format

public

Returns the type if the format is json api type.

public

hasAttribute(p: Object, attributeName: String, msg: String): String

If the parameter does not have the attribute, a message is returned

public

If there is no token, a message is returned.

public

isA(p: any, type: String, msg: String): String

If the parameter is not of primitive type 'type', a message is returned.

public

isDate(date: any, msg: String): String

If the value is not a date, a message is returned.

public

Determines if the string is an email address.

public

Returns if the format is json api type.

public

isRequired(p: any, msg: String): String

If the required item does not exist, a message is returned.

public

isValid(booleanStatement: Boolean, msg: String): String

If the boolean statement is false, return a message, otherwise return an empty string

public

Convert string from kebab to camel case

public

Convert string from kebab to snake case

public

objectToURI(obj: Any, prefix: String): *

Converts object to a URI to be used with Clinical6

public

Convert string from snake to camel case

public

Convert string from any to camel case

public

Convert string from any to snake case

public

toJsonApiStub(obj: *): *

public

union(arr1: Array, arr2: Array, eqFn: Function<Boolean>): *

http://stackoverflow.com/a/13319168 arr1 and arr2 are arrays of any length; eqFn is a function which can compare two items and return true if they're equal and false otherwise

public

unique(arr: Array, eqFn: Function<Boolean>): *

Returns an array with unique values given the Eq Function

public

validate(module: String, results: ...Object)

Loops through each validation item and throws an error if something fails (a message exists)

Static Public

public aggregate(baseClass: Class, mixins: Class[]): * source

import {aggregate} from 'clinical6/src/utilities/ClassUtility.js'

Support for mixin-style inheritance by extending from expressions yielding function objects.

Params:

NameTypeAttributeDescription
baseClass Class

The base class

mixins Class[]

The classes in which to mixin

Return:

*

Example:

class Colored {
    initializer ()     { this._color = "white"; }
    get color ()       { return this._color; }
    set color (v)      { this._color = v; }
}

class ZCoord {
    initializer ()     { this._z = 0; }
    get z ()           { return this._z; }
    set z (v)          { this._z = v; }
}

class Shape {
    constructor (x, y) { this._x = x; this._y = y; }
    get x ()           { return this._x; }
    set x (v)          { this._x = v; }
    get y ()           { return this._y; }
    set y (v)          { this._y = v; }
}

class Rectangle extends aggregation(Shape, Colored, ZCoord) {}

var rect = new Rectangle(7, 42);
rect.z     = 1000;
rect.color = "red";
console.log(rect.x, rect.y, rect.z, rect.color);

See:

public arrayToObject(_array: Array, options: Object): Object source

import {arrayToObject} from 'clinical6/src/utilities/ArrayUtility.js'

Convert the Array to an object

Params:

NameTypeAttributeDescription
_array Array

The array to convert to an object

options Object
  • optional

Options on how to conver the array

Return:

Object

The resulting object from the array

public camelToSnake(key: String): String source

import {camelToSnake} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from camel to snake case

Params:

NameTypeAttributeDescription
key String

Convert the string to snake case.

Return:

String

String in snake case

public fieldsToCamel(obj: Object): Object source

import {fieldsToCamel} from 'clinical6/src/utilities/ClassUtility.js'

Updates field names from the current case to snake case

Params:

NameTypeAttributeDescription
obj Object

Object in which to update field names

Return:

Object

Object with fields in snake case

public fieldsToSnake(obj: Object): Object source

import {fieldsToSnake} from 'clinical6/src/utilities/ClassUtility.js'

Updates field names from the current case to snake case

Params:

NameTypeAttributeDescription
obj Object

Object in which to update field names

Return:

Object

Object with fields in snake case

public flattenJsonApi(json: Object): Object source

import {flattenJsonApi} from 'clinical6/src/utilities/JsonApiUtility.js'

Flattens the json api format to a normal format

Params:

NameTypeAttributeDescription
json Object

Json to flatten

Return:

Object

Flattened json

public getJsonApiType(json: Object): String source

import {getJsonApiType} from 'clinical6/src/utilities/JsonApiUtility.js'

Returns the type if the format is json api type.

Params:

NameTypeAttributeDescription
json Object

Data if it's in json api format, return the type

Return:

String

Return type

public hasAttribute(p: Object, attributeName: String, msg: String): String source

If the parameter does not have the attribute, a message is returned

Params:

NameTypeAttributeDescription
p Object

Must contain a { key: value } to be the target of validation

attributeName String

Must be a string to valide p

msg String

Message to return if validation fails

Return:

String

A message if the validation fails and blank if it passes

public hasToken(msg: String): String source

If there is no token, a message is returned.

Params:

NameTypeAttributeDescription
msg String

Message to return if validation fails

Return:

String

A message if the validation fails and is blank if it passes

public isA(p: any, type: String, msg: String): String source

If the parameter is not of primitive type 'type', a message is returned.

Params:

NameTypeAttributeDescription
p any

The target value in which to see if the type exists.

type String

The type, must be 'object', 'string', 'number', 'boolean', or 'symbol'.

msg String

Message to return if validation fails

Return:

String

A message if the validation fails and is blank if it passes

public isDate(date: any, msg: String): String source

If the value is not a date, a message is returned.

Params:

NameTypeAttributeDescription
date any

The target value to see if it is a date.

msg String

Message to return if validation fails

Return:

String

A message if the validation fails and is blank if it passes

public isEmail(email: String): Boolean source

Determines if the string is an email address. Based on RFC 5322.

Params:

NameTypeAttributeDescription
email String

Email address to see if it is one.

Return:

Boolean

Either true or false

See:

public isJsonApiFormat(json: Object): Boolean source

import {isJsonApiFormat} from 'clinical6/src/utilities/JsonApiUtility.js'

Returns if the format is json api type.

Params:

NameTypeAttributeDescription
json Object

Check if it's in json api format

Return:

Boolean

Return true or false

public isRequired(p: any, msg: String): String source

If the required item does not exist, a message is returned.

Params:

NameTypeAttributeDescription
p any

The target value to see if it exists.

msg String

Message to return if validation fails

Return:

String

A message if the validation fails and is blank if it passes

public isValid(booleanStatement: Boolean, msg: String): String source

If the boolean statement is false, return a message, otherwise return an empty string

Params:

NameTypeAttributeDescription
booleanStatement Boolean

Any boolean statement that should be true

msg String

Message to return if validation fails

Return:

String

A message if the validation fails and blank if it passes

public kebabToCamel(key: String): String source

import {kebabToCamel} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from kebab to camel case

Params:

NameTypeAttributeDescription
key String

Convert the string to camel case.

Return:

String

String in camel case

public kebabToSnake(key: String): String source

import {kebabToSnake} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from kebab to snake case

Params:

NameTypeAttributeDescription
key String

Convert the string to snake case.

Return:

String

String in snake case

public objectToURI(obj: Any, prefix: String): * source

import {objectToURI} from 'clinical6/src/utilities/FormatUtility.js'

Converts object to a URI to be used with Clinical6

Params:

NameTypeAttributeDescription
obj Any

Object to convert to uri

prefix String

String prefix for each parameter

Return:

*

public snakeToCamel(key: String): String source

import {snakeToCamel} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from snake to camel case

Params:

NameTypeAttributeDescription
key String

Convert the string to camel case.

Return:

String

String in camel case

public stringToCamel(key: String): String source

import {stringToCamel} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from any to camel case

Params:

NameTypeAttributeDescription
key String

Convert the string to camel case.

Return:

String

String in camel case

public stringToSnake(key: String): String source

import {stringToSnake} from 'clinical6/src/utilities/FormatUtility.js'

Convert string from any to snake case

Params:

NameTypeAttributeDescription
key String

Convert the string to snake case.

Return:

String

String in snake case

public toJsonApiStub(obj: *): * source

import {toJsonApiStub} from 'clinical6/src/utilities/ClassUtility.js'

Params:

NameTypeAttributeDescription
obj *

Return:

*

public union(arr1: Array, arr2: Array, eqFn: Function<Boolean>): * source

http://stackoverflow.com/a/13319168 arr1 and arr2 are arrays of any length; eqFn is a function which can compare two items and return true if they're equal and false otherwise

Params:

NameTypeAttributeDescription
arr1 Array

Array of any length

arr2 Array

Array of any length

eqFn Function<Boolean>

Function which returns a Boolean

Return:

*

public unique(arr: Array, eqFn: Function<Boolean>): * source

Returns an array with unique values given the Eq Function

Params:

NameTypeAttributeDescription
arr Array

Array that may contain duplicates

eqFn Function<Boolean>

A function that returns a Boolean

Return:

*

public validate(module: String, results: ...Object) source

Loops through each validation item and throws an error if something fails (a message exists)

Params:

NameTypeAttributeDescription
module String

The location that calls this method.

results ...Object

An array of functions to test.