Home Reference Source

Function

Static Public Summary
public

AND()

public

FALSE()

public

FLATTEN(res: Array, arr: [type]): [type]

Use with a reducer

public

NOT()

public

OR()

public

TRUE()

public

accStr()

public

arrCMP(arr1: [sorted_elements], arr2: [sorted_elements]): integer

Compare array, assumes the arry is sorted returns -1, 0, +1 as required by a sotring compare function

public

arrConcat(arrays: Array): Array

concatinate a list of arrays

public

arrCountVal(list: [type], v: [type]): [type]

[arrCountVal description]

public

arrCurry(functionToDecorate: Function): Function

THis decorates and array function so that it can have one of two forms 1.

public

arrDiff(arr1: Array, arr2: Array): Array

return the difference of two arrays same as arr1 xor arr2

public

arrDistinct(arr1: [type], arr2: [type]): [type]

arrDistinct description, not array equal

public

arrEQ(arr1: [elements], arr2: [elements], eqFn: Function): boolean

Tests array for equality

public
public

arrIntersect(arr1: Array, arr2: Array): Array

return the intersection of two arrays

public

arrOf(aVal: any, n: int32): Array

create an array of same values (aVal) where the result has n of those values

public

arrProd(list: [type]): [type]

array cross product in n dimension, where n ils the number of arguments (length of list) Note: this can produce enormous amounts of data for n > 1, for esample n = 2, list[0].length = x ,and list[1].length = y the resultant array contains x*y values, x = 100, y=200 we produce 20,000 values;

public

arrRemove(arr: Array, listToRemove: Array): Array

array subtraction arr - listToRemove (return an array with all elements of arr this is not in listToRemove)

public

arrSplit(n: int, arr: Array): Array

split an array into n more or less equal length arrays

public

arrToCol(arr: [type]): [type]

[arrToCol description]

public

arrUnion(arr1: Array, arr2: Array): Array

return the union of two arrays

public

arrZip(arrays: Aarry): Array

zip and array, given an array of columns (each element is a column of values) converts and array of column arrays to and array row arrays

public

arrayUniq(list: [type]): [type]

[description]

public

asSortedSet(array: [type]): [type]

converts an array to sorted set, pure function - does not modify the input

public

changeNameTo(name: string, sep: string): [oldName, newName]

changeNameTo takes a change name description array of two elements containing the old names and the new names e.g oldName=newName 'a name change descriptor' where '=' is the seperator return an array of 2 strings [oldName, newName]

public

cmpNumOrStrBy(colIX: [type]): function

comapre string or number (used to sort frames)

public

cmpStr(a: string, b: string): int32

Compare two strings (for sorting) 0 == euqal, -1 a<b, 1 a>b

public

cmpStrNum(a: string | number, b: string | number): int32

cmpStrNum compare (number, number), or (number, string-of-number) or (string-of-number, number) (string-of-number, string-of-number) , (string, string)

public

colName(list: [string], colsNameList1: [string], colsNameList2: [string]): [[string],[string]]

colName(['1.DX=DX1', '2.DX=DX2', '1.FX=F1', ...], ['DX','FX',...],['DX',...])

public

combineCmp(funcs: ...[type]): [type]

combine a set of sorting comparison functions so tht the sort presidence is maintained

public

coreFrameFromBuffer(buffer: string, splitter: function, options: {noConvert: boolen, name: string, Fr: SomeFrameClass}): Frame

Create a Frame from a string buffer (string reat from a file)

  • Lines are seperaed into columns using a 'splitter' supports

    • TSV : tab seperated columns - tsvLine
    • CSV : comma seperated values - csvLine
    • PSV : pipe (|) seperated values popular in healthcare - tsvLine

    Default splitter (tsvLine) is tab seperated values

public

countCh(data: string, char: char, arr: [int32], start: int32, end: int32): int32

count the number of occurences of char in the string

public

createAccesClass(columns: [type]): [type]

[createAccesClass description]

public

csvLine(line: string): [string]

converts a line representing comma separated values (CSV) into an array of strings

public

dataSplit(data: [string], splitter: function, fn: function): [string]

Takes a array of string lines, representing a list of 'row' strings.

public

dedupSortedArr(arr: [Array]): [Array]

removes all duplicates in a sorted array, pure function - does not modify the input

public
public
public

filterDict(aDict: object, listOrFunc: [type]): Object

public

filterIX(fn: Function, arr: [any]): [integre]

filter an attar and return the index found

public

findIndexOf(aSet: [Array], searchElement: [Any]): [Int]

find the index of an element is a sorted array representing a set, uses binary search

public

flatten(arr: [with_inner_arra], level: integer): [type]

Flatten an array to a depth of level, for example if level = 1, only flatten at the top level (depath1)

public

frameCount(aFrame: Frme, colName: string, convName: function): [string, number]

[frameCount description]

public

frameFromBuffer(buffer: string, splitter: function, options: {noConvert: boolen, name: string, Fr: SomeFrameClass}): Frame

Create a Frame from a string buffer (string reat from a file)

  • Lines are seperaed into columns using a 'splitter' supports

    • TSV : tab seperated columns - tsvLine
    • CSV : comma seperated values - csvLine
    • PSV : pipe (|) seperated values popular in healthcare - tsvLine

    Default splitter (tsvLine) is tab seperated values

public

frameSum(aFrame: Frme, colName: string, convName: function, convValue: function): [type]

[frameSum description]

public

frameToString(aFrame: [type]): [type]

[frameToString description]

public

frameWithIndex(aFrame: Frame, indexName: string, atEnd: boolean): Frame

[frameWithIndex description]

public

fromKeyValueList(list: [type]): [type]

[fromKeyValueList description]

public

fromKeyValueListV(list: [type]): [type]

[fromKeyValueListV description]

public

fullInnerJoin(frame1: Frame, frame2: Frame, projectList: [string], joinOn: string, filter: function): Frame

 example of a join
public

gbCount(name: [type], newName: [type]): [type]

gbCount count elemnts (non empty) in a group, bases on sql group by operation
e.g.

public

gbMax(name: [type], newName: [type], fn: Function): [type]

gbMax max value in a group, see gbMin

public

gbMean(name: string, newName: string, fn: function): [type]

gbMean average (mean) value of a group - see gbMin

public

gbMerge(name: [type], newName: [type], sep: [type]): [type]

gbMerge merge the values grouped rows onto a single comma seperated value

public

gbMergeU(name: [type], newName: [type], sep: [type]): [type]

[gbMergeU description]

public

gbMin(name: [type], newName: [type], fn: Function): [type]

gbMin minimum elemnts value (non empty) in a group, bases on sql group by operation
e.g.

public

gbStdDiv(name: [type], newName: [type]): [type]

gbStdDiv standard deviation - see gbMin

public

gbSum(name: [type], newName: [type]): [type]

gbSum sum eelemnts in a group, bases on sql group by operation
e.g.

public

gbVal(newName: [type], value: [type]): [type]

create a column with constant value

public

genColIxFunc(aFrame: [type]): [type]

[genColIxFunc description]

public

genFilterFunction(aListOrStringOrEmpty: [string]): [type]

create a function that tests for elements in aListOrStringOrEmpty aListOrStringOrEmpty => undefined - allows everything aListOrStringOrEmpty => [...

public

genObjMapper(obj: [type]): [mapperFunction, [keys]]

genObjMapper generates a function to map object to an array this is useful to convert an array of object to the data of a frame

public
public
public

getTransform(projectList: [string], cols1: [string], cols2: [string]): Object

Takes two column list (or one) and a mapping list and returns a transform function That will create a new row taking columns from each of the lists

public

groupBy(groupColsOrig: [type], aFrame: [type], accumList: [type]): [type]

The frame should already be sorted by the groupBy order, or

public

groupByToDict(aFrame: [type], colName: [type], cmp: [type], mapFn: [type]): [type]

Returns an array of Frames, for each group the name of the Frameis the value of the grouping

public

groupToDict(aFrame: [type], colName: [type], cmp: [type], mapFn: [type]): [type]

[groupToDict description]

public

hasNoDups(arr: [Array]): [Boolean]

checks if sorted array has no dups, pure function - does not modify the input

public
public

indexFrameColumn(aFrame: Frame, colName: String, noNull: boolean, dict: Object): Dict

Creates a index for a column (dictionary)

public

innerJoin(frame1: Frame, frame2: Frame, projectList: Array<string>, joinOn: String, filter: function): Frame

innerJoin works like an SQL inner join, not quite as flexible, select a as A, b, frame1.x from frame1, frame2 where frame1.colName1 = frame2.colName2 and {filter}

public

intersect(sortedL: [Array]]): [Array]

intersection of a list of sets (sorted arrays) Intersects list sorted array sets (array that issorted and has no duplicates)

public

intersectL(lsa: [Array]): [Array]

intersection of an Array of sets, where each Set is represented as a sorted array of values (no dups)

public

isArray(arr: any): boolean

is the arr/object an array

public

isEmpty(arrOrObj: [Any]): [Boolean]

Check if an array is empty or an object has no attributes

public

isFunction(fun: any): boolean

is obj a function

public

isSorted(arr: [type]): [boolean]

checks if array is sorted, pure function - does not modify the input

public

is str a string

public

joinOp(frame1: Frame, frame2: Frame, col1: string, col2: string, filter: function): function

returns a function that will perform an innet joint test

public

keys()

public

last(arr: [type], defaultV: String): [type]

Get the last element of an array

public

leftJoin(frame1: Frame, frame2: Frame, projectList: Array<string>, joinOn: String, filter: function): Frame

leftJoin works like an SQL inner join, not quite as flexible, select a as A, b, frame1.x from frame1, frame2 where frame1.colName1 = frame2.colName2 and {filter}

public
public

matchIt(res: [type], row1: [type], arr: [type], cmp: [type], tr: [type]): [[row_element]

leftJoin on one row from left and arr from right

public

max(list: [any]): any

maximum of a sorted array

public
public

newArray(n: integer, v: value): Array

create a new array of length n

public

outerJoin(frame1: [type], frame2: [type], projectList: [type], joinOn: [type], filter: [type]): [type]

[outerJoin description]

public

padTo(padLength: number, padChar: char): function

Create a FUNCTION resturns padded (default is '0') string rep of a number

public

Same as the pick(...) function withour memoizing

public

gets the prefix string of 'a' and 'n', for example a = 'asset', b = 'assess', the return will be 'asse'

public

Find the length of the longest prefix of a and b string if a = pre + a1 and b = pre + b1 pre is the longet sting that satisfies the relationship i.e.

public

prefixTail(a: String, b: String): [string]

Gets the non-prefix string of 'a' and 'n', for example a = 'asset', b = 'assess', the return will be ['t', 'ss']

public
public

prod(s: string | [string], list: [string]): [string]

This is rthe cross product of two arrays, where each arrys is an array of strings the result is and array of length m x n, where m is the length of the first vector and n is the length of the second vector

public
public

psvLine(line: string): [string]

converts a line representing pipe (|) separated values (PSV) into an array of strings.

public

range(start: [int32], end: [int32]): [Array]

Creates a set (array) of numbers [start ...

public

redim(arr: [any], n: number): [type]

public
public

reord(subListWithNewOrder: [type], fullList: [type]): [type]

public

Reverses a sort compare function so it sorts in descending order

public

reverse a string

public
public
public

[safeDedup description]

public

setHash(arrOfInt: [int]): [type]

function to take the hash of an array of integers

public

setKey(obj: object, key: string, v: any): object

Set the vale of a key on an object and return the object

public

setKeyV(obj: [type], key: [type], v: [type])

setKeyV - set object's key (multiple) value, if there is no value argument is present get the value list for the key

public
public

similarity(sortedA: [Array], sortedB: [Array]): [Array]

Show how similar two sets (sorted list) actually are

public

sortFrameBy(columnNames: [type], aFrame: [type], cmpFn: [type]): [type]

create a comparison function for a frame usage sortFrameBy(['+surname', 'givenName', '-age'], aFrame)

  • == ascending
  • == descending
public

strEq(str: string, strStart: int32, strEnd: int32, otherStr: string): boolean

strEq str.substring(strStart,strEnd) === otherStr

public

strHash(str: string, start: int32, end: int32): int32

Code taken from https://github.com/darkskyapp/string-hash, Too small to be worth is own module.

public

strJoin(arrOfStrings: [String], sep: String): String

join an array of strings ignoring empty values

public

subtract(fromSet: [Array], elementsToRemove: [Array]): [Array]

Set subtraction: fromSet - elementsToRemove, assumes both sets are are represented by sorted array, and as per set definition there are no dups

public

toHTML()

public

toKeyValueList(obj: [type]): [type]

[toKeyValueList description]

public

toKeyValueListV(obj: [type]): [type]

[toKeyValueListV description]

public

toNumber(str: [type]): [type]

Convert a string to a Javascript number, thakes into accont number string with commas (,) and numbers

public

transpose(frame: [type], pivot: [type]): [type]

[transpose description]

public

trimListElements(arr: [string]): [string]

Takes an array of strings and trims all the strings in the array, modifies the input array and returns the same array with the trimed strings

public

tsvLine(line: string): [string]

converts a line representing tab separated values (TSV) into an array of strings

public

unionFrame(frame1: Frame, frame2: Frame, notSorted: boolean): Frame

Creates a new frame from the union of the rows of the two frames, similar to s set union.

public

unionL(lsa: [Array]): [set]

Union of a list of sets: assumes both sets are are represented by sorted array, and as per set definition there are no dups

public

vecAdd(a1: [number], a2: [number]): [number]

Add two vectors

public

xor(array1: [type], array2: [type]): [type]

remove all elements that are in both arrays

public

zipTo()

public

zipToDict(aListOfPairs: [[string, any]]): [type]

Static Private Summary
private

_makeUnique(listOfRows: [column_elements], colIx: [type]): dict

Static Public

public AND() source

public FALSE() source

public FLATTEN(res: Array, arr: [type]): [type] source

Use with a reducer

Params:

NameTypeAttributeDescription
res Array
arr [type]

Return:

[type]

public NOT() source

public OR() source

public TRUE() source

public accStr() source

public arrCMP(arr1: [sorted_elements], arr2: [sorted_elements]): integer source

Compare array, assumes the arry is sorted returns -1, 0, +1 as required by a sotring compare function

Params:

NameTypeAttributeDescription
arr1 [sorted_elements]
arr2 [sorted_elements]

Return:

integer

1 = less, 0 = equal, +1 = larger

public arrConcat(arrays: Array): Array source

concatinate a list of arrays

Params:

NameTypeAttributeDescription
arrays Array

[description]

Return:

Array

[description]

public arrCountVal(list: [type], v: [type]): [type] source

[arrCountVal description]

Params:

NameTypeAttributeDescription
list [type]

[description]

v [type]

[description]

Return:

[type]

[description]

public arrCurry(functionToDecorate: Function): Function source

THis decorates and array function so that it can have one of two forms

  1. arrayFunction(mappingFunction, array)
  2. arrayFunction(array)
  3. arrayFunction(mappingFunction) - return a new function that takes just an arra

the originam performs checks and currying for the functions below
acts on a function of the form arrFunc(transFormFunction, arr)

Params:

NameTypeAttributeDescription
functionToDecorate Function

[description]

Return:

Function

[description]

public arrDiff(arr1: Array, arr2: Array): Array source

return the difference of two arrays same as arr1 xor arr2

Params:

NameTypeAttributeDescription
arr1 Array

[description]

arr2 Array

[description]

Return:

Array

[description]

public arrDistinct(arr1: [type], arr2: [type]): [type] source

arrDistinct description, not array equal

Params:

NameTypeAttributeDescription
arr1 [type]

[description]

arr2 [type]

[description]

Return:

[type]

[description]

public arrEQ(arr1: [elements], arr2: [elements], eqFn: Function): boolean source

Tests array for equality

Params:

NameTypeAttributeDescription
arr1 [elements]
arr2 [elements]
eqFn Function

Return:

boolean

public arrHash() source

public arrIntersect(arr1: Array, arr2: Array): Array source

return the intersection of two arrays

Params:

NameTypeAttributeDescription
arr1 Array

[description]

arr2 Array

[description]

Return:

Array

[description]

public arrOf(aVal: any, n: int32): Array source

create an array of same values (aVal) where the result has n of those values

Params:

NameTypeAttributeDescription
aVal any

a value to duplicate n times

n int32

number of occurences in the array

Return:

Array

Array of length (n) all filled aValue

public arrProd(list: [type]): [type] source

array cross product in n dimension, where n ils the number of arguments (length of list) Note: this can produce enormous amounts of data for n > 1, for esample n = 2, list[0].length = x ,and list[1].length = y the resultant array contains x*y values, x = 100, y=200 we produce 20,000 values;

for diremsion n=3, z = 50

Params:

NameTypeAttributeDescription
list [type]

[description]

Return:

[type]

[description]

public arrRemove(arr: Array, listToRemove: Array): Array source

array subtraction arr - listToRemove (return an array with all elements of arr this is not in listToRemove)

Params:

NameTypeAttributeDescription
arr Array
listToRemove Array

Return:

Array

new array that contains all values of (arr) that are not in listToRemove

public arrSplit(n: int, arr: Array): Array source

split an array into n more or less equal length arrays

Params:

NameTypeAttributeDescription
n int
arr Array

Return:

Array

return an array of arrays where each inner array is approximately of length n or less

public arrToCol(arr: [type]): [type] source

[arrToCol description]

Params:

NameTypeAttributeDescription
arr [type]

[description]

Return:

[type]

[description]

public arrUnion(arr1: Array, arr2: Array): Array source

return the union of two arrays

Params:

NameTypeAttributeDescription
arr1 Array

[description]

arr2 Array

[description]

Return:

Array

[description]

public arrZip(arrays: Aarry): Array source

zip and array, given an array of columns (each element is a column of values) converts and array of column arrays to and array row arrays

Params:

NameTypeAttributeDescription
arrays Aarry

array of column arrays

Return:

Array

array of row arrays - [ [arrays[0][0],arrays[1][0], arrays[2][0], ... ], [arrays[0][1],arrays[1][1], arrays[2][1], ... ]

public arrayUniq(list: [type]): [type] source

[description]

Params:

NameTypeAttributeDescription
list [type]

[description]

Return:

[type]

[description]

public asSortedSet(array: [type]): [type] source

converts an array to sorted set, pure function - does not modify the input

Params:

NameTypeAttributeDescription
array [type]

the array of (string|number) to sorted and dedup

Return:

[type]

return a deduped sorted array of (string|number)

public changeNameTo(name: string, sep: string): [oldName, newName] source

changeNameTo takes a change name description array of two elements containing the old names and the new names e.g oldName=newName 'a name change descriptor' where '=' is the seperator return an array of 2 strings [oldName, newName]

Params:

NameTypeAttributeDescription
name string

old name to new name descriptor, 'OLD=NEW'

sep string

string that seperates the old name from the new

Return:

[oldName, newName]

and ar

public cmpNumOrStrBy(colIX: [type]): function source

comapre string or number (used to sort frames)

Params:

NameTypeAttributeDescription
colIX [type]

column index

Return:

function

(row1, row2) => compares row1[columnIX] to row2[columnIX]

public cmpStr(a: string, b: string): int32 source

Compare two strings (for sorting) 0 == euqal, -1 a<b, 1 a>b

Params:

NameTypeAttributeDescription
a string

left string

b string

right string

Return:

int32

0 == euqal, -1 = a<b, 1 = a>b

public cmpStrNum(a: string | number, b: string | number): int32 source

cmpStrNum compare (number, number), or (number, string-of-number) or (string-of-number, number) (string-of-number, string-of-number) , (string, string)

Params:

NameTypeAttributeDescription
a string | number

string or number, if is a string that represents a number it is treated as a number

b string | number

string or number, if is a string that represents a number it is treated as a number

Return:

int32

0 == euqal, -1 = a<b, 1 = a>b

public colName(list: [string], colsNameList1: [string], colsNameList2: [string]): [[string],[string]] source

colName(['1.DX=DX1', '2.DX=DX2', '1.FX=F1', ...], ['DX','FX',...],['DX',...])

returns [ [new-col-list], [ col-mapping]] where <col-mapping> = [<frame number>{0,1}, <old-col-index>, <new-col-index>] result od the code above [ [ 'DX1', 'DX2', 'F1', ...], [ [ 0, 0, 0 ], [ 1, 0, 1 ], [ 0, 1, 2 ], ...] ]

Note:

Params:

NameTypeAttributeDescription
list [string]

resulting column map

colsNameList1 [string]

[description]

colsNameList2 [string]

[description]

Return:

[[string],[string]]

[ [new-col-list], [ col-mapping]]

public combineCmp(funcs: ...[type]): [type] source

combine a set of sorting comparison functions so tht the sort presidence is maintained

Params:

NameTypeAttributeDescription
funcs ...[type]

[description]

Return:

[type]

[description]

public coreFrameFromBuffer(buffer: string, splitter: function, options: {noConvert: boolen, name: string, Fr: SomeFrameClass}): Frame source

Create a Frame from a string buffer (string reat from a file)

  • Lines are seperaed into columns using a 'splitter' supports

    • TSV : tab seperated columns - tsvLine
    • CSV : comma seperated values - csvLine
    • PSV : pipe (|) seperated values popular in healthcare - tsvLine

    Default splitter (tsvLine) is tab seperated values

Params:

NameTypeAttributeDescription
buffer string

[description]

splitter function

function to split a string representing a row to an array of strings

options {noConvert: boolen, name: string, Fr: SomeFrameClass}

Return:

Frame

Frame created from the buffer

public countCh(data: string, char: char, arr: [int32], start: int32, end: int32): int32 source

count the number of occurences of char in the string

Params:

NameTypeAttributeDescription
data string

[description]

char char

[description]

arr [int32]

optional array to place the index of char in string

start int32

optional start start index of the string

end int32

optional last index of the string

Return:

int32

number of occurences of the char in the string

public createAccesClass(columns: [type]): [type] source

import {createAccesClass} from 'nurulc.github.io/src/frame/frame_element.js'

[createAccesClass description]

Params:

NameTypeAttributeDescription
columns [type]

[description]

Return:

[type]

[description]

public csvLine(line: string): [string] source

converts a line representing comma separated values (CSV) into an array of strings

Params:

NameTypeAttributeDescription
line string

string representing a line of CSV data

Return:

[string]

an array of strings

public dataSplit(data: [string], splitter: function, fn: function): [string] source

Takes a array of string lines, representing a list of 'row' strings. and for each row is split into column elements (each a string) using a splitter function.

Params:

NameTypeAttributeDescription
data [string]

array of string lines

splitter function

function to split a string representing a row into an array of strings representing column elements

fn function

optional function to apply to string line fn(line,line_number) before applying the splitter

Return:

[string]

this is the same as buffer.map(fn|Idnetity).map(splitter)

public dedupSortedArr(arr: [Array]): [Array] source

removes all duplicates in a sorted array, pure function - does not modify the input

Params:

NameTypeAttributeDescription
arr [Array]

assumes the array is sorted (will throw an exception if the array is not sorted)

Return:

[Array]

returns a new array with no duplicates

public dictToZip() source

public dictToZipB() source

public filterDict(aDict: object, listOrFunc: [type]): Object source

Params:

NameTypeAttributeDescription
aDict object
listOrFunc [type]

Return:

Object

Object action as a dictionary

public filterIX(fn: Function, arr: [any]): [integre] source

filter an attar and return the index found

Params:

NameTypeAttributeDescription
fn Function

testing function for the filter

arr [any]

array of items to filter

Return:

[integre]

return an array of indexex

public findIndexOf(aSet: [Array], searchElement: [Any]): [Int] source

find the index of an element is a sorted array representing a set, uses binary search

Params:

NameTypeAttributeDescription
aSet [Array]

Sorted array representing a set

searchElement [Any]

he item to search for within the array

Return:

[Int]

The index of the element which defaults to -1 when not found.

public flatten(arr: [with_inner_arra], level: integer): [type] source

Flatten an array to a depth of level, for example if level = 1, only flatten at the top level (depath1)

Params:

NameTypeAttributeDescription
arr [with_inner_arra]
level integer

depth the given or undefined the flatten to the bottom

Return:

[type]

public frameCount(aFrame: Frme, colName: string, convName: function): [string, number] source

[frameCount description]

Params:

NameTypeAttributeDescription
aFrame Frme

[description]

colName string

[description]

convName function

function to convert a name to a new name

Return:

[string, number]

a two element array with the name and count [name, count]

public frameFromBuffer(buffer: string, splitter: function, options: {noConvert: boolen, name: string, Fr: SomeFrameClass}): Frame source

Create a Frame from a string buffer (string reat from a file)

  • Lines are seperaed into columns using a 'splitter' supports

    • TSV : tab seperated columns - tsvLine
    • CSV : comma seperated values - csvLine
    • PSV : pipe (|) seperated values popular in healthcare - tsvLine

    Default splitter (tsvLine) is tab seperated values

Params:

NameTypeAttributeDescription
buffer string

[description]

splitter function

function to split a string representing a row to an array of strings

options {noConvert: boolen, name: string, Fr: SomeFrameClass}

Return:

Frame

Frame created from the buffer

public frameSum(aFrame: Frme, colName: string, convName: function, convValue: function): [type] source

[frameSum description]

Params:

NameTypeAttributeDescription
aFrame Frme

the frme to operate on

colName string

name of the column to sum

convName function

optional function to convert a name to a new name

convValue function

optional function to conver the value

Return:

[type]

[description]

public frameToString(aFrame: [type]): [type] source

[frameToString description]

Params:

NameTypeAttributeDescription
aFrame [type]

[description]

Return:

[type]

[description]

public frameWithIndex(aFrame: Frame, indexName: string, atEnd: boolean): Frame source

[frameWithIndex description]

Params:

NameTypeAttributeDescription
aFrame Frame

The frame to add the index to

indexName string

Name of the index column

atEnd boolean

if true the index is placed after the last column, otherwise it is the first column

Return:

Frame

new frame with an index column (remove and previous index column)

public fromKeyValueList(list: [type]): [type] source

[fromKeyValueList description]

Params:

NameTypeAttributeDescription
list [type]

[description]

Return:

[type]

[description]

public fromKeyValueListV(list: [type]): [type] source

[fromKeyValueListV description]

Params:

NameTypeAttributeDescription
list [type]

[description]

Return:

[type]

[description]

public fullInnerJoin(frame1: Frame, frame2: Frame, projectList: [string], joinOn: string, filter: function): Frame source

 example of a join

 innerJoin(frame1,frame2, [list-of-cols in resulting table], "join-col1==join-col2")

Params:

NameTypeAttributeDescription
frame1 Frame

[description]

frame2 Frame

[description]

projectList [string]

the list of final column names

joinOn string

either a common column name, or a ttring of the form 'col1==col2'

filter function

filter function

Return:

Frame

a Frame resulting from the inner join

public gbCount(name: [type], newName: [type]): [type] source

gbCount count elemnts (non empty) in a group, bases on sql group by operation
e.g. 'select state, quater, count(sale_price) as items_sold from annual_sales groupby state, quater' in frame operation summary = frame.groupBy(['state', 'quater', gbCount('sale_price', 'items_sold')]);

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

Return:

[type]

[description]

public gbMax(name: [type], newName: [type], fn: Function): [type] source

gbMax max value in a group, see gbMin

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

fn Function

[description]

Return:

[type]

[description]

public gbMean(name: string, newName: string, fn: function): [type] source

gbMean average (mean) value of a group - see gbMin

Params:

NameTypeAttributeDescription
name string

column name to group

newName string

name to give to the grouping operation

fn function

function to test for empty value

Return:

[type]

[description]

public gbMerge(name: [type], newName: [type], sep: [type]): [type] source

gbMerge merge the values grouped rows onto a single comma seperated value

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

sep [type]

[description]

Return:

[type]

[description]

public gbMergeU(name: [type], newName: [type], sep: [type]): [type] source

[gbMergeU description]

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

sep [type]

[description]

Return:

[type]

[description]

public gbMin(name: [type], newName: [type], fn: Function): [type] source

gbMin minimum elemnts value (non empty) in a group, bases on sql group by operation
e.g. 'select state, quater, product_id, min(sale_price) as min_prod_price from annual_sales groupby state, quater' in frame operation summary = frame.groupBy(['state', 'quater', 'product_id", gbMin('sale_price', 'min_prod_price')]);

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

fn Function

[description]

Return:

[type]

[description]

public gbStdDiv(name: [type], newName: [type]): [type] source

gbStdDiv standard deviation - see gbMin

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

Return:

[type]

[description]

public gbSum(name: [type], newName: [type]): [type] source

gbSum sum eelemnts in a group, bases on sql group by operation
e.g. 'select state, quater, sum(sale_price) as sales from annual_sales groupby state, quater' in frame operation summary = frame.groupBy(['state', 'quater', gbSum('sale_price', 'sales')]);

Params:

NameTypeAttributeDescription
name [type]

[description]

newName [type]

[description]

Return:

[type]

[description]

public gbVal(newName: [type], value: [type]): [type] source

create a column with constant value

Params:

NameTypeAttributeDescription
newName [type]

[description]

value [type]

[description]

Return:

[type]

[description]

public genColIxFunc(aFrame: [type]): [type] source

[genColIxFunc description]

Params:

NameTypeAttributeDescription
aFrame [type]

[description]

Return:

[type]

[description]

public genFilterFunction(aListOrStringOrEmpty: [string]): [type] source

create a function that tests for elements in aListOrStringOrEmpty aListOrStringOrEmpty => undefined - allows everything aListOrStringOrEmpty => [... names ] - allow only the elelemnts in the list aListOrStringOrEmpty => <single string Name> (string) - allow only single name

Params:

NameTypeAttributeDescription
aListOrStringOrEmpty [string]

Return:

[type]

public genObjMapper(obj: [type]): [mapperFunction, [keys]] source

genObjMapper generates a function to map object to an array this is useful to convert an array of object to the data of a frame

Params:

NameTypeAttributeDescription
obj [type]

[description]

Return:

[mapperFunction, [keys]]

returns an array first element that function to convert the object to an array, and the secont element is an array of column names

public getColIx() source

public getDict() source

public getTransform(projectList: [string], cols1: [string], cols2: [string]): Object source

Takes two column list (or one) and a mapping list and returns a transform function That will create a new row taking columns from each of the lists

Params:

NameTypeAttributeDescription
projectList [string]

example ['1.DX=DX1', '2.DX=DX2', '1.FX=F1', ...], ['DX','FX',...],['DX',...]

cols1 [string]

example ['DX','FX',...]

cols2 [string]

example 'DX',...]

Return:

Object

return an object of the form {transform, newColumnNames, mapingArray} the mapping array = [ ...[<frame number>{0,1}, <old-col-index>, <new-col-index>]]

public groupBy(groupColsOrig: [type], aFrame: [type], accumList: [type]): [type] source

The frame should already be sorted by the groupBy order, or

Params:

NameTypeAttributeDescription
groupColsOrig [type]

[description]

aFrame [type]

[description]

accumList [type]

[description]

Return:

[type]

[description]

public groupByToDict(aFrame: [type], colName: [type], cmp: [type], mapFn: [type]): [type] source

Returns an array of Frames, for each group the name of the Frameis the value of the grouping

Params:

NameTypeAttributeDescription
aFrame [type]

[description]

colName [type]

[description]

cmp [type]

[description]

mapFn [type]

[description]

Return:

[type]

[description]

public groupToDict(aFrame: [type], colName: [type], cmp: [type], mapFn: [type]): [type] source

[groupToDict description]

Params:

NameTypeAttributeDescription
aFrame [type]

[description]

colName [type]

[description]

cmp [type]

[description]

mapFn [type]

[description]

Return:

[type]

[description]

public hasNoDups(arr: [Array]): [Boolean] source

checks if sorted array has no dups, pure function - does not modify the input

Params:

NameTypeAttributeDescription
arr [Array]

sorted set of values

Return:

[Boolean]

true if the sorted array has no diplicated, false otherwise (undefined is not a sorted set)

public haveFrame() source

public indexFrameColumn(aFrame: Frame, colName: String, noNull: boolean, dict: Object): Dict source

Creates a index for a column (dictionary)

Params:

NameTypeAttributeDescription
aFrame Frame

Fram to index

colName String

name of the column to index

noNull boolean

Optional (false) if false, null is added to the dictionary

dict Object

Optional

Return:

Dict

Dict[key] --> array of columns that contain the key in column(colName). Note a row is an array of columns

public innerJoin(frame1: Frame, frame2: Frame, projectList: Array<string>, joinOn: String, filter: function): Frame source

innerJoin works like an SQL inner join, not quite as flexible, select a as A, b, frame1.x from frame1, frame2 where frame1.colName1 = frame2.colName2 and {filter}

Params:

NameTypeAttributeDescription
frame1 Frame

[description]

frame2 Frame

[description]

projectList Array<string>

Array of column name mapping example ""

joinOn String

column name to join on, either "colName" (same name exists on both frame) or "colName1=colName2" (colName1 - column from frame1, colName2 - column from frame2)

filter function

*optional filter function - filter(row1,row2)

Return:

Frame

resulting frame

public intersect(sortedL: [Array]]): [Array] source

intersection of a list of sets (sorted arrays) Intersects list sorted array sets (array that issorted and has no duplicates)

Params:

NameTypeAttributeDescription
sortedL [Array]]

Array of sorted array representing a set (no duplicated)

Return:

[Array]

sorted array with no duplicates (a set)

public intersectL(lsa: [Array]): [Array] source

intersection of an Array of sets, where each Set is represented as a sorted array of values (no dups)

Params:

NameTypeAttributeDescription
lsa [Array]

Array of sets

Return:

[Array]

a Sorted array representing the intersection of all the sts

public isArray(arr: any): boolean source

is the arr/object an array

Params:

NameTypeAttributeDescription
arr any

Return:

boolean

public isEmpty(arrOrObj: [Any]): [Boolean] source

Check if an array is empty or an object has no attributes

Params:

NameTypeAttributeDescription
arrOrObj [Any]

Return:

[Boolean]

true if empty array or empty object

public isFunction(fun: any): boolean source

is obj a function

Params:

NameTypeAttributeDescription
fun any

is a object that may be a function object

Return:

boolean

true if it is a function, false otherwise

public isSorted(arr: [type]): [boolean] source

checks if array is sorted, pure function - does not modify the input

Params:

NameTypeAttributeDescription
arr [type]

Array of values (string|number)

Return:

[boolean]

true if the array is sorted, false otherwise (undefined is not a sorted set)

public isString(str: String): boolean source

is str a string

Params:

NameTypeAttributeDescription
str String

Return:

boolean

true if str is a string

public joinOp(frame1: Frame, frame2: Frame, col1: string, col2: string, filter: function): function source

returns a function that will perform an innet joint test

Params:

NameTypeAttributeDescription
frame1 Frame

left frame

frame2 Frame

right frame

col1 string

column name 1

col2 string

column name 2

filter function

optional filter function

Return:

function

boolean function given two rows returns true if the should be joined

public keys() source

public last(arr: [type], defaultV: String): [type] source

Get the last element of an array

Params:

NameTypeAttributeDescription
arr [type]

[description]

defaultV String

[description]

Return:

[type]

[description]

public leftJoin(frame1: Frame, frame2: Frame, projectList: Array<string>, joinOn: String, filter: function): Frame source

leftJoin works like an SQL inner join, not quite as flexible, select a as A, b, frame1.x from frame1, frame2 where frame1.colName1 = frame2.colName2 and {filter}

Params:

NameTypeAttributeDescription
frame1 Frame

[description]

frame2 Frame

[description]

projectList Array<string>

Array of column name mapping example ""

joinOn String

column name to join on, either "colName" (same name exists on both frame) or "colName1=colName2" (colName1 - column from frame1, colName2 - column from frame2)

filter function

*optional filter function - filter(row1,row2)

Return:

Frame

resulting frame

public localGroupBy() source

public matchIt(res: [type], row1: [type], arr: [type], cmp: [type], tr: [type]): [[row_element] source

leftJoin on one row from left and arr from right

Params:

NameTypeAttributeDescription
res [type]
row1 [type]
arr [type]
cmp [type]
tr [type]

Return:

[[row_element]

public max(list: [any]): any source

maximum of a sorted array

Params:

NameTypeAttributeDescription
list [any]

Return:

any

public memoize(fn: Function): Function source

Memoize a function (see https://en.wikipedia.org/wiki/Memoization)

Params:

NameTypeAttributeDescription
fn Function

function to memoize

Return:

Function

memoizing version of the function

public newArray(n: integer, v: value): Array source

create a new array of length n

Params:

NameTypeAttributeDescription
n integer

[description]

v value

optional value to initialize the array

Return:

Array

[description]

public outerJoin(frame1: [type], frame2: [type], projectList: [type], joinOn: [type], filter: [type]): [type] source

[outerJoin description]

Params:

NameTypeAttributeDescription
frame1 [type]

[description]

frame2 [type]

[description]

projectList [type]

[description]

joinOn [type]

[description]

filter [type]

[description]

Return:

[type]

[description]

public padTo(padLength: number, padChar: char): function source

Create a FUNCTION resturns padded (default is '0') string rep of a number

usage: padTo(5)(66) => '00066'; or let pad3 = padTo(3,' '); pad3(5) -> ' 5' pad3(45) -> ' 45' pad3(666) -> '666' pad3(76543) -> '76543'

Params:

NameTypeAttributeDescription
padLength number
padChar char

padding char '0' default

Return:

function

(number) => string

public pickRaw(list: String): function source

Same as the pick(...) function withour memoizing

Params:

NameTypeAttributeDescription
list String

String or array of strings

Return:

function

function that takes an object and returns the key or an array of keys

public prefixHead(a: string, b: string): string source

gets the prefix string of 'a' and 'n', for example a = 'asset', b = 'assess', the return will be 'asse'

Params:

NameTypeAttributeDescription
a string

first string

b string

second

Return:

string

the common prefix of both a and b

public prefixLen(a: string, b: string): Number source

Find the length of the longest prefix of a and b string if a = pre + a1 and b = pre + b1 pre is the longet sting that satisfies the relationship i.e. prefixLen(a1,b1) === 0 returns (pre.length )

Params:

NameTypeAttributeDescription
a string

first string

b string

second string

Return:

Number

length of prefix of a and b

public prefixTail(a: String, b: String): [string] source

Gets the non-prefix string of 'a' and 'n', for example a = 'asset', b = 'assess', the return will be ['t', 'ss']

Params:

NameTypeAttributeDescription
a String

[description]

b String

[description]

Return:

[string]

the non-common parts of a and b, the part after the common prefix

public primeAround() source

import {primeAround} from 'nurulc.github.io/src/utils/primes.js'

public prod(s: string | [string], list: [string]): [string] source

This is rthe cross product of two arrays, where each arrys is an array of strings the result is and array of length m x n, where m is the length of the first vector and n is the length of the second vector

this is like a full multiplication table where the inner operation (the multiplication) is string concatination. Note if either array is a scalar string it is converted into an array

tring prod out, example prod(['a','b'], ['x1', 'x2']) => [ 'ax1', 'bx1', 'ax2', 'bx2' ]

Params:

NameTypeAttributeDescription
s string | [string]

a string or array of strings

list [string]

of strings

Return:

[string]

[description]

public project() source

public psvLine(line: string): [string] source

converts a line representing pipe (|) separated values (PSV) into an array of strings. This is a commely data representation in USA healthcare

Params:

NameTypeAttributeDescription
line string

string representing a line of PSV data

Return:

[string]

an array of strings

public range(start: [int32], end: [int32]): [Array] source

Creates a set (array) of numbers [start ... (end-1)]

Params:

NameTypeAttributeDescription
start [int32]

start value

end [int32]

one mare then the last value in the result array

Return:

[Array]

[description]

public redim(arr: [any], n: number): [type] source

Params:

NameTypeAttributeDescription
arr [any]
n number

Return:

[type]

public renameColumns() source

public reord(subListWithNewOrder: [type], fullList: [type]): [type] source

Params:

NameTypeAttributeDescription
subListWithNewOrder [type]
fullList [type]

Return:

[type]

public revCmp(cmp: function): function source

Reverses a sort compare function so it sorts in descending order

Params:

NameTypeAttributeDescription
cmp function

sort comparison function

Return:

function

new function what will do a reverse sort

public reverse(s: string): string source

reverse a string

Params:

NameTypeAttributeDescription
s string

string to reverse

Return:

string

reversed string

public reverseProjectList1() source

public reverseProjectList2() source

public safeDedup(list: Array): Array source

[safeDedup description]

Params:

NameTypeAttributeDescription
list Array

[description]

Return:

Array

[description]

public setHash(arrOfInt: [int]): [type] source

function to take the hash of an array of integers

Params:

NameTypeAttributeDescription
arrOfInt [int]

array of integers

Return:

[type]

[description]

public setKey(obj: object, key: string, v: any): object source

Set the vale of a key on an object and return the object

obj[key] = v in Javascript the expression returns the javle of v rather than obj setKey(Obj, 'someKey', aVal) returns obj

Params:

NameTypeAttributeDescription
obj object

a Javascript object

key string

key to add to obj

v any

value to set to the key

Return:

object

the objct in the first parameter

public setKeyV(obj: [type], key: [type], v: [type]) source

setKeyV - set object's key (multiple) value, if there is no value argument is present get the value list for the key

Params:

NameTypeAttributeDescription
obj [type]

[description]

key [type]

[description]

v [type]

[description]

public shallow() source

public similarity(sortedA: [Array], sortedB: [Array]): [Array] source

Show how similar two sets (sorted list) actually are

Params:

NameTypeAttributeDescription
sortedA [Array]

[description]

sortedB [Array]

[description]

Return:

[Array]

where the array contains[same_count, different_count]

public sortFrameBy(columnNames: [type], aFrame: [type], cmpFn: [type]): [type] source

import sortFrameBy from 'nurulc.github.io/src/frame/sortFrame.js'

create a comparison function for a frame usage sortFrameBy(['+surname', 'givenName', '-age'], aFrame)

  • == ascending
  • == descending

Params:

NameTypeAttributeDescription
columnNames [type]

[description]

aFrame [type]

[description]

cmpFn [type]

[description]

Return:

[type]

[description]

public strEq(str: string, strStart: int32, strEnd: int32, otherStr: string): boolean source

strEq str.substring(strStart,strEnd) === otherStr

Params:

NameTypeAttributeDescription
str string

str take str.substring(strStart,strEnd)

strStart int32

start index for str

strEnd int32

end index for str

otherStr string

other string in the compare

Return:

boolean

true =equal, false = not equal

public strHash(str: string, start: int32, end: int32): int32 source

Code taken from https://github.com/darkskyapp/string-hash, Too small to be worth is own module.

Params:

NameTypeAttributeDescription
str string

The string to hash (isf str is not a string make it into a string)

start int32

start pos in the string

end int32

The end position of thestring

Return:

int32

The hash value

public strJoin(arrOfStrings: [String], sep: String): String source

join an array of strings ignoring empty values

Params:

NameTypeAttributeDescription
arrOfStrings [String]

array of strings

sep String

seperator string

Return:

String

return a string of values seperated by 'sep' string

public subtract(fromSet: [Array], elementsToRemove: [Array]): [Array] source

Set subtraction: fromSet - elementsToRemove, assumes both sets are are represented by sorted array, and as per set definition there are no dups

Params:

NameTypeAttributeDescription
fromSet [Array]

array - array(set) of sorted elements (ascending order) and no duplicated

elementsToRemove [Array]

array(set) - array of sorted elements (ascending order) and no duplicated

Return:

[Array]

a new set, where (∀ x ∈ fromSet), then (x ∈ result), if and only if (x ∉ elementsToRemove).

public toHTML() source

public toKeyValueList(obj: [type]): [type] source

[toKeyValueList description]

Params:

NameTypeAttributeDescription
obj [type]

[description]

Return:

[type]

[description]

public toKeyValueListV(obj: [type]): [type] source

[toKeyValueListV description]

Params:

NameTypeAttributeDescription
obj [type]

[description]

Return:

[type]

[description]

public toNumber(str: [type]): [type] source

Convert a string to a Javascript number, thakes into accont number string with commas (,) and numbers

Params:

NameTypeAttributeDescription
str [type]

[description]

Return:

[type]

[description]

public transpose(frame: [type], pivot: [type]): [type] source

[transpose description]

Params:

NameTypeAttributeDescription
frame [type]

[description]

pivot [type]

[description]

Return:

[type]

[description]

public trimListElements(arr: [string]): [string] source

Takes an array of strings and trims all the strings in the array, modifies the input array and returns the same array with the trimed strings

Params:

NameTypeAttributeDescription
arr [string]

array of strings

Return:

[string]

returns the same array with the stings trimmed

public tsvLine(line: string): [string] source

converts a line representing tab separated values (TSV) into an array of strings

Params:

NameTypeAttributeDescription
line string

string representing a line of TSV data

Return:

[string]

an array of strings

public unionFrame(frame1: Frame, frame2: Frame, notSorted: boolean): Frame source

Creates a new frame from the union of the rows of the two frames, similar to s set union. There are no duplicate rows in the result. This is anologous to the SQL union operation assumes the frames are sorted, if notSorted is true, then the frames are sorted first;

  1. the frames must have the same columns names
  2. the sorting is done in columns order
  3. The original frames are not modified

Params:

NameTypeAttributeDescription
frame1 Frame

[description]

frame2 Frame

[description]

notSorted boolean

[description]

Return:

Frame

[description]

public unionL(lsa: [Array]): [set] source

Union of a list of sets: assumes both sets are are represented by sorted array, and as per set definition there are no dups

Params:

NameTypeAttributeDescription
lsa [Array]

array[ array{set}... ] - array{set} of sorted elements (ascending order) and no duplicated

Return:

[set]

a new set, where result = lsa[0] ∪ lsa[1] ∪ ...

public vecAdd(a1: [number], a2: [number]): [number] source

Add two vectors

Params:

NameTypeAttributeDescription
a1 [number]
a2 [number]

Return:

[number]

public xor(array1: [type], array2: [type]): [type] source

remove all elements that are in both arrays

Params:

NameTypeAttributeDescription
array1 [type]
array2 [type]

Return:

[type]

public zipTo() source

public zipToDict(aListOfPairs: [[string, any]]): [type] source

Params:

NameTypeAttributeDescription
aListOfPairs [[string, any]]

list of key value pairs

Return:

[type]

Static Private

private _makeUnique(listOfRows: [column_elements], colIx: [type]): dict source

import {_makeUnique} from 'nurulc.github.io/src/frame/makeUnique.js'

Params:

NameTypeAttributeDescription
listOfRows [column_elements]
colIx [type]

The column to make unique

Return:

dict

returns an object representing mapping of unique values where key and value are the same