From 4789bad98fbcf3134ed11fe6aeca5751d19b4b5e Mon Sep 17 00:00:00 2001 From: slikts Date: Sun, 23 Feb 2020 18:29:13 +0000 Subject: [PATCH] fix(ValueObject): fix types, param name --- src/DeepCompositeSymbol.ts | 6 +++--- src/ValueObject.ts | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/DeepCompositeSymbol.ts b/src/DeepCompositeSymbol.ts index bf667723..036918d7 100644 --- a/src/DeepCompositeSymbol.ts +++ b/src/DeepCompositeSymbol.ts @@ -6,12 +6,12 @@ import { isObject } from './helpers'; * an object's entries (key-value pairs). */ // tslint:disable-next-line: variable-name -const DeepCompositeSymbol = ((object: any, filter?: (entry: [string, any]) => boolean) => { +const DeepCompositeSymbol = (object: any, filter?: (entry: [string, any]) => boolean) => { const entries = filter ? Object.entries(object).filter(filter) : Object.entries(object); // Recursively replace non-tuple object values with tuples - entries.forEach(x => update(x, filter)); + entries.forEach(entry => update(entry, filter)); return Tuple.unsafeSymbol(...flatten(entries)); -}) as any; +}; const update = (entry: any, filter?: any) => { const v = entry[1]; diff --git a/src/ValueObject.ts b/src/ValueObject.ts index a0e3b3a3..aaf03f9e 100644 --- a/src/ValueObject.ts +++ b/src/ValueObject.ts @@ -5,8 +5,11 @@ import DeepCompositeSymbol from './DeepCompositeSymbol'; * https://github.com/tc39/proposal-record-tuple */ // tslint:disable-next-line: variable-name -const ValueObject = (object: A, keyFilter?: (key: string) => boolean): A => { - const key = DeepCompositeSymbol(object, keyFilter); +const ValueObject = ( + object: A, + filter?: (entry: [string, any]) => boolean, +): A => { + const key = DeepCompositeSymbol(object, filter); if (cache.has(key)) { return cache.get(key) as A; }