import { DataTableSerializer } from './DataTableSerializer' ; var debug = require ( 'debug' ) ( 'dynamicsnode' ) ; export class DataTable { rows : Array < any > = [ ] ; class classdesc constructor ( public name ? , rows ? ) { if ( rows !== undefined ) { this . rows = rows ; } } callback DataTable param { object } row return { object } param { string } columnName param { DataTable method example example lookup ( columnName , updater , useCache = true ) { var cache = { } ; debug ( `Resolving lookups for columm '${ columnName }'. ${ useCache ? "Using Cache" : "" }...` ) ; for ( var i = 0 ; i < this . rows . length ; i ++ ) { debug ( `${ i } of ${ this . rows . length }` ) ; var currentRow = this . rows [ i ] ; var lookupValue = currentRow [ columnName ] ; var resolvedValue = null ; if ( useCache && lookupValue !== undefined && lookupValue !== null && cache [ lookupValue ] !== undefined ) { debug ( `Resolved Lookup '${ columnName }' value '${ lookupValue }' using cache` ) ; resolvedValue = cache [ lookupValue ] ; debug ( `resolved value: '${ resolvedValue }'` ) ; } else { resolvedValue = updater ( currentRow ) ; if ( useCache && lookupValue !== undefined && lookupValue !== null ) { cache [ lookupValue ] = resolvedValue ; } } if ( resolvedValue === undefined ) { if ( currentRow [ columnName ] !== undefined ) { delete currentRow [ columnName ] ; } } else { currentRow [ columnName ] = resolvedValue ; } } } method param columnName { string } example removeColumn ( columnName ) { for ( var i = 0 ; i < this . rows . length ; i ++ ) { delete this . rows [ i ] [ columnName ] ; } } method param columnName { string } param newName { string } example renameColumn ( columnName , newName ) { for ( var i = 0 ; i < this . rows . length ; i ++ ) { if ( this . rows [ i ] [ columnName ] !== undefined ) { this . rows [ i ] [ newName ] = this . rows [ i ] [ columnName ] ; delete this . rows [ i ] [ columnName ] ; } } } method param { dataTable } DataTable param { fileName } string example save ( fileName ) { DataTableSerializer . save ( this , fileName ) ; } /**
     * Loads the  DataTable object from the specified file.
     *  memberof static param { fileName } string example static load ( fileName ) { return DataTableSerializer . load ( fileName ) ; } }