feat: gatherWithLatus

This commit is contained in:
cha0s 2021-01-12 22:34:55 -06:00
parent 2b2c932580
commit c9a0a3fff9
2 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,14 @@
import {basename, extname} from 'path';
const capitalize = (token) => token.substring(0, 1).toUpperCase() + token.substring(1);
export const gatherWithLatus = (context) => (latus) => (
Object.fromEntries(context.keys().map((path) => [
capitalize(basename(path, extname(path))),
context(path).default(latus),
]))
);
export default (latus, type, idAttribute, typeAttribute, check = () => {}) => {
const gathered = latus.invokeReduce(type);
check(gathered, type);

View File

@ -8,7 +8,7 @@ export {default as ensureUniqueReduction} from './ensure-unique-reduction';
export {default as EventEmitter} from './event-emitter';
export {deflate, inflate} from './flate';
export {compose, fastApply} from './function';
export {default as gather} from './gather';
export {gatherWithLatus, default as gather} from './gather';
export {default as Middleware} from './middleware';
export {default as Latus} from './latus';