@donation-alerts/common
Version:
Common utils and types that are used in other @donation-alerts packages.
34 lines (33 loc) • 884 B
JavaScript
var _a;
import { __decorate } from "tslib";
import { nonenumerable } from '@stimulcross/shared-utils';
import { klona } from 'klona';
/** @internal */
export const rawDataSymbol = Symbol('donationAlertsRawData');
/**
* Retrieves a deep clone of the raw data of the given `DataObject` instance.
*
* @param data The `DataObject` instance from which to obtain the raw data.
*
* @returns A deep-cloned copy of the raw data stored within the given data object.
*
* @example
* ```ts
* const rawData = getRawData(myDataObject);
* console.log(rawData); // Logs the raw data
* ```
*/
export function getRawData(data) {
return klona(data[rawDataSymbol]);
}
/** @internal */
export class DataObject {
/** @internal */
constructor(data) {
this[rawDataSymbol] = data;
}
}
_a = rawDataSymbol;
__decorate([
nonenumerable
], DataObject.prototype, _a, void 0);