@humanspeak/svelte-headless-table
Version:
A powerful, headless table library for Svelte that provides complete control over table UI while handling complex data operations like sorting, filtering, pagination, grouping, and row expansion. Build custom, accessible data tables with zero styling opin
19 lines (18 loc) • 718 B
JavaScript
export const isClonable = (obj) => {
return typeof obj.clone === 'function';
};
/**
* Create a new instance of a class instance with all properties shallow
* copied. This is unsafe as it does not re-run the constructor. Therefore,
* cloned instances will share a reference to the same property instances.
* @param source The original instance object.
* @param props Any additional properties to override.
* @returns A new instance object with all properties shallow copied.
*/
export const unsafeClone = (source, props) => {
const clone = Object.assign(Object.create(Object.getPrototypeOf(source)), source);
if (props !== undefined) {
Object.assign(clone, props);
}
return clone;
};