bingo-functional-js
Version:
A port of the PHP bingo-functional library
23 lines (19 loc) • 397 B
JavaScript
/**
* toPairs function
*
* toPairs :: Object k v -> [[k, v]]
* @param {object} object
* @returns {array}
* @example
*
* toPairs({ foo: 'bar', baz: 'fooz' })
* // => [['foo', 'bar'], ['baz', 'fooz']]
*/
const toPairs = (object) => {
const result = []
for (const [key, value] of Object.entries(object)) {
result.push([key, value])
}
return result
}
module.exports = toPairs