-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.js
105 lines (86 loc) · 2.05 KB
/
types.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// @ title Type checking
// @ ignore
const R = require('ramda');
const $ = require('sanctuary-def');
const Kefir = require('kefir');
const WS = require('ws');
const { Events, Requests } = require('./tokens');
const a = $.TypeVariable('a');
const b = $.TypeVariable('b');
const pkgName = 'obs.remote.kefir';
const ident = n => `${pkgName}/${n}`;
const url = n => `https://github.com/stuf/obs.remote.kefir#${n}`;
//. ### OBS types
//# ObsRequest
//.
//. Represents a `Request` in OBS.
const ObsRequest =
$.EnumType(ident('ObsRequest'),
url('ObsRequest'),
Requests);
//# ObsEvent
//.
//. Represents an `Event` in OBS.
const ObsEvent =
$.EnumType(ident('ObsEvent'),
url('ObsEvent'),
Events);
//
//. ### Observable
//# KefirObservable
//.
//. Represents a Kefir `Observable` instance.
const KefirObservable =
$.NullaryType(ident('KefirObservable'),
url('KefirObservable'),
R.is(Kefir.Observable));
//# KefirProperty
//.
//. Represents a Kefir `Property` instance.
const KefirProperty =
$.NullaryType(ident('KefirProperty'),
url('KefirProperty'),
R.is(Kefir.Property));
//# KefirStream
//.
//. Represents a Kefir `Stream` instance.
const KefirStream =
$.NullaryType(ident('KefirStream'),
url('KefirStream'),
R.is(Kefir.Stream));
//
//# WebSocket
//.
//. Represents an instance of `WebSocket`
const WebSocket =
$.NullaryType(ident('WebSocket'),
url('WebSocket'),
maybeWs =>
!!(R.is(WS, maybeWs) &&
R.has('onopen', maybeWs.__proto__) &&
R.has('onclose', maybeWs.__proto__)));
//
const env =
[KefirObservable,
KefirProperty,
KefirStream,
ObsRequest,
ObsEvent,
WebSocket];
const def = $.create({
env: $.env.concat(env),
checkTypes: process.env.NODE_ENV !== 'production'
});
//
module.exports = {
ObsRequest,
ObsEvent,
KefirObservable,
KefirProperty,
KefirStream,
WebSocket,
def,
env,
a,
b
};