1 | import { isClient } from "./platform"
|
2 |
|
3 |
|
4 |
|
5 | const arrayify = (x) => (
|
6 | Array.isArray(x) ? x : [x]
|
7 | )
|
8 |
|
9 | const find = (f, xs) => (
|
10 | xs.reduce(((b, x) => b ? b : f(x) ? x : null), null)
|
11 | )
|
12 |
|
13 | const equalRecords = (o1, o2) => {
|
14 | for (const key in o1) if (o1[key] !== o2[key]) return false
|
15 | return true
|
16 | }
|
17 |
|
18 | const noop = () => (
|
19 | undefined
|
20 | )
|
21 |
|
22 | const clientOnly = (f) => (
|
23 | isClient ? f : noop
|
24 | )
|
25 |
|
26 |
|
27 |
|
28 | export default {
|
29 | arrayify,
|
30 | find,
|
31 | equalRecords,
|
32 | noop,
|
33 | clientOnly,
|
34 | }
|
35 | export {
|
36 | arrayify,
|
37 | find,
|
38 | equalRecords,
|
39 | noop,
|
40 | clientOnly,
|
41 | }
|