@wener/console
Version:
Base console UI toolkit
30 lines (29 loc) • 814 B
JavaScript
import { startCase } from "es-toolkit";
import { get, set } from "es-toolkit/compat";
export function createMetadataKey(a, b) {
const opts = typeof a === 'string' ? {
key: a,
...b
} : a;
const { key } = opts;
opts.title ||= startCase(key);
const k = {
...opts,
type: null
};
if ('toStringTag' in Symbol && typeof Symbol.toStringTag === 'symbol') {
Object.defineProperty(k, Symbol.toStringTag, {
value: key
});
}
return k;
}
export function defineMetadata(res, key, opts) {
res.metadata = res.metadata || {};
set(res.metadata, key.key, opts);
}
export function getMetadata(res, key) {
if (!res?.metadata) return undefined;
return get(res.metadata, key.key);
}
//# sourceMappingURL=defineMetadata.js.map