-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
130 lines (124 loc) · 3.93 KB
/
index.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//. # fluture-sanctuary-types
//.
//. [Fluture][] type definitions for [Sanctuary][].
//.
//. ## Usage
//.
//. ### Node
//.
//. ```console
//. $ npm install --save fluture-sanctuary-types
//. ```
//.
//. Note that you also need [Fluture][] and [sanctuary-def][] installed.
//. Sanctuary-def comes preinstalled with Sanctuary, so you could install
//. either one. Fluture has to be installed separately. See `package.json`
//. for compatible versions (defined in `peerDependencies`).
//.
//. On Node 12 and up, this module can be loaded directly with `import` or
//. `require`. On Node versions below 12, `require` or the [esm][]-loader can
//. be used.
//.
//. ```js
//. import $ from 'sanctuary-def';
//. import sanctuary from 'sanctuary';
//. import {env, FutureType} from 'fluture-sanctuary-types/index.js';
//. import {resolve} from 'fluture/index.js';
//.
//. const S = sanctuary.create ({
//. checkTypes: process.env.NODE_ENV !== 'production',
//. env: sanctuary.env.concat (env)
//. });
//.
//. S.is (FutureType ($.String) ($.Number)) (resolve (42));
//. ```
//.
//. ### Deno and Modern Browsers
//.
//. You can load the EcmaScript module from various content delivery networks:
//.
//. - [Skypack](https://cdn.skypack.dev/[email protected])
//. - [JSPM](https://jspm.dev/[email protected])
//. - [jsDelivr](https://cdn.jsdelivr.net/npm/[email protected]/+esm)
//.
//. ### Old Browsers and Code Pens
//.
//. There's a [UMD][] file included in the NPM package, also available via
//. jsDelivr: https://cdn.jsdelivr.net/npm/[email protected]/dist/umd.js
//.
//. This file adds `flutureSanctuaryTypes` to the global scope, or use
//. CommonJS/AMD when available.
//.
//. ```js
//. const $ = require ('sanctuary-def');
//. const sanctuary = require ('sanctuary');
//. const {env, FutureType} = require ('fluture-sanctuary-types');
//. const {resolve} = require ('fluture');
//.
//. const S = sanctuary.create ({
//. checkTypes: process.env.NODE_ENV !== 'production',
//. env: sanctuary.env.concat (env)
//. });
//.
//. S.is (FutureType ($.String) ($.Number)) (resolve (42));
//. ```
import $ from 'sanctuary-def';
import type from 'sanctuary-type-identifiers';
import {
Future,
isFuture,
extractLeft,
extractRight,
Par,
seq
} from 'fluture/index.js';
// $$type :: String
var $$type = '@@type';
//# FutureType :: Type -> Type -> Type
//.
//. The binary type constructor for members of Future.
//.
//. ```js
//. > $.test (env)
//. . (FutureType ($.String) ($.Number))
//. . (Future['fantasy-land/of'] (1));
//. true
//. ```
export var FutureType = $.BinaryType
(type.parse (Future[$$type]).name)
('https://github.com/fluture-js/Fluture#readme')
([])
(isFuture)
(extractLeft)
(extractRight);
//# ConcurrentFutureType :: Type -> Type -> Type
//.
//. The binary type constructor for members of ConcurrentFuture.
//.
//. ```js
//. > $.test (env)
//. . (ConcurrentFutureType ($.String) ($.Number))
//. . (Par['fantasy-land/of'] (1));
//. true
//. ```
export var ConcurrentFutureType = $.BinaryType
(type.parse (Par[$$type]).name)
('https://github.com/fluture-js/Fluture#concurrentfuture')
([])
(function(x) { return type (x) === Par[$$type] && x !== Par; })
(function(f) { return (seq (f)).extractLeft (); })
(function(f) { return (seq (f)).extractRight (); });
//# env :: Array Type
//.
//. An Array containing all types applied to [`$.Unknown`][Unknown] for
//. direct use as a Sanctuary environment, as shown in [Usage](#usage).
export var env = [
FutureType ($.Unknown) ($.Unknown),
ConcurrentFutureType ($.Unknown) ($.Unknown)
];
//. [Fluture]: https://github.com/fluture-js/Fluture
//. [Sanctuary]: https://sanctuary.js.org/
//. [sanctuary-def]: https://github.com/sanctuary-js/sanctuary-def
//. [Unknown]: https://github.com/sanctuary-js/sanctuary-def#Unknown
//. [esm]: https://github.com/standard-things/esm
//. [UMD]: https://github.com/umdjs/umd