Skip to content

Commit

Permalink
issue-#57 - Progress on idiomatic curry - Converted methods up to './…
Browse files Browse the repository at this point in the history
…src/object/'.
  • Loading branch information
elycruz committed Aug 9, 2022
1 parent 3f05bcf commit e877790
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/fjl/src/object/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const
lookup = (key: string | number | symbol, obj: Indexable): any =>
!obj ? undefined : obj[key],

$lookup = (key: string | number | symbol) => (obj: Indexable) => lookup(key, obj);
$lookup = (key: string | number | symbol) =>
(obj: Indexable) => lookup(key, obj);
4 changes: 3 additions & 1 deletion packages/fjl/src/object/searchObj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ export const
return parent;
},

$searchObj = curry(searchObj)
$searchObj = <T>(nsString: string) =>
(obj: T): any => searchObj(nsString, obj)

;
16 changes: 10 additions & 6 deletions packages/fjl/src/object/setTheory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {assignDeep} from './assignDeep';
import {$assignDeep, assignDeep} from './assignDeep';
import {keys, hasOwnProperty} from '../platform/object';
import {reduce} from '../list/utils';
import {curry, curry2} from '../function/curry';

export const

objUnion = assignDeep,

$objUnion = curry2(objUnion),
$objUnion = $assignDeep,

objIntersect = <T, T2>(obj1: T, obj2: T2): { [index in keyof T] } =>
reduce((agg, key: keyof T) => {
Expand All @@ -17,7 +16,8 @@ export const
return agg;
}, {} as { [index in keyof T] }, keys(obj1)),

$objIntersect = curry(objIntersect),
$objIntersect = <T, T2>(obj1: T) =>
(obj2: T2): { [index in keyof T] } => objIntersect(obj1, obj2),

objDifference = <T, T2>(obj1: T, obj2: T2): { [index in keyof T] } =>
reduce((agg, key: keyof T) => {
Expand All @@ -27,10 +27,14 @@ export const
return agg;
}, {} as { [index in keyof T] }, keys(obj1)),

$objDifference = curry(objDifference),
$objDifference = <T, T2>(obj1: T) =>
(obj2: T2): { [index in keyof T] } => objDifference(obj1, obj2),

objComplement = <T, T2>(obj0: T, ...objs: T2[]): { [index in keyof T] } =>
reduce((agg, obj) =>
assignDeep(agg, objDifference(obj, obj0)), {} as { [index in keyof T] }, objs),

$objComplement = curry2(objComplement);
$objComplement = <T, T2>(obj0: T) =>
(...objs: T2[]): { [index in keyof T] } => objComplement(obj0, ...objs)

;

0 comments on commit e877790

Please sign in to comment.