deno.land / x / rambda@v9.1.1 / source / sortObject.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { sort } from './sort.js'
export function sortObject(predicate, obj){ if (arguments.length === 1){ return _obj => sortObject(predicate, _obj) } const keys = Object.keys(obj) const sortedKeys = sort((a, b) => predicate( a, b, obj[ a ], obj[ b ] ), keys)
const toReturn = {} sortedKeys.forEach(singleKey => { toReturn[ singleKey ] = obj[ singleKey ] })
return toReturn}
rambda

Version Info

Tagged at
2 months ago