UNPKG
@orbitdb/ordered-keyvalue-db
Version:
latest (1.3.5)
next (1.1.1-a361551.0)
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.4
1.1.3
1.1.2
1.1.1
1.1.1-a361551.0
1.1.0
1.0.1
1.0.1-d1a4782.0
1.0.1-2d92e7e.0
1.0.0
Ordered keyvalue database type for orbit-db.
@orbitdb/ordered-keyvalue-db
/
test
/
utils.ts
8 lines
(7 loc)
•
256 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
export
const
sortPosition = <T>(
array
: (T & {
position
:
number
})[]): T[] => {
const
sorted = array.
toSorted
(
(
a, b
) =>
a.
position
- b.
position
);
return
sorted.
map
(
(
x
) =>
{
delete
(x
as
T & {
position
?:
number
})[
"position"
];
return
x; }); };