object-to-property-value-array

This commit is contained in:
Niels Lyngsø
2024-10-10 14:53:37 +02:00
parent 8ef41d6e02
commit 40db46c920
2 changed files with 15 additions and 1 deletions

View File

@@ -7,10 +7,10 @@ export * from './entity/index.js';
export * from './modals/index.js';
export * from './paths.js';
export * from './submittable/index.js';
export * from './utils/object-to-property-value-array.function.js';
export * from './workspace-context.interface.js';
export * from './workspace-property-dataset/index.js';
export * from './workspace.context-token.js';
export * from './workspace.element.js';
export * from './workspace.element.js';
export type * from './conditions/index.js';
export type * from './types.js';

View File

@@ -0,0 +1,14 @@
import type { UmbPropertyValueData } from '../../property/types';
/**
* @function UmbObjectToPropertyValueArray
* @param {object} data - an object with properties to be converted.
* @returns {Array<UmbPropertyValueData> | undefined} - and array of property values or undefined
*/
export function umbObjectToPropertyValueArray(data: object | undefined): Array<UmbPropertyValueData> | undefined {
if (!data) return;
return Object.keys(data).map((key) => ({
alias: key,
value: (data as any)[key],
}));
}