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:
parent
d9dca04017
commit
f515091ac5
@ -36,6 +36,35 @@ describe('Object Loop Tests', () => {
|
|||||||
throw "it should not come here"
|
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)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ export function objectMap<T = any, J = any>(
|
|||||||
/**
|
/**
|
||||||
* Loop through the object
|
* Loop through the object
|
||||||
* @param obj the object to loop through
|
* @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>(
|
export function objectLoop<T = any>(
|
||||||
obj: Record<string, T>,
|
obj: Record<string, T>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user