-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj.bench.ts
50 lines (43 loc) · 973 Bytes
/
obj.bench.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import flat from "npm:flat";
import { flattie } from "npm:flattie";
import { camelizeKeys, flatten } from "./obj.ts";
// import camelizeTs from "npm:camelize-ts";
import humps from "npm:humps";
const objToFlat = {
foo: "bar",
baz: {
nested: "value",
deeper: {
nested: "value",
},
},
};
Deno.bench("flat", { group: "obj.flatten" }, () => {
flat(objToFlat);
});
Deno.bench("flattie", { group: "obj.flatten" }, () => {
flattie(objToFlat);
});
Deno.bench("* flatten", { group: "obj.flatten" }, () => {
flatten(objToFlat);
});
const obj = {
user_obj: {
name: "Andrew",
created_at: "2023-05-22T19:30:29",
},
meta_data: {
is_new: false,
accepted_tos: true,
arr: [1, 2, 3, 4, 5],
meta_meta_data: {
foo: "bar",
},
},
};
Deno.bench("* camelizeKeys", { group: "obj.camelizeKeys" }, () => {
camelizeKeys(obj);
});
Deno.bench("humps", { group: "obj.camelizeKeys" }, () => {
humps.camelizeKeys(obj);
});