@attocash/cli 0.1.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 (400) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +707 -0
  3. package/dist/application/app.d.ts +138 -0
  4. package/dist/application/app.js +654 -0
  5. package/dist/application/operations.d.ts +9 -0
  6. package/dist/application/operations.js +96 -0
  7. package/dist/cli/cli.d.ts +1 -0
  8. package/dist/cli/cli.js +460 -0
  9. package/dist/cli/help.d.ts +4 -0
  10. package/dist/cli/help.js +49 -0
  11. package/dist/cli/main.d.ts +2 -0
  12. package/dist/cli/main.js +13 -0
  13. package/dist/cli/onboarding.d.ts +14 -0
  14. package/dist/cli/onboarding.js +144 -0
  15. package/dist/cli/output.d.ts +2 -0
  16. package/dist/cli/output.js +231 -0
  17. package/dist/cli/terminal.d.ts +6 -0
  18. package/dist/cli/terminal.js +92 -0
  19. package/dist/cli/update-check.d.ts +1 -0
  20. package/dist/cli/update-check.js +12 -0
  21. package/dist/cli/updates.d.ts +2 -0
  22. package/dist/cli/updates.js +98 -0
  23. package/dist/core.d.ts +14 -0
  24. package/dist/core.js +14 -0
  25. package/dist/doctor/credential-probe.d.ts +7 -0
  26. package/dist/doctor/credential-probe.js +49 -0
  27. package/dist/doctor/doctor.d.ts +4 -0
  28. package/dist/doctor/doctor.js +213 -0
  29. package/dist/doctor/keyring.d.ts +7 -0
  30. package/dist/doctor/keyring.js +150 -0
  31. package/dist/doctor/profile.d.ts +19 -0
  32. package/dist/doctor/profile.js +73 -0
  33. package/dist/doctor/types.d.ts +40 -0
  34. package/dist/doctor/types.js +1 -0
  35. package/dist/domain/amount.d.ts +6 -0
  36. package/dist/domain/amount.js +27 -0
  37. package/dist/domain/errors.d.ts +10 -0
  38. package/dist/domain/errors.js +16 -0
  39. package/dist/labels/directory.d.ts +87 -0
  40. package/dist/labels/directory.js +140 -0
  41. package/dist/labels/personal.d.ts +17 -0
  42. package/dist/labels/personal.js +56 -0
  43. package/dist/labels/presentation.d.ts +154 -0
  44. package/dist/labels/presentation.js +90 -0
  45. package/dist/network/reader.d.ts +31 -0
  46. package/dist/network/reader.js +370 -0
  47. package/dist/network/retry.d.ts +7 -0
  48. package/dist/network/retry.js +53 -0
  49. package/dist/network/work.d.ts +3 -0
  50. package/dist/network/work.js +66 -0
  51. package/dist/pricing/market.d.ts +29 -0
  52. package/dist/pricing/market.js +150 -0
  53. package/dist/pricing/terms.d.ts +6 -0
  54. package/dist/pricing/terms.js +12 -0
  55. package/dist/spending/destination.d.ts +16 -0
  56. package/dist/spending/destination.js +42 -0
  57. package/dist/spending/journal.d.ts +28 -0
  58. package/dist/spending/journal.js +69 -0
  59. package/dist/spending/ledger.d.ts +118 -0
  60. package/dist/spending/ledger.js +444 -0
  61. package/dist/spending/payments.d.ts +67 -0
  62. package/dist/spending/payments.js +424 -0
  63. package/dist/spending/pool.d.ts +13 -0
  64. package/dist/spending/pool.js +38 -0
  65. package/dist/spending/reconcile.d.ts +18 -0
  66. package/dist/spending/reconcile.js +64 -0
  67. package/dist/storage/profiles.d.ts +13 -0
  68. package/dist/storage/profiles.js +86 -0
  69. package/dist/storage/secrets.d.ts +16 -0
  70. package/dist/storage/secrets.js +104 -0
  71. package/dist/storage/state.d.ts +32 -0
  72. package/dist/storage/state.js +255 -0
  73. package/dist/wallet/auto-receive.d.ts +57 -0
  74. package/dist/wallet/auto-receive.js +140 -0
  75. package/dist/wallet/defaults.d.ts +3 -0
  76. package/dist/wallet/defaults.js +26 -0
  77. package/dist/wallet/signing.d.ts +17 -0
  78. package/dist/wallet/signing.js +128 -0
  79. package/dist/wallet/types.d.ts +65 -0
  80. package/dist/wallet/types.js +1 -0
  81. package/dist/wallet/work.d.ts +29 -0
  82. package/dist/wallet/work.js +154 -0
  83. package/dist/watches/manager.d.ts +75 -0
  84. package/dist/watches/manager.js +197 -0
  85. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +6678 -0
  86. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -0
  87. package/node_modules/@attocash/commons-core/LICENSE +28 -0
  88. package/node_modules/@attocash/commons-core/README.md +118 -0
  89. package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +1036 -0
  90. package/node_modules/@attocash/commons-core/commons-commons-core.mjs +7701 -0
  91. package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -0
  92. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +17681 -0
  93. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -0
  94. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs +4 -0
  95. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -0
  96. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +209 -0
  97. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -0
  98. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +2284 -0
  99. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -0
  100. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +6042 -0
  101. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -0
  102. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  103. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  104. package/node_modules/@attocash/commons-core/package.json +27 -0
  105. package/node_modules/@attocash/commons-node/LICENSE +28 -0
  106. package/node_modules/@attocash/commons-node/README.md +92 -0
  107. package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +255 -0
  108. package/node_modules/@attocash/commons-node/commons-commons-node.mjs +2977 -0
  109. package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -0
  110. package/node_modules/@attocash/commons-node/kotlin-logging.mjs +432 -0
  111. package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -0
  112. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  113. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  114. package/node_modules/@attocash/commons-node/package.json +29 -0
  115. package/node_modules/@attocash/commons-node-remote/LICENSE +28 -0
  116. package/node_modules/@attocash/commons-node-remote/README.md +61 -0
  117. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +122 -0
  118. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +1810 -0
  119. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -0
  120. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +432 -0
  121. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -0
  122. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs +8 -0
  123. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -0
  124. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  125. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  126. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  127. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  128. package/node_modules/@attocash/commons-node-remote/package.json +31 -0
  129. package/node_modules/@attocash/commons-transport/LICENSE +28 -0
  130. package/node_modules/@attocash/commons-transport/README.md +5 -0
  131. package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +64 -0
  132. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +249 -0
  133. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -0
  134. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +263 -0
  135. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -0
  136. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs +8 -0
  137. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -0
  138. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +11604 -0
  139. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -0
  140. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  141. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  142. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  143. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  144. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +499 -0
  145. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -0
  146. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +6456 -0
  147. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -0
  148. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +83 -0
  149. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -0
  150. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +1714 -0
  151. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -0
  152. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +3197 -0
  153. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -0
  154. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +2290 -0
  155. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -0
  156. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +46 -0
  157. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -0
  158. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +482 -0
  159. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -0
  160. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +165 -0
  161. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -0
  162. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs +4 -0
  163. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -0
  164. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +3222 -0
  165. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -0
  166. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs +4 -0
  167. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -0
  168. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +1485 -0
  169. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -0
  170. package/node_modules/@attocash/commons-transport/package.json +29 -0
  171. package/node_modules/@attocash/commons-worker/LICENSE +28 -0
  172. package/node_modules/@attocash/commons-worker/README.md +48 -0
  173. package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +73 -0
  174. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +702 -0
  175. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -0
  176. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +432 -0
  177. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -0
  178. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  179. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  180. package/node_modules/@attocash/commons-worker/package.json +29 -0
  181. package/node_modules/@attocash/commons-worker-remote/LICENSE +28 -0
  182. package/node_modules/@attocash/commons-worker-remote/README.md +60 -0
  183. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +93 -0
  184. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +289 -0
  185. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -0
  186. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +432 -0
  187. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -0
  188. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs +8 -0
  189. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -0
  190. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  191. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  192. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  193. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  194. package/node_modules/@attocash/commons-worker-remote/package.json +31 -0
  195. package/node_modules/@js-joda/core/CHANGELOG.md +363 -0
  196. package/node_modules/@js-joda/core/CheatSheet.md +947 -0
  197. package/node_modules/@js-joda/core/LICENSE +34 -0
  198. package/node_modules/@js-joda/core/README.md +155 -0
  199. package/node_modules/@js-joda/core/bower.json +21 -0
  200. package/node_modules/@js-joda/core/dist/js-joda.d.ts +2452 -0
  201. package/node_modules/@js-joda/core/dist/js-joda.esm.js +13564 -0
  202. package/node_modules/@js-joda/core/dist/js-joda.flow.js +949 -0
  203. package/node_modules/@js-joda/core/dist/js-joda.js +13630 -0
  204. package/node_modules/@js-joda/core/dist/js-joda.js.map +1 -0
  205. package/node_modules/@js-joda/core/dist/js-joda.min.js +5 -0
  206. package/node_modules/@js-joda/core/package.json +76 -0
  207. package/node_modules/@js-joda/core/src/Clock.js +330 -0
  208. package/node_modules/@js-joda/core/src/DayOfWeek.js +451 -0
  209. package/node_modules/@js-joda/core/src/Duration.js +1205 -0
  210. package/node_modules/@js-joda/core/src/Enum.js +30 -0
  211. package/node_modules/@js-joda/core/src/Instant.js +1012 -0
  212. package/node_modules/@js-joda/core/src/LocalDate.js +1703 -0
  213. package/node_modules/@js-joda/core/src/LocalDateTime.js +1686 -0
  214. package/node_modules/@js-joda/core/src/LocalTime.js +1415 -0
  215. package/node_modules/@js-joda/core/src/MathUtil.js +236 -0
  216. package/node_modules/@js-joda/core/src/Month.js +600 -0
  217. package/node_modules/@js-joda/core/src/MonthDay.js +730 -0
  218. package/node_modules/@js-joda/core/src/OffsetDateTime.js +757 -0
  219. package/node_modules/@js-joda/core/src/OffsetTime.js +621 -0
  220. package/node_modules/@js-joda/core/src/Period.js +933 -0
  221. package/node_modules/@js-joda/core/src/StringUtil.js +43 -0
  222. package/node_modules/@js-joda/core/src/Year.js +1015 -0
  223. package/node_modules/@js-joda/core/src/YearConstants.js +21 -0
  224. package/node_modules/@js-joda/core/src/YearMonth.js +1096 -0
  225. package/node_modules/@js-joda/core/src/ZoneId.js +236 -0
  226. package/node_modules/@js-joda/core/src/ZoneIdFactory.js +201 -0
  227. package/node_modules/@js-joda/core/src/ZoneOffset.js +486 -0
  228. package/node_modules/@js-joda/core/src/ZoneRegion.js +72 -0
  229. package/node_modules/@js-joda/core/src/ZonedDateTime.js +2007 -0
  230. package/node_modules/@js-joda/core/src/_init.js +68 -0
  231. package/node_modules/@js-joda/core/src/assert.js +33 -0
  232. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDate.js +230 -0
  233. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDateTime.js +130 -0
  234. package/node_modules/@js-joda/core/src/chrono/ChronoZonedDateTime.js +194 -0
  235. package/node_modules/@js-joda/core/src/chrono/IsoChronology.js +235 -0
  236. package/node_modules/@js-joda/core/src/convert.js +83 -0
  237. package/node_modules/@js-joda/core/src/errors.js +54 -0
  238. package/node_modules/@js-joda/core/src/format/DateTimeBuilder.js +535 -0
  239. package/node_modules/@js-joda/core/src/format/DateTimeFormatter.js +728 -0
  240. package/node_modules/@js-joda/core/src/format/DateTimeFormatterBuilder.js +1545 -0
  241. package/node_modules/@js-joda/core/src/format/DateTimeParseContext.js +297 -0
  242. package/node_modules/@js-joda/core/src/format/DateTimePrintContext.js +138 -0
  243. package/node_modules/@js-joda/core/src/format/DecimalStyle.js +113 -0
  244. package/node_modules/@js-joda/core/src/format/EnumMap.js +70 -0
  245. package/node_modules/@js-joda/core/src/format/ParsePosition.js +31 -0
  246. package/node_modules/@js-joda/core/src/format/ResolverStyle.js +93 -0
  247. package/node_modules/@js-joda/core/src/format/SignStyle.js +38 -0
  248. package/node_modules/@js-joda/core/src/format/StringBuilder.js +47 -0
  249. package/node_modules/@js-joda/core/src/format/TextStyle.js +114 -0
  250. package/node_modules/@js-joda/core/src/format/parser/CharLiteralPrinterParser.js +46 -0
  251. package/node_modules/@js-joda/core/src/format/parser/CompositePrinterParser.js +89 -0
  252. package/node_modules/@js-joda/core/src/format/parser/FractionPrinterParser.js +162 -0
  253. package/node_modules/@js-joda/core/src/format/parser/NumberPrinterParser.js +367 -0
  254. package/node_modules/@js-joda/core/src/format/parser/OffsetIdPrinterParser.js +177 -0
  255. package/node_modules/@js-joda/core/src/format/parser/PadPrinterParserDecorator.js +81 -0
  256. package/node_modules/@js-joda/core/src/format/parser/SettingsParser.js +44 -0
  257. package/node_modules/@js-joda/core/src/format/parser/StringLiteralPrinterParser.js +39 -0
  258. package/node_modules/@js-joda/core/src/format/parser/ZoneIdPrinterParser.js +218 -0
  259. package/node_modules/@js-joda/core/src/js-joda.js +210 -0
  260. package/node_modules/@js-joda/core/src/license-preamble.js +3 -0
  261. package/node_modules/@js-joda/core/src/temporal/ChronoField.js +470 -0
  262. package/node_modules/@js-joda/core/src/temporal/ChronoUnit.js +310 -0
  263. package/node_modules/@js-joda/core/src/temporal/DefaultInterfaceTemporal.js +118 -0
  264. package/node_modules/@js-joda/core/src/temporal/IsoFields.js +859 -0
  265. package/node_modules/@js-joda/core/src/temporal/NativeJsTemporal.js +105 -0
  266. package/node_modules/@js-joda/core/src/temporal/Temporal.js +346 -0
  267. package/node_modules/@js-joda/core/src/temporal/TemporalAccessor.js +125 -0
  268. package/node_modules/@js-joda/core/src/temporal/TemporalAdjuster.js +92 -0
  269. package/node_modules/@js-joda/core/src/temporal/TemporalAdjusters.js +464 -0
  270. package/node_modules/@js-joda/core/src/temporal/TemporalAmount.js +166 -0
  271. package/node_modules/@js-joda/core/src/temporal/TemporalField.js +248 -0
  272. package/node_modules/@js-joda/core/src/temporal/TemporalQueries.js +223 -0
  273. package/node_modules/@js-joda/core/src/temporal/TemporalQueriesFactory.js +77 -0
  274. package/node_modules/@js-joda/core/src/temporal/TemporalQuery.js +107 -0
  275. package/node_modules/@js-joda/core/src/temporal/TemporalUnit.js +179 -0
  276. package/node_modules/@js-joda/core/src/temporal/ValueRange.js +257 -0
  277. package/node_modules/@js-joda/core/src/use.js +20 -0
  278. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneId.js +31 -0
  279. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneRules.js +162 -0
  280. package/node_modules/@js-joda/core/src/zone/ZoneOffsetTransition.js +289 -0
  281. package/node_modules/@js-joda/core/src/zone/ZoneRules.js +464 -0
  282. package/node_modules/@js-joda/core/src/zone/ZoneRulesProvider.js +36 -0
  283. package/node_modules/@noble/hashes/LICENSE +21 -0
  284. package/node_modules/@noble/hashes/README.md +563 -0
  285. package/node_modules/@noble/hashes/_blake.d.ts +21 -0
  286. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  287. package/node_modules/@noble/hashes/_blake.js +52 -0
  288. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  289. package/node_modules/@noble/hashes/_md.d.ts +99 -0
  290. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  291. package/node_modules/@noble/hashes/_md.js +202 -0
  292. package/node_modules/@noble/hashes/_md.js.map +1 -0
  293. package/node_modules/@noble/hashes/_u64.d.ts +63 -0
  294. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  295. package/node_modules/@noble/hashes/_u64.js +84 -0
  296. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  297. package/node_modules/@noble/hashes/argon2.d.ts +112 -0
  298. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  299. package/node_modules/@noble/hashes/argon2.js +517 -0
  300. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  301. package/node_modules/@noble/hashes/blake1.d.ts +156 -0
  302. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  303. package/node_modules/@noble/hashes/blake1.js +560 -0
  304. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  305. package/node_modules/@noble/hashes/blake2.d.ts +184 -0
  306. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  307. package/node_modules/@noble/hashes/blake2.js +501 -0
  308. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  309. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  310. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  311. package/node_modules/@noble/hashes/blake3.js +284 -0
  312. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  313. package/node_modules/@noble/hashes/eskdf.d.ts +92 -0
  314. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  315. package/node_modules/@noble/hashes/eskdf.js +218 -0
  316. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  317. package/node_modules/@noble/hashes/hkdf.d.ts +64 -0
  318. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  319. package/node_modules/@noble/hashes/hkdf.js +120 -0
  320. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  321. package/node_modules/@noble/hashes/hmac.d.ts +47 -0
  322. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  323. package/node_modules/@noble/hashes/hmac.js +93 -0
  324. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  325. package/node_modules/@noble/hashes/index.d.ts +2 -0
  326. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  327. package/node_modules/@noble/hashes/index.js +35 -0
  328. package/node_modules/@noble/hashes/index.js.map +1 -0
  329. package/node_modules/@noble/hashes/legacy.d.ts +102 -0
  330. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  331. package/node_modules/@noble/hashes/legacy.js +327 -0
  332. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  333. package/node_modules/@noble/hashes/package.json +97 -0
  334. package/node_modules/@noble/hashes/pbkdf2.d.ts +56 -0
  335. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  336. package/node_modules/@noble/hashes/pbkdf2.js +135 -0
  337. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  338. package/node_modules/@noble/hashes/scrypt.d.ts +65 -0
  339. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  340. package/node_modules/@noble/hashes/scrypt.js +257 -0
  341. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  342. package/node_modules/@noble/hashes/sha2.d.ts +249 -0
  343. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  344. package/node_modules/@noble/hashes/sha2.js +458 -0
  345. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  346. package/node_modules/@noble/hashes/sha3-addons.d.ts +461 -0
  347. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  348. package/node_modules/@noble/hashes/sha3-addons.js +783 -0
  349. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  350. package/node_modules/@noble/hashes/sha3.d.ts +199 -0
  351. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  352. package/node_modules/@noble/hashes/sha3.js +431 -0
  353. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  354. package/node_modules/@noble/hashes/src/_blake.ts +57 -0
  355. package/node_modules/@noble/hashes/src/_md.ts +222 -0
  356. package/node_modules/@noble/hashes/src/_u64.ts +117 -0
  357. package/node_modules/@noble/hashes/src/argon2.ts +667 -0
  358. package/node_modules/@noble/hashes/src/blake1.ts +614 -0
  359. package/node_modules/@noble/hashes/src/blake2.ts +582 -0
  360. package/node_modules/@noble/hashes/src/blake3.ts +317 -0
  361. package/node_modules/@noble/hashes/src/eskdf.ts +259 -0
  362. package/node_modules/@noble/hashes/src/hkdf.ts +133 -0
  363. package/node_modules/@noble/hashes/src/hmac.ts +126 -0
  364. package/node_modules/@noble/hashes/src/index.ts +33 -0
  365. package/node_modules/@noble/hashes/src/legacy.ts +339 -0
  366. package/node_modules/@noble/hashes/src/pbkdf2.ts +175 -0
  367. package/node_modules/@noble/hashes/src/scrypt.ts +315 -0
  368. package/node_modules/@noble/hashes/src/sha2.ts +530 -0
  369. package/node_modules/@noble/hashes/src/sha3-addons.ts +983 -0
  370. package/node_modules/@noble/hashes/src/sha3.ts +485 -0
  371. package/node_modules/@noble/hashes/src/utils.ts +848 -0
  372. package/node_modules/@noble/hashes/src/webcrypto.ts +239 -0
  373. package/node_modules/@noble/hashes/utils.d.ts +519 -0
  374. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  375. package/node_modules/@noble/hashes/utils.js +578 -0
  376. package/node_modules/@noble/hashes/utils.js.map +1 -0
  377. package/node_modules/@noble/hashes/webcrypto.d.ts +120 -0
  378. package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
  379. package/node_modules/@noble/hashes/webcrypto.js +165 -0
  380. package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
  381. package/node_modules/ws/LICENSE +20 -0
  382. package/node_modules/ws/README.md +548 -0
  383. package/node_modules/ws/browser.js +8 -0
  384. package/node_modules/ws/index.js +22 -0
  385. package/node_modules/ws/lib/buffer-util.js +131 -0
  386. package/node_modules/ws/lib/constants.js +19 -0
  387. package/node_modules/ws/lib/event-target.js +292 -0
  388. package/node_modules/ws/lib/extension.js +203 -0
  389. package/node_modules/ws/lib/limiter.js +55 -0
  390. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  391. package/node_modules/ws/lib/receiver.js +743 -0
  392. package/node_modules/ws/lib/sender.js +607 -0
  393. package/node_modules/ws/lib/stream.js +161 -0
  394. package/node_modules/ws/lib/subprotocol.js +62 -0
  395. package/node_modules/ws/lib/validation.js +152 -0
  396. package/node_modules/ws/lib/websocket-server.js +562 -0
  397. package/node_modules/ws/lib/websocket.js +1407 -0
  398. package/node_modules/ws/package.json +74 -0
  399. package/node_modules/ws/wrapper.mjs +21 -0
  400. package/package.json +53 -0
@@ -0,0 +1,1096 @@
1
+ /*
2
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3
+ * @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
4
+ */
5
+
6
+ import {requireNonNull, requireInstance} from './assert';
7
+ import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
8
+ import {MathUtil} from './MathUtil';
9
+
10
+ import {ChronoField} from './temporal/ChronoField';
11
+ import {ChronoUnit} from './temporal/ChronoUnit';
12
+ import {Clock} from './Clock';
13
+ import {DateTimeFormatterBuilder} from './format/DateTimeFormatterBuilder';
14
+ import {IsoChronology} from './chrono/IsoChronology';
15
+ import {LocalDate} from './LocalDate';
16
+ import {Month} from './Month';
17
+ import {SignStyle} from './format/SignStyle';
18
+ import {Temporal} from './temporal/Temporal';
19
+ import {TemporalAmount} from './temporal/TemporalAmount';
20
+ import {TemporalField} from './temporal/TemporalField';
21
+ import {TemporalQueries} from './temporal/TemporalQueries';
22
+ import {TemporalQuery} from './temporal/TemporalQuery';
23
+ import {TemporalUnit} from './temporal/TemporalUnit';
24
+ import {createTemporalQuery} from './temporal/TemporalQuery';
25
+ import {ValueRange} from './temporal/ValueRange';
26
+ import {Year} from './Year';
27
+ import {ZoneId} from './ZoneId';
28
+
29
+ /**
30
+ * A year-month in the ISO-8601 calendar system, such as `2007-12`.
31
+ *
32
+ * {@link YearMonth} is an immutable date-time object that represents the combination
33
+ * of a year and month. Any field that can be derived from a year and month, such as
34
+ * quarter-of-year, can be obtained.
35
+ *
36
+ * This class does not store or represent a day, time or time-zone.
37
+ * For example, the value "October 2007" can be stored in a {@link YearMonth}.
38
+ *
39
+ * The ISO-8601 calendar system is the modern civil calendar system used today
40
+ * in most of the world. It is equivalent to the proleptic Gregorian calendar
41
+ * system, in which today's rules for leap years are applied for all time.
42
+ * For most applications written today, the ISO-8601 rules are entirely suitable.
43
+ * However, any application that makes use of historical dates, and requires them
44
+ * to be accurate will find the ISO-8601 approach unsuitable.
45
+ *
46
+ * ### Specification for implementors
47
+ *
48
+ * This class is immutable and thread-safe.
49
+ */
50
+ export class YearMonth extends Temporal {
51
+ //-----------------------------------------------------------------------
52
+ /**
53
+ * function overloading for {@link YearMonth.now}
54
+ *
55
+ * if called with 0 argument {@link YearMonth.now0} is executed,
56
+ *
57
+ * if called with 1 argument and first argument is an instance of ZoneId, then {@link YearMonth.nowZoneId} is executed,
58
+ *
59
+ * otherwise {@link YearMonth.nowClock} is executed
60
+ *
61
+ * @param {?(ZoneId|Clock)} zoneIdOrClock
62
+ * @returns {YearMonth}
63
+ */
64
+ static now(zoneIdOrClock) {
65
+ if (arguments.length === 0) {
66
+ return YearMonth.now0();
67
+ } else if (arguments.length === 1 && zoneIdOrClock instanceof ZoneId) {
68
+ return YearMonth.nowZoneId(zoneIdOrClock);
69
+ } else {
70
+ return YearMonth.nowClock(zoneIdOrClock);
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Obtains the current year-month from the system clock in the default time-zone.
76
+ *
77
+ * This will query the system clock (see {@link Clock#systemDefaultZone}) in the default
78
+ * time-zone to obtain the current year-month.
79
+ * The zone and offset will be set based on the time-zone in the clock.
80
+ *
81
+ * Using this method will prevent the ability to use an alternate clock for testing
82
+ * because the clock is hard-coded.
83
+ *
84
+ * @return {YearMonth} the current year-month using the system clock and default time-zone, not null
85
+ */
86
+ static now0() {
87
+ return YearMonth.nowClock(Clock.systemDefaultZone());
88
+ }
89
+
90
+ /**
91
+ * Obtains the current year-month from the system clock in the specified time-zone.
92
+ *
93
+ * This will query the system clock (see {@link Clock#system}) to obtain the current year-month.
94
+ * Specifying the time-zone avoids dependence on the default time-zone.
95
+ *
96
+ * Using this method will prevent the ability to use an alternate clock for testing
97
+ * because the clock is hard-coded.
98
+ *
99
+ * @param {ZoneId} zone the zone ID to use, not null
100
+ * @return {YearMonth} the current year-month using the system clock, not null
101
+ */
102
+ static nowZoneId(zone) {
103
+ return YearMonth.nowClock(Clock.system(zone));
104
+ }
105
+
106
+ /**
107
+ * Obtains the current year-month from the specified clock.
108
+ *
109
+ * This will query the specified clock to obtain the current year-month.
110
+ * Using this method allows the use of an alternate clock for testing.
111
+ * The alternate clock may be introduced using dependency injection.
112
+ *
113
+ * @param {Clock} clock the clock to use, not null
114
+ * @return {YearMonth} the current year-month, not null
115
+ */
116
+ static nowClock(clock) {
117
+ const now = LocalDate.now(clock);
118
+ return YearMonth.of(now.year(), now.month());
119
+ }
120
+
121
+ //-----------------------------------------------------------------------
122
+ /**
123
+ * function overloading for {@link YearMonth.of}
124
+ *
125
+ * if called with 2 argument and first argument is an instance of Month, then {@link YearMonth.ofNumberMonth} is executed,
126
+ *
127
+ * otherwise {@link YearMonth.ofNumberNumber} is executed
128
+ *
129
+ * @param {!number} year
130
+ * @param {!(Month|number)} monthOrNumber
131
+ * @returns {YearMonth}
132
+ */
133
+ static of(year, monthOrNumber) {
134
+ if (arguments.length === 2 && monthOrNumber instanceof Month) {
135
+ return YearMonth.ofNumberMonth(year, monthOrNumber);
136
+ } else {
137
+ return YearMonth.ofNumberNumber(year, monthOrNumber);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Obtains an instance of {@link YearMonth} from a year and month.
143
+ *
144
+ * @param {number} year the year to represent, from MIN_YEAR to MAX_YEAR
145
+ * @param {Month} month the month-of-year to represent, not null
146
+ * @return {YearMonth} the year-month, not null
147
+ * @throws DateTimeException if the year value is invalid
148
+ */
149
+ static ofNumberMonth(year, month) {
150
+ requireNonNull(month, 'month');
151
+ requireInstance(month, Month, 'month');
152
+ return YearMonth.ofNumberNumber(year, month.value());
153
+ }
154
+
155
+ /**
156
+ * Obtains an instance of {@link YearMonth} from a year and month.
157
+ *
158
+ * @param {number} year the year to represent, from MIN_YEAR to MAX_YEAR
159
+ * @param {number} month the month-of-year to represent, from 1 (January) to 12 (December)
160
+ * @return {YearMonth} the year-month, not null
161
+ * @throws DateTimeException if either field value is invalid
162
+ */
163
+ static ofNumberNumber(year, month) {
164
+ requireNonNull(year, 'year');
165
+ requireNonNull(month, 'month');
166
+ ChronoField.YEAR.checkValidValue(year);
167
+ ChronoField.MONTH_OF_YEAR.checkValidValue(month);
168
+ return new YearMonth(year, month);
169
+ }
170
+
171
+ //-----------------------------------------------------------------------
172
+ /**
173
+ * Obtains an instance of {@link YearMonth} from a temporal object.
174
+ *
175
+ * A {@link TemporalAccessor} represents some form of date and time information.
176
+ * This factory converts the arbitrary temporal object to an instance of {@link YearMonth}.
177
+ *
178
+ * The conversion extracts the {@link ChronoField#YEAR} and
179
+ * {@link ChronoField#MONTH_OF_YEAR} fields.
180
+ * The extraction is only permitted if the temporal object has an ISO
181
+ * chronology, or can be converted to a {@link LocalDate}.
182
+ *
183
+ * This method matches the signature of the functional interface {@link TemporalQuery}
184
+ * allowing it to be used in queries via method reference, {@link YearMonth::from}.
185
+ *
186
+ * @param {TemporalAccessor} temporal the temporal object to convert, not null
187
+ * @return {YearMonth} the year-month, not null
188
+ * @throws DateTimeException if unable to convert to a {@link YearMonth}
189
+ */
190
+ static from(temporal) {
191
+ requireNonNull(temporal, 'temporal');
192
+ if (temporal instanceof YearMonth) {
193
+ return temporal;
194
+ }
195
+ try {
196
+ /* TODO: only IsoChronology for now
197
+ if (IsoChronology.INSTANCE.equals(Chronology.from(temporal)) == false) {
198
+ temporal = LocalDate.from(temporal);
199
+ }*/
200
+ return YearMonth.of(temporal.get(ChronoField.YEAR), temporal.get(ChronoField.MONTH_OF_YEAR));
201
+ } catch (ex) {
202
+ throw new DateTimeException('Unable to obtain YearMonth from TemporalAccessor: ' +
203
+ temporal + ', type ' + (temporal && temporal.constructor != null ? temporal.constructor.name : ''));
204
+ }
205
+ }
206
+ //-----------------------------------------------------------------------
207
+ /**
208
+ * function overloading for {@link YearMonth.parse}
209
+ *
210
+ * if called with 2 argument and first argument is an instance of Month, then {@link YearMonth.parseString} is executed,
211
+ *
212
+ * otherwise {@link YearMonth.parseStringFormatter} is executed
213
+ *
214
+ * @param {!(String)} text
215
+ * @param {?DateTimeFormatter} formatter
216
+ * @returns {YearMonth}
217
+ */
218
+ static parse(text, formatter) {
219
+ if (arguments.length === 1) {
220
+ return YearMonth.parseString(text);
221
+ } else {
222
+ return YearMonth.parseStringFormatter(text, formatter);
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Obtains an instance of {@link YearMonth} from a text string such as `2007-12`.
228
+ *
229
+ * The string must represent a valid year-month.
230
+ * The format must be {@link yyyy-MM}.
231
+ * Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
232
+ *
233
+ * @param {String} text the text to parse such as "2007-12", not null
234
+ * @return {YearMonth} the parsed year-month, not null
235
+ * @throws DateTimeParseException if the text cannot be parsed
236
+ */
237
+ static parseString(text) {
238
+ return YearMonth.parseStringFormatter(text, PARSER);
239
+ }
240
+
241
+ /**
242
+ * Obtains an instance of {@link YearMonth} from a text string using a specific formatter.
243
+ *
244
+ * The text is parsed using the formatter, returning a year-month.
245
+ *
246
+ * @param {String} text the text to parse, not null
247
+ * @param {DateTimeFormatter} formatter the formatter to use, not null
248
+ * @return the parsed year-month, not null
249
+ * @throws DateTimeParseException if the text cannot be parsed
250
+ */
251
+ static parseStringFormatter(text, formatter) {
252
+ requireNonNull(formatter, 'formatter');
253
+ return formatter.parse(text, YearMonth.FROM);
254
+ }
255
+
256
+
257
+ /**
258
+ * Constructor.
259
+ *
260
+ * @param {number} year the year to represent, validated from MIN_YEAR to MAX_YEAR
261
+ * @param {number} month the month-of-year to represent, validated from 1 (January) to 12 (December)
262
+ * @private
263
+ */
264
+ constructor(year, month) {
265
+ super();
266
+ this._year = MathUtil.safeToInt(year);
267
+ this._month = MathUtil.safeToInt(month);
268
+ }
269
+
270
+ /**
271
+ * function overloading for {@link YearMonth.isSupported}
272
+ *
273
+ * if called with 1 argument and first argument is an instance of TemporalField, then {@link YearMonth.isSupportedField} is executed,
274
+ *
275
+ * otherwise {@link YearMonth.isSupportedUnit} is executed
276
+ *
277
+ * @param {!(TemporalField|ChronoUnit)} fieldOrUnit
278
+ * @returns {boolean}
279
+ */
280
+ isSupported(fieldOrUnit) {
281
+ if (arguments.length === 1 && fieldOrUnit instanceof TemporalField) {
282
+ return this.isSupportedField(fieldOrUnit);
283
+ } else {
284
+ return this.isSupportedUnit(fieldOrUnit);
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Checks if the specified field is supported.
290
+ *
291
+ * This checks if this year-month can be queried for the specified field.
292
+ * If false, then calling {@link range} and {@link get} will throw an exception.
293
+ *
294
+ * If the field is a {@link ChronoField} then the query is implemented here.
295
+ * The supported fields (see {@link isSupported}) will return valid
296
+ * values based on this date-time.
297
+ * The supported fields are:
298
+ *
299
+ * * {@link MONTH_OF_YEAR}
300
+ * * {@link EPOCH_MONTH}
301
+ * * {@link YEAR_OF_ERA}
302
+ * * {@link YEAR}
303
+ * * {@link ERA}
304
+ *
305
+ * All other {@link ChronoField} instances will return false.
306
+ *
307
+ * If the field is not a {@link ChronoField}, then the result of this method
308
+ * is obtained by invoking {@link TemporalField.isSupportedBy}
309
+ * passing `this` as the argument.
310
+ * Whether the field is supported is determined by the field.
311
+ *
312
+ * @param {TemporalField} field the field to check, null returns false
313
+ * @return {boolean} true if the field is supported on this year-month, false if not
314
+ */
315
+ isSupportedField(field) {
316
+ if (field instanceof ChronoField) {
317
+ return field === ChronoField.YEAR || field === ChronoField.MONTH_OF_YEAR ||
318
+ field === ChronoField.PROLEPTIC_MONTH || field === ChronoField.YEAR_OF_ERA || field === ChronoField.ERA;
319
+ }
320
+ return field != null && field.isSupportedBy(this);
321
+ }
322
+
323
+ isSupportedUnit(unit) {
324
+ if (unit instanceof ChronoUnit) {
325
+ return unit === ChronoUnit.MONTHS || unit === ChronoUnit.YEARS || unit === ChronoUnit.DECADES || unit === ChronoUnit.CENTURIES || unit === ChronoUnit.MILLENNIA || unit === ChronoUnit.ERAS;
326
+ }
327
+ return unit != null && unit.isSupportedBy(this);
328
+ }
329
+
330
+ /**
331
+ * Gets the range of valid values for the specified field.
332
+ *
333
+ * The range object expresses the minimum and maximum valid values for a field.
334
+ * This year-month is used to enhance the accuracy of the returned range.
335
+ * If it is not possible to return the range, because the field is not supported
336
+ * or for some other reason, an exception is thrown.
337
+ *
338
+ * If the field is a {@link ChronoField} then the query is implemented here.
339
+ * The supported fields (see {@link isSupported}) will return
340
+ * appropriate range instances.
341
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
342
+ *
343
+ * If the field is not a {@link ChronoField}, then the result of this method
344
+ * is obtained by invoking {@link TemporalField.rangeRefinedBy}
345
+ * passing `this` as the argument.
346
+ * Whether the range can be obtained is determined by the field.
347
+ *
348
+ * @param {TemporalField} field the field to query the range for, not null
349
+ * @return {ValueRange} the range of valid values for the field, not null
350
+ * @throws DateTimeException if the range for the field cannot be obtained
351
+ */
352
+ range(field) {
353
+ if (field === ChronoField.YEAR_OF_ERA) {
354
+ return (this.year() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE));
355
+ }
356
+ return super.range(field);
357
+ }
358
+
359
+ /**
360
+ * Gets the value of the specified field from this year-month as an `int`.
361
+ *
362
+ * This queries this year-month for the value for the specified field.
363
+ * The returned value will always be within the valid range of values for the field.
364
+ * If it is not possible to return the value, because the field is not supported
365
+ * or for some other reason, an exception is thrown.
366
+ *
367
+ * If the field is a {@link ChronoField} then the query is implemented here.
368
+ * The supported fields (see {@link isSupported}) will return valid
369
+ * values based on this year-month, except {@link EPOCH_MONTH} which is too
370
+ * large to fit in an `int` and throw a {@link DateTimeException}.
371
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
372
+ *
373
+ * If the field is not a {@link ChronoField}, then the result of this method
374
+ * is obtained by invoking {@link TemporalField.getFrom}
375
+ * passing `this` as the argument. Whether the value can be obtained,
376
+ * and what the value represents, is determined by the field.
377
+ *
378
+ * @param {TemporalField} field the field to get, not null
379
+ * @return {number} the value for the field
380
+ * @throws DateTimeException if a value for the field cannot be obtained
381
+ * @throws ArithmeticException if numeric overflow occurs
382
+ */
383
+ get(field) {
384
+ requireNonNull(field, 'field');
385
+ requireInstance(field, TemporalField, 'field');
386
+ return this.range(field).checkValidIntValue(this.getLong(field), field);
387
+ }
388
+
389
+ /**
390
+ * Gets the value of the specified field from this year-month as a `long`.
391
+ *
392
+ * This queries this year-month for the value for the specified field.
393
+ * If it is not possible to return the value, because the field is not supported
394
+ * or for some other reason, an exception is thrown.
395
+ *
396
+ * If the field is a {@link ChronoField} then the query is implemented here.
397
+ * The supported fields (see {@link isSupported}) will return valid
398
+ * values based on this year-month.
399
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
400
+ *
401
+ * If the field is not a {@link ChronoField}, then the result of this method
402
+ * is obtained by invoking {@link TemporalField.getFrom}
403
+ * passing `this` as the argument. Whether the value can be obtained,
404
+ * and what the value represents, is determined by the field.
405
+ *
406
+ * @param {TemporalField} field the field to get, not null
407
+ * @return {number} the value for the field
408
+ * @throws DateTimeException if a value for the field cannot be obtained
409
+ * @throws ArithmeticException if numeric overflow occurs
410
+ */
411
+ getLong(field) {
412
+ requireNonNull(field, 'field');
413
+ requireInstance(field, TemporalField, 'field');
414
+ if (field instanceof ChronoField) {
415
+ switch (field) {
416
+ case ChronoField.MONTH_OF_YEAR: return this._month;
417
+ case ChronoField.PROLEPTIC_MONTH: return this._getProlepticMonth();
418
+ case ChronoField.YEAR_OF_ERA: return (this._year < 1 ? 1 - this._year : this._year);
419
+ case ChronoField.YEAR: return this._year;
420
+ case ChronoField.ERA: return (this._year < 1 ? 0 : 1);
421
+ }
422
+ throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
423
+ }
424
+ return field.getFrom(this);
425
+ }
426
+
427
+ _getProlepticMonth() {
428
+ return MathUtil.safeAdd(MathUtil.safeMultiply(this._year, 12), (this._month - 1));
429
+ }
430
+
431
+ //-----------------------------------------------------------------------
432
+ /**
433
+ * Gets the year field.
434
+ *
435
+ * This method returns the primitive `int` value for the year.
436
+ *
437
+ * The year returned by this method is proleptic as per {@link get}.
438
+ *
439
+ * @return {number} the year, from MIN_YEAR to MAX_YEAR
440
+ */
441
+ year() {
442
+ return this._year;
443
+ }
444
+
445
+ /**
446
+ * Gets the month-of-year field from 1 to 12.
447
+ *
448
+ * This method returns the month as an `int` from 1 to 12.
449
+ * Application code is frequently clearer if the enum {@link Month}
450
+ * is used by calling {@link getMonth}.
451
+ *
452
+ * @return {number} the month-of-year, from 1 to 12
453
+ * @see #getMonth()
454
+ */
455
+ monthValue() {
456
+ return this._month;
457
+ }
458
+
459
+ /**
460
+ * Gets the month-of-year field using the {@link Month} enum.
461
+ *
462
+ * This method returns the enum {@link Month} for the month.
463
+ * This avoids confusion as to what `int` values mean.
464
+ * If you need access to the primitive `int` value, use {@link Month#getValue}.
465
+ *
466
+ * @return {Month} the month-of-year, not null
467
+ */
468
+ month() {
469
+ return Month.of(this._month);
470
+ }
471
+
472
+ //-----------------------------------------------------------------------
473
+ /**
474
+ * Checks if the year is a leap year, according to the ISO proleptic
475
+ * calendar system rules.
476
+ *
477
+ * This method applies the current rules for leap years across the whole time-line.
478
+ * In general, a year is a leap year if it is divisible by four without
479
+ * remainder. However, years divisible by 100, are not leap years, with
480
+ * the exception of years divisible by 400 which are.
481
+ *
482
+ * For example, 1904 is a leap year it is divisible by 4.
483
+ * 1900 was not a leap year as it is divisible by 100, however 2000 was a
484
+ * leap year as it is divisible by 400.
485
+ *
486
+ * The calculation is proleptic - applying the same rules into the far future and far past.
487
+ * This is historically inaccurate, but is correct for the ISO-8601 standard.
488
+ *
489
+ * @return {boolean} true if the year is leap, false otherwise
490
+ */
491
+ isLeapYear() {
492
+ return IsoChronology.isLeapYear(this._year);
493
+ }
494
+
495
+ /**
496
+ * Checks if the day-of-month is valid for this year-month.
497
+ *
498
+ * This method checks whether this year and month and the input day form
499
+ * a valid date.
500
+ *
501
+ * @param {number} dayOfMonth the day-of-month to validate, from 1 to 31, invalid value returns false
502
+ * @return {boolean} true if the day is valid for this year-month
503
+ */
504
+ isValidDay(dayOfMonth) {
505
+ return dayOfMonth >= 1 && dayOfMonth <= this.lengthOfMonth();
506
+ }
507
+
508
+ /**
509
+ * Returns the length of the month, taking account of the year.
510
+ *
511
+ * This returns the length of the month in days.
512
+ * For example, a date in January would return 31.
513
+ *
514
+ * @return {number} the length of the month in days, from 28 to 31
515
+ */
516
+ lengthOfMonth() {
517
+ return this.month().length(this.isLeapYear());
518
+ }
519
+
520
+ /**
521
+ * Returns the length of the year.
522
+ *
523
+ * This returns the length of the year in days, either 365 or 366.
524
+ *
525
+ * @return {number} 366 if the year is leap, 365 otherwise
526
+ */
527
+ lengthOfYear() {
528
+ return (this.isLeapYear() ? 366 : 365);
529
+ }
530
+
531
+ /**
532
+ * function overloading for {@link YearMonth.with}
533
+ *
534
+ * if called with 1 argument, then {@link YearMonth.withAdjuster} is executed,
535
+ * otherwise {@link YearMonth.withFieldValue} is executed.
536
+ *
537
+ * @param {!(TemporalAdjuster|TemporalField)} adjusterOrField
538
+ * @param {?number} value nullable only of first argument is an instance of TemporalAdjuster
539
+ * @returns {YearMonth}
540
+ */
541
+ with(adjusterOrField, value) {
542
+ if (arguments.length === 1) {
543
+ return this.withAdjuster(adjusterOrField);
544
+ } else {
545
+ return this.withFieldValue(adjusterOrField, value);
546
+ }
547
+ }
548
+
549
+ /**
550
+ * Returns an adjusted copy of this year-month.
551
+ *
552
+ * This returns a new {@link YearMonth}, based on this one, with the year-month adjusted.
553
+ * The adjustment takes place using the specified adjuster strategy object.
554
+ * Read the documentation of the adjuster to understand what adjustment will be made.
555
+ *
556
+ * A simple adjuster might simply set the one of the fields, such as the year field.
557
+ * A more complex adjuster might set the year-month to the next month that
558
+ * Halley's comet will pass the Earth.
559
+ *
560
+ * The result of this method is obtained by invoking the
561
+ * {@link TemporalAdjuster#adjustInto} method on the
562
+ * specified adjuster passing `this` as the argument.
563
+ *
564
+ * This instance is immutable and unaffected by this method call.
565
+ *
566
+ * @param {TemporalAdjuster} adjuster the adjuster to use, not null
567
+ * @return {YearMonth} based on `this` with the adjustment made, not null
568
+ * @throws DateTimeException if the adjustment cannot be made
569
+ * @throws ArithmeticException if numeric overflow occurs
570
+ */
571
+ withAdjuster(adjuster) {
572
+ requireNonNull(adjuster, 'adjuster');
573
+ return adjuster.adjustInto(this);
574
+ }
575
+
576
+ /**
577
+ * Returns a copy of this year-month with the specified field set to a new value.
578
+ *
579
+ * This returns a new {@link YearMonth}, based on this one, with the value
580
+ * for the specified field changed.
581
+ * This can be used to change any supported field, such as the year or month.
582
+ * If it is not possible to set the value, because the field is not supported or for
583
+ * some other reason, an exception is thrown.
584
+ *
585
+ * If the field is a {@link ChronoField} then the adjustment is implemented here.
586
+ * The supported fields behave as follows:
587
+ *
588
+ * * {@link MONTH_OF_YEAR} -
589
+ * Returns a {@link YearMonth} with the specified month-of-year.
590
+ * The year will be unchanged.
591
+ * * {@link PROLEPTIC_MONTH} -
592
+ * Returns a {@link YearMonth} with the specified proleptic-month.
593
+ * This completely replaces the year and month of this object.
594
+ * * {@link YEAR_OF_ERA} -
595
+ * Returns a {@link YearMonth} with the specified year-of-era
596
+ * The month and era will be unchanged.
597
+ * * {@link YEAR} -
598
+ * Returns a {@link YearMonth} with the specified year.
599
+ * The month will be unchanged.
600
+ * * {@link ERA} -
601
+ * Returns a {@link YearMonth} with the specified era.
602
+ * The month and year-of-era will be unchanged.
603
+ *
604
+ * In all cases, if the new value is outside the valid range of values for the field
605
+ * then a {@link DateTimeException} will be thrown.
606
+ *
607
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
608
+ *
609
+ * If the field is not a {@link ChronoField}, then the result of this method
610
+ * is obtained by invoking {@link TemporalField.adjustInto}
611
+ * passing `this` as the argument. In this case, the field determines
612
+ * whether and how to adjust the instant.
613
+ *
614
+ * This instance is immutable and unaffected by this method call.
615
+ *
616
+ * @param {TemporalField} field the field to set in the result, not null
617
+ * @param {number} newValue the new value of the field in the result
618
+ * @return a {@link YearMonth} based on `this` with the specified field set, not null
619
+ * @throws DateTimeException if the field cannot be set
620
+ * @throws ArithmeticException if numeric overflow occurs
621
+ */
622
+ withFieldValue(field, newValue) {
623
+ requireNonNull(field, 'field');
624
+ requireInstance(field, TemporalField, 'field');
625
+ if (field instanceof ChronoField) {
626
+ const f = field;
627
+ f.checkValidValue(newValue);
628
+ switch (f) {
629
+ case ChronoField.MONTH_OF_YEAR: return this.withMonth(newValue);
630
+ case ChronoField.PROLEPTIC_MONTH: return this.plusMonths(newValue - this.getLong(ChronoField.PROLEPTIC_MONTH));
631
+ case ChronoField.YEAR_OF_ERA: return this.withYear((this._year < 1 ? 1 - newValue : newValue));
632
+ case ChronoField.YEAR: return this.withYear(newValue);
633
+ case ChronoField.ERA: return (this.getLong(ChronoField.ERA) === newValue ? this : this.withYear(1 - this._year));
634
+ }
635
+ throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
636
+ }
637
+ return field.adjustInto(this, newValue);
638
+ }
639
+
640
+ //-----------------------------------------------------------------------
641
+ /**
642
+ * Returns a copy of this {@link YearMonth} with the year altered.
643
+ *
644
+ * This instance is immutable and unaffected by this method call.
645
+ *
646
+ * @param {number} year the year to set in the returned year-month, from MIN_YEAR to MAX_YEAR
647
+ * @return {YearMonth} based on this year-month with the requested year, not null
648
+ * @throws DateTimeException if the year value is invalid
649
+ */
650
+ withYear(year) {
651
+ ChronoField.YEAR.checkValidValue(year);
652
+ return new YearMonth(year, this._month);
653
+ }
654
+
655
+ /**
656
+ * Returns a copy of this {@link YearMonth} with the month-of-year altered.
657
+ *
658
+ * This instance is immutable and unaffected by this method call.
659
+ *
660
+ * @param {number} month the month-of-year to set in the returned year-month, from 1 (January) to 12 (December)
661
+ * @return {YearMonth} based on this year-month with the requested month, not null
662
+ * @throws DateTimeException if the month-of-year value is invalid
663
+ */
664
+ withMonth(month) {
665
+ ChronoField.MONTH_OF_YEAR.checkValidValue(month);
666
+ return new YearMonth(this._year, month);
667
+ }
668
+
669
+ //-----------------------------------------------------------------------
670
+
671
+ /**
672
+ * Returns a copy of this year-month with the specified period added.
673
+ *
674
+ * This method returns a new year-month based on this year-month with the specified period added.
675
+ * The adder is typically {@link Period} but may be any other type implementing
676
+ * the {@link TemporalAmount} interface.
677
+ * The calculation is delegated to the specified adjuster, which typically calls
678
+ * back to {@link plus}.
679
+ *
680
+ * This instance is immutable and unaffected by this method call.
681
+ *
682
+ * @param {TemporalAmount} amount the amount to add, not null
683
+ * @return {YearMonth} based on this year-month with the addition made, not null
684
+ * @throws DateTimeException if the addition cannot be made
685
+ * @throws ArithmeticException if numeric overflow occurs
686
+ */
687
+ plusAmount(amount) {
688
+ requireNonNull(amount, 'amount');
689
+ requireInstance(amount, TemporalAmount, 'amount');
690
+ return amount.addTo(this);
691
+ }
692
+
693
+ /**
694
+ * @param {number} amountToAdd
695
+ * @param {TemporalUnit} unit
696
+ * @return {YearMonth} based on this year-month with the addition made, not null
697
+ * @throws DateTimeException if the addition cannot be made
698
+ * @throws ArithmeticException if numeric overflow occurs
699
+ */
700
+ plusAmountUnit(amountToAdd, unit) {
701
+ requireNonNull(unit, 'unit');
702
+ requireInstance(unit, TemporalUnit, 'unit');
703
+ if (unit instanceof ChronoUnit) {
704
+ switch (unit) {
705
+ case ChronoUnit.MONTHS: return this.plusMonths(amountToAdd);
706
+ case ChronoUnit.YEARS: return this.plusYears(amountToAdd);
707
+ case ChronoUnit.DECADES: return this.plusYears(MathUtil.safeMultiply(amountToAdd, 10));
708
+ case ChronoUnit.CENTURIES: return this.plusYears(MathUtil.safeMultiply(amountToAdd, 100));
709
+ case ChronoUnit.MILLENNIA: return this.plusYears(MathUtil.safeMultiply(amountToAdd, 1000));
710
+ case ChronoUnit.ERAS: return this.with(ChronoField.ERA, MathUtil.safeAdd(this.getLong(ChronoField.ERA), amountToAdd));
711
+ }
712
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
713
+ }
714
+ return unit.addTo(this, amountToAdd);
715
+ }
716
+
717
+ /**
718
+ * Returns a copy of this year-month with the specified period in years added.
719
+ *
720
+ * This instance is immutable and unaffected by this method call.
721
+ *
722
+ * @param {number} yearsToAdd the years to add, may be negative
723
+ * @return {YearMonth} based on this year-month with the years added, not null
724
+ * @throws DateTimeException if the result exceeds the supported range
725
+ */
726
+ plusYears(yearsToAdd) {
727
+ if (yearsToAdd === 0) {
728
+ return this;
729
+ }
730
+ const newYear = ChronoField.YEAR.checkValidIntValue(this._year + yearsToAdd); // safe overflow
731
+ return this.withYear(newYear);
732
+ }
733
+
734
+ /**
735
+ * Returns a copy of this year-month with the specified period in months added.
736
+ *
737
+ * This instance is immutable and unaffected by this method call.
738
+ *
739
+ * @param {number} monthsToAdd the months to add, may be negative
740
+ * @return {YearMonth} based on this year-month with the months added, not null
741
+ * @throws DateTimeException if the result exceeds the supported range
742
+ */
743
+ plusMonths(monthsToAdd) {
744
+ if (monthsToAdd === 0) {
745
+ return this;
746
+ }
747
+ const monthCount = (this._year * 12) + (this._month - 1);
748
+ const calcMonths = monthCount + monthsToAdd;
749
+ const newYear = ChronoField.YEAR.checkValidIntValue(MathUtil.floorDiv(calcMonths, 12));
750
+ const newMonth = MathUtil.floorMod(calcMonths, 12) + 1;
751
+ return new YearMonth(newYear, newMonth);
752
+ }
753
+
754
+ //-----------------------------------------------------------------------
755
+
756
+ /**
757
+ * Returns a copy of this year-month with the specified period subtracted.
758
+ *
759
+ * This method returns a new year-month based on this year-month with the specified period subtracted.
760
+ * The subtractor is typically {@link Period} but may be any other type implementing
761
+ * the {@link TemporalAmount} interface.
762
+ * The calculation is delegated to the specified adjuster, which typically calls
763
+ * back to {@link minus}.
764
+ *
765
+ * This instance is immutable and unaffected by this method call.
766
+ *
767
+ * @param {TemporalAmount} amount the amount to subtract, not null
768
+ * @return {YearMonth} based on this year-month with the subtraction made, not null
769
+ * @throws DateTimeException if the subtraction cannot be made
770
+ * @throws ArithmeticException if numeric overflow occurs
771
+ */
772
+ minusAmount(amount) {
773
+ requireNonNull(amount, 'amount');
774
+ return amount.subtractFrom(this);
775
+ }
776
+
777
+ /**
778
+ * @param {number} amountToSubtract the amount to subtract, not null
779
+ * @param {TemporalUnit} unit
780
+ * @return {YearMonth} based on this year-month with the subtraction made, not null
781
+ * @throws DateTimeException if the subtraction cannot be made
782
+ * @throws ArithmeticException if numeric overflow occurs
783
+ */
784
+ minusAmountUnit(amountToSubtract, unit) {
785
+ return (amountToSubtract === MathUtil.MIN_SAFE_INTEGER ? this.plusAmountUnit(MathUtil.MAX_SAFE_INTEGER, unit).plusAmountUnit(1, unit) : this.plusAmountUnit(-amountToSubtract, unit));
786
+ }
787
+
788
+ /**
789
+ * Returns a copy of this year-month with the specified period in years subtracted.
790
+ *
791
+ * This instance is immutable and unaffected by this method call.
792
+ *
793
+ * @param {number} yearsToSubtract the years to subtract, may be negative
794
+ * @return {YearMonth} based on this year-month with the years subtracted, not null
795
+ * @throws DateTimeException if the result exceeds the supported range
796
+ */
797
+ minusYears(yearsToSubtract) {
798
+ return (yearsToSubtract === MathUtil.MIN_SAFE_INTEGER ? this.plusYears(MathUtil.MIN_SAFE_INTEGER).plusYears(1) : this.plusYears(-yearsToSubtract));
799
+ }
800
+
801
+ /**
802
+ * Returns a copy of this year-month with the specified period in months subtracted.
803
+ *
804
+ * This instance is immutable and unaffected by this method call.
805
+ *
806
+ * @param {number} monthsToSubtract the months to subtract, may be negative
807
+ * @return {YearMonth} based on this year-month with the months subtracted, not null
808
+ * @throws DateTimeException if the result exceeds the supported range
809
+ */
810
+ minusMonths(monthsToSubtract) {
811
+ return (monthsToSubtract === MathUtil.MIN_SAFE_INTEGER ? this.plusMonths(Math.MAX_SAFE_INTEGER).plusMonths(1) : this.plusMonths(-monthsToSubtract));
812
+ }
813
+
814
+ //-----------------------------------------------------------------------
815
+ /**
816
+ * Queries this year-month using the specified query.
817
+ *
818
+ * This queries this year-month using the specified query strategy object.
819
+ * The {@link TemporalQuery} object defines the logic to be used to
820
+ * obtain the result. Read the documentation of the query to understand
821
+ * what the result of this method will be.
822
+ *
823
+ * The result of this method is obtained by invoking the
824
+ * {@link TemporalQuery#queryFrom} method on the
825
+ * specified query passing `this` as the argument.
826
+ *
827
+ * @param {TemporalQuery} query the query to invoke, not null
828
+ * @return {*} the query result, null may be returned (defined by the query)
829
+ * @throws DateTimeException if unable to query (defined by the query)
830
+ * @throws ArithmeticException if numeric overflow occurs (defined by the query)
831
+ */
832
+ query(query) {
833
+ requireNonNull(query, 'query');
834
+ requireInstance(query, TemporalQuery, 'query');
835
+ if (query === TemporalQueries.chronology()) {
836
+ return IsoChronology.INSTANCE;
837
+ } else if (query === TemporalQueries.precision()) {
838
+ return ChronoUnit.MONTHS;
839
+ } else if (query === TemporalQueries.localDate() || query === TemporalQueries.localTime() ||
840
+ query === TemporalQueries.zone() || query === TemporalQueries.zoneId() || query === TemporalQueries.offset()) {
841
+ return null;
842
+ }
843
+ return super.query(query);
844
+ }
845
+
846
+ /**
847
+ * Adjusts the specified temporal object to have this year-month.
848
+ *
849
+ * This returns a temporal object of the same observable type as the input
850
+ * with the year and month changed to be the same as this.
851
+ *
852
+ * The adjustment is equivalent to using {@link Temporal#with}
853
+ * passing {@link ChronoField#PROLEPTIC_MONTH} as the field.
854
+ * If the specified temporal object does not use the ISO calendar system then
855
+ * a {@link DateTimeException} is thrown.
856
+ *
857
+ * In most cases, it is clearer to reverse the calling pattern by using
858
+ * {@link Temporal#with}:
859
+ * <pre>
860
+ * // these two lines are equivalent, but the second approach is recommended
861
+ * temporal = thisYearMonth.adjustInto(temporal);
862
+ * temporal = temporal.with(thisYearMonth);
863
+ * </pre>
864
+ *
865
+ * This instance is immutable and unaffected by this method call.
866
+ *
867
+ * @param {Temporal} temporal the target object to be adjusted, not null
868
+ * @return {Temporal} the adjusted object, not null
869
+ * @throws DateTimeException if unable to make the adjustment
870
+ * @throws ArithmeticException if numeric overflow occurs
871
+ */
872
+ adjustInto(temporal) {
873
+ requireNonNull(temporal, 'temporal');
874
+ requireInstance(temporal, Temporal, 'temporal');
875
+ /* TODO: only IsoChronology for now
876
+ if (Chronology.from(temporal).equals(IsoChronology.INSTANCE) == false) {
877
+ throw new DateTimeException("Adjustment only supported on ISO date-time");
878
+ }*/
879
+ return temporal.with(ChronoField.PROLEPTIC_MONTH, this._getProlepticMonth());
880
+ }
881
+
882
+ /**
883
+ * Calculates the period between this year-month and another year-month in
884
+ * terms of the specified unit.
885
+ *
886
+ * This calculates the period between two year-months in terms of a single unit.
887
+ * The start and end points are `this` and the specified year-month.
888
+ * The result will be negative if the end is before the start.
889
+ * The {@link Temporal} passed to this method must be a {@link YearMonth}.
890
+ * For example, the period in years between two year-months can be calculated
891
+ * using {@link startYearMonth.until}.
892
+ *
893
+ * The calculation returns a whole number, representing the number of
894
+ * complete units between the two year-months.
895
+ * For example, the period in decades between 2012-06 and 2032-05
896
+ * will only be one decade as it is one month short of two decades.
897
+ *
898
+ * This method operates in association with {@link TemporalUnit#between}.
899
+ * The result of this method is a `long` representing the amount of
900
+ * the specified unit. By contrast, the result of {@link between} is an
901
+ * object that can be used directly in addition/subtraction:
902
+ * <pre>
903
+ * long period = start.until(end, YEARS); // this method
904
+ * dateTime.plus(YEARS.between(start, end)); // use in plus/minus
905
+ * </pre>
906
+ *
907
+ * The calculation is implemented in this method for {@link ChronoUnit}.
908
+ * The units {@link MONTHS}, {@link YEARS}, {@link DECADES},
909
+ * {@link CENTURIES}, {@link MILLENNIA} and {@link ERAS} are supported.
910
+ * Other {@link ChronoUnit} values will throw an exception.
911
+ *
912
+ * If the unit is not a {@link ChronoUnit}, then the result of this method
913
+ * is obtained by invoking {@link TemporalUnit.between}
914
+ * passing `this` as the first argument and the input temporal as
915
+ * the second argument.
916
+ *
917
+ * This instance is immutable and unaffected by this method call.
918
+ *
919
+ * @param {Temporal} endExclusive the end year-month, which is converted to a {@link YearMonth}, not null
920
+ * @param {TemporalUnit} unit the unit to measure the period in, not null
921
+ * @return {number} the amount of the period between this year-month and the end year-month
922
+ * @throws DateTimeException if the period cannot be calculated
923
+ * @throws ArithmeticException if numeric overflow occurs
924
+ */
925
+ until(endExclusive, unit) {
926
+ requireNonNull(endExclusive, 'endExclusive');
927
+ requireNonNull(unit, 'unit');
928
+ requireInstance(endExclusive, Temporal, 'endExclusive');
929
+ requireInstance(unit, TemporalUnit, 'unit');
930
+
931
+ const end = YearMonth.from(endExclusive);
932
+ if (unit instanceof ChronoUnit) {
933
+ const monthsUntil = end._getProlepticMonth() - this._getProlepticMonth(); // no overflow
934
+ switch (unit) {
935
+ case ChronoUnit.MONTHS: return monthsUntil;
936
+ case ChronoUnit.YEARS: return monthsUntil / 12;
937
+ case ChronoUnit.DECADES: return monthsUntil / 120;
938
+ case ChronoUnit.CENTURIES: return monthsUntil / 1200;
939
+ case ChronoUnit.MILLENNIA: return monthsUntil / 12000;
940
+ case ChronoUnit.ERAS: return end.getLong(ChronoField.ERA) - this.getLong(ChronoField.ERA);
941
+ }
942
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
943
+ }
944
+ return unit.between(this, end);
945
+ }
946
+
947
+ //-----------------------------------------------------------------------
948
+ /**
949
+ * Combines this year-month with a day-of-month to create a {@link LocalDate}.
950
+ *
951
+ * This returns a {@link LocalDate} formed from this year-month and the specified day-of-month.
952
+ *
953
+ * The day-of-month value must be valid for the year-month.
954
+ *
955
+ * This method can be used as part of a chain to produce a date:
956
+ * <pre>
957
+ * LocalDate date = year.atMonth(month).atDay(day);
958
+ * </pre>
959
+ *
960
+ * @param {number} dayOfMonth the day-of-month to use, from 1 to 31
961
+ * @return {LocalDate} the date formed from this year-month and the specified day, not null
962
+ * @throws DateTimeException if the day is invalid for the year-month
963
+ * @see #isValidDay(int)
964
+ */
965
+ atDay(dayOfMonth) {
966
+ return LocalDate.of(this._year, this._month, dayOfMonth);
967
+ }
968
+
969
+ /**
970
+ * Returns a {@link LocalDate} at the end of the month.
971
+ *
972
+ * This returns a {@link LocalDate} based on this year-month.
973
+ * The day-of-month is set to the last valid day of the month, taking
974
+ * into account leap years.
975
+ *
976
+ * This method can be used as part of a chain to produce a date:
977
+ * <pre>
978
+ * LocalDate date = year.atMonth(month).atEndOfMonth();
979
+ * </pre>
980
+ *
981
+ * @return {LocalDate} the last valid date of this year-month, not null
982
+ */
983
+ atEndOfMonth() {
984
+ return LocalDate.of(this._year, this._month, this.lengthOfMonth());
985
+ }
986
+
987
+ //-----------------------------------------------------------------------
988
+ /**
989
+ * Compares this year-month to another year-month.
990
+ *
991
+ * The comparison is based first on the value of the year, then on the value of the month.
992
+ * It is "consistent with equals", as defined by {@link Comparable}.
993
+ *
994
+ * @param {YearMonth} other the other year-month to compare to, not null
995
+ * @return {number} the comparator value, negative if less, positive if greater
996
+ */
997
+ compareTo(other) {
998
+ requireNonNull(other, 'other');
999
+ requireInstance(other, YearMonth, 'other');
1000
+ let cmp = (this._year - other.year());
1001
+ if (cmp === 0) {
1002
+ cmp = (this._month - other.monthValue());
1003
+ }
1004
+ return cmp;
1005
+ }
1006
+
1007
+ /**
1008
+ * Is this year-month after the specified year-month.
1009
+ *
1010
+ * @param {YearMonth} other the other year-month to compare to, not null
1011
+ * @return {boolean} true if this is after the specified year-month
1012
+ */
1013
+ isAfter(other) {
1014
+ return this.compareTo(other) > 0;
1015
+ }
1016
+
1017
+ /**
1018
+ * Is this year-month before the specified year-month.
1019
+ *
1020
+ * @param {YearMonth} other the other year-month to compare to, not null
1021
+ * @return {boolean} true if this point is before the specified year-month
1022
+ */
1023
+ isBefore(other) {
1024
+ return this.compareTo(other) < 0;
1025
+ }
1026
+
1027
+ //-----------------------------------------------------------------------
1028
+ /**
1029
+ * Checks if this year-month is equal to another year-month.
1030
+ *
1031
+ * The comparison is based on the time-line position of the year-months.
1032
+ *
1033
+ * @param {*} obj the object to check, null returns false
1034
+ * @return {boolean} true if this is equal to the other year-month
1035
+ */
1036
+ equals(obj) {
1037
+ if (this === obj) {
1038
+ return true;
1039
+ }
1040
+ if (obj instanceof YearMonth) {
1041
+ const other = obj;
1042
+ return this.year() === other.year() && this.monthValue() === other.monthValue();
1043
+ }
1044
+ return false;
1045
+ }
1046
+
1047
+ //-----------------------------------------------------------------------
1048
+ /**
1049
+ * Outputs this year-month as a string, such as `2007-12`.
1050
+ *
1051
+ * The output will be in the format {@link yyyy-MM}:
1052
+ *
1053
+ * @return {String} a string representation of this year-month, not null
1054
+ */
1055
+ toString() {
1056
+ return PARSER.format(this);
1057
+ }
1058
+
1059
+ /**
1060
+ * toJSON() use by JSON.stringify
1061
+ * delegates to toString()
1062
+ *
1063
+ * @return {string}
1064
+ */
1065
+ toJSON() {
1066
+ return this.toString();
1067
+ }
1068
+
1069
+ /**
1070
+ * Outputs this year-month as a string using the formatter.
1071
+ *
1072
+ * @param {DateTimeFormatter} formatter the formatter to use, not null
1073
+ * @return {String} the formatted year-month string, not null
1074
+ * @throws DateTimeException if an error occurs during printing
1075
+ */
1076
+ format(formatter) {
1077
+ requireNonNull(formatter, 'formatter');
1078
+ return formatter.format(this);
1079
+ }
1080
+
1081
+ }
1082
+
1083
+ let PARSER;
1084
+
1085
+ export function _init() {
1086
+
1087
+ PARSER = new DateTimeFormatterBuilder()
1088
+ .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
1089
+ .appendLiteral('-')
1090
+ .appendValue(ChronoField.MONTH_OF_YEAR, 2)
1091
+ .toFormatter();
1092
+
1093
+ YearMonth.FROM = createTemporalQuery('YearMonth.FROM', (temporal) => {
1094
+ return YearMonth.from(temporal);
1095
+ });
1096
+ }