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

fix(special-missings): fixed formats table sent as part of sasjs_tables

This commit is contained in:
Yury Shkoda
2022-06-28 10:17:22 +03:00
parent c073d72dd4
commit 283800dfa6
4 changed files with 34 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import { isSpecialMissing } from '@sasjs/utils/input/validators'
import { prefixMessage } from '@sasjs/utils/error'
/**
* Converts the given JSON object array to a CSV string.
@@ -9,7 +10,10 @@ export const convertToCSV = (
tableName: string
) => {
if (!data[tableName]) {
throw new Error('No table provided to be converted to CSV')
throw prefixMessage(
'No table provided to be converted to CSV.',
'Error while converting to CSV. '
)
}
const table = data[tableName]
@@ -170,6 +174,12 @@ export const convertToCSV = (
return finalCSV
}
/**
* Checks if table is table of formats (table name should start from '$' character).
* @param tableName - table name.
*/
export const isFormatsTable = (tableName: string) => /^\$.*/.test(tableName)
const getByteSize = (str: string) => {
let byteSize = str.length
for (let i = str.length - 1; i >= 0; i--) {