1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-10 22:00:05 +00:00

feat: h54s Tables() compatibility

This commit is contained in:
Trevor Moody
2025-08-22 10:24:02 +01:00
parent 8a10c229d6
commit fd6fad9b07
6 changed files with 79 additions and 1 deletions

29
src/types/Tables.ts Normal file
View File

@@ -0,0 +1,29 @@
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
}
}