1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00
Files
adapter/src/types/Tables.ts
2025-08-22 10:24:02 +01:00

30 lines
821 B
TypeScript

import { ArgumentError } from './errors'
export class Tables {
_tables: { [macroName: string]: Record<string, any> }
constructor(table: Record<string, any>, macroName: string) {
this._tables = {}
this.add(table, macroName)
}
add(table: Record<string, any> | null, macroName: string) {
if (table && macroName) {
if (!(table instanceof Array)) {
throw new ArgumentError('First argument must be array')
}
if (typeof macroName !== 'string') {
throw new ArgumentError('Second argument must be string')
}
if (!isNaN(Number(macroName[macroName.length - 1]))) {
throw new ArgumentError('Macro name cannot have number at the end')
}
} else {
throw new ArgumentError('Missing arguments')
}
this._tables[macroName] = table
}
}