1
0
mirror of https://github.com/dzeiocom/libs.git synced 2025-04-22 10:52:11 +00:00

Updated tests and documentation to be more clear

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
Florian Bouillon 2021-11-18 17:38:19 +01:00
parent d9dca04017
commit f515091ac5
Signed by: Florian Bouillon
GPG Key ID: BEEAF3722D0EBF64
2 changed files with 30 additions and 1 deletions

View File

@ -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)
})
})

View File

@ -20,7 +20,7 @@ export function objectMap<T = any, J = any>(
/**
* 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<T = any>(
obj: Record<string, T>,