effect-app 1.32.0 → 2.0.0

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 (310) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/Array.cjs +132 -0
  3. package/_cjs/Array.cjs.map +1 -0
  4. package/_cjs/Chunk.cjs +128 -0
  5. package/_cjs/Chunk.cjs.map +1 -0
  6. package/_cjs/Config/SecretURL.cjs +3 -3
  7. package/_cjs/Config/SecretURL.cjs.map +1 -1
  8. package/_cjs/Config/internal/configSecretURL.cjs +2 -2
  9. package/_cjs/Config/internal/configSecretURL.cjs.map +1 -1
  10. package/_cjs/Context.cjs +243 -0
  11. package/_cjs/Context.cjs.map +1 -0
  12. package/_cjs/Dictionary.cjs +522 -0
  13. package/_cjs/Dictionary.cjs.map +1 -0
  14. package/_cjs/Effect.cjs +202 -0
  15. package/_cjs/Effect.cjs.map +1 -0
  16. package/_cjs/Function.cjs +107 -0
  17. package/_cjs/Function.cjs.map +1 -0
  18. package/_cjs/NonEmptySet.cjs +26 -0
  19. package/_cjs/NonEmptySet.cjs.map +1 -0
  20. package/_cjs/NonEmptySetAspects.cjs +17 -0
  21. package/_cjs/NonEmptySetAspects.cjs.map +1 -0
  22. package/_cjs/NonEmptySetBase.cjs +82 -0
  23. package/_cjs/NonEmptySetBase.cjs.map +1 -0
  24. package/_cjs/Object.cjs +24 -0
  25. package/_cjs/Object.cjs.map +1 -0
  26. package/_cjs/Operations.cjs +1 -1
  27. package/_cjs/Option.cjs +88 -0
  28. package/_cjs/Option.cjs.map +1 -0
  29. package/_cjs/Prelude.cjs +51 -0
  30. package/_cjs/Prelude.cjs.map +1 -0
  31. package/_cjs/Prelude.code.cjs +51 -0
  32. package/_cjs/Prelude.code.cjs.map +1 -0
  33. package/_cjs/Pure.cjs +39 -36
  34. package/_cjs/Pure.cjs.map +1 -1
  35. package/_cjs/Schema/Class.cjs +61 -0
  36. package/_cjs/Schema/Class.cjs.map +1 -0
  37. package/_cjs/Schema/FastCheck.cjs +39 -0
  38. package/_cjs/Schema/FastCheck.cjs.map +1 -0
  39. package/_cjs/Schema/Methods.cjs +6 -0
  40. package/_cjs/Schema/Methods.cjs.map +1 -0
  41. package/_cjs/Schema/brand.cjs +17 -0
  42. package/_cjs/Schema/brand.cjs.map +1 -0
  43. package/_cjs/Schema/email.cjs +20 -0
  44. package/_cjs/Schema/email.cjs.map +1 -0
  45. package/_cjs/Schema/ext.cjs +174 -0
  46. package/_cjs/Schema/ext.cjs.map +1 -0
  47. package/_cjs/Schema/moreStrings.cjs +124 -0
  48. package/_cjs/Schema/moreStrings.cjs.map +1 -0
  49. package/_cjs/Schema/numbers.cjs +52 -0
  50. package/_cjs/Schema/numbers.cjs.map +1 -0
  51. package/_cjs/Schema/phoneNumber.cjs +22 -0
  52. package/_cjs/Schema/phoneNumber.cjs.map +1 -0
  53. package/_cjs/Schema/schema.cjs +15 -0
  54. package/_cjs/Schema/schema.cjs.map +1 -0
  55. package/_cjs/Schema/strings.cjs +32 -0
  56. package/_cjs/Schema/strings.cjs.map +1 -0
  57. package/_cjs/Schema.cjs +334 -0
  58. package/_cjs/Schema.cjs.map +1 -0
  59. package/_cjs/Set.cjs +567 -0
  60. package/_cjs/Set.cjs.map +1 -0
  61. package/_cjs/Struct.cjs +51 -0
  62. package/_cjs/Struct.cjs.map +1 -0
  63. package/_cjs/Tag.cjs +25 -0
  64. package/_cjs/Tag.cjs.map +1 -0
  65. package/_cjs/Unify.cjs +40 -0
  66. package/_cjs/Unify.cjs.map +1 -0
  67. package/_cjs/_ext/misc.cjs +16 -16
  68. package/_cjs/_ext/misc.cjs.map +1 -1
  69. package/_cjs/_ext/ord.ext.cjs +52 -0
  70. package/_cjs/_ext/ord.ext.cjs.map +1 -0
  71. package/_cjs/builtin.cjs +6 -0
  72. package/_cjs/builtin.cjs.map +1 -0
  73. package/_cjs/client/clientFor.cjs +5 -3
  74. package/_cjs/client/clientFor.cjs.map +1 -1
  75. package/_cjs/client/config.cjs +4 -4
  76. package/_cjs/client/config.cjs.map +1 -1
  77. package/_cjs/client/errors.cjs +9 -9
  78. package/_cjs/client/errors.cjs.map +1 -1
  79. package/_cjs/http/http-client.cjs +35 -0
  80. package/_cjs/http/http-client.cjs.map +1 -0
  81. package/_cjs/ids.cjs +5 -5
  82. package/_cjs/ids.cjs.map +1 -1
  83. package/_cjs/index.cjs +1 -1
  84. package/_cjs/lib.cjs +178 -9
  85. package/_cjs/lib.cjs.map +1 -1
  86. package/_cjs/logger.cjs +1 -1
  87. package/_cjs/transform.cjs +45 -0
  88. package/_cjs/transform.cjs.map +1 -0
  89. package/_cjs/utils/effectify.cjs +25 -0
  90. package/_cjs/utils/effectify.cjs.map +1 -0
  91. package/_cjs/utils/extend.cjs +17 -0
  92. package/_cjs/utils/extend.cjs.map +1 -0
  93. package/_cjs/utils/logger.cjs +23 -0
  94. package/_cjs/utils/logger.cjs.map +1 -0
  95. package/_cjs/utils.cjs +431 -4
  96. package/_cjs/utils.cjs.map +1 -1
  97. package/_cjs/validation/validators.cjs +32 -0
  98. package/_cjs/validation/validators.cjs.map +1 -0
  99. package/_cjs/validation.cjs +45 -0
  100. package/_cjs/validation.cjs.map +1 -0
  101. package/dist/Array.d.ts +64 -0
  102. package/dist/Array.d.ts.map +1 -0
  103. package/dist/Array.js +89 -0
  104. package/dist/Chunk.d.ts +68 -0
  105. package/dist/Chunk.d.ts.map +1 -0
  106. package/dist/Chunk.js +93 -0
  107. package/dist/Config/SecretURL.d.ts +3 -3
  108. package/dist/Config/SecretURL.d.ts.map +1 -1
  109. package/dist/Config/SecretURL.js +2 -2
  110. package/dist/Config/internal/configSecretURL.js +2 -2
  111. package/dist/Context.d.ts +55 -0
  112. package/dist/Context.d.ts.map +1 -0
  113. package/dist/Context.js +204 -0
  114. package/dist/Dictionary.d.ts +260 -0
  115. package/dist/Dictionary.d.ts.map +1 -0
  116. package/dist/Dictionary.js +448 -0
  117. package/dist/Effect.d.ts +115 -0
  118. package/dist/Effect.d.ts.map +1 -0
  119. package/dist/Effect.js +153 -0
  120. package/dist/Function.d.ts +72 -0
  121. package/dist/Function.d.ts.map +1 -0
  122. package/dist/Function.js +71 -0
  123. package/dist/Inputify.type.d.ts +1 -1
  124. package/dist/Inputify.type.d.ts.map +1 -1
  125. package/dist/NonEmptySet.d.ts +3 -0
  126. package/dist/NonEmptySet.d.ts.map +1 -0
  127. package/dist/NonEmptySet.js +3 -0
  128. package/dist/NonEmptySetAspects.d.ts +2 -0
  129. package/dist/NonEmptySetAspects.d.ts.map +1 -0
  130. package/dist/NonEmptySetAspects.js +2 -0
  131. package/dist/NonEmptySetBase.d.ts +39 -0
  132. package/dist/NonEmptySetBase.d.ts.map +1 -0
  133. package/dist/NonEmptySetBase.js +63 -0
  134. package/dist/Object.d.ts +7 -0
  135. package/dist/Object.d.ts.map +1 -0
  136. package/dist/Object.js +7 -0
  137. package/dist/Operations.d.ts +2 -2
  138. package/dist/Operations.js +1 -1
  139. package/dist/Option.d.ts +39 -0
  140. package/dist/Option.d.ts.map +1 -0
  141. package/dist/Option.js +55 -0
  142. package/dist/Prelude.code.d.ts +24 -0
  143. package/dist/Prelude.code.d.ts.map +1 -0
  144. package/dist/Prelude.code.js +23 -0
  145. package/dist/Prelude.d.ts +163 -0
  146. package/dist/Prelude.d.ts.map +1 -0
  147. package/dist/Prelude.js +23 -0
  148. package/dist/Pure.d.ts +13 -12
  149. package/dist/Pure.d.ts.map +1 -1
  150. package/dist/Pure.js +18 -17
  151. package/dist/Schema/Class.d.ts +45 -0
  152. package/dist/Schema/Class.d.ts.map +1 -0
  153. package/dist/Schema/Class.js +50 -0
  154. package/dist/Schema/FastCheck.d.ts +10 -0
  155. package/dist/Schema/FastCheck.d.ts.map +1 -0
  156. package/dist/Schema/FastCheck.js +12 -0
  157. package/dist/Schema/Methods.d.ts +6 -0
  158. package/dist/Schema/Methods.d.ts.map +1 -0
  159. package/dist/Schema/Methods.js +2 -0
  160. package/dist/Schema/brand.d.ts +35 -0
  161. package/dist/Schema/brand.d.ts.map +1 -0
  162. package/dist/Schema/brand.js +7 -0
  163. package/dist/Schema/email.d.ts +9 -0
  164. package/dist/Schema/email.d.ts.map +1 -0
  165. package/dist/Schema/email.js +12 -0
  166. package/dist/Schema/ext.d.ts +89 -0
  167. package/dist/Schema/ext.d.ts.map +1 -0
  168. package/dist/Schema/ext.js +111 -0
  169. package/dist/Schema/moreStrings.d.ts +109 -0
  170. package/dist/Schema/moreStrings.d.ts.map +1 -0
  171. package/dist/Schema/moreStrings.js +108 -0
  172. package/dist/Schema/numbers.d.ts +46 -0
  173. package/dist/Schema/numbers.d.ts.map +1 -0
  174. package/dist/Schema/numbers.js +28 -0
  175. package/dist/Schema/phoneNumber.d.ts +9 -0
  176. package/dist/Schema/phoneNumber.d.ts.map +1 -0
  177. package/dist/Schema/phoneNumber.js +14 -0
  178. package/dist/Schema/schema.d.ts +6 -0
  179. package/dist/Schema/schema.d.ts.map +1 -0
  180. package/dist/Schema/schema.js +5 -0
  181. package/dist/Schema/strings.d.ts +19 -0
  182. package/dist/Schema/strings.d.ts.map +1 -0
  183. package/dist/Schema/strings.js +32 -0
  184. package/dist/{schema.d.ts → Schema.d.ts} +25 -9
  185. package/dist/Schema.d.ts.map +1 -0
  186. package/dist/Schema.js +89 -0
  187. package/dist/Set.d.ts +221 -0
  188. package/dist/Set.d.ts.map +1 -0
  189. package/dist/Set.js +516 -0
  190. package/dist/Struct.d.ts +44 -0
  191. package/dist/Struct.d.ts.map +1 -0
  192. package/dist/Struct.js +29 -0
  193. package/dist/Tag.d.ts +9 -0
  194. package/dist/Tag.d.ts.map +1 -0
  195. package/dist/Tag.js +18 -0
  196. package/dist/Unify.d.ts +43 -0
  197. package/dist/Unify.d.ts.map +1 -0
  198. package/dist/Unify.js +31 -0
  199. package/dist/Widen.type.d.ts +1 -1
  200. package/dist/Widen.type.d.ts.map +1 -1
  201. package/dist/_ext/misc.d.ts +11 -11
  202. package/dist/_ext/misc.d.ts.map +1 -1
  203. package/dist/_ext/misc.js +8 -8
  204. package/dist/_ext/ord.ext.d.ts +23 -0
  205. package/dist/_ext/ord.ext.d.ts.map +1 -0
  206. package/dist/_ext/ord.ext.js +44 -0
  207. package/dist/builtin.d.ts +51 -0
  208. package/dist/builtin.d.ts.map +1 -0
  209. package/dist/builtin.js +2 -0
  210. package/dist/client/clientFor.d.ts +1 -1
  211. package/dist/client/clientFor.d.ts.map +1 -1
  212. package/dist/client/clientFor.js +2 -2
  213. package/dist/client/config.d.ts +1 -1
  214. package/dist/client/config.d.ts.map +1 -1
  215. package/dist/client/config.js +2 -2
  216. package/dist/client/errors.js +1 -1
  217. package/dist/http/http-client.d.ts +43 -0
  218. package/dist/http/http-client.d.ts.map +1 -0
  219. package/dist/http/http-client.js +30 -0
  220. package/dist/ids.d.ts +3 -3
  221. package/dist/ids.d.ts.map +1 -1
  222. package/dist/ids.js +2 -2
  223. package/dist/index.d.ts +1 -1
  224. package/dist/index.d.ts.map +1 -1
  225. package/dist/index.js +2 -2
  226. package/dist/lib.d.ts +22 -4
  227. package/dist/lib.d.ts.map +1 -1
  228. package/dist/lib.js +20 -5
  229. package/dist/logger.d.ts.map +1 -1
  230. package/dist/logger.js +2 -2
  231. package/dist/transform.d.ts +12 -0
  232. package/dist/transform.d.ts.map +1 -0
  233. package/dist/transform.js +39 -0
  234. package/dist/utils/effectify.d.ts +210 -0
  235. package/dist/utils/effectify.d.ts.map +1 -0
  236. package/dist/utils/effectify.js +19 -0
  237. package/dist/utils/extend.d.ts +3 -0
  238. package/dist/utils/extend.d.ts.map +1 -0
  239. package/dist/utils/extend.js +9 -0
  240. package/dist/utils/logger.d.ts +12 -0
  241. package/dist/utils/logger.d.ts.map +1 -0
  242. package/dist/utils/logger.js +15 -0
  243. package/dist/utils.d.ts +192 -1
  244. package/dist/utils.d.ts.map +1 -1
  245. package/dist/utils.js +332 -2
  246. package/dist/validation/validators.d.ts +11 -0
  247. package/dist/validation/validators.d.ts.map +1 -0
  248. package/dist/validation/validators.js +26 -0
  249. package/dist/validation.d.ts +13 -0
  250. package/dist/validation.d.ts.map +1 -0
  251. package/dist/validation.js +14 -0
  252. package/package.json +360 -9
  253. package/src/Array.ts +127 -0
  254. package/src/Chunk.ts +112 -0
  255. package/src/Config/SecretURL.ts +3 -3
  256. package/src/Config/internal/configSecretURL.ts +1 -1
  257. package/src/Context.ts +293 -0
  258. package/src/Dictionary.ts +669 -0
  259. package/src/Effect.ts +265 -0
  260. package/src/Function.ts +175 -0
  261. package/src/Inputify.type.ts +1 -1
  262. package/src/NonEmptySet.ts +3 -0
  263. package/src/NonEmptySetAspects.ts +1 -0
  264. package/src/NonEmptySetBase.ts +109 -0
  265. package/src/Object.ts +19 -0
  266. package/src/Operations.ts +1 -1
  267. package/src/Option.ts +82 -0
  268. package/src/Prelude.code.ts +26 -0
  269. package/src/Prelude.ts +220 -0
  270. package/src/Pure.ts +37 -30
  271. package/src/Schema/Class.ts +225 -0
  272. package/src/Schema/FastCheck.ts +23 -0
  273. package/src/Schema/Methods.ts +8 -0
  274. package/src/Schema/brand.ts +50 -0
  275. package/src/Schema/email.ts +22 -0
  276. package/src/Schema/ext.ts +273 -0
  277. package/src/Schema/moreStrings.ts +260 -0
  278. package/src/Schema/numbers.ts +83 -0
  279. package/src/Schema/phoneNumber.ts +24 -0
  280. package/src/Schema/schema.ts +6 -0
  281. package/src/Schema/strings.ts +60 -0
  282. package/src/{schema.ts → Schema.ts} +52 -20
  283. package/src/Set.ts +674 -0
  284. package/src/Struct.ts +54 -0
  285. package/src/Tag.ts +20 -0
  286. package/src/Unify.ts +56 -0
  287. package/src/Widen.type.ts +1 -1
  288. package/src/_ext/misc.ts +22 -22
  289. package/src/_ext/ord.ext.ts +49 -0
  290. package/src/builtin.ts +64 -0
  291. package/src/client/clientFor.ts +1 -1
  292. package/src/client/config.ts +1 -1
  293. package/src/client/errors.ts +1 -1
  294. package/src/http/http-client.ts +73 -0
  295. package/src/ids.ts +3 -3
  296. package/src/index.ts +1 -1
  297. package/src/lib.ts +88 -4
  298. package/src/logger.ts +1 -1
  299. package/src/transform.ts +80 -0
  300. package/src/utils/effectify.ts +259 -0
  301. package/src/utils/extend.ts +9 -0
  302. package/src/utils/logger.ts +24 -0
  303. package/src/utils.ts +805 -1
  304. package/src/validation/validators.ts +32 -0
  305. package/src/validation.ts +18 -0
  306. package/tsconfig.src.json +1 -5
  307. package/_cjs/schema.cjs +0 -110
  308. package/_cjs/schema.cjs.map +0 -1
  309. package/dist/schema.d.ts.map +0 -1
  310. package/dist/schema.js +0 -73
package/src/utils.ts CHANGED
@@ -1 +1,805 @@
1
- export * from "@effect-app/core/utils"
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Effect, Option } from "effect"
3
+ import * as Either from "effect/Either"
4
+ import { dual, isFunction } from "effect/Function"
5
+ import type { GetFieldType, NumericDictionary, PropertyPath } from "lodash"
6
+ import type { Dictionary } from "./Dictionary.js"
7
+ import * as D from "./Dictionary.js"
8
+ import { identity, pipe } from "./Function.js"
9
+
10
+ // codegen:start {preset: barrel, include: ./utils/*.ts, nodir: false }
11
+ export * from "./utils/effectify.js"
12
+ export * from "./utils/extend.js"
13
+ export * from "./utils/logger.js"
14
+ // codegen:end
15
+
16
+ export const cloneTrait = Symbol.for("clone-trait")
17
+ export interface Clone {
18
+ [cloneTrait](this: this, that: any): this
19
+ }
20
+
21
+ function get<TObject extends object, TKey extends keyof TObject>(object: TObject, path: TKey | [TKey]): TObject[TKey]
22
+ function get<TObject extends object, TKey extends keyof TObject>(
23
+ object: TObject | null | undefined,
24
+ path: TKey | [TKey]
25
+ ): TObject[TKey] | undefined
26
+ function get<TObject extends object, TKey extends keyof TObject, TDefault>(
27
+ object: TObject | null | undefined,
28
+ path: TKey | [TKey],
29
+ defaultValue: TDefault
30
+ ): Exclude<TObject[TKey], undefined> | TDefault
31
+ function get<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1]>(
32
+ object: TObject,
33
+ path: [TKey1, TKey2]
34
+ ): TObject[TKey1][TKey2]
35
+ function get<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1]>(
36
+ object: TObject | null | undefined,
37
+ path: [TKey1, TKey2]
38
+ ): TObject[TKey1][TKey2] | undefined
39
+ function get<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1], TDefault>(
40
+ object: TObject | null | undefined,
41
+ path: [TKey1, TKey2],
42
+ defaultValue: TDefault
43
+ ): Exclude<TObject[TKey1][TKey2], undefined> | TDefault
44
+ function get<
45
+ TObject extends object,
46
+ TKey1 extends keyof TObject,
47
+ TKey2 extends keyof TObject[TKey1],
48
+ TKey3 extends keyof TObject[TKey1][TKey2]
49
+ >(object: TObject, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3]
50
+ function get<
51
+ TObject extends object,
52
+ TKey1 extends keyof TObject,
53
+ TKey2 extends keyof TObject[TKey1],
54
+ TKey3 extends keyof TObject[TKey1][TKey2]
55
+ >(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3] | undefined
56
+ function get<
57
+ TObject extends object,
58
+ TKey1 extends keyof TObject,
59
+ TKey2 extends keyof TObject[TKey1],
60
+ TKey3 extends keyof TObject[TKey1][TKey2],
61
+ TDefault
62
+ >(
63
+ object: TObject | null | undefined,
64
+ path: [TKey1, TKey2, TKey3],
65
+ defaultValue: TDefault
66
+ ): Exclude<TObject[TKey1][TKey2][TKey3], undefined> | TDefault
67
+ function get<
68
+ TObject extends object,
69
+ TKey1 extends keyof TObject,
70
+ TKey2 extends keyof TObject[TKey1],
71
+ TKey3 extends keyof TObject[TKey1][TKey2],
72
+ TKey4 extends keyof TObject[TKey1][TKey2][TKey3]
73
+ >(object: TObject, path: [TKey1, TKey2, TKey3, TKey4]): TObject[TKey1][TKey2][TKey3][TKey4]
74
+ function get<
75
+ TObject extends object,
76
+ TKey1 extends keyof TObject,
77
+ TKey2 extends keyof TObject[TKey1],
78
+ TKey3 extends keyof TObject[TKey1][TKey2],
79
+ TKey4 extends keyof TObject[TKey1][TKey2][TKey3]
80
+ >(
81
+ object: TObject | null | undefined,
82
+ path: [TKey1, TKey2, TKey3, TKey4]
83
+ ): TObject[TKey1][TKey2][TKey3][TKey4] | undefined
84
+ function get<
85
+ TObject extends object,
86
+ TKey1 extends keyof TObject,
87
+ TKey2 extends keyof TObject[TKey1],
88
+ TKey3 extends keyof TObject[TKey1][TKey2],
89
+ TKey4 extends keyof TObject[TKey1][TKey2][TKey3],
90
+ TDefault
91
+ >(
92
+ object: TObject | null | undefined,
93
+ path: [TKey1, TKey2, TKey3, TKey4],
94
+ defaultValue: TDefault
95
+ ): Exclude<TObject[TKey1][TKey2][TKey3][TKey4], undefined> | TDefault
96
+ function get<T>(object: NumericDictionary<T>, path: number): T
97
+ function get<T>(object: NumericDictionary<T> | null | undefined, path: number): T | undefined
98
+ function get<T, TDefault>(
99
+ object: NumericDictionary<T> | null | undefined,
100
+ path: number,
101
+ defaultValue: TDefault
102
+ ): T | TDefault
103
+ function get<TDefault>(object: null | undefined, path: PropertyPath, defaultValue: TDefault): TDefault
104
+ function get(object: null | undefined, path: PropertyPath): undefined
105
+ function get<TObject, TPath extends string>(
106
+ data: TObject,
107
+ path: TPath
108
+ ): string extends TPath ? any : GetFieldType<TObject, TPath>
109
+ function get<TObject, TPath extends string, TDefault = GetFieldType<TObject, TPath>>(
110
+ data: TObject,
111
+ path: TPath,
112
+ defaultValue: TDefault
113
+ ): Exclude<GetFieldType<TObject, TPath>, null | undefined> | TDefault
114
+ function get(object: any, path: PropertyPath, defaultValue?: any): any
115
+ function get(obj: any, path: any, defaultValue = undefined) {
116
+ // https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore?tab=readme-ov-file#_get
117
+ const travel = (regexp: any) =>
118
+ String
119
+ .prototype
120
+ .split
121
+ .call(path, regexp)
122
+ .filter(Boolean)
123
+ .reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj)
124
+ const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/)
125
+ return result === undefined || result === obj ? defaultValue : result
126
+ }
127
+
128
+ // codegen:start {preset: barrel, include: ./utils/*.ts }
129
+ export * from "./utils/effectify.js"
130
+ export * from "./utils/extend.js"
131
+ export * from "./utils/logger.js"
132
+ // codegen:end
133
+
134
+ export const unsafeRight = <E, A>(ei: Either.Either<A, E>) => {
135
+ if (Either.isLeft(ei)) {
136
+ console.error(ei.left)
137
+ throw ei.left
138
+ }
139
+ return ei.right
140
+ }
141
+
142
+ export const unsafeSome = (makeErrorMessage: () => string) => <A>(o: Option.Option<A>) => {
143
+ if (Option.isNone(o)) {
144
+ throw new Error(makeErrorMessage())
145
+ }
146
+ return o.value
147
+ }
148
+
149
+ export function toString(v: unknown) {
150
+ return `${v}`
151
+ }
152
+
153
+ export const typedKeysOf = <T extends {}>(obj: T) => Object.keys(obj) as (keyof T)[]
154
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
155
+ export const typedValuesOf = <T extends {}>(obj: T) => Object.values(obj) as ValueOf<T>[]
156
+ type ValueOf<T> = T[keyof T]
157
+
158
+ export type Constructor<T = any> = { new(...args: any[]): T }
159
+ export type ThenArg<T> = T extends Promise<infer U> ? U
160
+ : T extends (...args: any[]) => Promise<infer V> ? V
161
+ : T
162
+
163
+ /**
164
+ * @deprecated TODO: does not filter optional fields!
165
+ */
166
+ type NoUndefinedField<T> = { [P in keyof T]: Exclude<T[P], undefined> }
167
+ export function dropUndefinedT<A extends Record<string, any>>(
168
+ input: A
169
+ ): NoUndefinedField<A> {
170
+ const newR = pipe(
171
+ input,
172
+ D.filter((x): x is A => x !== undefined)
173
+ )
174
+ return newR as any
175
+ }
176
+
177
+ export function dropUndefined<A>(
178
+ input: Dictionary<A | undefined>
179
+ ): Dictionary<A> {
180
+ const newR = pipe(
181
+ input,
182
+ D.filter((x): x is A => x !== undefined)
183
+ )
184
+ return newR
185
+ }
186
+
187
+ type GetTag<T> = T extends { _tag: infer K } ? K : never
188
+ export const isOfType = <T extends { _tag: string }>(tag: GetTag<T>) => (e: { _tag: string }): e is T => e._tag === tag
189
+
190
+ export function capitalize<T extends string>(string: T): Capitalize<T> {
191
+ return (string.charAt(0).toUpperCase() + string.slice(1)) as Capitalize<T>
192
+ }
193
+
194
+ export function uncapitalize<T extends string>(string: T): Uncapitalize<T> {
195
+ return (string.charAt(0).toLowerCase() + string.slice(1)) as Uncapitalize<T>
196
+ }
197
+
198
+ export function pretty(o: unknown): string {
199
+ return JSON.stringify(o, undefined, 2) ?? "undefined"
200
+ }
201
+
202
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
203
+ k: infer I
204
+ ) => void ? I
205
+ : never
206
+
207
+ // generally A | B is not assignable to A & B
208
+ export type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true
209
+
210
+ export type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R
211
+
212
+ export function intersect<AS extends unknown[] & { 0: unknown }>(
213
+ ...as: AS
214
+ ): UnionToIntersection<{ [k in keyof AS]: AS[k] }[number]> {
215
+ return as.reduce((a: any, b: any) => ({ ...a, ...b })) as any
216
+ }
217
+
218
+ export type IsEqualTo<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
219
+ T
220
+ >() => T extends Y ? 1 : 2 ? true
221
+ : false
222
+
223
+ export const unifyIndex = Symbol()
224
+ export type unifyIndex = typeof unifyIndex
225
+
226
+ // @ts-expect-error abc
227
+ export interface UnifiableIndexed<X> {}
228
+ export type UnifiableIndexedURI = keyof UnifiableIndexed<any>
229
+
230
+ export interface Unifiable<X> {
231
+ // Sync: [X] extends [Sync<infer R, infer E, infer A>] ? Sync<R, E, A> : never
232
+ // Effect: [X] extends [Effect<infer R, infer E, infer A>]
233
+ // ? [X] extends [Sync<infer R, infer E, infer A>]
234
+ // ? never
235
+ // : Effect<R, E, A>
236
+ // : never
237
+ Unify: [X] extends [{ readonly [unifyIndex]: infer K }] ? K extends UnifiableIndexedURI ? UnifiableIndexed<X>[K]
238
+ : never
239
+ : never
240
+ }
241
+
242
+ export type Unify<X> = Unifiable<X>[keyof Unifiable<any>] extends never ? X
243
+ : Unifiable<X>[keyof Unifiable<any>]
244
+
245
+ // forked from https://github.com/Alorel/typescript-lazy-get-decorator
246
+
247
+ type DecoratorReturn = PropertyDescriptor | NewDescriptor
248
+
249
+ function decorateNew(
250
+ inp: NewDescriptor,
251
+ setProto: boolean,
252
+ makeNonConfigurable: boolean,
253
+ resultSelector: ResultSelectorFn
254
+ ): NewDescriptor {
255
+ const out: NewDescriptor = Object.assign({}, inp)
256
+ if (out.descriptor) {
257
+ out.descriptor = Object.assign({}, out.descriptor)
258
+ }
259
+ const actualDesc: PropertyDescriptor = <any> (
260
+ out.descriptor || /* istanbul ignore next */ out
261
+ )
262
+
263
+ const originalMethod = validateAndExtractMethodFromDescriptor(actualDesc)
264
+ const isStatic = inp.placement === "static"
265
+
266
+ actualDesc.get = function(this: any): any {
267
+ return getterCommon(
268
+ isStatic ? this : Object.getPrototypeOf(this),
269
+ out.key,
270
+ isStatic,
271
+ !!actualDesc.enumerable,
272
+ originalMethod,
273
+ this,
274
+ // eslint-disable-next-line prefer-rest-params
275
+ arguments,
276
+ setProto,
277
+ makeNonConfigurable,
278
+ resultSelector
279
+ )
280
+ }
281
+
282
+ return out
283
+ }
284
+
285
+ function decorateLegacy(
286
+ target: any,
287
+ key: PropertyKey,
288
+ descriptor: PropertyDescriptor,
289
+ setProto: boolean,
290
+ makeNonConfigurable: boolean,
291
+ // tslint:enable:bool-param-default
292
+ resultSelector: ResultSelectorFn
293
+ ): PropertyDescriptor {
294
+ /* istanbul ignore if */
295
+ if (!descriptor) {
296
+ descriptor = <any> Object.getOwnPropertyDescriptor(target, key)
297
+ if (!descriptor) {
298
+ const e = new Error("@LazyGetter is unable to determine the property descriptor")
299
+ ;(<any> e).$target = target
300
+ ;(<any> e).$key = key
301
+ throw e
302
+ }
303
+ }
304
+
305
+ const originalMethod = validateAndExtractMethodFromDescriptor(descriptor)
306
+
307
+ return Object.assign({}, descriptor, {
308
+ get(this: any): any {
309
+ return getterCommon(
310
+ target,
311
+ key,
312
+ Object.getPrototypeOf(target) === Function.prototype,
313
+ !!descriptor.enumerable,
314
+ originalMethod,
315
+ this,
316
+ // eslint-disable-next-line prefer-rest-params
317
+ arguments,
318
+ setProto,
319
+ makeNonConfigurable,
320
+ resultSelector
321
+ )
322
+ }
323
+ })
324
+ }
325
+
326
+ /** Signifies that the modified property descriptor can be reset to its original state */
327
+ interface ResettableDescriptor {
328
+ /**
329
+ * Restore the property descriptor on the given class instance or prototype and re-apply the lazy getter.
330
+ * @param on The class instance or prototype
331
+ */
332
+ reset(on: any): void
333
+ }
334
+
335
+ /** ES7 proposal descriptor, tweaked for Babel */
336
+ interface NewDescriptor extends PropertyDescriptor {
337
+ descriptor?: PropertyDescriptor
338
+
339
+ key: PropertyKey
340
+
341
+ kind: string
342
+
343
+ placement: string
344
+ }
345
+
346
+ /** A filter function that must return true for the value to cached */
347
+ export type ResultSelectorFn = (v: any) => boolean
348
+
349
+ function defaultFilter(): boolean {
350
+ return true
351
+ }
352
+
353
+ function validateAndExtractMethodFromDescriptor(desc: PropertyDescriptor): Function {
354
+ // eslint-disable-next-line @typescript-eslint/unbound-method
355
+ const originalMethod = <Function> desc.get
356
+
357
+ if (!originalMethod) {
358
+ throw new Error("@LazyGetter can only decorate getters!")
359
+ } else if (!desc.configurable) {
360
+ throw new Error("@LazyGetter target must be configurable")
361
+ }
362
+
363
+ return originalMethod
364
+ }
365
+
366
+ function getterCommon( // tslint:disable-line:parameters-max-number
367
+ target: any,
368
+ key: PropertyKey,
369
+ isStatic: boolean,
370
+ enumerable: boolean,
371
+ originalMethod: Function,
372
+ thisArg: any,
373
+ args: IArguments,
374
+ setProto: boolean,
375
+ makeNonConfigurable: boolean,
376
+ resultSelector: ResultSelectorFn
377
+ ): any {
378
+ const value = originalMethod.apply(thisArg, <any> args)
379
+
380
+ if (resultSelector(value)) {
381
+ const newDescriptor: PropertyDescriptor = {
382
+ configurable: !makeNonConfigurable,
383
+ enumerable,
384
+ value
385
+ }
386
+
387
+ if (isStatic || setProto) {
388
+ Object.defineProperty(target, key, newDescriptor)
389
+ }
390
+
391
+ if (!isStatic) {
392
+ Object.defineProperty(thisArg, key, newDescriptor)
393
+ }
394
+ }
395
+
396
+ return value
397
+ }
398
+
399
+ /**
400
+ * Evaluate the getter function and cache the result
401
+ * @param [setProto=false] Set the value on the class prototype as well. Only applies to non-static getters.
402
+ * @param [makeNonConfigurable=false] Set to true to make the resolved property non-configurable
403
+ * @param [resultSelector] A filter function that must return true for the value to cached
404
+ * @return A decorator function
405
+ */
406
+ export function LazyGetter(
407
+ setProto = false,
408
+ makeNonConfigurable = false,
409
+ resultSelector: ResultSelectorFn = defaultFilter
410
+ ): MethodDecorator & ResettableDescriptor {
411
+ let desc: PropertyDescriptor
412
+ let prop: PropertyKey
413
+ let args: IArguments = <any> null
414
+ let isLegacy: boolean
415
+
416
+ function decorator(
417
+ targetOrDesc: any,
418
+ key: PropertyKey,
419
+ descriptor: PropertyDescriptor
420
+ ): DecoratorReturn {
421
+ // eslint-disable-next-line prefer-rest-params
422
+ args = arguments
423
+ if (key === undefined) {
424
+ if (typeof desc === "undefined") {
425
+ isLegacy = false
426
+ prop = (<NewDescriptor> targetOrDesc).key
427
+ desc = Object.assign(
428
+ {},
429
+ (<NewDescriptor> targetOrDesc).descriptor
430
+ /* istanbul ignore next */ || targetOrDesc
431
+ )
432
+ }
433
+
434
+ return decorateNew(targetOrDesc, setProto, makeNonConfigurable, resultSelector)
435
+ } else {
436
+ if (typeof desc === "undefined") {
437
+ isLegacy = true
438
+ prop = key
439
+ desc = Object.assign(
440
+ {},
441
+ descriptor
442
+ /* istanbul ignore next */ || Object.getOwnPropertyDescriptor(
443
+ targetOrDesc,
444
+ key
445
+ )
446
+ )
447
+ }
448
+
449
+ return decorateLegacy(
450
+ targetOrDesc,
451
+ key,
452
+ descriptor,
453
+ setProto,
454
+ makeNonConfigurable,
455
+ resultSelector
456
+ )
457
+ }
458
+ }
459
+
460
+ decorator.reset = setProto
461
+ ? thrower
462
+ : (on: any): void => {
463
+ if (!on) {
464
+ throw new Error("Unable to restore descriptor on an undefined target")
465
+ }
466
+ if (!desc) {
467
+ throw new Error(
468
+ "Unable to restore descriptor. Did you remember to apply your decorator to a method?"
469
+ )
470
+ }
471
+ // Restore descriptor to its original state
472
+ Object.defineProperty(on, prop, desc)
473
+ // eslint-disable-next-line prefer-spread
474
+ const ret: any = decorator.apply(null, <any> args)
475
+ Object.defineProperty(on, prop, isLegacy ? ret : ret.descriptor || ret)
476
+ }
477
+
478
+ return decorator
479
+ }
480
+
481
+ function thrower(): never {
482
+ throw new Error("This decoration modifies the class prototype and cannot be reset.")
483
+ }
484
+
485
+ export type RefinementWithIndex<I, A, B extends A> = (i: I, a: A) => a is B
486
+
487
+ export type PredicateWithIndex<I, A> = (i: I, a: A) => boolean
488
+
489
+ export type Erase<R, K> = R & K extends K & infer R1 ? R1 : R
490
+
491
+ /** from ts-toolbelt, minimal port of Compute */
492
+
493
+ export type Depth = "flat" | "deep"
494
+
495
+ type Errors = Error
496
+ // | EvalError
497
+ // | RangeError
498
+ // | ReferenceError
499
+ // | SyntaxError
500
+ // | TypeError
501
+ // | URIError
502
+
503
+ type Numeric =
504
+ // | Number
505
+ // | BigInt // not needed
506
+ // | Math
507
+ Date
508
+
509
+ type Textual =
510
+ // | String
511
+ RegExp
512
+
513
+ type Arrays =
514
+ // | Array<unknown>
515
+ // | ReadonlyArray<unknown>
516
+ | Int8Array
517
+ | Uint8Array
518
+ | Uint8ClampedArray
519
+ | Int16Array
520
+ | Uint16Array
521
+ | Int32Array
522
+ | Uint32Array
523
+ | Float32Array
524
+ | Float64Array
525
+ // | BigInt64Array
526
+ // | BigUint64Array
527
+
528
+ type Maps =
529
+ // | Map<unknown, unknown>
530
+ // | Set<unknown>
531
+ | ReadonlyMap<unknown, unknown>
532
+ | ReadonlySet<unknown>
533
+ | WeakMap<object, unknown>
534
+ | WeakSet<object>
535
+
536
+ type Structures =
537
+ | ArrayBuffer
538
+ // | SharedArrayBuffer
539
+ // | Atomics
540
+ | DataView
541
+ // | JSON
542
+
543
+ type Abstractions = Function | Promise<unknown> | Generator
544
+ // | GeneratorFunction
545
+
546
+ type WebAssembly = never
547
+
548
+ export type BuiltInObject =
549
+ | Errors
550
+ | Numeric
551
+ | Textual
552
+ | Arrays
553
+ | Maps
554
+ | Structures
555
+ | Abstractions
556
+ | WebAssembly
557
+
558
+ export type ComputeRaw<A> = A extends Function ? A
559
+ :
560
+ & {
561
+ [K in keyof A]: A[K]
562
+ }
563
+ & {}
564
+
565
+ export type ComputeFlat<A> = A extends BuiltInObject ? A
566
+ :
567
+ & {
568
+ [K in keyof A]: A[K]
569
+ }
570
+ & {}
571
+
572
+ export type ComputeDeep<A> = A extends BuiltInObject ? A
573
+ :
574
+ & {
575
+ [K in keyof A]: ComputeDeep<A[K]>
576
+ }
577
+ & {}
578
+
579
+ export type Compute<A, depth extends Depth = "deep"> = {
580
+ flat: ComputeFlat<A>
581
+ deep: ComputeDeep<A>
582
+ }[depth]
583
+
584
+ /////
585
+
586
+ export const LazySymbol = Symbol("lazy")
587
+
588
+ interface Lazy {
589
+ [LazySymbol]: Record<symbol, any>
590
+ }
591
+
592
+ export function lazyGetter<T extends object, T2>(creator: (target: T) => T2) {
593
+ const key = Symbol(creator.name)
594
+ const f = (target: T): T2 => {
595
+ let lazy = (target as unknown as Lazy)[LazySymbol]
596
+ if (!lazy) {
597
+ lazy = {}
598
+ Object.defineProperty(target, LazySymbol, { enumerable: false, value: lazy })
599
+ } else if (lazy[key]) {
600
+ return lazy[key]
601
+ }
602
+ const value = creator(target)
603
+ lazy[key] = value
604
+ return value
605
+ }
606
+ Object.defineProperty(f, "name", {
607
+ enumerable: false,
608
+ value: `Lazy<${creator.name}>`
609
+ })
610
+ return f
611
+ }
612
+
613
+ export function exhaustiveMatch<T extends string>() {
614
+ return <Out extends Record<T, (t: T) => any>>(handlers: Out) => (t: T): ReturnType<Out[keyof Out]> => handlers[t](t)
615
+ }
616
+
617
+ export function exhaustiveMatch_<T extends string>(t: T) {
618
+ return <Out extends Record<T, (t: T) => any>>(handlers: Out): ReturnType<Out[keyof Out]> => handlers[t](t)
619
+ }
620
+
621
+ export function assertUnreachable(x: never): never {
622
+ throw new Error("Unknown case " + x)
623
+ }
624
+
625
+ export type OptPromise<T extends () => any> = (
626
+ ...args: Parameters<T>
627
+ ) => Promise<ReturnType<T>> | ReturnType<T>
628
+
629
+ export function access<T extends string, T2>(t: Record<T, T2>) {
630
+ return (key: T) => t[key] as T2
631
+ }
632
+
633
+ export function todayAtUTCNoon() {
634
+ const localDate = new Date()
635
+ const utcDateAtNoon = Date.UTC(
636
+ localDate.getFullYear(),
637
+ localDate.getMonth(),
638
+ localDate.getDate(),
639
+ 12
640
+ )
641
+ return new Date(utcDateAtNoon)
642
+ }
643
+
644
+ function anyOp_$<T>(self: T) {
645
+ return {
646
+ get subject() {
647
+ return self
648
+ }
649
+ }
650
+ }
651
+
652
+ /**
653
+ * @tsplus getter Object $$
654
+ * @tsplus getter number $$
655
+ * @tsplus getter bigint $$
656
+ * @tsplus getter boolean $$
657
+ * @tsplus getter regexp $$
658
+ * @tsplus getter string $$
659
+ */
660
+ export function anyOp$<T>(self: T): AnyOps<T> {
661
+ return anyOp_$(self)
662
+ }
663
+
664
+ /**
665
+ * @tsplus type Any.Ops
666
+ * @tsplus type Object.Ops
667
+ */
668
+ export interface AnyOps<T> {
669
+ subject: T
670
+ }
671
+
672
+ export const clone = dual<
673
+ <A extends object>(f: NoInfer<A>) => (self: A) => A,
674
+ <A extends object>(self: A, f: A) => A
675
+ >(2, (self, f) => {
676
+ if (cloneTrait in (self as any)) {
677
+ const selfWithClone = self as typeof self & Clone
678
+ return selfWithClone[cloneTrait](f)
679
+ }
680
+ return Object.setPrototypeOf(f, Object.getPrototypeOf(self)) as typeof self
681
+ })
682
+
683
+ export const copy = dual<
684
+ {
685
+ <A extends object>(f: (a: A) => Partial<NoInfer<A>>): (self: A) => A
686
+ <A extends object>(f: Partial<NoInfer<A>>): (self: A) => A
687
+ },
688
+ {
689
+ <A extends object>(self: A, f: (a: A) => Partial<A>): A
690
+ <A extends object>(self: A, f: Partial<A>): A
691
+ }
692
+ >(2, <A>(self: A, f: Partial<A> | ((a: A) => Partial<A>)) => clone(self, { ...self, ...(isFunction(f) ? f(self) : f) }))
693
+
694
+ /**
695
+ * @tsplus fluent Any.Ops debug
696
+ * @tsplus fluent Object.Ops debug
697
+ */
698
+ export function debug<A>(a: AnyOps<A>, name: string) {
699
+ let r: string | A = a.subject
700
+ try {
701
+ r = pretty(a.subject)
702
+ } catch { /* empty */ }
703
+ return Effect
704
+ .logDebug("print")
705
+ .pipe(
706
+ Effect.annotateLogs(name, `${r}`),
707
+ Effect
708
+ .map(() => a.subject)
709
+ )
710
+ }
711
+
712
+ /**
713
+ * @tsplus fluent Any.Ops debugUnsafe
714
+ * @tsplus fluent Object.Ops debugUnsafe
715
+ */
716
+ export function debugUnsafe<A>(a: AnyOps<A>, name: string) {
717
+ console.log(name, a.subject)
718
+ return a.subject
719
+ }
720
+
721
+ export function spread<
722
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
723
+ Fields extends Record<any, any>,
724
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
725
+ NewProps
726
+ >(fields: Fields, fnc: (fields: Fields) => NewProps) {
727
+ return fnc(fields)
728
+ }
729
+
730
+ export function spreadS<
731
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
732
+ Fields extends Record<any, any>
733
+ >(fields: Fields, fnc: (fields: Fields) => Fields) {
734
+ return fnc(fields)
735
+ }
736
+
737
+ export function makeAzureFriendly(path: string) {
738
+ return path.replace(/\//g, "___SL@SH___")
739
+ }
740
+
741
+ export function undoAzureFriendly<T extends string>(path: T): T {
742
+ return path.replace(/___SL@SH___/g, "/") as T
743
+ }
744
+
745
+ export function arrayMove<T>(
746
+ arrInput: readonly T[],
747
+ oldIndex: number,
748
+ newIndex: number
749
+ ) {
750
+ const arr: (T | undefined)[] = [...arrInput]
751
+ while (oldIndex < 0) {
752
+ oldIndex += arr.length
753
+ }
754
+ while (newIndex < 0) {
755
+ newIndex += arr.length
756
+ }
757
+ if (newIndex >= arr.length) {
758
+ let k = newIndex - arr.length + 1
759
+ while (k--) {
760
+ arr.push(undefined)
761
+ }
762
+ }
763
+ arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0])
764
+ return arr
765
+ }
766
+
767
+ export function arrayMoveDropUndefined<T>(
768
+ arrInput: readonly (T | undefined)[],
769
+ oldIndex: number,
770
+ newIndex: number
771
+ ): T[] {
772
+ return arrayMove(arrInput, oldIndex, newIndex).filter((x): x is T => x !== undefined)
773
+ }
774
+
775
+ export function arMoveElDropUndefined<T>(el: T, newIndex: number) {
776
+ return (arrInput: ReadonlyArray<T | undefined>): Option.Option<ReadonlyArray<T>> => {
777
+ const ar = [...arrInput]
778
+ const index = ar.findIndex((x) => x === el)
779
+ if (index === -1) {
780
+ return Option.none()
781
+ }
782
+ return Option.some(arrayMoveDropUndefined(ar, index, newIndex))
783
+ }
784
+ }
785
+
786
+ export function setMoveElDropUndefined<T>(el: T, newIndex: number) {
787
+ return (arrInput: ReadonlySet<T | undefined>): Option.Option<ReadonlySet<T>> =>
788
+ pipe([...arrInput], arMoveElDropUndefined(el, newIndex), Option.map((ar) => new Set(ar)))
789
+ }
790
+
791
+ export { get }
792
+
793
+ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K>
794
+ : never
795
+
796
+ type RemoveNonArray<T> = T extends readonly any[] ? T : never
797
+ export function isNativeTuple<A>(a: A): a is RemoveNonArray<A> {
798
+ return Array.isArray(a)
799
+ }
800
+
801
+ export type Writable<T> = { -readonly [P in keyof T]: T[P] }
802
+
803
+ export type DeepWritable<T> = { -readonly [P in keyof T]: DeepWritable<T[P]> }
804
+
805
+ export const writable: { <A>(a: A, deep: true): DeepWritable<A>; <A>(a: A): Writable<A> } = identity