diff --git a/packages/object-util/__tests__/index.test.ts b/packages/object-util/__tests__/index.test.ts index 46b32e1..cd60265 100644 --- a/packages/object-util/__tests__/index.test.ts +++ b/packages/object-util/__tests__/index.test.ts @@ -36,6 +36,35 @@ describe('Object Loop Tests', () => { throw "it should not come here" } }) + + }) + + it('Should return false', () => { + const obj = { + pouet: true + } + expect(objectLoop(obj, () => { + return false + })).toBe(false) + // TO BE EXPECTED in MAJOR change + // expect(objectLoop(obj, () => { + // return undefined + // })).toBe(false) + + }) + + it('Should return true', () => { + const obj = { + pouet: true + } + expect(objectLoop(obj, () => { + return true + })).toBe(true) + // TO BE EXPECTED until major change + expect(objectLoop(obj, () => { + return undefined + })).toBe(true) + }) }) diff --git a/packages/object-util/src/ObjectUtil.ts b/packages/object-util/src/ObjectUtil.ts index 30833fc..e25acfb 100644 --- a/packages/object-util/src/ObjectUtil.ts +++ b/packages/object-util/src/ObjectUtil.ts @@ -20,7 +20,7 @@ export function objectMap( /** * Loop through the object * @param obj the object to loop through - * @param fn the function to run for each childs + * @param fn the function to run for each childs if the function return `false` it will stop */ export function objectLoop( obj: Record,