2025-10-08 21:25:22 +03:00
|
|
|
import { Dictionary } from '@freearhey/core'
|
|
|
|
|
|
2026-04-12 08:46:28 +03:00
|
|
|
export class DataSet {
|
2025-10-08 21:25:22 +03:00
|
|
|
_data: Dictionary<string>
|
|
|
|
|
constructor(data: Dictionary<string>) {
|
|
|
|
|
this._data = data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
has(key: string): boolean {
|
|
|
|
|
return this._data.has(key)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
missing(key: string): boolean {
|
2026-09-03 14:53:13 +03:00
|
|
|
const keys = Array.isArray(key) ? key : [key]
|
|
|
|
|
|
|
|
|
|
return keys.every(_key => this._data.get(_key) === undefined)
|
2025-10-08 21:25:22 +03:00
|
|
|
}
|
|
|
|
|
|
2026-08-16 22:54:31 +03:00
|
|
|
isDeleted(key: string): boolean {
|
|
|
|
|
const deleteSymbol = '~'
|
|
|
|
|
|
|
|
|
|
return this._data.get(key) === deleteSymbol
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-03 14:53:13 +03:00
|
|
|
getBoolean(key: string): boolean | undefined {
|
2026-09-04 18:02:35 +02:00
|
|
|
const value = this._data.get(key)
|
2026-09-03 14:53:13 +03:00
|
|
|
|
2026-09-04 18:02:35 +02:00
|
|
|
if (value === undefined || value === '') return undefined
|
|
|
|
|
|
|
|
|
|
return value === 'TRUE'
|
2025-10-08 21:25:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getString(key: string): string | undefined {
|
2026-08-16 22:54:31 +03:00
|
|
|
return this._data.get(key)
|
2025-10-08 21:25:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getArray(key: string): string[] | undefined {
|
|
|
|
|
if (this._data.missing(key)) return undefined
|
|
|
|
|
|
|
|
|
|
const value = this._data.get(key)
|
|
|
|
|
|
2026-08-16 22:54:31 +03:00
|
|
|
return !value || this.isDeleted(key) ? [] : value.split('\r\n')
|
2025-10-08 21:25:22 +03:00
|
|
|
}
|
|
|
|
|
}
|