Home Reference Source Test Repository
public class | source

Log

Log stores tabular (array-of-array) data in JS memory on the browser, but streams it to disk using fs.writeSync() in nodejs server apps. .last is used to cache the last log row As a kind of limited guarantee of history on both platforms

Constructor Summary

Public Constructor
public

Create Log with suggested file name in browser memory or on-disk in nodejs

Member Summary

Public Members
public

data array for browser and test usage

public

log file descriptor from open call

public

header array for Log, as set by setHeader(header)

public

last item written to log

public

if true, uses nodejs fs calls

Method Summary

Public Methods
public

last value for some column recorded in Log

public

sets header row and writes it to Log for csv-style Log.

public

writes data to Log and sets .last

Public Constructors

public constructor(fname: string) source

Create Log with suggested file name in browser memory or on-disk in nodejs

Params:

NameTypeAttributeDescription
fname string

Suggested file name

Public Members

public data: Array source

data array for browser and test usage

public fd: number source

log file descriptor from open call

public header: string[] source

header array for Log, as set by setHeader(header)

public last: Object source

last item written to log

public useFS: boolean source

if true, uses nodejs fs calls

Public Methods

public lastByKey(k: *): number | string | undefined source

last value for some column recorded in Log

Params:

NameTypeAttributeDescription
k *

Return:

number | string | undefined

value from last write at column position matching header for given key

public setHeader(x: string[]): Object source

sets header row and writes it to Log for csv-style Log.

Params:

NameTypeAttributeDescription
x string[]

Header array giving names of columns for future writes

Return:

Object

Returns this Log; chainable

public write(x: Array | number | string): Object source

writes data to Log and sets .last

Params:

NameTypeAttributeDescription
x Array | number | string

data to write to Log's log file or memory

Return:

Object

returns Log object, chainable