quill-component-library
Version:
A library for components shared between Quill apps.
22 lines (18 loc) • 426 B
text/typescript
import _ from 'lodash';
interface HashWithKey {
key?: string;
[key:string]: any;
}
export function embedKeys(hash: object) {
return _.mapValues(hash, (val: HashWithKey, key) => {
if (val) {
val.key = key;
return val;
}
});
}
export function hashToCollection(hash: object):Array<any> {
const wEmbeddedKeys = embedKeys(hash);
const array = _.values(wEmbeddedKeys);
return _.compact(array)
}