@flarehr/apollo-benefits 0.1.109 → 0.3.53405

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/@splitsoftware-7d799540.js +18 -0
  3. package/dist/assets/all_tab_color-548783b9.svg +21 -0
  4. package/dist/assets/all_tab_gray-a5051313.svg +6 -0
  5. package/dist/assets/check-57fe1dcb.svg +15 -0
  6. package/dist/assets/datadog-ff247651.js +5 -0
  7. package/dist/assets/date-fns-c5d8fbc0.js +1 -0
  8. package/dist/assets/default_backdrop-fdd955b8.png +0 -0
  9. package/dist/assets/external_link-599a0aec.svg +3 -0
  10. package/dist/assets/external_link_white-55111b2e.svg +3 -0
  11. package/dist/assets/framer-motion-bb8d6b82.js +1 -0
  12. package/dist/assets/index-0b3afb09.js +5 -0
  13. package/dist/assets/index-5e9e5aa9.js +35 -0
  14. package/dist/assets/index-cfa25e28.css +1 -0
  15. package/dist/assets/lodash-5d893f8c.js +1 -0
  16. package/dist/assets/logo-a34e9b4b.png +0 -0
  17. package/dist/assets/oidc-client-6f6e47c2.js +101 -0
  18. package/dist/assets/padlock-8c081120.svg +26 -0
  19. package/dist/assets/suitcase-6471ad05.svg +17 -0
  20. package/dist/assets/vendor-2d0139ca.js +788 -0
  21. package/dist/assets/warning-a7f1af23.svg +14 -0
  22. package/dist/assets/welcome_image_mobile-dbde6c80.png +0 -0
  23. package/dist/assets/welcome_image_v2-869c59e4.png +0 -0
  24. package/dist/assets/wellbeing_banner-6903d615.png +0 -0
  25. package/dist/assets/workplace_link_banner_mobile-6ebaa24b.png +0 -0
  26. package/dist/assets/workplace_link_banner_v2-c81ed849.png +0 -0
  27. package/dist/config.json +14 -0
  28. package/dist/favicon.ico +0 -0
  29. package/dist/icons/android-chrome-192x192.png +0 -0
  30. package/dist/icons/android-chrome-512x512.png +0 -0
  31. package/dist/icons/apple-touch-icon.png +0 -0
  32. package/dist/icons/favicon-16x16.png +0 -0
  33. package/dist/icons/favicon-32x32.png +0 -0
  34. package/dist/index.html +114 -0
  35. package/dist/manifest.json +21 -0
  36. package/dist/sw-esm.js +16 -0
  37. package/package.json +129 -60
  38. package/LICENSE +0 -21
  39. package/dist/lib/apollo-benefits/apollo-benefits.esm.js +0 -1
  40. package/dist/lib/apollo-benefits/assets/car-placeholder.svg +0 -5
  41. package/dist/lib/apollo-benefits/assets/check.svg +0 -13
  42. package/dist/lib/apollo-benefits/index.esm.js +0 -0
  43. package/dist/lib/apollo-benefits/p-06a1f65f.js +0 -1
  44. package/dist/lib/apollo-benefits/p-077d7f8d.entry.js +0 -1
  45. package/dist/lib/apollo-benefits/p-14054f15.js +0 -1
  46. package/dist/lib/apollo-benefits/p-24a37d64.js +0 -1
  47. package/dist/lib/apollo-benefits/p-2b3f3b72.entry.js +0 -1
  48. package/dist/lib/apollo-benefits/p-3111d565.entry.js +0 -1
  49. package/dist/lib/apollo-benefits/p-327396fa.entry.js +0 -1
  50. package/dist/lib/apollo-benefits/p-3d4d2683.js +0 -1
  51. package/dist/lib/apollo-benefits/p-4474bcf8.entry.js +0 -1
  52. package/dist/lib/apollo-benefits/p-4bff99bd.entry.js +0 -1
  53. package/dist/lib/apollo-benefits/p-50fe790f.js +0 -1
  54. package/dist/lib/apollo-benefits/p-53bcbd1d.js +0 -1
  55. package/dist/lib/apollo-benefits/p-68c136da.js +0 -1
  56. package/dist/lib/apollo-benefits/p-6bd16f5b.js +0 -1
  57. package/dist/lib/apollo-benefits/p-71dbc8ff.entry.js +0 -1
  58. package/dist/lib/apollo-benefits/p-774d9bc5.entry.js +0 -1
  59. package/dist/lib/apollo-benefits/p-7a2ca86d.entry.js +0 -1
  60. package/dist/lib/apollo-benefits/p-7a572b50.js +0 -1
  61. package/dist/lib/apollo-benefits/p-7c2cd94a.entry.js +0 -1
  62. package/dist/lib/apollo-benefits/p-839493d7.entry.js +0 -1
  63. package/dist/lib/apollo-benefits/p-a24d169b.entry.js +0 -1
  64. package/dist/lib/apollo-benefits/p-b33fc683.js +0 -1
  65. package/dist/lib/apollo-benefits/p-beb8f728.entry.js +0 -1
  66. package/dist/lib/apollo-benefits/p-e241f55b.entry.js +0 -1
  67. package/dist/lib/apollo-benefits/p-e28cee25.js +0 -1
  68. package/dist/lib/apollo-benefits/p-e3cf51f1.entry.js +0 -1
  69. package/dist/lib/apollo-benefits/p-ef8ea713.entry.js +0 -1
  70. package/dist/lib/apollo-benefits/p-f0a7c9fa.entry.js +0 -1
  71. package/dist/lib/apollo-benefits/p-f603197d.js +0 -15
  72. package/dist/lib/cjs/active-router-0ecaf2b8.js +0 -75
  73. package/dist/lib/cjs/ap-ben-choose-vehicle-section_4.cjs.entry.js +0 -2708
  74. package/dist/lib/cjs/ap-ben-complete-section_4.cjs.entry.js +0 -108
  75. package/dist/lib/cjs/ap-ben-notifications-section.cjs.entry.js +0 -238
  76. package/dist/lib/cjs/apollo-benefits.cjs.js +0 -25
  77. package/dist/lib/cjs/app-globals-67583b8b.js +0 -12
  78. package/dist/lib/cjs/async-6a7926f0.js +0 -753
  79. package/dist/lib/cjs/cars-calculator-app.cjs.entry.js +0 -55
  80. package/dist/lib/cjs/cars-calculator.service-c0e51584.js +0 -904
  81. package/dist/lib/cjs/context-consumer.cjs.entry.js +0 -29
  82. package/dist/lib/cjs/datorama-akita-31d23240.js +0 -2551
  83. package/dist/lib/cjs/delay-d31618c3.js +0 -206
  84. package/dist/lib/cjs/distinctUntilChanged-e8538790.js +0 -371
  85. package/dist/lib/cjs/dom-utils-b8befdd5.js +0 -63
  86. package/dist/lib/cjs/fl-button_2.cjs.entry.js +0 -50
  87. package/dist/lib/cjs/fl-dropdown-async_2.cjs.entry.js +0 -467
  88. package/dist/lib/cjs/fl-dropdown.cjs.entry.js +0 -232
  89. package/dist/lib/cjs/fl-style-guide.cjs.entry.js +0 -91
  90. package/dist/lib/cjs/index-f1fadf90.js +0 -1735
  91. package/dist/lib/cjs/index.cjs.js +0 -2
  92. package/dist/lib/cjs/loader.cjs.js +0 -27
  93. package/dist/lib/cjs/location-utils-36fe7e5e.js +0 -237
  94. package/dist/lib/cjs/match-path-be4ea5f6.js +0 -279
  95. package/dist/lib/cjs/session.query-d61ba7ec.js +0 -1731
  96. package/dist/lib/cjs/stencil-async-content.cjs.entry.js +0 -32
  97. package/dist/lib/cjs/stencil-route-link.cjs.entry.js +0 -78
  98. package/dist/lib/cjs/stencil-route-switch.cjs.entry.js +0 -104
  99. package/dist/lib/cjs/stencil-route-title.cjs.entry.js +0 -32
  100. package/dist/lib/cjs/stencil-route.cjs.entry.js +0 -97
  101. package/dist/lib/cjs/stencil-router-prompt.cjs.entry.js +0 -59
  102. package/dist/lib/cjs/stencil-router-redirect.cjs.entry.js +0 -32
  103. package/dist/lib/cjs/stencil-router.cjs.entry.js +0 -640
  104. package/dist/lib/collection/assets/image/complete.svg +0 -122
  105. package/dist/lib/collection/collection-manifest.json +0 -53
  106. package/dist/lib/collection/components/cars-calculator-app/api/api-client.js +0 -5
  107. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator.api.js +0 -45
  108. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.css +0 -22
  109. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.js +0 -97
  110. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.css +0 -0
  111. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.js +0 -144
  112. package/dist/lib/collection/components/cars-calculator-app/notifications-section/notifications-section.js +0 -25
  113. package/dist/lib/collection/components/cars-calculator-app/pages/assets/car-placeholder.svg +0 -5
  114. package/dist/lib/collection/components/cars-calculator-app/pages/assets/check.svg +0 -13
  115. package/dist/lib/collection/components/cars-calculator-app/pages/choose-vehicle-section.component.js +0 -196
  116. package/dist/lib/collection/components/cars-calculator-app/pages/complete-section.component.js +0 -38
  117. package/dist/lib/collection/components/cars-calculator-app/pages/cost-breakdown-section.component.js +0 -45
  118. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.css +0 -34
  119. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.js +0 -85
  120. package/dist/lib/collection/components/cars-calculator-app/pages/personal-info-section.component.js +0 -66
  121. package/dist/lib/collection/components/cars-calculator-app/pages/quote-result-section.component.js +0 -86
  122. package/dist/lib/collection/components/cars-calculator-app/pages/submit-quote-section.component.js +0 -75
  123. package/dist/lib/collection/components/cars-calculator-app/services/app-configuration.service.js +0 -13
  124. package/dist/lib/collection/components/cars-calculator-app/services/cars-calculator.service.js +0 -106
  125. package/dist/lib/collection/components/cars-calculator-app/services/notifications.service.js +0 -37
  126. package/dist/lib/collection/components/cars-calculator-app/services/notifications.store.js +0 -3
  127. package/dist/lib/collection/components/cars-calculator-app/services/session.query.js +0 -35
  128. package/dist/lib/collection/components/cars-calculator-app/services/session.store.js +0 -78
  129. package/dist/lib/collection/global/config.js +0 -2
  130. package/dist/lib/collection/global/main.dev.js +0 -5
  131. package/dist/lib/collection/global/main.js +0 -5
  132. package/dist/lib/collection/index.js +0 -2
  133. package/dist/lib/collection/utils/config.js +0 -2
  134. package/dist/lib/collection/utils/index.js +0 -15
  135. package/dist/lib/collection/utils/lazy.js +0 -29
  136. package/dist/lib/esm/active-router-7c2ca849.js +0 -73
  137. package/dist/lib/esm/ap-ben-choose-vehicle-section_4.entry.js +0 -2701
  138. package/dist/lib/esm/ap-ben-complete-section_4.entry.js +0 -101
  139. package/dist/lib/esm/ap-ben-notifications-section.entry.js +0 -234
  140. package/dist/lib/esm/apollo-benefits.js +0 -23
  141. package/dist/lib/esm/app-globals-65714cca.js +0 -10
  142. package/dist/lib/esm/async-68e9cad7.js +0 -738
  143. package/dist/lib/esm/cars-calculator-app.entry.js +0 -51
  144. package/dist/lib/esm/cars-calculator.service-27826530.js +0 -897
  145. package/dist/lib/esm/context-consumer.entry.js +0 -25
  146. package/dist/lib/esm/datorama-akita-c87196a0.js +0 -2545
  147. package/dist/lib/esm/delay-115d4292.js +0 -200
  148. package/dist/lib/esm/distinctUntilChanged-bf69e0f8.js +0 -363
  149. package/dist/lib/esm/dom-utils-109a7d75.js +0 -55
  150. package/dist/lib/esm/fl-button_2.entry.js +0 -45
  151. package/dist/lib/esm/fl-dropdown-async_2.entry.js +0 -462
  152. package/dist/lib/esm/fl-dropdown.entry.js +0 -228
  153. package/dist/lib/esm/fl-style-guide.entry.js +0 -87
  154. package/dist/lib/esm/index-19c4d245.js +0 -1703
  155. package/dist/lib/esm/index.js +0 -1
  156. package/dist/lib/esm/loader.js +0 -23
  157. package/dist/lib/esm/location-utils-312665d3.js +0 -226
  158. package/dist/lib/esm/match-path-4b5c7d98.js +0 -276
  159. package/dist/lib/esm/polyfills/core-js.js +0 -11
  160. package/dist/lib/esm/polyfills/css-shim.js +0 -1
  161. package/dist/lib/esm/polyfills/dom.js +0 -79
  162. package/dist/lib/esm/polyfills/es5-html-element.js +0 -1
  163. package/dist/lib/esm/polyfills/index.js +0 -34
  164. package/dist/lib/esm/polyfills/system.js +0 -6
  165. package/dist/lib/esm/session.query-0f1c9503.js +0 -1719
  166. package/dist/lib/esm/stencil-async-content.entry.js +0 -28
  167. package/dist/lib/esm/stencil-route-link.entry.js +0 -74
  168. package/dist/lib/esm/stencil-route-switch.entry.js +0 -100
  169. package/dist/lib/esm/stencil-route-title.entry.js +0 -28
  170. package/dist/lib/esm/stencil-route.entry.js +0 -93
  171. package/dist/lib/esm/stencil-router-prompt.entry.js +0 -55
  172. package/dist/lib/esm/stencil-router-redirect.entry.js +0 -28
  173. package/dist/lib/esm/stencil-router.entry.js +0 -636
  174. package/dist/lib/index.cjs.js +0 -1
  175. package/dist/lib/index.js +0 -1
  176. package/dist/lib/loader/cdn.js +0 -3
  177. package/dist/lib/loader/index.cjs.js +0 -3
  178. package/dist/lib/loader/index.d.ts +0 -13
  179. package/dist/lib/loader/index.es2017.js +0 -3
  180. package/dist/lib/loader/index.js +0 -4
  181. package/dist/lib/loader/package.json +0 -10
  182. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/button/button.css +0 -45
  183. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown/dropdown.css +0 -9
  184. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown-async/dropdown-async.css +0 -9
  185. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/loading-indicator/loading-indicator.css +0 -141
  186. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/promise-button/promise-button.css +0 -5
  187. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/style-guide/style-guide.css +0 -0
  188. package/dist/lib/node_modules/@stencil/router/dist/collection/components/route/route.css +0 -3
  189. package/dist/lib/types/components/cars-calculator-app/api/api-client.d.ts +0 -2
  190. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator.api.d.ts +0 -99
  191. package/dist/lib/types/components/cars-calculator-app/cars-calculator-app.d.ts +0 -17
  192. package/dist/lib/types/components/cars-calculator-app/modal-section/modal-section.d.ts +0 -16
  193. package/dist/lib/types/components/cars-calculator-app/notifications-section/notifications-section.d.ts +0 -5
  194. package/dist/lib/types/components/cars-calculator-app/pages/choose-vehicle-section.component.d.ts +0 -23
  195. package/dist/lib/types/components/cars-calculator-app/pages/complete-section.component.d.ts +0 -5
  196. package/dist/lib/types/components/cars-calculator-app/pages/cost-breakdown-section.component.d.ts +0 -6
  197. package/dist/lib/types/components/cars-calculator-app/pages/model-variants-section.component.d.ts +0 -12
  198. package/dist/lib/types/components/cars-calculator-app/pages/personal-info-section.component.d.ts +0 -10
  199. package/dist/lib/types/components/cars-calculator-app/pages/quote-result-section.component.d.ts +0 -13
  200. package/dist/lib/types/components/cars-calculator-app/pages/submit-quote-section.component.d.ts +0 -10
  201. package/dist/lib/types/components/cars-calculator-app/services/app-configuration.service.d.ts +0 -7
  202. package/dist/lib/types/components/cars-calculator-app/services/cars-calculator.service.d.ts +0 -11
  203. package/dist/lib/types/components/cars-calculator-app/services/notifications.service.d.ts +0 -15
  204. package/dist/lib/types/components/cars-calculator-app/services/notifications.store.d.ts +0 -14
  205. package/dist/lib/types/components/cars-calculator-app/services/session.query.d.ts +0 -25
  206. package/dist/lib/types/components/cars-calculator-app/services/session.store.d.ts +0 -77
  207. package/dist/lib/types/components.d.ts +0 -170
  208. package/dist/lib/types/global/config.d.ts +0 -2
  209. package/dist/lib/types/global/main.d.ts +0 -1
  210. package/dist/lib/types/global/main.dev.d.ts +0 -1
  211. package/dist/lib/types/index.d.ts +0 -2
  212. package/dist/lib/types/stencil-public-runtime.d.ts +0 -1555
  213. package/dist/lib/types/utils/config.d.ts +0 -2
  214. package/dist/lib/types/utils/index.d.ts +0 -7
  215. package/dist/lib/types/utils/lazy.d.ts +0 -12
  216. package/readme.md +0 -1
@@ -1,1719 +0,0 @@
1
- import { S as StoreConfig, a as Store, Q as Query } from './datorama-akita-c87196a0.js';
2
-
3
- // -------------------------------------------------------------------------------------
4
- // guards
5
- // -------------------------------------------------------------------------------------
6
- /**
7
- * Returns `true` if the option is an instance of `Some`, `false` otherwise.
8
- *
9
- * @example
10
- * import { some, none, isSome } from 'fp-ts/Option'
11
- *
12
- * assert.strictEqual(isSome(some(1)), true)
13
- * assert.strictEqual(isSome(none), false)
14
- *
15
- * @category guards
16
- * @since 2.0.0
17
- */
18
- var isSome = function (fa) { return fa._tag === 'Some'; };
19
- /**
20
- * Returns `true` if the option is `None`, `false` otherwise.
21
- *
22
- * @example
23
- * import { some, none, isNone } from 'fp-ts/Option'
24
- *
25
- * assert.strictEqual(isNone(some(1)), false)
26
- * assert.strictEqual(isNone(none), true)
27
- *
28
- * @category guards
29
- * @since 2.0.0
30
- */
31
- var isNone = function (fa) { return fa._tag === 'None'; };
32
- // -------------------------------------------------------------------------------------
33
- // constructors
34
- // -------------------------------------------------------------------------------------
35
- /**
36
- * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
37
- *
38
- * @category constructors
39
- * @since 2.0.0
40
- */
41
- var none = { _tag: 'None' };
42
- /**
43
- * Constructs a `Some`. Represents an optional value that exists.
44
- *
45
- * @category constructors
46
- * @since 2.0.0
47
- */
48
- var some = function (a) { return ({ _tag: 'Some', value: a }); };
49
- /**
50
- * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
51
- * returns the value wrapped in a `Some`.
52
- *
53
- * @example
54
- * import { none, some, fromNullable } from 'fp-ts/Option'
55
- *
56
- * assert.deepStrictEqual(fromNullable(undefined), none)
57
- * assert.deepStrictEqual(fromNullable(null), none)
58
- * assert.deepStrictEqual(fromNullable(1), some(1))
59
- *
60
- * @category constructors
61
- * @since 2.0.0
62
- */
63
- function fromNullable(a) {
64
- return a == null ? none : some(a);
65
- }
66
- // -------------------------------------------------------------------------------------
67
- // destructors
68
- // -------------------------------------------------------------------------------------
69
- /**
70
- * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is
71
- * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.
72
- *
73
- * @example
74
- * import { some, none, fold } from 'fp-ts/Option'
75
- * import { pipe } from 'fp-ts/function'
76
- *
77
- * assert.strictEqual(
78
- * pipe(
79
- * some(1),
80
- * fold(() => 'a none', a => `a some containing ${a}`)
81
- * ),
82
- * 'a some containing 1'
83
- * )
84
- *
85
- * assert.strictEqual(
86
- * pipe(
87
- * none,
88
- * fold(() => 'a none', a => `a some containing ${a}`)
89
- * ),
90
- * 'a none'
91
- * )
92
- *
93
- * @category destructors
94
- * @since 2.0.0
95
- */
96
- function fold(onNone, onSome) {
97
- return function (ma) { return (isNone(ma) ? onNone() : onSome(ma.value)); };
98
- }
99
- /**
100
- * Less strict version of [`getOrElse`](#getOrElse).
101
- *
102
- * @category destructors
103
- * @since 2.6.0
104
- */
105
- var getOrElseW = function (onNone) { return function (ma) { return (isNone(ma) ? onNone() : ma.value); }; };
106
- /**
107
- * Extracts the value out of the structure, if it exists. Otherwise returns the given default value
108
- *
109
- * @example
110
- * import { some, none, getOrElse } from 'fp-ts/Option'
111
- * import { pipe } from 'fp-ts/function'
112
- *
113
- * assert.strictEqual(
114
- * pipe(
115
- * some(1),
116
- * getOrElse(() => 0)
117
- * ),
118
- * 1
119
- * )
120
- * assert.strictEqual(
121
- * pipe(
122
- * none,
123
- * getOrElse(() => 0)
124
- * ),
125
- * 0
126
- * )
127
- *
128
- * @category destructors
129
- * @since 2.0.0
130
- */
131
- var getOrElse = getOrElseW;
132
-
133
- function createCommonjsModule(fn, basedir, module) {
134
- return module = {
135
- path: basedir,
136
- exports: {},
137
- require: function (path, base) {
138
- return commonjsRequire();
139
- }
140
- }, fn(module, module.exports), module.exports;
141
- }
142
-
143
- function commonjsRequire () {
144
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
145
- }
146
-
147
- var _function = createCommonjsModule(function (module, exports) {
148
- /**
149
- * @since 2.0.0
150
- */
151
- Object.defineProperty(exports, "__esModule", { value: true });
152
- exports.bindTo_ = exports.bind_ = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.not = exports.unsafeCoerce = exports.identity = void 0;
153
- /**
154
- * @since 2.0.0
155
- */
156
- function identity(a) {
157
- return a;
158
- }
159
- exports.identity = identity;
160
- /**
161
- * @since 2.0.0
162
- */
163
- exports.unsafeCoerce = identity;
164
- /**
165
- * @since 2.0.0
166
- */
167
- function not(predicate) {
168
- return function (a) { return !predicate(a); };
169
- }
170
- exports.not = not;
171
- /**
172
- * @since 2.0.0
173
- */
174
- function constant(a) {
175
- return function () { return a; };
176
- }
177
- exports.constant = constant;
178
- /**
179
- * A thunk that returns always `true`.
180
- *
181
- * @since 2.0.0
182
- */
183
- exports.constTrue =
184
- /*#__PURE__*/
185
- constant(true);
186
- /**
187
- * A thunk that returns always `false`.
188
- *
189
- * @since 2.0.0
190
- */
191
- exports.constFalse =
192
- /*#__PURE__*/
193
- constant(false);
194
- /**
195
- * A thunk that returns always `null`.
196
- *
197
- * @since 2.0.0
198
- */
199
- exports.constNull =
200
- /*#__PURE__*/
201
- constant(null);
202
- /**
203
- * A thunk that returns always `undefined`.
204
- *
205
- * @since 2.0.0
206
- */
207
- exports.constUndefined =
208
- /*#__PURE__*/
209
- constant(undefined);
210
- /**
211
- * A thunk that returns always `void`.
212
- *
213
- * @since 2.0.0
214
- */
215
- exports.constVoid = exports.constUndefined;
216
- // TODO: remove in v3
217
- /**
218
- * Flips the order of the arguments of a function of two arguments.
219
- *
220
- * @since 2.0.0
221
- */
222
- function flip(f) {
223
- return function (b, a) { return f(a, b); };
224
- }
225
- exports.flip = flip;
226
- function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
227
- switch (arguments.length) {
228
- case 1:
229
- return ab;
230
- case 2:
231
- return function () {
232
- return bc(ab.apply(this, arguments));
233
- };
234
- case 3:
235
- return function () {
236
- return cd(bc(ab.apply(this, arguments)));
237
- };
238
- case 4:
239
- return function () {
240
- return de(cd(bc(ab.apply(this, arguments))));
241
- };
242
- case 5:
243
- return function () {
244
- return ef(de(cd(bc(ab.apply(this, arguments)))));
245
- };
246
- case 6:
247
- return function () {
248
- return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
249
- };
250
- case 7:
251
- return function () {
252
- return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
253
- };
254
- case 8:
255
- return function () {
256
- return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
257
- };
258
- case 9:
259
- return function () {
260
- return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
261
- };
262
- }
263
- return;
264
- }
265
- exports.flow = flow;
266
- /**
267
- * @since 2.0.0
268
- */
269
- function tuple() {
270
- var t = [];
271
- for (var _i = 0; _i < arguments.length; _i++) {
272
- t[_i] = arguments[_i];
273
- }
274
- return t;
275
- }
276
- exports.tuple = tuple;
277
- /**
278
- * @since 2.0.0
279
- */
280
- function increment(n) {
281
- return n + 1;
282
- }
283
- exports.increment = increment;
284
- /**
285
- * @since 2.0.0
286
- */
287
- function decrement(n) {
288
- return n - 1;
289
- }
290
- exports.decrement = decrement;
291
- /**
292
- * @since 2.0.0
293
- */
294
- function absurd(_) {
295
- throw new Error('Called `absurd` function which should be uncallable');
296
- }
297
- exports.absurd = absurd;
298
- /**
299
- * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.
300
- *
301
- * @example
302
- * import { tupled } from 'fp-ts/function'
303
- *
304
- * const add = tupled((x: number, y: number): number => x + y)
305
- *
306
- * assert.strictEqual(add([1, 2]), 3)
307
- *
308
- * @since 2.4.0
309
- */
310
- function tupled(f) {
311
- return function (a) { return f.apply(void 0, a); };
312
- }
313
- exports.tupled = tupled;
314
- /**
315
- * Inverse function of `tupled`
316
- *
317
- * @since 2.4.0
318
- */
319
- function untupled(f) {
320
- return function () {
321
- var a = [];
322
- for (var _i = 0; _i < arguments.length; _i++) {
323
- a[_i] = arguments[_i];
324
- }
325
- return f(a);
326
- };
327
- }
328
- exports.untupled = untupled;
329
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) {
330
- switch (arguments.length) {
331
- case 1:
332
- return a;
333
- case 2:
334
- return ab(a);
335
- case 3:
336
- return bc(ab(a));
337
- case 4:
338
- return cd(bc(ab(a)));
339
- case 5:
340
- return de(cd(bc(ab(a))));
341
- case 6:
342
- return ef(de(cd(bc(ab(a)))));
343
- case 7:
344
- return fg(ef(de(cd(bc(ab(a))))));
345
- case 8:
346
- return gh(fg(ef(de(cd(bc(ab(a)))))));
347
- case 9:
348
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
349
- case 10:
350
- return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))));
351
- case 11:
352
- return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))));
353
- case 12:
354
- return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))));
355
- case 13:
356
- return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))));
357
- case 14:
358
- return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))));
359
- case 15:
360
- return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))));
361
- case 16:
362
- return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))));
363
- case 17:
364
- return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))));
365
- case 18:
366
- return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))));
367
- case 19:
368
- return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))));
369
- case 20:
370
- return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))));
371
- }
372
- return;
373
- }
374
- exports.pipe = pipe;
375
- /**
376
- * Type hole simulation
377
- *
378
- * @since 2.7.0
379
- */
380
- exports.hole = absurd;
381
- /**
382
- * @internal
383
- */
384
- var bind_ = function (a, name, b) {
385
- var _a;
386
- return Object.assign({}, a, (_a = {}, _a[name] = b, _a));
387
- };
388
- exports.bind_ = bind_;
389
- /**
390
- * @internal
391
- */
392
- var bindTo_ = function (name) { return function (b) {
393
- var _a;
394
- return (_a = {}, _a[name] = b, _a);
395
- }; };
396
- exports.bindTo_ = bindTo_;
397
- });
398
-
399
- var Option = createCommonjsModule(function (module, exports) {
400
- Object.defineProperty(exports, "__esModule", { value: true });
401
- exports.getApplySemigroup = exports.getOrd = exports.getEq = exports.getShow = exports.URI = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.duplicate = exports.extend = exports.throwError = exports.zero = exports.alt = exports.altW = exports.flatten = exports.chainFirst = exports.chain = exports.of = exports.apSecond = exports.apFirst = exports.ap = exports.map = exports.chainNullableK = exports.mapNullable = exports.fromNullableK = exports.getOrElse = exports.getOrElseW = exports.toUndefined = exports.toNullable = exports.fold = exports.fromEither = exports.getRight = exports.getLeft = exports.tryCatch = exports.fromPredicate = exports.fromNullable = exports.some = exports.none = exports.isNone = exports.isSome = void 0;
402
- exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.getRefinement = exports.exists = exports.elem = exports.option = exports.MonadThrow = exports.Witherable = exports.Traversable = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.Alt = exports.Foldable = exports.Monad = exports.Applicative = exports.Functor = exports.getMonoid = exports.getLastMonoid = exports.getFirstMonoid = exports.getApplyMonoid = void 0;
403
-
404
- // -------------------------------------------------------------------------------------
405
- // guards
406
- // -------------------------------------------------------------------------------------
407
- /**
408
- * Returns `true` if the option is an instance of `Some`, `false` otherwise.
409
- *
410
- * @example
411
- * import { some, none, isSome } from 'fp-ts/Option'
412
- *
413
- * assert.strictEqual(isSome(some(1)), true)
414
- * assert.strictEqual(isSome(none), false)
415
- *
416
- * @category guards
417
- * @since 2.0.0
418
- */
419
- var isSome = function (fa) { return fa._tag === 'Some'; };
420
- exports.isSome = isSome;
421
- /**
422
- * Returns `true` if the option is `None`, `false` otherwise.
423
- *
424
- * @example
425
- * import { some, none, isNone } from 'fp-ts/Option'
426
- *
427
- * assert.strictEqual(isNone(some(1)), false)
428
- * assert.strictEqual(isNone(none), true)
429
- *
430
- * @category guards
431
- * @since 2.0.0
432
- */
433
- var isNone = function (fa) { return fa._tag === 'None'; };
434
- exports.isNone = isNone;
435
- // -------------------------------------------------------------------------------------
436
- // constructors
437
- // -------------------------------------------------------------------------------------
438
- /**
439
- * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
440
- *
441
- * @category constructors
442
- * @since 2.0.0
443
- */
444
- exports.none = { _tag: 'None' };
445
- /**
446
- * Constructs a `Some`. Represents an optional value that exists.
447
- *
448
- * @category constructors
449
- * @since 2.0.0
450
- */
451
- var some = function (a) { return ({ _tag: 'Some', value: a }); };
452
- exports.some = some;
453
- /**
454
- * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
455
- * returns the value wrapped in a `Some`.
456
- *
457
- * @example
458
- * import { none, some, fromNullable } from 'fp-ts/Option'
459
- *
460
- * assert.deepStrictEqual(fromNullable(undefined), none)
461
- * assert.deepStrictEqual(fromNullable(null), none)
462
- * assert.deepStrictEqual(fromNullable(1), some(1))
463
- *
464
- * @category constructors
465
- * @since 2.0.0
466
- */
467
- function fromNullable(a) {
468
- return a == null ? exports.none : exports.some(a);
469
- }
470
- exports.fromNullable = fromNullable;
471
- function fromPredicate(predicate) {
472
- return function (a) { return (predicate(a) ? exports.some(a) : exports.none); };
473
- }
474
- exports.fromPredicate = fromPredicate;
475
- /**
476
- * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a
477
- * `Some`.
478
- *
479
- * @example
480
- * import { none, some, tryCatch } from 'fp-ts/Option'
481
- *
482
- * assert.deepStrictEqual(
483
- * tryCatch(() => {
484
- * throw new Error()
485
- * }),
486
- * none
487
- * )
488
- * assert.deepStrictEqual(tryCatch(() => 1), some(1))
489
- *
490
- * @category constructors
491
- * @since 2.0.0
492
- */
493
- function tryCatch(f) {
494
- try {
495
- return exports.some(f());
496
- }
497
- catch (e) {
498
- return exports.none;
499
- }
500
- }
501
- exports.tryCatch = tryCatch;
502
- /**
503
- * Returns the `Left` value of an `Either` if possible.
504
- *
505
- * @example
506
- * import { getLeft, none, some } from 'fp-ts/Option'
507
- * import { right, left } from 'fp-ts/Either'
508
- *
509
- * assert.deepStrictEqual(getLeft(right(1)), none)
510
- * assert.deepStrictEqual(getLeft(left('a')), some('a'))
511
- *
512
- * @category constructors
513
- * @since 2.0.0
514
- */
515
- function getLeft(ma) {
516
- return ma._tag === 'Right' ? exports.none : exports.some(ma.left);
517
- }
518
- exports.getLeft = getLeft;
519
- /**
520
- * Returns the `Right` value of an `Either` if possible.
521
- *
522
- * @example
523
- * import { getRight, none, some } from 'fp-ts/Option'
524
- * import { right, left } from 'fp-ts/Either'
525
- *
526
- * assert.deepStrictEqual(getRight(right(1)), some(1))
527
- * assert.deepStrictEqual(getRight(left('a')), none)
528
- *
529
- * @category constructors
530
- * @since 2.0.0
531
- */
532
- function getRight(ma) {
533
- return ma._tag === 'Left' ? exports.none : exports.some(ma.right);
534
- }
535
- exports.getRight = getRight;
536
- /**
537
- * Transforms an `Either` to an `Option` discarding the error.
538
- *
539
- * Alias of [getRight](#getRight)
540
- *
541
- * Derivable from `MonadThrow`.
542
- *
543
- * @category constructors
544
- * @since 2.0.0
545
- */
546
- exports.fromEither = getRight;
547
- // -------------------------------------------------------------------------------------
548
- // destructors
549
- // -------------------------------------------------------------------------------------
550
- /**
551
- * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is
552
- * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.
553
- *
554
- * @example
555
- * import { some, none, fold } from 'fp-ts/Option'
556
- * import { pipe } from 'fp-ts/function'
557
- *
558
- * assert.strictEqual(
559
- * pipe(
560
- * some(1),
561
- * fold(() => 'a none', a => `a some containing ${a}`)
562
- * ),
563
- * 'a some containing 1'
564
- * )
565
- *
566
- * assert.strictEqual(
567
- * pipe(
568
- * none,
569
- * fold(() => 'a none', a => `a some containing ${a}`)
570
- * ),
571
- * 'a none'
572
- * )
573
- *
574
- * @category destructors
575
- * @since 2.0.0
576
- */
577
- function fold(onNone, onSome) {
578
- return function (ma) { return (exports.isNone(ma) ? onNone() : onSome(ma.value)); };
579
- }
580
- exports.fold = fold;
581
- /**
582
- * Extracts the value out of the structure, if it exists. Otherwise returns `null`.
583
- *
584
- * @example
585
- * import { some, none, toNullable } from 'fp-ts/Option'
586
- * import { pipe } from 'fp-ts/function'
587
- *
588
- * assert.strictEqual(
589
- * pipe(
590
- * some(1),
591
- * toNullable
592
- * ),
593
- * 1
594
- * )
595
- * assert.strictEqual(
596
- * pipe(
597
- * none,
598
- * toNullable
599
- * ),
600
- * null
601
- * )
602
- *
603
- * @category destructors
604
- * @since 2.0.0
605
- */
606
- function toNullable(ma) {
607
- return exports.isNone(ma) ? null : ma.value;
608
- }
609
- exports.toNullable = toNullable;
610
- /**
611
- * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
612
- *
613
- * @example
614
- * import { some, none, toUndefined } from 'fp-ts/Option'
615
- * import { pipe } from 'fp-ts/function'
616
- *
617
- * assert.strictEqual(
618
- * pipe(
619
- * some(1),
620
- * toUndefined
621
- * ),
622
- * 1
623
- * )
624
- * assert.strictEqual(
625
- * pipe(
626
- * none,
627
- * toUndefined
628
- * ),
629
- * undefined
630
- * )
631
- *
632
- * @category destructors
633
- * @since 2.0.0
634
- */
635
- function toUndefined(ma) {
636
- return exports.isNone(ma) ? undefined : ma.value;
637
- }
638
- exports.toUndefined = toUndefined;
639
- /**
640
- * Less strict version of [`getOrElse`](#getOrElse).
641
- *
642
- * @category destructors
643
- * @since 2.6.0
644
- */
645
- var getOrElseW = function (onNone) { return function (ma) { return (exports.isNone(ma) ? onNone() : ma.value); }; };
646
- exports.getOrElseW = getOrElseW;
647
- /**
648
- * Extracts the value out of the structure, if it exists. Otherwise returns the given default value
649
- *
650
- * @example
651
- * import { some, none, getOrElse } from 'fp-ts/Option'
652
- * import { pipe } from 'fp-ts/function'
653
- *
654
- * assert.strictEqual(
655
- * pipe(
656
- * some(1),
657
- * getOrElse(() => 0)
658
- * ),
659
- * 1
660
- * )
661
- * assert.strictEqual(
662
- * pipe(
663
- * none,
664
- * getOrElse(() => 0)
665
- * ),
666
- * 0
667
- * )
668
- *
669
- * @category destructors
670
- * @since 2.0.0
671
- */
672
- exports.getOrElse = exports.getOrElseW;
673
- // -------------------------------------------------------------------------------------
674
- // combinators
675
- // -------------------------------------------------------------------------------------
676
- /**
677
- * Returns a *smart constructor* from a function that returns a nullable value.
678
- *
679
- * @example
680
- * import { fromNullableK, none, some } from 'fp-ts/Option'
681
- *
682
- * const f = (s: string): number | undefined => {
683
- * const n = parseFloat(s)
684
- * return isNaN(n) ? undefined : n
685
- * }
686
- *
687
- * const g = fromNullableK(f)
688
- *
689
- * assert.deepStrictEqual(g('1'), some(1))
690
- * assert.deepStrictEqual(g('a'), none)
691
- *
692
- * @category combinators
693
- * @since 2.9.0
694
- */
695
- function fromNullableK(f) {
696
- return function () {
697
- var a = [];
698
- for (var _i = 0; _i < arguments.length; _i++) {
699
- a[_i] = arguments[_i];
700
- }
701
- return fromNullable(f.apply(void 0, a));
702
- };
703
- }
704
- exports.fromNullableK = fromNullableK;
705
- /**
706
- * @category combinators
707
- * @since 2.0.0
708
- * @deprecated
709
- */
710
- exports.mapNullable = chainNullableK;
711
- /**
712
- * This is `chain` + `fromNullable`, useful when working with optional values.
713
- *
714
- * @example
715
- * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'
716
- * import { pipe } from 'fp-ts/function'
717
- *
718
- * interface Employee {
719
- * company?: {
720
- * address?: {
721
- * street?: {
722
- * name?: string
723
- * }
724
- * }
725
- * }
726
- * }
727
- *
728
- * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
729
- *
730
- * assert.deepStrictEqual(
731
- * pipe(
732
- * fromNullable(employee1.company),
733
- * chainNullableK(company => company.address),
734
- * chainNullableK(address => address.street),
735
- * chainNullableK(street => street.name)
736
- * ),
737
- * some('high street')
738
- * )
739
- *
740
- * const employee2: Employee = { company: { address: { street: {} } } }
741
- *
742
- * assert.deepStrictEqual(
743
- * pipe(
744
- * fromNullable(employee2.company),
745
- * chainNullableK(company => company.address),
746
- * chainNullableK(address => address.street),
747
- * chainNullableK(street => street.name)
748
- * ),
749
- * none
750
- * )
751
- *
752
- * @category combinators
753
- * @since 2.9.0
754
- */
755
- function chainNullableK(f) {
756
- return function (ma) { return (exports.isNone(ma) ? exports.none : fromNullable(f(ma.value))); };
757
- }
758
- exports.chainNullableK = chainNullableK;
759
- // -------------------------------------------------------------------------------------
760
- // non-pipeables
761
- // -------------------------------------------------------------------------------------
762
- var map_ = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
763
- var ap_ = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
764
- var chain_ = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
765
- var reduce_ = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
766
- var foldMap_ = function (M) {
767
- var foldMapM = exports.foldMap(M);
768
- return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
769
- };
770
- var reduceRight_ = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
771
- var traverse_ = function (F) {
772
- var traverseF = exports.traverse(F);
773
- return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
774
- };
775
- /* istanbul ignore next */
776
- var alt_ = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
777
- var filter_ = function (fa, predicate) {
778
- return _function.pipe(fa, exports.filter(predicate));
779
- };
780
- /* istanbul ignore next */
781
- var filterMap_ = function (fa, f) { return _function.pipe(fa, exports.filterMap(f)); };
782
- /* istanbul ignore next */
783
- var extend_ = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
784
- /* istanbul ignore next */
785
- var partition_ = function (fa, predicate) { return _function.pipe(fa, exports.partition(predicate)); };
786
- /* istanbul ignore next */
787
- var partitionMap_ = function (fa, f) { return _function.pipe(fa, exports.partitionMap(f)); };
788
- /* istanbul ignore next */
789
- var wither_ = function (F) {
790
- var witherF = exports.wither(F);
791
- return function (fa, f) { return _function.pipe(fa, witherF(f)); };
792
- };
793
- /* istanbul ignore next */
794
- var wilt_ = function (F) {
795
- var wiltF = exports.wilt(F);
796
- return function (fa, f) { return _function.pipe(fa, wiltF(f)); };
797
- };
798
- // -------------------------------------------------------------------------------------
799
- // pipeables
800
- // -------------------------------------------------------------------------------------
801
- /**
802
- * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
803
- * use the type constructor `F` to represent some computational context.
804
- *
805
- * @category Functor
806
- * @since 2.0.0
807
- */
808
- var map = function (f) { return function (fa) {
809
- return exports.isNone(fa) ? exports.none : exports.some(f(fa.value));
810
- }; };
811
- exports.map = map;
812
- /**
813
- * Apply a function to an argument under a type constructor.
814
- *
815
- * @category Apply
816
- * @since 2.0.0
817
- */
818
- var ap = function (fa) { return function (fab) {
819
- return exports.isNone(fab) ? exports.none : exports.isNone(fa) ? exports.none : exports.some(fab.value(fa.value));
820
- }; };
821
- exports.ap = ap;
822
- /**
823
- * Combine two effectful actions, keeping only the result of the first.
824
- *
825
- * Derivable from `Apply`.
826
- *
827
- * @category combinators
828
- * @since 2.0.0
829
- */
830
- var apFirst = function (fb) {
831
- return _function.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb));
832
- };
833
- exports.apFirst = apFirst;
834
- /**
835
- * Combine two effectful actions, keeping only the result of the second.
836
- *
837
- * Derivable from `Apply`.
838
- *
839
- * @category combinators
840
- * @since 2.0.0
841
- */
842
- var apSecond = function (fb) {
843
- return _function.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb));
844
- };
845
- exports.apSecond = apSecond;
846
- /**
847
- * Wrap a value into the type constructor.
848
- *
849
- * @category Applicative
850
- * @since 2.7.0
851
- */
852
- exports.of = exports.some;
853
- /**
854
- * Composes computations in sequence, using the return value of one computation to determine the next computation.
855
- *
856
- * @category Monad
857
- * @since 2.0.0
858
- */
859
- var chain = function (f) { return function (ma) {
860
- return exports.isNone(ma) ? exports.none : f(ma.value);
861
- }; };
862
- exports.chain = chain;
863
- /**
864
- * Composes computations in sequence, using the return value of one computation to determine the next computation and
865
- * keeping only the result of the first.
866
- *
867
- * Derivable from `Monad`.
868
- *
869
- * @category combinators
870
- * @since 2.0.0
871
- */
872
- var chainFirst = function (f) {
873
- return exports.chain(function (a) {
874
- return _function.pipe(f(a), exports.map(function () { return a; }));
875
- });
876
- };
877
- exports.chainFirst = chainFirst;
878
- /**
879
- * Derivable from `Monad`.
880
- *
881
- * @category combinators
882
- * @since 2.0.0
883
- */
884
- exports.flatten =
885
- /*#__PURE__*/
886
- exports.chain(_function.identity);
887
- /**
888
- * Less strict version of [`alt`](#alt).
889
- *
890
- * @category Alt
891
- * @since 2.9.0
892
- */
893
- var altW = function (that) { return function (fa) {
894
- return exports.isNone(fa) ? that() : fa;
895
- }; };
896
- exports.altW = altW;
897
- /**
898
- * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
899
- * types of kind `* -> *`.
900
- *
901
- * In case of `Option` returns the left-most non-`None` value.
902
- *
903
- * @example
904
- * import * as O from 'fp-ts/Option'
905
- * import { pipe } from 'fp-ts/function'
906
- *
907
- * assert.deepStrictEqual(
908
- * pipe(
909
- * O.some('a'),
910
- * O.alt(() => O.some('b'))
911
- * ),
912
- * O.some('a')
913
- * )
914
- * assert.deepStrictEqual(
915
- * pipe(
916
- * O.none,
917
- * O.alt(() => O.some('b'))
918
- * ),
919
- * O.some('b')
920
- * )
921
- *
922
- * @category Alt
923
- * @since 2.0.0
924
- */
925
- exports.alt = exports.altW;
926
- /**
927
- * @category Alternative
928
- * @since 2.7.0
929
- */
930
- var zero = function () { return exports.none; };
931
- exports.zero = zero;
932
- /**
933
- * @category MonadThrow
934
- * @since 2.7.0
935
- */
936
- var throwError = function () { return exports.none; };
937
- exports.throwError = throwError;
938
- /**
939
- * @category Extend
940
- * @since 2.0.0
941
- */
942
- var extend = function (f) { return function (wa) {
943
- return exports.isNone(wa) ? exports.none : exports.some(f(wa));
944
- }; };
945
- exports.extend = extend;
946
- /**
947
- * Derivable from `Extend`.
948
- *
949
- * @category combinators
950
- * @since 2.0.0
951
- */
952
- exports.duplicate =
953
- /*#__PURE__*/
954
- exports.extend(_function.identity);
955
- /**
956
- * @category Foldable
957
- * @since 2.0.0
958
- */
959
- var reduce = function (b, f) { return function (fa) {
960
- return exports.isNone(fa) ? b : f(b, fa.value);
961
- }; };
962
- exports.reduce = reduce;
963
- /**
964
- * @category Foldable
965
- * @since 2.0.0
966
- */
967
- var foldMap = function (M) { return function (f) { return function (fa) {
968
- return exports.isNone(fa) ? M.empty : f(fa.value);
969
- }; }; };
970
- exports.foldMap = foldMap;
971
- /**
972
- * @category Foldable
973
- * @since 2.0.0
974
- */
975
- var reduceRight = function (b, f) { return function (fa) {
976
- return exports.isNone(fa) ? b : f(fa.value, b);
977
- }; };
978
- exports.reduceRight = reduceRight;
979
- /**
980
- * @category Compactable
981
- * @since 2.0.0
982
- */
983
- exports.compact = exports.flatten;
984
- var defaultSeparate = { left: exports.none, right: exports.none };
985
- /**
986
- * @category Compactable
987
- * @since 2.0.0
988
- */
989
- var separate = function (ma) {
990
- var o = _function.pipe(ma, exports.map(function (e) { return ({
991
- left: getLeft(e),
992
- right: getRight(e)
993
- }); }));
994
- return exports.isNone(o) ? defaultSeparate : o.value;
995
- };
996
- exports.separate = separate;
997
- /**
998
- * @category Filterable
999
- * @since 2.0.0
1000
- */
1001
- var filter = function (predicate) { return function (fa) { return (exports.isNone(fa) ? exports.none : predicate(fa.value) ? fa : exports.none); }; };
1002
- exports.filter = filter;
1003
- /**
1004
- * @category Filterable
1005
- * @since 2.0.0
1006
- */
1007
- var filterMap = function (f) { return function (fa) {
1008
- return exports.isNone(fa) ? exports.none : f(fa.value);
1009
- }; };
1010
- exports.filterMap = filterMap;
1011
- /**
1012
- * @category Filterable
1013
- * @since 2.0.0
1014
- */
1015
- var partition = function (predicate) { return function (fa) {
1016
- return {
1017
- left: filter_(fa, function (a) { return !predicate(a); }),
1018
- right: filter_(fa, predicate)
1019
- };
1020
- }; };
1021
- exports.partition = partition;
1022
- /**
1023
- * @category Filterable
1024
- * @since 2.0.0
1025
- */
1026
- var partitionMap = function (f) { return _function.flow(exports.map(f), exports.separate); };
1027
- exports.partitionMap = partitionMap;
1028
- /**
1029
- * @category Traversable
1030
- * @since 2.6.3
1031
- */
1032
- var traverse = function (F) { return function (f) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(f(ta.value), exports.some)); }; }; };
1033
- exports.traverse = traverse;
1034
- /**
1035
- * @category Traversable
1036
- * @since 2.6.3
1037
- */
1038
- var sequence = function (F) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(ta.value, exports.some)); }; };
1039
- exports.sequence = sequence;
1040
- /**
1041
- * @category Witherable
1042
- * @since 2.6.5
1043
- */
1044
- var wither = function (F) { return function (f) { return function (fa) { return (exports.isNone(fa) ? F.of(exports.none) : f(fa.value)); }; }; };
1045
- exports.wither = wither;
1046
- /**
1047
- * @category Witherable
1048
- * @since 2.6.5
1049
- */
1050
- var wilt = function (F) { return function (f) { return function (fa) {
1051
- return exports.isNone(fa)
1052
- ? F.of({
1053
- left: exports.none,
1054
- right: exports.none
1055
- })
1056
- : F.map(f(fa.value), function (e) { return ({
1057
- left: getLeft(e),
1058
- right: getRight(e)
1059
- }); });
1060
- }; }; };
1061
- exports.wilt = wilt;
1062
- // -------------------------------------------------------------------------------------
1063
- // instances
1064
- // -------------------------------------------------------------------------------------
1065
- /**
1066
- * @category instances
1067
- * @since 2.0.0
1068
- */
1069
- exports.URI = 'Option';
1070
- /**
1071
- * @category instances
1072
- * @since 2.0.0
1073
- */
1074
- function getShow(S) {
1075
- return {
1076
- show: function (ma) { return (exports.isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); }
1077
- };
1078
- }
1079
- exports.getShow = getShow;
1080
- /**
1081
- * @example
1082
- * import { none, some, getEq } from 'fp-ts/Option'
1083
- * import { eqNumber } from 'fp-ts/Eq'
1084
- *
1085
- * const E = getEq(eqNumber)
1086
- * assert.strictEqual(E.equals(none, none), true)
1087
- * assert.strictEqual(E.equals(none, some(1)), false)
1088
- * assert.strictEqual(E.equals(some(1), none), false)
1089
- * assert.strictEqual(E.equals(some(1), some(2)), false)
1090
- * assert.strictEqual(E.equals(some(1), some(1)), true)
1091
- *
1092
- * @category instances
1093
- * @since 2.0.0
1094
- */
1095
- function getEq(E) {
1096
- return {
1097
- equals: function (x, y) { return x === y || (exports.isNone(x) ? exports.isNone(y) : exports.isNone(y) ? false : E.equals(x.value, y.value)); }
1098
- };
1099
- }
1100
- exports.getEq = getEq;
1101
- /**
1102
- * The `Ord` instance allows `Option` values to be compared with
1103
- * `compare`, whenever there is an `Ord` instance for
1104
- * the type the `Option` contains.
1105
- *
1106
- * `None` is considered to be less than any `Some` value.
1107
- *
1108
- *
1109
- * @example
1110
- * import { none, some, getOrd } from 'fp-ts/Option'
1111
- * import { ordNumber } from 'fp-ts/Ord'
1112
- *
1113
- * const O = getOrd(ordNumber)
1114
- * assert.strictEqual(O.compare(none, none), 0)
1115
- * assert.strictEqual(O.compare(none, some(1)), -1)
1116
- * assert.strictEqual(O.compare(some(1), none), 1)
1117
- * assert.strictEqual(O.compare(some(1), some(2)), -1)
1118
- * assert.strictEqual(O.compare(some(1), some(1)), 0)
1119
- *
1120
- * @category instances
1121
- * @since 2.0.0
1122
- */
1123
- function getOrd(O) {
1124
- return {
1125
- equals: getEq(O).equals,
1126
- compare: function (x, y) { return (x === y ? 0 : exports.isSome(x) ? (exports.isSome(y) ? O.compare(x.value, y.value) : 1) : -1); }
1127
- };
1128
- }
1129
- exports.getOrd = getOrd;
1130
- /**
1131
- * `Apply` semigroup
1132
- *
1133
- * | x | y | concat(x, y) |
1134
- * | ------- | ------- | ------------------ |
1135
- * | none | none | none |
1136
- * | some(a) | none | none |
1137
- * | none | some(a) | none |
1138
- * | some(a) | some(b) | some(concat(a, b)) |
1139
- *
1140
- * @example
1141
- * import { getApplySemigroup, some, none } from 'fp-ts/Option'
1142
- * import { semigroupSum } from 'fp-ts/Semigroup'
1143
- *
1144
- * const S = getApplySemigroup(semigroupSum)
1145
- * assert.deepStrictEqual(S.concat(none, none), none)
1146
- * assert.deepStrictEqual(S.concat(some(1), none), none)
1147
- * assert.deepStrictEqual(S.concat(none, some(1)), none)
1148
- * assert.deepStrictEqual(S.concat(some(1), some(2)), some(3))
1149
- *
1150
- * @category instances
1151
- * @since 2.0.0
1152
- */
1153
- function getApplySemigroup(S) {
1154
- return {
1155
- concat: function (x, y) { return (exports.isSome(x) && exports.isSome(y) ? exports.some(S.concat(x.value, y.value)) : exports.none); }
1156
- };
1157
- }
1158
- exports.getApplySemigroup = getApplySemigroup;
1159
- /**
1160
- * @category instances
1161
- * @since 2.0.0
1162
- */
1163
- function getApplyMonoid(M) {
1164
- return {
1165
- concat: getApplySemigroup(M).concat,
1166
- empty: exports.some(M.empty)
1167
- };
1168
- }
1169
- exports.getApplyMonoid = getApplyMonoid;
1170
- /**
1171
- * Monoid returning the left-most non-`None` value
1172
- *
1173
- * | x | y | concat(x, y) |
1174
- * | ------- | ------- | ------------ |
1175
- * | none | none | none |
1176
- * | some(a) | none | some(a) |
1177
- * | none | some(a) | some(a) |
1178
- * | some(a) | some(b) | some(a) |
1179
- *
1180
- * @example
1181
- * import { getFirstMonoid, some, none } from 'fp-ts/Option'
1182
- *
1183
- * const M = getFirstMonoid<number>()
1184
- * assert.deepStrictEqual(M.concat(none, none), none)
1185
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1186
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1187
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))
1188
- *
1189
- * @category instances
1190
- * @since 2.0.0
1191
- */
1192
- function getFirstMonoid() {
1193
- return {
1194
- concat: function (x, y) { return (exports.isNone(x) ? y : x); },
1195
- empty: exports.none
1196
- };
1197
- }
1198
- exports.getFirstMonoid = getFirstMonoid;
1199
- /**
1200
- * Monoid returning the right-most non-`None` value
1201
- *
1202
- * | x | y | concat(x, y) |
1203
- * | ------- | ------- | ------------ |
1204
- * | none | none | none |
1205
- * | some(a) | none | some(a) |
1206
- * | none | some(a) | some(a) |
1207
- * | some(a) | some(b) | some(b) |
1208
- *
1209
- * @example
1210
- * import { getLastMonoid, some, none } from 'fp-ts/Option'
1211
- *
1212
- * const M = getLastMonoid<number>()
1213
- * assert.deepStrictEqual(M.concat(none, none), none)
1214
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1215
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1216
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))
1217
- *
1218
- * @category instances
1219
- * @since 2.0.0
1220
- */
1221
- function getLastMonoid() {
1222
- return {
1223
- concat: function (x, y) { return (exports.isNone(y) ? x : y); },
1224
- empty: exports.none
1225
- };
1226
- }
1227
- exports.getLastMonoid = getLastMonoid;
1228
- /**
1229
- * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are
1230
- * concatenated using the provided `Semigroup`
1231
- *
1232
- * | x | y | concat(x, y) |
1233
- * | ------- | ------- | ------------------ |
1234
- * | none | none | none |
1235
- * | some(a) | none | some(a) |
1236
- * | none | some(a) | some(a) |
1237
- * | some(a) | some(b) | some(concat(a, b)) |
1238
- *
1239
- * @example
1240
- * import { getMonoid, some, none } from 'fp-ts/Option'
1241
- * import { semigroupSum } from 'fp-ts/Semigroup'
1242
- *
1243
- * const M = getMonoid(semigroupSum)
1244
- * assert.deepStrictEqual(M.concat(none, none), none)
1245
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1246
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1247
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))
1248
- *
1249
- * @category instances
1250
- * @since 2.0.0
1251
- */
1252
- function getMonoid(S) {
1253
- return {
1254
- concat: function (x, y) { return (exports.isNone(x) ? y : exports.isNone(y) ? x : exports.some(S.concat(x.value, y.value))); },
1255
- empty: exports.none
1256
- };
1257
- }
1258
- exports.getMonoid = getMonoid;
1259
- /**
1260
- * @category instances
1261
- * @since 2.7.0
1262
- */
1263
- exports.Functor = {
1264
- URI: exports.URI,
1265
- map: map_
1266
- };
1267
- /**
1268
- * @category instances
1269
- * @since 2.7.0
1270
- */
1271
- exports.Applicative = {
1272
- URI: exports.URI,
1273
- map: map_,
1274
- ap: ap_,
1275
- of: exports.of
1276
- };
1277
- /**
1278
- * @category instances
1279
- * @since 2.7.0
1280
- */
1281
- exports.Monad = {
1282
- URI: exports.URI,
1283
- map: map_,
1284
- ap: ap_,
1285
- of: exports.of,
1286
- chain: chain_
1287
- };
1288
- /**
1289
- * @category instances
1290
- * @since 2.7.0
1291
- */
1292
- exports.Foldable = {
1293
- URI: exports.URI,
1294
- reduce: reduce_,
1295
- foldMap: foldMap_,
1296
- reduceRight: reduceRight_
1297
- };
1298
- /**
1299
- * @category instances
1300
- * @since 2.7.0
1301
- */
1302
- exports.Alt = {
1303
- URI: exports.URI,
1304
- map: map_,
1305
- alt: alt_
1306
- };
1307
- /**
1308
- * @category instances
1309
- * @since 2.7.0
1310
- */
1311
- exports.Alternative = {
1312
- URI: exports.URI,
1313
- map: map_,
1314
- ap: ap_,
1315
- of: exports.of,
1316
- alt: alt_,
1317
- zero: exports.zero
1318
- };
1319
- /**
1320
- * @category instances
1321
- * @since 2.7.0
1322
- */
1323
- exports.Extend = {
1324
- URI: exports.URI,
1325
- map: map_,
1326
- extend: extend_
1327
- };
1328
- /**
1329
- * @category instances
1330
- * @since 2.7.0
1331
- */
1332
- exports.Compactable = {
1333
- URI: exports.URI,
1334
- compact: exports.compact,
1335
- separate: exports.separate
1336
- };
1337
- /**
1338
- * @category instances
1339
- * @since 2.7.0
1340
- */
1341
- exports.Filterable = {
1342
- URI: exports.URI,
1343
- map: map_,
1344
- compact: exports.compact,
1345
- separate: exports.separate,
1346
- filter: filter_,
1347
- filterMap: filterMap_,
1348
- partition: partition_,
1349
- partitionMap: partitionMap_
1350
- };
1351
- /**
1352
- * @category instances
1353
- * @since 2.7.0
1354
- */
1355
- exports.Traversable = {
1356
- URI: exports.URI,
1357
- map: map_,
1358
- reduce: reduce_,
1359
- foldMap: foldMap_,
1360
- reduceRight: reduceRight_,
1361
- traverse: traverse_,
1362
- sequence: exports.sequence
1363
- };
1364
- /**
1365
- * @category instances
1366
- * @since 2.7.0
1367
- */
1368
- exports.Witherable = {
1369
- URI: exports.URI,
1370
- map: map_,
1371
- reduce: reduce_,
1372
- foldMap: foldMap_,
1373
- reduceRight: reduceRight_,
1374
- traverse: traverse_,
1375
- sequence: exports.sequence,
1376
- compact: exports.compact,
1377
- separate: exports.separate,
1378
- filter: filter_,
1379
- filterMap: filterMap_,
1380
- partition: partition_,
1381
- partitionMap: partitionMap_,
1382
- wither: wither_,
1383
- wilt: wilt_
1384
- };
1385
- /**
1386
- * @category instances
1387
- * @since 2.7.0
1388
- */
1389
- exports.MonadThrow = {
1390
- URI: exports.URI,
1391
- map: map_,
1392
- ap: ap_,
1393
- of: exports.of,
1394
- chain: chain_,
1395
- throwError: exports.throwError
1396
- };
1397
- // TODO: remove in v3
1398
- /**
1399
- * @category instances
1400
- * @since 2.0.0
1401
- */
1402
- exports.option = {
1403
- URI: exports.URI,
1404
- map: map_,
1405
- of: exports.of,
1406
- ap: ap_,
1407
- chain: chain_,
1408
- reduce: reduce_,
1409
- foldMap: foldMap_,
1410
- reduceRight: reduceRight_,
1411
- traverse: traverse_,
1412
- sequence: exports.sequence,
1413
- zero: exports.zero,
1414
- alt: alt_,
1415
- extend: extend_,
1416
- compact: exports.compact,
1417
- separate: exports.separate,
1418
- filter: filter_,
1419
- filterMap: filterMap_,
1420
- partition: partition_,
1421
- partitionMap: partitionMap_,
1422
- wither: wither_,
1423
- wilt: wilt_,
1424
- throwError: exports.throwError
1425
- };
1426
- // -------------------------------------------------------------------------------------
1427
- // utils
1428
- // -------------------------------------------------------------------------------------
1429
- /**
1430
- * Returns `true` if `ma` contains `a`
1431
- *
1432
- * @example
1433
- * import { some, none, elem } from 'fp-ts/Option'
1434
- * import { eqNumber } from 'fp-ts/Eq'
1435
- *
1436
- * assert.strictEqual(elem(eqNumber)(1, some(1)), true)
1437
- * assert.strictEqual(elem(eqNumber)(2, some(1)), false)
1438
- * assert.strictEqual(elem(eqNumber)(1, none), false)
1439
- *
1440
- * @since 2.0.0
1441
- */
1442
- function elem(E) {
1443
- return function (a, ma) { return (exports.isNone(ma) ? false : E.equals(a, ma.value)); };
1444
- }
1445
- exports.elem = elem;
1446
- /**
1447
- * Returns `true` if the predicate is satisfied by the wrapped value
1448
- *
1449
- * @example
1450
- * import { some, none, exists } from 'fp-ts/Option'
1451
- * import { pipe } from 'fp-ts/function'
1452
- *
1453
- * assert.strictEqual(
1454
- * pipe(
1455
- * some(1),
1456
- * exists(n => n > 0)
1457
- * ),
1458
- * true
1459
- * )
1460
- * assert.strictEqual(
1461
- * pipe(
1462
- * some(1),
1463
- * exists(n => n > 1)
1464
- * ),
1465
- * false
1466
- * )
1467
- * assert.strictEqual(
1468
- * pipe(
1469
- * none,
1470
- * exists(n => n > 0)
1471
- * ),
1472
- * false
1473
- * )
1474
- *
1475
- * @since 2.0.0
1476
- */
1477
- function exists(predicate) {
1478
- return function (ma) { return (exports.isNone(ma) ? false : predicate(ma.value)); };
1479
- }
1480
- exports.exists = exists;
1481
- /**
1482
- * Returns a `Refinement` (i.e. a custom type guard) from a `Option` returning function.
1483
- * This function ensures that a custom type guard definition is type-safe.
1484
- *
1485
- * ```ts
1486
- * import { some, none, getRefinement } from 'fp-ts/Option'
1487
- *
1488
- * type A = { type: 'A' }
1489
- * type B = { type: 'B' }
1490
- * type C = A | B
1491
- *
1492
- * const isA = (c: C): c is A => c.type === 'B' // <= typo but typescript doesn't complain
1493
- * const isA = getRefinement<C, A>(c => (c.type === 'B' ? some(c) : none)) // static error: Type '"B"' is not assignable to type '"A"'
1494
- * ```
1495
- *
1496
- * @since 2.0.0
1497
- */
1498
- function getRefinement(getOption) {
1499
- return function (a) { return exports.isSome(getOption(a)); };
1500
- }
1501
- exports.getRefinement = getRefinement;
1502
- // -------------------------------------------------------------------------------------
1503
- // do notation
1504
- // -------------------------------------------------------------------------------------
1505
- /**
1506
- * @since 2.9.0
1507
- */
1508
- exports.Do =
1509
- /*#__PURE__*/
1510
- exports.of({});
1511
- /**
1512
- * @since 2.8.0
1513
- */
1514
- var bindTo = function (name) { return exports.map(_function.bindTo_(name)); };
1515
- exports.bindTo = bindTo;
1516
- /**
1517
- * @since 2.8.0
1518
- */
1519
- var bind = function (name, f) {
1520
- return exports.chain(function (a) {
1521
- return _function.pipe(f(a), exports.map(function (b) { return _function.bind_(a, name, b); }));
1522
- });
1523
- };
1524
- exports.bind = bind;
1525
- // -------------------------------------------------------------------------------------
1526
- // pipeable sequence S
1527
- // -------------------------------------------------------------------------------------
1528
- /**
1529
- * @since 2.8.0
1530
- */
1531
- var apS = function (name, fb) {
1532
- return _function.flow(exports.map(function (a) { return function (b) { return _function.bind_(a, name, b); }; }), exports.ap(fb));
1533
- };
1534
- exports.apS = apS;
1535
- // -------------------------------------------------------------------------------------
1536
- // array utils
1537
- // -------------------------------------------------------------------------------------
1538
- /**
1539
- *
1540
- * @since 2.9.0
1541
- */
1542
- var traverseArrayWithIndex = function (f) { return function (arr) {
1543
- // tslint:disable-next-line: readonly-array
1544
- var result = [];
1545
- for (var i = 0; i < arr.length; i++) {
1546
- var b = f(i, arr[i]);
1547
- if (exports.isNone(b)) {
1548
- return exports.none;
1549
- }
1550
- result.push(b.value);
1551
- }
1552
- return exports.some(result);
1553
- }; };
1554
- exports.traverseArrayWithIndex = traverseArrayWithIndex;
1555
- /**
1556
- * Runs an action for every element in array and accumulates the results in option
1557
- *
1558
- * this function has the same behavior of `A.sequence(O.option)` but it's optimized and performs better
1559
- *
1560
- * @example
1561
- *
1562
- * import * as A from 'fp-ts/Array'
1563
- * import { traverseArray, some, fromPredicate, none } from 'fp-ts/Option'
1564
- * import { pipe } from 'fp-ts/function'
1565
- *
1566
- * const arr = A.range(0, 10)
1567
- * assert.deepStrictEqual(pipe(arr, traverseArray(some)), some(arr))
1568
- * assert.deepStrictEqual(pipe(arr, traverseArray(fromPredicate((x) => x > 5))), none)
1569
- *
1570
- * @since 2.9.0
1571
- */
1572
- var traverseArray = function (f) { return exports.traverseArrayWithIndex(function (_, a) { return f(a); }); };
1573
- exports.traverseArray = traverseArray;
1574
- /**
1575
- * get an array of option and convert it to option of array
1576
- *
1577
- * this function has the same behavior of `A.sequence(O.option)` but it's optimized and performs better
1578
- *
1579
- * @example
1580
- *
1581
- * import * as A from 'fp-ts/Array'
1582
- * import { sequenceArray, some, none, fromPredicate } from 'fp-ts/Option'
1583
- * import { pipe } from 'fp-ts/function'
1584
- *
1585
- * const arr = A.range(0, 10)
1586
- * assert.deepStrictEqual(pipe(arr, A.map(some), sequenceArray), some(arr))
1587
- * assert.deepStrictEqual(pipe(arr, A.map(fromPredicate(x => x > 8)), sequenceArray), none)
1588
- *
1589
- * @since 2.9.0
1590
- */
1591
- exports.sequenceArray =
1592
- /*#__PURE__*/
1593
- exports.traverseArray(_function.identity);
1594
- });
1595
-
1596
- class AppConfigurationService {
1597
- set apiBaseUrl(url) {
1598
- AppConfigurationService._apiBaseUrl = Option.fromNullable(url);
1599
- }
1600
- get apiBaseUrl() {
1601
- if (Option.isNone(AppConfigurationService._apiBaseUrl)) {
1602
- throw Error('API base URL is not set');
1603
- }
1604
- return AppConfigurationService._apiBaseUrl.value;
1605
- }
1606
- }
1607
- const appConfigurationService = new AppConfigurationService();
1608
-
1609
- var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1610
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1611
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1612
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1613
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1614
- };
1615
- function createInitialState() {
1616
- return {
1617
- vehicle: {
1618
- make: none,
1619
- makeId: none,
1620
- model: none,
1621
- modelId: none,
1622
- year: none,
1623
- bodyType: none,
1624
- bodyTypeId: none,
1625
- selectedVariant: none,
1626
- isUsedCarRequested: some(false),
1627
- approximatePrice: none
1628
- },
1629
- user: {
1630
- annualSalary: none,
1631
- annualKms: none,
1632
- paymentPeriod: none,
1633
- state: none,
1634
- term: none
1635
- },
1636
- quote: {
1637
- afterTaxEffectPerPayCycle: none,
1638
- taxSaving: none,
1639
- residualValue: none,
1640
- financedAmount: none,
1641
- fuel: none,
1642
- serviceAndMaintenance: none,
1643
- registrationAndCtp: none,
1644
- comprehensiveInsurance: none,
1645
- managementFee: none,
1646
- quoteState: 'Not calculated'
1647
- },
1648
- userDetails: {
1649
- employerName: none,
1650
- userFirstName: none,
1651
- userLastName: none,
1652
- contactNumber: none,
1653
- emailAddress: none
1654
- },
1655
- refLists: {
1656
- makeList: none,
1657
- modelList: none,
1658
- yearList: none,
1659
- bodyTypeList: none,
1660
- modelVariantsList: none
1661
- }
1662
- };
1663
- }
1664
- let SessionStore = class SessionStore extends Store {
1665
- constructor() {
1666
- super(createInitialState());
1667
- }
1668
- updateQuote(quote) {
1669
- this.update({
1670
- quote: quote
1671
- });
1672
- }
1673
- setVehicleState(key, value) {
1674
- this.update((state) => (Object.assign(Object.assign({}, state), { vehicle: Object.assign(Object.assign({}, state.vehicle), { [key]: value === null ? none : some(value) }) })));
1675
- }
1676
- updateList(name, value) {
1677
- this.update((state) => (Object.assign(Object.assign({}, state), { refLists: Object.assign(Object.assign({}, state.refLists), { [name]: some(value) }) })));
1678
- }
1679
- };
1680
- SessionStore = __decorate([
1681
- StoreConfig({ name: 'cars-calc-session', resettable: true })
1682
- ], SessionStore);
1683
- const sessionStore = new SessionStore();
1684
-
1685
- class SessionQuery extends Query {
1686
- constructor(store) {
1687
- super(store);
1688
- this.store = store;
1689
- this.vehicle$ = this.select((state) => state.vehicle);
1690
- this.user$ = this.select((state) => state.user);
1691
- this.result$ = this.select((state) => state.quote);
1692
- this.userDetails$ = this.select((state) => state.userDetails);
1693
- this.makeList$ = this.select((state) => state.refLists.makeList);
1694
- this.modelList$ = this.select((state) => state.refLists.modelList);
1695
- this.yearList$ = this.select((state) => state.refLists.yearList);
1696
- this.bodyTypeList$ = this.select((state) => state.refLists.bodyTypeList);
1697
- this.modelVariantsList$ = this.select((state) => state.refLists.modelVariantsList);
1698
- this.selectedVariant$ = this.select((state) => state.vehicle.selectedVariant);
1699
- this.quote$ = this.select((state) => state.quote);
1700
- }
1701
- get selectedVariant() {
1702
- return this.getValue().vehicle.selectedVariant;
1703
- }
1704
- get vehicle() {
1705
- return this.getValue().vehicle;
1706
- }
1707
- get user() {
1708
- return this.getValue().user;
1709
- }
1710
- get result() {
1711
- return this.getValue().quote;
1712
- }
1713
- get userDetails() {
1714
- return this.getValue().userDetails;
1715
- }
1716
- }
1717
- const sessionQuery = new SessionQuery(sessionStore);
1718
-
1719
- export { appConfigurationService as a, isNone as b, sessionStore as c, fold as d, some as e, fromNullable as f, getOrElse as g, getOrElseW as h, isSome as i, none as n, sessionQuery as s };