UNPKG

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