vviinn-widgets 2.1.0 → 2.2.2
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.
- package/dist/cjs/Handler-d1a8a86a.js +329 -0
- package/dist/{vviinn-widgets/app-globals-e0943e34.js → cjs/app-globals-30781f30.js} +15 -925
- package/{www/build/cropper-handler.entry.js → dist/cjs/cropper-handler.cjs.entry.js} +11 -7
- package/dist/{vviinn-widgets/customized-slots-f3449695.js → cjs/customized-slots-5d904d8e.js} +6 -3
- package/dist/cjs/highlight-box_22.cjs.entry.js +737 -0
- package/{www/build/imageSearch.store-407f49f0.js → dist/cjs/imageSearch.store-128957a4.js} +11573 -11902
- package/dist/cjs/index-741a970d.js +1354 -0
- package/dist/cjs/index-c493804d.js +41 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +23 -0
- package/dist/cjs/vviinn-carousel_5.cjs.entry.js +1232 -0
- package/dist/{vviinn-widgets/vviinn-error.entry.js → cjs/vviinn-error.cjs.entry.js} +8 -4
- package/{www/build/vviinn-preloader.entry.js → dist/cjs/vviinn-preloader.cjs.entry.js} +11 -10
- package/dist/cjs/vviinn-vps-button.cjs.entry.js +43 -0
- package/{www/build/vviinn-vps-widget.entry.js → dist/cjs/vviinn-vps-widget.cjs.entry.js} +31 -30
- package/dist/cjs/vviinn-widgets.cjs.js +21 -0
- package/dist/collection/Image/error.js +14 -0
- package/dist/collection/Image/form.js +5 -0
- package/dist/collection/Image/fromFile.js +18 -0
- package/dist/collection/Image/imageToB64.js +9 -0
- package/dist/collection/Image/index.js +0 -0
- package/dist/collection/Image/renderPromise.js +6 -0
- package/dist/collection/Image/resizeImage.js +28 -0
- package/dist/collection/Image/sizing.js +39 -0
- package/dist/collection/Image/toFile.js +17 -0
- package/dist/collection/analytics/GAnalytics.js +32 -0
- package/dist/collection/analytics/GeneralAnalytics.js +9 -0
- package/dist/collection/analytics/GtagAnalytics.js +35 -0
- package/dist/collection/analytics/ProductAnalytics.js +1 -0
- package/dist/collection/campaign/Campaign.js +8 -0
- package/dist/collection/campaign/CampaignService.js +5 -0
- package/dist/collection/campaign/VCSCampaign.js +1 -0
- package/dist/collection/campaign/VCSCampaignResponse.js +1 -0
- package/dist/collection/campaign/VCSCampaignService.js +5 -0
- package/dist/collection/campaign/VPRCampaignResponse.js +1 -0
- package/dist/collection/campaign/VPRCampaignService.js +5 -0
- package/dist/collection/collection-manifest.json +43 -0
- package/dist/collection/components/customized-slots.js +47 -0
- package/dist/collection/components/image-search/image-view/highlight-box/highlight-box.css +71 -0
- package/dist/collection/components/image-search/image-view/highlight-box/highlight-box.js +25 -0
- package/dist/collection/components/image-search/image-view/image-cropper/cropper-handler/cropper-handler.css +49 -0
- package/dist/collection/components/image-search/image-view/image-cropper/cropper-handler/cropper-handler.js +64 -0
- package/dist/collection/components/image-search/image-view/image-cropper/image-cropper.css +33 -0
- package/dist/{vviinn-widgets/image-cropper.entry.js → collection/components/image-search/image-view/image-cropper/image-cropper.js} +54 -32
- package/dist/collection/components/image-search/search-filters/search-filters.css +120 -0
- package/dist/collection/components/image-search/search-filters/search-filters.js +102 -0
- package/dist/collection/components/vviinn-carousel/vviinn-carousel.css +138 -0
- package/{www/build/vviinn-carousel.entry.js → dist/collection/components/vviinn-carousel/vviinn-carousel.js} +115 -18
- package/dist/collection/components/vviinn-error/vviinn-empty-results/vviinn-empty-results.css +7 -0
- package/dist/collection/components/vviinn-error/vviinn-empty-results/vviinn-empty-results.js +36 -0
- package/dist/collection/components/vviinn-error/vviinn-error.css +38 -0
- package/dist/collection/components/vviinn-error/vviinn-error.js +18 -0
- package/dist/collection/components/vviinn-error/vviinn-server-error/vviinn-server-error.css +3 -0
- package/dist/collection/components/vviinn-error/vviinn-server-error/vviinn-server-error.js +34 -0
- package/dist/collection/components/vviinn-error/vviinn-wrong-format/vviinn-wrong-format.css +3 -0
- package/dist/collection/components/vviinn-error/vviinn-wrong-format/vviinn-wrong-format.js +34 -0
- package/dist/collection/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.css +34 -0
- package/dist/collection/components/vviinn-example-images/vviinn-example-image/vviinn-example-image.js +129 -0
- package/dist/collection/components/vviinn-example-images/vviinn-example-images.css +19 -0
- package/dist/collection/components/vviinn-example-images/vviinn-example-images.js +80 -0
- package/dist/{vviinn-widgets/index-c9483145.js → collection/components/vviinn-icons/index.js} +13 -12
- package/dist/collection/components/vviinn-image-selector/vviinn-image-selector.css +25 -0
- package/dist/collection/components/vviinn-image-selector/vviinn-image-selector.js +64 -0
- package/dist/collection/components/vviinn-image-view/vviinn-detected-object/vviinn-detected-object.css +47 -0
- package/dist/collection/components/vviinn-image-view/vviinn-detected-object/vviinn-detected-object.js +83 -0
- package/dist/collection/components/vviinn-image-view/vviinn-image-view.css +31 -0
- package/dist/collection/components/vviinn-image-view/vviinn-image-view.js +61 -0
- package/dist/collection/components/vviinn-modal/vviinn-modal.css +105 -0
- package/dist/collection/components/vviinn-modal/vviinn-modal.js +98 -0
- package/dist/collection/components/vviinn-onboarding/onboarding-cards/onboarding-card.css +41 -0
- package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-1/vviinn-onboarding-card-1.js +26 -0
- package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-2/vviinn-onboarding-card-2.js +26 -0
- package/dist/collection/components/vviinn-onboarding/onboarding-cards/vviinn-onboarding-card-3/vviinn-onboarding-card-3.js +26 -0
- package/dist/collection/components/vviinn-onboarding/vviinn-onboarding.css +58 -0
- package/dist/collection/components/vviinn-onboarding/vviinn-onboarding.js +28 -0
- package/dist/collection/components/vviinn-overlay/vviinn-overlay.css +33 -0
- package/dist/collection/components/vviinn-overlay/vviinn-overlay.js +15 -0
- package/dist/collection/components/vviinn-overlayed-modal/vviinn-overlayed-modal.css +29 -0
- package/dist/collection/components/vviinn-overlayed-modal/vviinn-overlayed-modal.js +71 -0
- package/dist/collection/components/vviinn-preloader/vviinn-preloader.css +37 -0
- package/dist/collection/components/vviinn-preloader/vviinn-preloader.js +20 -0
- package/dist/collection/components/vviinn-privacy-badge/vviinn-privacy-badge.css +19 -0
- package/dist/collection/components/vviinn-privacy-badge/vviinn-privacy-badge.js +27 -0
- package/dist/collection/components/vviinn-product-card/render-helpers.js +32 -0
- package/dist/collection/components/vviinn-product-card/vviinn-product-card.css +95 -0
- package/dist/collection/components/vviinn-product-card/vviinn-product-card.js +425 -0
- package/dist/collection/components/vviinn-slider/arrow.js +11 -0
- package/dist/collection/components/vviinn-slider/vviinn-slide/vviinn-slide.css +4 -0
- package/dist/collection/components/vviinn-slider/vviinn-slide/vviinn-slide.js +15 -0
- package/dist/collection/components/vviinn-slider/vviinn-slider.css +109 -0
- package/dist/collection/components/vviinn-slider/vviinn-slider.js +181 -0
- package/dist/collection/components/vviinn-teaser/vviinn-teaser.css +14 -0
- package/dist/collection/components/vviinn-teaser/vviinn-teaser.js +29 -0
- package/dist/collection/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.css +238 -0
- package/dist/collection/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.js +200 -0
- package/dist/collection/components/vviinn-vpr-button/stories/kek.stories.js +18 -0
- package/dist/collection/components/vviinn-vpr-button/vviinn-vpr-button.css +35 -0
- package/dist/collection/components/vviinn-vpr-button/vviinn-vpr-button.js +149 -0
- package/dist/collection/components/vviinn-vpr-widget/GridMode.js +1 -0
- package/dist/collection/components/vviinn-vpr-widget/token-helpers.js +11 -0
- package/dist/collection/components/vviinn-vpr-widget/vviinn-vpr-vidget.js +441 -0
- package/dist/collection/components/vviinn-vpr-widget/vviinn-vpr-widget.css +74 -0
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.css +0 -0
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +177 -0
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.css +350 -0
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.js +247 -0
- package/dist/collection/cropper/Cropper.js +1 -0
- package/dist/collection/cropper/Handler.js +61 -0
- package/dist/collection/dom/index.js +3 -0
- package/dist/collection/error.js +14 -0
- package/dist/collection/file/index.js +4 -0
- package/dist/collection/geometry/Clip.js +14 -0
- package/dist/collection/geometry/Point.js +32 -0
- package/dist/collection/geometry/Rectangle.js +95 -0
- package/dist/collection/geometry/RectangleAlt.js +1 -0
- package/dist/collection/geometry/Sized.js +8 -0
- package/dist/collection/global.js +19 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/interfaces/generated.js +5 -0
- package/dist/collection/interfaces/recommendation.js +1 -0
- package/dist/collection/network/apiClient.js +9 -0
- package/dist/collection/network/ion/File.js +14 -0
- package/dist/collection/network/ion/Form.js +64 -0
- package/dist/collection/network/ion/Link.js +8 -0
- package/dist/collection/network/ion/ValueObject.js +23 -0
- package/dist/collection/network/request.js +19 -0
- package/dist/collection/network/utils.js +37 -0
- package/dist/collection/recommendation/recommendation.js +1 -0
- package/dist/collection/searchSession/searchSession.js +26 -0
- package/dist/collection/sentry.js +14 -0
- package/dist/collection/slider/GridMode.js +1 -0
- package/dist/collection/store/file-processing.js +13 -0
- package/dist/collection/store/imageSearch.store.js +138 -0
- package/dist/collection/store/store.js +11 -0
- package/dist/collection/stories/Button.js +21 -0
- package/dist/collection/stories/Button.stories.js +42 -0
- package/dist/collection/stories/Header.js +45 -0
- package/dist/collection/stories/Header.stories.js +15 -0
- package/dist/collection/stories/Page.js +61 -0
- package/dist/collection/stories/Page.stories.js +19 -0
- package/dist/collection/stories/assets/code-brackets.svg +1 -0
- package/dist/collection/stories/assets/colors.svg +1 -0
- package/dist/collection/stories/assets/comments.svg +1 -0
- package/dist/collection/stories/assets/direction.svg +1 -0
- package/dist/collection/stories/assets/flow.svg +1 -0
- package/dist/collection/stories/assets/plugin.svg +1 -0
- package/dist/collection/stories/assets/repo.svg +1 -0
- package/dist/collection/stories/assets/stackalt.svg +1 -0
- package/dist/collection/stories/image-selector.stories.js +6 -0
- package/dist/collection/stories/image-view.stories.js +6 -0
- package/dist/collection/stories/modal.stories.js +12 -0
- package/dist/collection/stories/onboarding.stories.js +11 -0
- package/dist/collection/stories/overlay.stories.js +5 -0
- package/dist/collection/stories/overlayedModal.stories.js +8 -0
- package/dist/collection/stories/privacy-badge.stories.js +11 -0
- package/dist/collection/stories/slider.stories.js +17 -0
- package/dist/collection/stories/teaser.stories.js +5 -0
- package/dist/collection/stories/vps-widget.stories.js +47 -0
- package/dist/collection/stories/vviinn-product.stories.js +19 -0
- package/dist/collection/utils/collections/collectionsUtils.js +5 -0
- package/dist/collection/utils/either.js +3 -0
- package/dist/collection/utils/enum/enumUtils.js +3 -0
- package/dist/collection/utils/event/Events.js +1 -0
- package/dist/collection/utils/number/index.js +4 -0
- package/dist/collection/utils/option/option.js +4 -0
- package/dist/collection/utils/semigroup/semigroupDiff.js +6 -0
- package/dist/collection/utils/token/tokenUtils.js +9 -0
- package/dist/esm/Handler-639a4cb3.js +308 -0
- package/{www/build/app-globals-e0943e34.js → dist/esm/app-globals-345e497d.js} +10 -922
- package/dist/{vviinn-widgets → esm}/cropper-handler.entry.js +2 -2
- package/{www/build/customized-slots-f3449695.js → dist/esm/customized-slots-a76a8d41.js} +1 -1
- package/dist/esm/highlight-box_22.entry.js +712 -0
- package/dist/{vviinn-widgets/imageSearch.store-407f49f0.js → esm/imageSearch.store-8eab0da1.js} +11510 -11872
- package/dist/esm/index-6fa21e24.js +1323 -0
- package/{www/build/index-c9483145.js → dist/esm/index-8cb063df.js} +6 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +19 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/vviinn-carousel_5.entry.js +1224 -0
- package/{www/build → dist/esm}/vviinn-error.entry.js +1 -1
- package/dist/{vviinn-widgets → esm}/vviinn-preloader.entry.js +3 -6
- package/dist/{vviinn-widgets → esm}/vviinn-vps-button.entry.js +3 -3
- package/dist/{vviinn-widgets → esm}/vviinn-vps-widget.entry.js +4 -7
- package/dist/esm/vviinn-widgets.js +19 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +12 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +10 -0
- package/dist/types/components/vviinn-carousel/vviinn-carousel.d.ts +1 -0
- package/dist/types/components/vviinn-icons/index.d.ts +2 -0
- package/dist/types/components/vviinn-product-card/render-helpers.d.ts +3 -2
- package/dist/types/components/vviinn-product-card/vviinn-product-card.d.ts +2 -0
- package/dist/types/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.d.ts +25 -0
- package/dist/types/components/vviinn-vpr-button/stories/kek.stories.d.ts +7 -0
- package/dist/types/components/vviinn-vpr-button/vviinn-vpr-button.d.ts +14 -0
- package/dist/types/components/vviinn-vpr-widget/vviinn-vpr-vidget.d.ts +13 -3
- package/dist/types/components.d.ts +54 -0
- package/dist/vviinn-widgets/index.esm.js +0 -1
- package/dist/vviinn-widgets/p-04b06ea9.entry.js +1 -0
- package/dist/vviinn-widgets/p-400eb62f.entry.js +1 -0
- package/dist/vviinn-widgets/p-56fc949a.js +1 -0
- package/dist/vviinn-widgets/p-59edfbe2.js +1 -0
- package/dist/vviinn-widgets/p-78ccc9eb.js +15 -0
- package/dist/vviinn-widgets/p-9d24f51e.entry.js +1 -0
- package/dist/vviinn-widgets/p-d085199d.entry.js +1 -0
- package/dist/vviinn-widgets/p-e1ba8626.js +1 -0
- package/dist/vviinn-widgets/p-e38f4aa2.entry.js +1 -0
- package/dist/vviinn-widgets/p-e67cae57.js +1 -0
- package/dist/vviinn-widgets/p-f47e82b2.entry.js +1 -0
- package/dist/vviinn-widgets/p-f582db5c.js +1 -0
- package/dist/vviinn-widgets/p-fb14e3cc.entry.js +1 -0
- package/dist/vviinn-widgets/vviinn-widgets.css +1 -6
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -125
- package/package.json +3 -1
- package/www/build/index.esm.js +0 -1
- package/www/build/p-04b06ea9.entry.js +1 -0
- package/www/build/p-400eb62f.entry.js +1 -0
- package/www/build/p-56fc949a.js +1 -0
- package/www/build/p-59edfbe2.js +1 -0
- package/www/build/p-78ccc9eb.js +15 -0
- package/www/build/p-7e4978d5.js +1 -0
- package/www/build/p-9d24f51e.entry.js +1 -0
- package/www/build/p-a67898be.css +1 -0
- package/www/build/p-d085199d.entry.js +1 -0
- package/www/build/p-e1ba8626.js +1 -0
- package/www/build/p-e38f4aa2.entry.js +1 -0
- package/www/build/p-e67cae57.js +1 -0
- package/www/build/p-f47e82b2.entry.js +1 -0
- package/www/build/p-f582db5c.js +1 -0
- package/www/build/p-fb14e3cc.entry.js +1 -0
- package/www/build/vviinn-widgets.css +1 -6
- package/www/build/vviinn-widgets.esm.js +1 -125
- package/www/index.html +6 -13
- package/dist/vviinn-widgets/Array-4b9f84cf.js +0 -4295
- package/dist/vviinn-widgets/Handler-47db9890.js +0 -1428
- package/dist/vviinn-widgets/NonEmptyArray-6ef0d207.js +0 -4370
- package/dist/vviinn-widgets/css-shim-f0027935.js +0 -4
- package/dist/vviinn-widgets/dom-db0073f0.js +0 -73
- package/dist/vviinn-widgets/highlight-box.entry.js +0 -41
- package/dist/vviinn-widgets/index-b6d739a9.js +0 -3010
- package/dist/vviinn-widgets/number-98d54dd6.js +0 -1533
- package/dist/vviinn-widgets/search-filters.entry.js +0 -73
- package/dist/vviinn-widgets/shadow-css-c1fdfa9f.js +0 -389
- package/dist/vviinn-widgets/vviinn-carousel.entry.js +0 -205
- package/dist/vviinn-widgets/vviinn-detected-object.entry.js +0 -52
- package/dist/vviinn-widgets/vviinn-empty-results.entry.js +0 -16
- package/dist/vviinn-widgets/vviinn-example-image.entry.js +0 -38
- package/dist/vviinn-widgets/vviinn-example-images.entry.js +0 -28
- package/dist/vviinn-widgets/vviinn-image-selector.entry.js +0 -31
- package/dist/vviinn-widgets/vviinn-image-view.entry.js +0 -55
- package/dist/vviinn-widgets/vviinn-modal.entry.js +0 -30
- package/dist/vviinn-widgets/vviinn-onboarding-card-1.entry.js +0 -21
- package/dist/vviinn-widgets/vviinn-onboarding-card-2.entry.js +0 -21
- package/dist/vviinn-widgets/vviinn-onboarding-card-3.entry.js +0 -21
- package/dist/vviinn-widgets/vviinn-onboarding.entry.js +0 -20
- package/dist/vviinn-widgets/vviinn-overlay.entry.js +0 -15
- package/dist/vviinn-widgets/vviinn-overlayed-modal.entry.js +0 -18
- package/dist/vviinn-widgets/vviinn-privacy-badge.entry.js +0 -20
- package/dist/vviinn-widgets/vviinn-product-card.entry.js +0 -176
- package/dist/vviinn-widgets/vviinn-server-error.entry.js +0 -16
- package/dist/vviinn-widgets/vviinn-slide.entry.js +0 -15
- package/dist/vviinn-widgets/vviinn-slider.entry.js +0 -120
- package/dist/vviinn-widgets/vviinn-teaser.entry.js +0 -20
- package/dist/vviinn-widgets/vviinn-vpr-widget.entry.js +0 -128
- package/dist/vviinn-widgets/vviinn-wrong-format.entry.js +0 -16
- package/www/build/Array-4b9f84cf.js +0 -4295
- package/www/build/Handler-47db9890.js +0 -1428
- package/www/build/NonEmptyArray-6ef0d207.js +0 -4370
- package/www/build/css-shim-f0027935.js +0 -4
- package/www/build/dom-db0073f0.js +0 -73
- package/www/build/highlight-box.entry.js +0 -41
- package/www/build/image-cropper.entry.js +0 -113
- package/www/build/index-b6d739a9.js +0 -3010
- package/www/build/number-98d54dd6.js +0 -1533
- package/www/build/search-filters.entry.js +0 -73
- package/www/build/shadow-css-c1fdfa9f.js +0 -389
- package/www/build/vviinn-detected-object.entry.js +0 -52
- package/www/build/vviinn-empty-results.entry.js +0 -16
- package/www/build/vviinn-example-image.entry.js +0 -38
- package/www/build/vviinn-example-images.entry.js +0 -28
- package/www/build/vviinn-image-selector.entry.js +0 -31
- package/www/build/vviinn-image-view.entry.js +0 -55
- package/www/build/vviinn-modal.entry.js +0 -30
- package/www/build/vviinn-onboarding-card-1.entry.js +0 -21
- package/www/build/vviinn-onboarding-card-2.entry.js +0 -21
- package/www/build/vviinn-onboarding-card-3.entry.js +0 -21
- package/www/build/vviinn-onboarding.entry.js +0 -20
- package/www/build/vviinn-overlay.entry.js +0 -15
- package/www/build/vviinn-overlayed-modal.entry.js +0 -18
- package/www/build/vviinn-privacy-badge.entry.js +0 -20
- package/www/build/vviinn-product-card.entry.js +0 -176
- package/www/build/vviinn-server-error.entry.js +0 -16
- package/www/build/vviinn-slide.entry.js +0 -15
- package/www/build/vviinn-slider.entry.js +0 -120
- package/www/build/vviinn-teaser.entry.js +0 -20
- package/www/build/vviinn-vpr-widget.entry.js +0 -128
- package/www/build/vviinn-vps-button.entry.js +0 -39
- package/www/build/vviinn-wrong-format.entry.js +0 -16
|
@@ -1,1533 +0,0 @@
|
|
|
1
|
-
import { c as createCommonjsModule, A as Apply, F as Functor, _ as _function, g as getDefaultExportFromCjs, a as commonjsGlobal, i as internal, Z as Zero, S as Separated, W as Witherable, C as Chain, b as FromEither, d as Semigroup } from './NonEmptyArray-6ef0d207.js';
|
|
2
|
-
|
|
3
|
-
var Applicative = createCommonjsModule(function (module, exports) {
|
|
4
|
-
"use strict";
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getApplicativeComposition = exports.getApplicativeMonoid = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* The `Applicative` type class extends the `Apply` type class with a `of` function, which can be used to create values
|
|
9
|
-
* of type `f a` from values of type `a`.
|
|
10
|
-
*
|
|
11
|
-
* Where `Apply` provides the ability to lift functions of two or more arguments to functions whose arguments are
|
|
12
|
-
* wrapped using `f`, and `Functor` provides the ability to lift functions of one argument, `pure` can be seen as the
|
|
13
|
-
* function which lifts functions of _zero_ arguments. That is, `Applicative` functors support a lifting operation for
|
|
14
|
-
* any number of function arguments.
|
|
15
|
-
*
|
|
16
|
-
* Instances must satisfy the following laws in addition to the `Apply` laws:
|
|
17
|
-
*
|
|
18
|
-
* 1. Identity: `A.ap(A.of(a => a), fa) <-> fa`
|
|
19
|
-
* 2. Homomorphism: `A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a))`
|
|
20
|
-
* 3. Interchange: `A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab)`
|
|
21
|
-
*
|
|
22
|
-
* Note. `Functor`'s `map` can be derived: `A.map(x, f) = A.ap(A.of(f), x)`
|
|
23
|
-
*
|
|
24
|
-
* @since 2.0.0
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function getApplicativeMonoid(F) {
|
|
30
|
-
var f = Apply.getApplySemigroup(F);
|
|
31
|
-
return function (M) { return ({
|
|
32
|
-
concat: f(M).concat,
|
|
33
|
-
empty: F.of(M.empty)
|
|
34
|
-
}); };
|
|
35
|
-
}
|
|
36
|
-
exports.getApplicativeMonoid = getApplicativeMonoid;
|
|
37
|
-
/** @deprecated */
|
|
38
|
-
function getApplicativeComposition(F, G) {
|
|
39
|
-
var map = Functor.getFunctorComposition(F, G).map;
|
|
40
|
-
var _ap = Apply.ap(F, G);
|
|
41
|
-
return {
|
|
42
|
-
map: map,
|
|
43
|
-
of: function (a) { return F.of(G.of(a)); },
|
|
44
|
-
ap: function (fgab, fga) { return _function.pipe(fgab, _ap(fga)); }
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
exports.getApplicativeComposition = getApplicativeComposition;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const Applicative$1 = /*@__PURE__*/getDefaultExportFromCjs(Applicative);
|
|
51
|
-
|
|
52
|
-
var Predicate = createCommonjsModule(function (module, exports) {
|
|
53
|
-
"use strict";
|
|
54
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.and = exports.or = exports.not = exports.Contravariant = exports.getMonoidAll = exports.getSemigroupAll = exports.getMonoidAny = exports.getSemigroupAny = exports.URI = exports.contramap = void 0;
|
|
56
|
-
|
|
57
|
-
// -------------------------------------------------------------------------------------
|
|
58
|
-
// type class members
|
|
59
|
-
// -------------------------------------------------------------------------------------
|
|
60
|
-
var contramap_ = function (predicate, f) { return _function.pipe(predicate, exports.contramap(f)); };
|
|
61
|
-
/**
|
|
62
|
-
* @category Contravariant
|
|
63
|
-
* @since 2.11.0
|
|
64
|
-
*/
|
|
65
|
-
var contramap = function (f) { return function (predicate) { return _function.flow(f, predicate); }; };
|
|
66
|
-
exports.contramap = contramap;
|
|
67
|
-
// -------------------------------------------------------------------------------------
|
|
68
|
-
// instances
|
|
69
|
-
// -------------------------------------------------------------------------------------
|
|
70
|
-
/**
|
|
71
|
-
* @category instances
|
|
72
|
-
* @since 2.11.0
|
|
73
|
-
*/
|
|
74
|
-
exports.URI = 'Predicate';
|
|
75
|
-
/**
|
|
76
|
-
* @category instances
|
|
77
|
-
* @since 2.11.0
|
|
78
|
-
*/
|
|
79
|
-
var getSemigroupAny = function () { return ({
|
|
80
|
-
concat: function (first, second) { return _function.pipe(first, exports.or(second)); }
|
|
81
|
-
}); };
|
|
82
|
-
exports.getSemigroupAny = getSemigroupAny;
|
|
83
|
-
/**
|
|
84
|
-
* @category instances
|
|
85
|
-
* @since 2.11.0
|
|
86
|
-
*/
|
|
87
|
-
var getMonoidAny = function () { return ({
|
|
88
|
-
concat: exports.getSemigroupAny().concat,
|
|
89
|
-
empty: _function.constFalse
|
|
90
|
-
}); };
|
|
91
|
-
exports.getMonoidAny = getMonoidAny;
|
|
92
|
-
/**
|
|
93
|
-
* @category instances
|
|
94
|
-
* @since 2.11.0
|
|
95
|
-
*/
|
|
96
|
-
var getSemigroupAll = function () { return ({
|
|
97
|
-
concat: function (first, second) { return _function.pipe(first, exports.and(second)); }
|
|
98
|
-
}); };
|
|
99
|
-
exports.getSemigroupAll = getSemigroupAll;
|
|
100
|
-
/**
|
|
101
|
-
* @category instances
|
|
102
|
-
* @since 2.11.0
|
|
103
|
-
*/
|
|
104
|
-
var getMonoidAll = function () { return ({
|
|
105
|
-
concat: exports.getSemigroupAll().concat,
|
|
106
|
-
empty: _function.constTrue
|
|
107
|
-
}); };
|
|
108
|
-
exports.getMonoidAll = getMonoidAll;
|
|
109
|
-
/**
|
|
110
|
-
* @category instances
|
|
111
|
-
* @since 2.11.0
|
|
112
|
-
*/
|
|
113
|
-
exports.Contravariant = {
|
|
114
|
-
URI: exports.URI,
|
|
115
|
-
contramap: contramap_
|
|
116
|
-
};
|
|
117
|
-
// -------------------------------------------------------------------------------------
|
|
118
|
-
// utils
|
|
119
|
-
// -------------------------------------------------------------------------------------
|
|
120
|
-
/**
|
|
121
|
-
* @since 2.11.0
|
|
122
|
-
*/
|
|
123
|
-
var not = function (predicate) { return function (a) { return !predicate(a); }; };
|
|
124
|
-
exports.not = not;
|
|
125
|
-
/**
|
|
126
|
-
* @since 2.11.0
|
|
127
|
-
*/
|
|
128
|
-
var or = function (second) { return function (first) { return function (a) { return first(a) || second(a); }; }; };
|
|
129
|
-
exports.or = or;
|
|
130
|
-
/**
|
|
131
|
-
* @since 2.11.0
|
|
132
|
-
*/
|
|
133
|
-
var and = function (second) { return function (first) { return function (a) { return first(a) && second(a); }; }; };
|
|
134
|
-
exports.and = and;
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const Predicate$1 = /*@__PURE__*/getDefaultExportFromCjs(Predicate);
|
|
138
|
-
|
|
139
|
-
var Option = createCommonjsModule(function (module, exports) {
|
|
140
|
-
"use strict";
|
|
141
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
142
|
-
if (k2 === undefined) k2 = k;
|
|
143
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
144
|
-
}) : (function(o, m, k, k2) {
|
|
145
|
-
if (k2 === undefined) k2 = k;
|
|
146
|
-
o[k2] = m[k];
|
|
147
|
-
}));
|
|
148
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
149
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
150
|
-
}) : function(o, v) {
|
|
151
|
-
o["default"] = v;
|
|
152
|
-
});
|
|
153
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
154
|
-
if (mod && mod.__esModule) return mod;
|
|
155
|
-
var result = {};
|
|
156
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
157
|
-
__setModuleDefault(result, mod);
|
|
158
|
-
return result;
|
|
159
|
-
};
|
|
160
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
161
|
-
exports.fromEither = exports.MonadThrow = exports.throwError = exports.Witherable = exports.wilt = exports.wither = exports.Traversable = exports.sequence = exports.traverse = exports.Filterable = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.Compactable = exports.separate = exports.compact = exports.Extend = exports.extend = exports.Alternative = exports.guard = exports.Zero = exports.zero = exports.Alt = exports.alt = exports.altW = exports.Foldable = exports.reduceRight = exports.foldMap = exports.reduce = exports.Monad = exports.Chain = exports.chain = exports.Applicative = exports.Apply = exports.ap = exports.Pointed = exports.of = exports.Functor = exports.map = exports.getMonoid = exports.getOrd = exports.getEq = exports.getShow = exports.URI = exports.getRight = exports.getLeft = exports.fromPredicate = exports.some = exports.none = void 0;
|
|
162
|
-
exports.getLastMonoid = exports.getFirstMonoid = exports.getApplyMonoid = exports.getApplySemigroup = exports.option = exports.mapNullable = exports.getRefinement = exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex = exports.traverseReadonlyNonEmptyArrayWithIndex = exports.ApT = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.exists = exports.elem = exports.toUndefined = exports.toNullable = exports.chainNullableK = exports.fromNullableK = exports.tryCatchK = exports.tryCatch = exports.fromNullable = exports.chainEitherK = exports.fromEitherK = exports.duplicate = exports.chainFirst = exports.flatten = exports.apSecond = exports.apFirst = exports.flap = exports.getOrElse = exports.getOrElseW = exports.fold = exports.match = exports.foldW = exports.matchW = exports.isNone = exports.isSome = exports.FromEither = void 0;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var _ = __importStar(internal);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
// -------------------------------------------------------------------------------------
|
|
176
|
-
// constructors
|
|
177
|
-
// -------------------------------------------------------------------------------------
|
|
178
|
-
/**
|
|
179
|
-
* `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
|
|
180
|
-
*
|
|
181
|
-
* @category constructors
|
|
182
|
-
* @since 2.0.0
|
|
183
|
-
*/
|
|
184
|
-
exports.none = _.none;
|
|
185
|
-
/**
|
|
186
|
-
* Constructs a `Some`. Represents an optional value that exists.
|
|
187
|
-
*
|
|
188
|
-
* @category constructors
|
|
189
|
-
* @since 2.0.0
|
|
190
|
-
*/
|
|
191
|
-
exports.some = _.some;
|
|
192
|
-
function fromPredicate(predicate) {
|
|
193
|
-
return function (a) { return (predicate(a) ? exports.some(a) : exports.none); };
|
|
194
|
-
}
|
|
195
|
-
exports.fromPredicate = fromPredicate;
|
|
196
|
-
/**
|
|
197
|
-
* Returns the `Left` value of an `Either` if possible.
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* import { getLeft, none, some } from 'fp-ts/Option'
|
|
201
|
-
* import { right, left } from 'fp-ts/Either'
|
|
202
|
-
*
|
|
203
|
-
* assert.deepStrictEqual(getLeft(right(1)), none)
|
|
204
|
-
* assert.deepStrictEqual(getLeft(left('a')), some('a'))
|
|
205
|
-
*
|
|
206
|
-
* @category constructors
|
|
207
|
-
* @since 2.0.0
|
|
208
|
-
*/
|
|
209
|
-
var getLeft = function (ma) { return (ma._tag === 'Right' ? exports.none : exports.some(ma.left)); };
|
|
210
|
-
exports.getLeft = getLeft;
|
|
211
|
-
/**
|
|
212
|
-
* Returns the `Right` value of an `Either` if possible.
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
* import { getRight, none, some } from 'fp-ts/Option'
|
|
216
|
-
* import { right, left } from 'fp-ts/Either'
|
|
217
|
-
*
|
|
218
|
-
* assert.deepStrictEqual(getRight(right(1)), some(1))
|
|
219
|
-
* assert.deepStrictEqual(getRight(left('a')), none)
|
|
220
|
-
*
|
|
221
|
-
* @category constructors
|
|
222
|
-
* @since 2.0.0
|
|
223
|
-
*/
|
|
224
|
-
var getRight = function (ma) { return (ma._tag === 'Left' ? exports.none : exports.some(ma.right)); };
|
|
225
|
-
exports.getRight = getRight;
|
|
226
|
-
// -------------------------------------------------------------------------------------
|
|
227
|
-
// non-pipeables
|
|
228
|
-
// -------------------------------------------------------------------------------------
|
|
229
|
-
var _map = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
|
|
230
|
-
var _ap = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
|
|
231
|
-
var _chain = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
|
|
232
|
-
var _reduce = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
|
|
233
|
-
var _foldMap = function (M) {
|
|
234
|
-
var foldMapM = exports.foldMap(M);
|
|
235
|
-
return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
|
|
236
|
-
};
|
|
237
|
-
var _reduceRight = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
|
|
238
|
-
var _traverse = function (F) {
|
|
239
|
-
var traverseF = exports.traverse(F);
|
|
240
|
-
return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
|
|
241
|
-
};
|
|
242
|
-
/* istanbul ignore next */
|
|
243
|
-
var _alt = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
|
|
244
|
-
var _filter = function (fa, predicate) { return _function.pipe(fa, exports.filter(predicate)); };
|
|
245
|
-
/* istanbul ignore next */
|
|
246
|
-
var _filterMap = function (fa, f) { return _function.pipe(fa, exports.filterMap(f)); };
|
|
247
|
-
/* istanbul ignore next */
|
|
248
|
-
var _extend = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
|
|
249
|
-
/* istanbul ignore next */
|
|
250
|
-
var _partition = function (fa, predicate) {
|
|
251
|
-
return _function.pipe(fa, exports.partition(predicate));
|
|
252
|
-
};
|
|
253
|
-
/* istanbul ignore next */
|
|
254
|
-
var _partitionMap = function (fa, f) { return _function.pipe(fa, exports.partitionMap(f)); };
|
|
255
|
-
// -------------------------------------------------------------------------------------
|
|
256
|
-
// instances
|
|
257
|
-
// -------------------------------------------------------------------------------------
|
|
258
|
-
/**
|
|
259
|
-
* @category instances
|
|
260
|
-
* @since 2.0.0
|
|
261
|
-
*/
|
|
262
|
-
exports.URI = 'Option';
|
|
263
|
-
/**
|
|
264
|
-
* @category instances
|
|
265
|
-
* @since 2.0.0
|
|
266
|
-
*/
|
|
267
|
-
var getShow = function (S) { return ({
|
|
268
|
-
show: function (ma) { return (exports.isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); }
|
|
269
|
-
}); };
|
|
270
|
-
exports.getShow = getShow;
|
|
271
|
-
/**
|
|
272
|
-
* @example
|
|
273
|
-
* import { none, some, getEq } from 'fp-ts/Option'
|
|
274
|
-
* import * as N from 'fp-ts/number'
|
|
275
|
-
*
|
|
276
|
-
* const E = getEq(N.Eq)
|
|
277
|
-
* assert.strictEqual(E.equals(none, none), true)
|
|
278
|
-
* assert.strictEqual(E.equals(none, some(1)), false)
|
|
279
|
-
* assert.strictEqual(E.equals(some(1), none), false)
|
|
280
|
-
* assert.strictEqual(E.equals(some(1), some(2)), false)
|
|
281
|
-
* assert.strictEqual(E.equals(some(1), some(1)), true)
|
|
282
|
-
*
|
|
283
|
-
* @category instances
|
|
284
|
-
* @since 2.0.0
|
|
285
|
-
*/
|
|
286
|
-
var getEq = function (E) { return ({
|
|
287
|
-
equals: function (x, y) { return x === y || (exports.isNone(x) ? exports.isNone(y) : exports.isNone(y) ? false : E.equals(x.value, y.value)); }
|
|
288
|
-
}); };
|
|
289
|
-
exports.getEq = getEq;
|
|
290
|
-
/**
|
|
291
|
-
* The `Ord` instance allows `Option` values to be compared with
|
|
292
|
-
* `compare`, whenever there is an `Ord` instance for
|
|
293
|
-
* the type the `Option` contains.
|
|
294
|
-
*
|
|
295
|
-
* `None` is considered to be less than any `Some` value.
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* import { none, some, getOrd } from 'fp-ts/Option'
|
|
300
|
-
* import * as N from 'fp-ts/number'
|
|
301
|
-
*
|
|
302
|
-
* const O = getOrd(N.Ord)
|
|
303
|
-
* assert.strictEqual(O.compare(none, none), 0)
|
|
304
|
-
* assert.strictEqual(O.compare(none, some(1)), -1)
|
|
305
|
-
* assert.strictEqual(O.compare(some(1), none), 1)
|
|
306
|
-
* assert.strictEqual(O.compare(some(1), some(2)), -1)
|
|
307
|
-
* assert.strictEqual(O.compare(some(1), some(1)), 0)
|
|
308
|
-
*
|
|
309
|
-
* @category instances
|
|
310
|
-
* @since 2.0.0
|
|
311
|
-
*/
|
|
312
|
-
var getOrd = function (O) { return ({
|
|
313
|
-
equals: exports.getEq(O).equals,
|
|
314
|
-
compare: function (x, y) { return (x === y ? 0 : exports.isSome(x) ? (exports.isSome(y) ? O.compare(x.value, y.value) : 1) : -1); }
|
|
315
|
-
}); };
|
|
316
|
-
exports.getOrd = getOrd;
|
|
317
|
-
/**
|
|
318
|
-
* Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are
|
|
319
|
-
* concatenated using the provided `Semigroup`
|
|
320
|
-
*
|
|
321
|
-
* | x | y | concat(x, y) |
|
|
322
|
-
* | ------- | ------- | ------------------ |
|
|
323
|
-
* | none | none | none |
|
|
324
|
-
* | some(a) | none | some(a) |
|
|
325
|
-
* | none | some(b) | some(b) |
|
|
326
|
-
* | some(a) | some(b) | some(concat(a, b)) |
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* import { getMonoid, some, none } from 'fp-ts/Option'
|
|
330
|
-
* import { SemigroupSum } from 'fp-ts/number'
|
|
331
|
-
*
|
|
332
|
-
* const M = getMonoid(SemigroupSum)
|
|
333
|
-
* assert.deepStrictEqual(M.concat(none, none), none)
|
|
334
|
-
* assert.deepStrictEqual(M.concat(some(1), none), some(1))
|
|
335
|
-
* assert.deepStrictEqual(M.concat(none, some(1)), some(1))
|
|
336
|
-
* assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))
|
|
337
|
-
*
|
|
338
|
-
* @category instances
|
|
339
|
-
* @since 2.0.0
|
|
340
|
-
*/
|
|
341
|
-
var getMonoid = function (S) { return ({
|
|
342
|
-
concat: function (x, y) { return (exports.isNone(x) ? y : exports.isNone(y) ? x : exports.some(S.concat(x.value, y.value))); },
|
|
343
|
-
empty: exports.none
|
|
344
|
-
}); };
|
|
345
|
-
exports.getMonoid = getMonoid;
|
|
346
|
-
/**
|
|
347
|
-
* @category instance operations
|
|
348
|
-
* @since 2.0.0
|
|
349
|
-
*/
|
|
350
|
-
var map = function (f) { return function (fa) {
|
|
351
|
-
return exports.isNone(fa) ? exports.none : exports.some(f(fa.value));
|
|
352
|
-
}; };
|
|
353
|
-
exports.map = map;
|
|
354
|
-
/**
|
|
355
|
-
* @category instances
|
|
356
|
-
* @since 2.7.0
|
|
357
|
-
*/
|
|
358
|
-
exports.Functor = {
|
|
359
|
-
URI: exports.URI,
|
|
360
|
-
map: _map
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* @category instance operations
|
|
364
|
-
* @since 2.7.0
|
|
365
|
-
*/
|
|
366
|
-
exports.of = exports.some;
|
|
367
|
-
/**
|
|
368
|
-
* @category instances
|
|
369
|
-
* @since 2.10.0
|
|
370
|
-
*/
|
|
371
|
-
exports.Pointed = {
|
|
372
|
-
URI: exports.URI,
|
|
373
|
-
of: exports.of
|
|
374
|
-
};
|
|
375
|
-
/**
|
|
376
|
-
* @category instance operations
|
|
377
|
-
* @since 2.0.0
|
|
378
|
-
*/
|
|
379
|
-
var ap = function (fa) { return function (fab) {
|
|
380
|
-
return exports.isNone(fab) ? exports.none : exports.isNone(fa) ? exports.none : exports.some(fab.value(fa.value));
|
|
381
|
-
}; };
|
|
382
|
-
exports.ap = ap;
|
|
383
|
-
/**
|
|
384
|
-
* @category instances
|
|
385
|
-
* @since 2.10.0
|
|
386
|
-
*/
|
|
387
|
-
exports.Apply = {
|
|
388
|
-
URI: exports.URI,
|
|
389
|
-
map: _map,
|
|
390
|
-
ap: _ap
|
|
391
|
-
};
|
|
392
|
-
/**
|
|
393
|
-
* @category instances
|
|
394
|
-
* @since 2.7.0
|
|
395
|
-
*/
|
|
396
|
-
exports.Applicative = {
|
|
397
|
-
URI: exports.URI,
|
|
398
|
-
map: _map,
|
|
399
|
-
ap: _ap,
|
|
400
|
-
of: exports.of
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation.
|
|
404
|
-
*
|
|
405
|
-
* @category instance operations
|
|
406
|
-
* @since 2.0.0
|
|
407
|
-
*/
|
|
408
|
-
var chain = function (f) { return function (ma) {
|
|
409
|
-
return exports.isNone(ma) ? exports.none : f(ma.value);
|
|
410
|
-
}; };
|
|
411
|
-
exports.chain = chain;
|
|
412
|
-
/**
|
|
413
|
-
* @category instances
|
|
414
|
-
* @since 2.10.0
|
|
415
|
-
*/
|
|
416
|
-
exports.Chain = {
|
|
417
|
-
URI: exports.URI,
|
|
418
|
-
map: _map,
|
|
419
|
-
ap: _ap,
|
|
420
|
-
chain: _chain
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* @category instances
|
|
424
|
-
* @since 2.7.0
|
|
425
|
-
*/
|
|
426
|
-
exports.Monad = {
|
|
427
|
-
URI: exports.URI,
|
|
428
|
-
map: _map,
|
|
429
|
-
ap: _ap,
|
|
430
|
-
of: exports.of,
|
|
431
|
-
chain: _chain
|
|
432
|
-
};
|
|
433
|
-
/**
|
|
434
|
-
* @category instance operations
|
|
435
|
-
* @since 2.0.0
|
|
436
|
-
*/
|
|
437
|
-
var reduce = function (b, f) { return function (fa) {
|
|
438
|
-
return exports.isNone(fa) ? b : f(b, fa.value);
|
|
439
|
-
}; };
|
|
440
|
-
exports.reduce = reduce;
|
|
441
|
-
/**
|
|
442
|
-
* @category instance operations
|
|
443
|
-
* @since 2.0.0
|
|
444
|
-
*/
|
|
445
|
-
var foldMap = function (M) { return function (f) { return function (fa) {
|
|
446
|
-
return exports.isNone(fa) ? M.empty : f(fa.value);
|
|
447
|
-
}; }; };
|
|
448
|
-
exports.foldMap = foldMap;
|
|
449
|
-
/**
|
|
450
|
-
* @category instance operations
|
|
451
|
-
* @since 2.0.0
|
|
452
|
-
*/
|
|
453
|
-
var reduceRight = function (b, f) { return function (fa) {
|
|
454
|
-
return exports.isNone(fa) ? b : f(fa.value, b);
|
|
455
|
-
}; };
|
|
456
|
-
exports.reduceRight = reduceRight;
|
|
457
|
-
/**
|
|
458
|
-
* @category instances
|
|
459
|
-
* @since 2.7.0
|
|
460
|
-
*/
|
|
461
|
-
exports.Foldable = {
|
|
462
|
-
URI: exports.URI,
|
|
463
|
-
reduce: _reduce,
|
|
464
|
-
foldMap: _foldMap,
|
|
465
|
-
reduceRight: _reduceRight
|
|
466
|
-
};
|
|
467
|
-
/**
|
|
468
|
-
* Less strict version of [`alt`](#alt).
|
|
469
|
-
*
|
|
470
|
-
* @category instance operations
|
|
471
|
-
* @since 2.9.0
|
|
472
|
-
*/
|
|
473
|
-
var altW = function (that) { return function (fa) {
|
|
474
|
-
return exports.isNone(fa) ? that() : fa;
|
|
475
|
-
}; };
|
|
476
|
-
exports.altW = altW;
|
|
477
|
-
/**
|
|
478
|
-
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
|
|
479
|
-
* types of kind `* -> *`.
|
|
480
|
-
*
|
|
481
|
-
* In case of `Option` returns the left-most non-`None` value.
|
|
482
|
-
*
|
|
483
|
-
* @example
|
|
484
|
-
* import * as O from 'fp-ts/Option'
|
|
485
|
-
* import { pipe } from 'fp-ts/function'
|
|
486
|
-
*
|
|
487
|
-
* assert.deepStrictEqual(
|
|
488
|
-
* pipe(
|
|
489
|
-
* O.some('a'),
|
|
490
|
-
* O.alt(() => O.some('b'))
|
|
491
|
-
* ),
|
|
492
|
-
* O.some('a')
|
|
493
|
-
* )
|
|
494
|
-
* assert.deepStrictEqual(
|
|
495
|
-
* pipe(
|
|
496
|
-
* O.none,
|
|
497
|
-
* O.alt(() => O.some('b'))
|
|
498
|
-
* ),
|
|
499
|
-
* O.some('b')
|
|
500
|
-
* )
|
|
501
|
-
*
|
|
502
|
-
* @category instance operations
|
|
503
|
-
* @since 2.0.0
|
|
504
|
-
*/
|
|
505
|
-
exports.alt = exports.altW;
|
|
506
|
-
/**
|
|
507
|
-
* @category instances
|
|
508
|
-
* @since 2.7.0
|
|
509
|
-
*/
|
|
510
|
-
exports.Alt = {
|
|
511
|
-
URI: exports.URI,
|
|
512
|
-
map: _map,
|
|
513
|
-
alt: _alt
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* @category instance operations
|
|
517
|
-
* @since 2.7.0
|
|
518
|
-
*/
|
|
519
|
-
var zero = function () { return exports.none; };
|
|
520
|
-
exports.zero = zero;
|
|
521
|
-
/**
|
|
522
|
-
* @category instances
|
|
523
|
-
* @since 2.11.0
|
|
524
|
-
*/
|
|
525
|
-
exports.Zero = {
|
|
526
|
-
URI: exports.URI,
|
|
527
|
-
zero: exports.zero
|
|
528
|
-
};
|
|
529
|
-
/**
|
|
530
|
-
* @category constructors
|
|
531
|
-
* @since 2.11.0
|
|
532
|
-
*/
|
|
533
|
-
exports.guard =
|
|
534
|
-
/*#__PURE__*/
|
|
535
|
-
Zero.guard(exports.Zero, exports.Pointed);
|
|
536
|
-
/**
|
|
537
|
-
* @category instances
|
|
538
|
-
* @since 2.7.0
|
|
539
|
-
*/
|
|
540
|
-
exports.Alternative = {
|
|
541
|
-
URI: exports.URI,
|
|
542
|
-
map: _map,
|
|
543
|
-
ap: _ap,
|
|
544
|
-
of: exports.of,
|
|
545
|
-
alt: _alt,
|
|
546
|
-
zero: exports.zero
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* @category instance operations
|
|
550
|
-
* @since 2.0.0
|
|
551
|
-
*/
|
|
552
|
-
var extend = function (f) { return function (wa) {
|
|
553
|
-
return exports.isNone(wa) ? exports.none : exports.some(f(wa));
|
|
554
|
-
}; };
|
|
555
|
-
exports.extend = extend;
|
|
556
|
-
/**
|
|
557
|
-
* @category instances
|
|
558
|
-
* @since 2.7.0
|
|
559
|
-
*/
|
|
560
|
-
exports.Extend = {
|
|
561
|
-
URI: exports.URI,
|
|
562
|
-
map: _map,
|
|
563
|
-
extend: _extend
|
|
564
|
-
};
|
|
565
|
-
/**
|
|
566
|
-
* @category instance operations
|
|
567
|
-
* @since 2.0.0
|
|
568
|
-
*/
|
|
569
|
-
exports.compact =
|
|
570
|
-
/*#__PURE__*/
|
|
571
|
-
exports.chain(_function.identity);
|
|
572
|
-
var defaultSeparated =
|
|
573
|
-
/*#__PURE__*/
|
|
574
|
-
Separated.separated(exports.none, exports.none);
|
|
575
|
-
/**
|
|
576
|
-
* @category instance operations
|
|
577
|
-
* @since 2.0.0
|
|
578
|
-
*/
|
|
579
|
-
var separate = function (ma) {
|
|
580
|
-
return exports.isNone(ma) ? defaultSeparated : Separated.separated(exports.getLeft(ma.value), exports.getRight(ma.value));
|
|
581
|
-
};
|
|
582
|
-
exports.separate = separate;
|
|
583
|
-
/**
|
|
584
|
-
* @category instances
|
|
585
|
-
* @since 2.7.0
|
|
586
|
-
*/
|
|
587
|
-
exports.Compactable = {
|
|
588
|
-
URI: exports.URI,
|
|
589
|
-
compact: exports.compact,
|
|
590
|
-
separate: exports.separate
|
|
591
|
-
};
|
|
592
|
-
/**
|
|
593
|
-
* @category instance operations
|
|
594
|
-
* @since 2.0.0
|
|
595
|
-
*/
|
|
596
|
-
var filter = function (predicate) { return function (fa) { return (exports.isNone(fa) ? exports.none : predicate(fa.value) ? fa : exports.none); }; };
|
|
597
|
-
exports.filter = filter;
|
|
598
|
-
/**
|
|
599
|
-
* @category instance operations
|
|
600
|
-
* @since 2.0.0
|
|
601
|
-
*/
|
|
602
|
-
var filterMap = function (f) { return function (fa) {
|
|
603
|
-
return exports.isNone(fa) ? exports.none : f(fa.value);
|
|
604
|
-
}; };
|
|
605
|
-
exports.filterMap = filterMap;
|
|
606
|
-
/**
|
|
607
|
-
* @category instance operations
|
|
608
|
-
* @since 2.0.0
|
|
609
|
-
*/
|
|
610
|
-
var partition = function (predicate) { return function (fa) { return Separated.separated(_filter(fa, Predicate.not(predicate)), _filter(fa, predicate)); }; };
|
|
611
|
-
exports.partition = partition;
|
|
612
|
-
/**
|
|
613
|
-
* @category instance operations
|
|
614
|
-
* @since 2.0.0
|
|
615
|
-
*/
|
|
616
|
-
var partitionMap = function (f) { return _function.flow(exports.map(f), exports.separate); };
|
|
617
|
-
exports.partitionMap = partitionMap;
|
|
618
|
-
/**
|
|
619
|
-
* @category instances
|
|
620
|
-
* @since 2.7.0
|
|
621
|
-
*/
|
|
622
|
-
exports.Filterable = {
|
|
623
|
-
URI: exports.URI,
|
|
624
|
-
map: _map,
|
|
625
|
-
compact: exports.compact,
|
|
626
|
-
separate: exports.separate,
|
|
627
|
-
filter: _filter,
|
|
628
|
-
filterMap: _filterMap,
|
|
629
|
-
partition: _partition,
|
|
630
|
-
partitionMap: _partitionMap
|
|
631
|
-
};
|
|
632
|
-
/**
|
|
633
|
-
* @category instance operations
|
|
634
|
-
* @since 2.6.3
|
|
635
|
-
*/
|
|
636
|
-
var traverse = function (F) { return function (f) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(f(ta.value), exports.some)); }; }; };
|
|
637
|
-
exports.traverse = traverse;
|
|
638
|
-
/**
|
|
639
|
-
* @category instance operations
|
|
640
|
-
* @since 2.6.3
|
|
641
|
-
*/
|
|
642
|
-
var sequence = function (F) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(ta.value, exports.some)); }; };
|
|
643
|
-
exports.sequence = sequence;
|
|
644
|
-
/**
|
|
645
|
-
* @category instances
|
|
646
|
-
* @since 2.7.0
|
|
647
|
-
*/
|
|
648
|
-
exports.Traversable = {
|
|
649
|
-
URI: exports.URI,
|
|
650
|
-
map: _map,
|
|
651
|
-
reduce: _reduce,
|
|
652
|
-
foldMap: _foldMap,
|
|
653
|
-
reduceRight: _reduceRight,
|
|
654
|
-
traverse: _traverse,
|
|
655
|
-
sequence: exports.sequence
|
|
656
|
-
};
|
|
657
|
-
var _wither =
|
|
658
|
-
/*#__PURE__*/
|
|
659
|
-
Witherable.witherDefault(exports.Traversable, exports.Compactable);
|
|
660
|
-
var _wilt =
|
|
661
|
-
/*#__PURE__*/
|
|
662
|
-
Witherable.wiltDefault(exports.Traversable, exports.Compactable);
|
|
663
|
-
/**
|
|
664
|
-
* @category instance operations
|
|
665
|
-
* @since 2.6.5
|
|
666
|
-
*/
|
|
667
|
-
var wither = function (F) {
|
|
668
|
-
var _witherF = _wither(F);
|
|
669
|
-
return function (f) { return function (fa) { return _witherF(fa, f); }; };
|
|
670
|
-
};
|
|
671
|
-
exports.wither = wither;
|
|
672
|
-
/**
|
|
673
|
-
* @category instance operations
|
|
674
|
-
* @since 2.6.5
|
|
675
|
-
*/
|
|
676
|
-
var wilt = function (F) {
|
|
677
|
-
var _wiltF = _wilt(F);
|
|
678
|
-
return function (f) { return function (fa) { return _wiltF(fa, f); }; };
|
|
679
|
-
};
|
|
680
|
-
exports.wilt = wilt;
|
|
681
|
-
/**
|
|
682
|
-
* @category instances
|
|
683
|
-
* @since 2.7.0
|
|
684
|
-
*/
|
|
685
|
-
exports.Witherable = {
|
|
686
|
-
URI: exports.URI,
|
|
687
|
-
map: _map,
|
|
688
|
-
reduce: _reduce,
|
|
689
|
-
foldMap: _foldMap,
|
|
690
|
-
reduceRight: _reduceRight,
|
|
691
|
-
traverse: _traverse,
|
|
692
|
-
sequence: exports.sequence,
|
|
693
|
-
compact: exports.compact,
|
|
694
|
-
separate: exports.separate,
|
|
695
|
-
filter: _filter,
|
|
696
|
-
filterMap: _filterMap,
|
|
697
|
-
partition: _partition,
|
|
698
|
-
partitionMap: _partitionMap,
|
|
699
|
-
wither: _wither,
|
|
700
|
-
wilt: _wilt
|
|
701
|
-
};
|
|
702
|
-
/**
|
|
703
|
-
* @category instance operations
|
|
704
|
-
* @since 2.7.0
|
|
705
|
-
*/
|
|
706
|
-
var throwError = function () { return exports.none; };
|
|
707
|
-
exports.throwError = throwError;
|
|
708
|
-
/**
|
|
709
|
-
* @category instances
|
|
710
|
-
* @since 2.7.0
|
|
711
|
-
*/
|
|
712
|
-
exports.MonadThrow = {
|
|
713
|
-
URI: exports.URI,
|
|
714
|
-
map: _map,
|
|
715
|
-
ap: _ap,
|
|
716
|
-
of: exports.of,
|
|
717
|
-
chain: _chain,
|
|
718
|
-
throwError: exports.throwError
|
|
719
|
-
};
|
|
720
|
-
/**
|
|
721
|
-
* Transforms an `Either` to an `Option` discarding the error.
|
|
722
|
-
*
|
|
723
|
-
* Alias of [getRight](#getright)
|
|
724
|
-
*
|
|
725
|
-
* @category natural transformations
|
|
726
|
-
* @since 2.0.0
|
|
727
|
-
*/
|
|
728
|
-
exports.fromEither = exports.getRight;
|
|
729
|
-
/**
|
|
730
|
-
* @category instances
|
|
731
|
-
* @since 2.11.0
|
|
732
|
-
*/
|
|
733
|
-
exports.FromEither = {
|
|
734
|
-
URI: exports.URI,
|
|
735
|
-
fromEither: exports.fromEither
|
|
736
|
-
};
|
|
737
|
-
// -------------------------------------------------------------------------------------
|
|
738
|
-
// refinements
|
|
739
|
-
// -------------------------------------------------------------------------------------
|
|
740
|
-
/**
|
|
741
|
-
* Returns `true` if the option is an instance of `Some`, `false` otherwise.
|
|
742
|
-
*
|
|
743
|
-
* @example
|
|
744
|
-
* import { some, none, isSome } from 'fp-ts/Option'
|
|
745
|
-
*
|
|
746
|
-
* assert.strictEqual(isSome(some(1)), true)
|
|
747
|
-
* assert.strictEqual(isSome(none), false)
|
|
748
|
-
*
|
|
749
|
-
* @category refinements
|
|
750
|
-
* @since 2.0.0
|
|
751
|
-
*/
|
|
752
|
-
exports.isSome = _.isSome;
|
|
753
|
-
/**
|
|
754
|
-
* Returns `true` if the option is `None`, `false` otherwise.
|
|
755
|
-
*
|
|
756
|
-
* @example
|
|
757
|
-
* import { some, none, isNone } from 'fp-ts/Option'
|
|
758
|
-
*
|
|
759
|
-
* assert.strictEqual(isNone(some(1)), false)
|
|
760
|
-
* assert.strictEqual(isNone(none), true)
|
|
761
|
-
*
|
|
762
|
-
* @category refinements
|
|
763
|
-
* @since 2.0.0
|
|
764
|
-
*/
|
|
765
|
-
var isNone = function (fa) { return fa._tag === 'None'; };
|
|
766
|
-
exports.isNone = isNone;
|
|
767
|
-
// -------------------------------------------------------------------------------------
|
|
768
|
-
// destructors
|
|
769
|
-
// -------------------------------------------------------------------------------------
|
|
770
|
-
/**
|
|
771
|
-
* Less strict version of [`match`](#match).
|
|
772
|
-
*
|
|
773
|
-
* @category destructors
|
|
774
|
-
* @since 2.10.0
|
|
775
|
-
*/
|
|
776
|
-
var matchW = function (onNone, onSome) { return function (ma) {
|
|
777
|
-
return exports.isNone(ma) ? onNone() : onSome(ma.value);
|
|
778
|
-
}; };
|
|
779
|
-
exports.matchW = matchW;
|
|
780
|
-
/**
|
|
781
|
-
* Alias of [`matchW`](#matchw).
|
|
782
|
-
*
|
|
783
|
-
* @category destructors
|
|
784
|
-
* @since 2.10.0
|
|
785
|
-
*/
|
|
786
|
-
exports.foldW = exports.matchW;
|
|
787
|
-
/**
|
|
788
|
-
* Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is
|
|
789
|
-
* returned, otherwise the function is applied to the value inside the `Some` and the result is returned.
|
|
790
|
-
*
|
|
791
|
-
* @example
|
|
792
|
-
* import { some, none, match } from 'fp-ts/Option'
|
|
793
|
-
* import { pipe } from 'fp-ts/function'
|
|
794
|
-
*
|
|
795
|
-
* assert.strictEqual(
|
|
796
|
-
* pipe(
|
|
797
|
-
* some(1),
|
|
798
|
-
* match(() => 'a none', a => `a some containing ${a}`)
|
|
799
|
-
* ),
|
|
800
|
-
* 'a some containing 1'
|
|
801
|
-
* )
|
|
802
|
-
*
|
|
803
|
-
* assert.strictEqual(
|
|
804
|
-
* pipe(
|
|
805
|
-
* none,
|
|
806
|
-
* match(() => 'a none', a => `a some containing ${a}`)
|
|
807
|
-
* ),
|
|
808
|
-
* 'a none'
|
|
809
|
-
* )
|
|
810
|
-
*
|
|
811
|
-
* @category destructors
|
|
812
|
-
* @since 2.10.0
|
|
813
|
-
*/
|
|
814
|
-
exports.match = exports.matchW;
|
|
815
|
-
/**
|
|
816
|
-
* Alias of [`match`](#match).
|
|
817
|
-
*
|
|
818
|
-
* @category destructors
|
|
819
|
-
* @since 2.0.0
|
|
820
|
-
*/
|
|
821
|
-
exports.fold = exports.match;
|
|
822
|
-
/**
|
|
823
|
-
* Less strict version of [`getOrElse`](#getorelse).
|
|
824
|
-
*
|
|
825
|
-
* @category destructors
|
|
826
|
-
* @since 2.6.0
|
|
827
|
-
*/
|
|
828
|
-
var getOrElseW = function (onNone) { return function (ma) { return (exports.isNone(ma) ? onNone() : ma.value); }; };
|
|
829
|
-
exports.getOrElseW = getOrElseW;
|
|
830
|
-
/**
|
|
831
|
-
* Extracts the value out of the structure, if it exists. Otherwise returns the given default value
|
|
832
|
-
*
|
|
833
|
-
* @example
|
|
834
|
-
* import { some, none, getOrElse } from 'fp-ts/Option'
|
|
835
|
-
* import { pipe } from 'fp-ts/function'
|
|
836
|
-
*
|
|
837
|
-
* assert.strictEqual(
|
|
838
|
-
* pipe(
|
|
839
|
-
* some(1),
|
|
840
|
-
* getOrElse(() => 0)
|
|
841
|
-
* ),
|
|
842
|
-
* 1
|
|
843
|
-
* )
|
|
844
|
-
* assert.strictEqual(
|
|
845
|
-
* pipe(
|
|
846
|
-
* none,
|
|
847
|
-
* getOrElse(() => 0)
|
|
848
|
-
* ),
|
|
849
|
-
* 0
|
|
850
|
-
* )
|
|
851
|
-
*
|
|
852
|
-
* @category destructors
|
|
853
|
-
* @since 2.0.0
|
|
854
|
-
*/
|
|
855
|
-
exports.getOrElse = exports.getOrElseW;
|
|
856
|
-
// -------------------------------------------------------------------------------------
|
|
857
|
-
// combinators
|
|
858
|
-
// -------------------------------------------------------------------------------------
|
|
859
|
-
/**
|
|
860
|
-
* Derivable from `Functor`.
|
|
861
|
-
*
|
|
862
|
-
* @category combinators
|
|
863
|
-
* @since 2.10.0
|
|
864
|
-
*/
|
|
865
|
-
exports.flap =
|
|
866
|
-
/*#__PURE__*/
|
|
867
|
-
Functor.flap(exports.Functor);
|
|
868
|
-
/**
|
|
869
|
-
* Combine two effectful actions, keeping only the result of the first.
|
|
870
|
-
*
|
|
871
|
-
* Derivable from `Apply`.
|
|
872
|
-
*
|
|
873
|
-
* @category combinators
|
|
874
|
-
* @since 2.0.0
|
|
875
|
-
*/
|
|
876
|
-
exports.apFirst =
|
|
877
|
-
/*#__PURE__*/
|
|
878
|
-
Apply.apFirst(exports.Apply);
|
|
879
|
-
/**
|
|
880
|
-
* Combine two effectful actions, keeping only the result of the second.
|
|
881
|
-
*
|
|
882
|
-
* Derivable from `Apply`.
|
|
883
|
-
*
|
|
884
|
-
* @category combinators
|
|
885
|
-
* @since 2.0.0
|
|
886
|
-
*/
|
|
887
|
-
exports.apSecond =
|
|
888
|
-
/*#__PURE__*/
|
|
889
|
-
Apply.apSecond(exports.Apply);
|
|
890
|
-
/**
|
|
891
|
-
* Derivable from `Chain`.
|
|
892
|
-
*
|
|
893
|
-
* @category combinators
|
|
894
|
-
* @since 2.0.0
|
|
895
|
-
*/
|
|
896
|
-
exports.flatten = exports.compact;
|
|
897
|
-
/**
|
|
898
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation and
|
|
899
|
-
* keeping only the result of the first.
|
|
900
|
-
*
|
|
901
|
-
* Derivable from `Chain`.
|
|
902
|
-
*
|
|
903
|
-
* @category combinators
|
|
904
|
-
* @since 2.0.0
|
|
905
|
-
*/
|
|
906
|
-
exports.chainFirst =
|
|
907
|
-
/*#__PURE__*/
|
|
908
|
-
Chain.chainFirst(exports.Chain);
|
|
909
|
-
/**
|
|
910
|
-
* Derivable from `Extend`.
|
|
911
|
-
*
|
|
912
|
-
* @category combinators
|
|
913
|
-
* @since 2.0.0
|
|
914
|
-
*/
|
|
915
|
-
exports.duplicate =
|
|
916
|
-
/*#__PURE__*/
|
|
917
|
-
exports.extend(_function.identity);
|
|
918
|
-
/**
|
|
919
|
-
* @category combinators
|
|
920
|
-
* @since 2.11.0
|
|
921
|
-
*/
|
|
922
|
-
exports.fromEitherK =
|
|
923
|
-
/*#__PURE__*/
|
|
924
|
-
FromEither.fromEitherK(exports.FromEither);
|
|
925
|
-
/**
|
|
926
|
-
* @category combinators
|
|
927
|
-
* @since 2.11.0
|
|
928
|
-
*/
|
|
929
|
-
exports.chainEitherK =
|
|
930
|
-
/*#__PURE__*/
|
|
931
|
-
FromEither.chainEitherK(exports.FromEither, exports.Chain);
|
|
932
|
-
// -------------------------------------------------------------------------------------
|
|
933
|
-
// interop
|
|
934
|
-
// -------------------------------------------------------------------------------------
|
|
935
|
-
/**
|
|
936
|
-
* Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
|
|
937
|
-
* returns the value wrapped in a `Some`.
|
|
938
|
-
*
|
|
939
|
-
* @example
|
|
940
|
-
* import { none, some, fromNullable } from 'fp-ts/Option'
|
|
941
|
-
*
|
|
942
|
-
* assert.deepStrictEqual(fromNullable(undefined), none)
|
|
943
|
-
* assert.deepStrictEqual(fromNullable(null), none)
|
|
944
|
-
* assert.deepStrictEqual(fromNullable(1), some(1))
|
|
945
|
-
*
|
|
946
|
-
* @category interop
|
|
947
|
-
* @since 2.0.0
|
|
948
|
-
*/
|
|
949
|
-
var fromNullable = function (a) { return (a == null ? exports.none : exports.some(a)); };
|
|
950
|
-
exports.fromNullable = fromNullable;
|
|
951
|
-
/**
|
|
952
|
-
* Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a
|
|
953
|
-
* `Some`.
|
|
954
|
-
*
|
|
955
|
-
* See also [`tryCatchK`](#trycatchk).
|
|
956
|
-
*
|
|
957
|
-
* @example
|
|
958
|
-
* import { none, some, tryCatch } from 'fp-ts/Option'
|
|
959
|
-
*
|
|
960
|
-
* assert.deepStrictEqual(
|
|
961
|
-
* tryCatch(() => {
|
|
962
|
-
* throw new Error()
|
|
963
|
-
* }),
|
|
964
|
-
* none
|
|
965
|
-
* )
|
|
966
|
-
* assert.deepStrictEqual(tryCatch(() => 1), some(1))
|
|
967
|
-
*
|
|
968
|
-
* @category interop
|
|
969
|
-
* @since 2.0.0
|
|
970
|
-
*/
|
|
971
|
-
var tryCatch = function (f) {
|
|
972
|
-
try {
|
|
973
|
-
return exports.some(f());
|
|
974
|
-
}
|
|
975
|
-
catch (e) {
|
|
976
|
-
return exports.none;
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
exports.tryCatch = tryCatch;
|
|
980
|
-
/**
|
|
981
|
-
* Converts a function that may throw to one returning a `Option`.
|
|
982
|
-
*
|
|
983
|
-
* @category interop
|
|
984
|
-
* @since 2.10.0
|
|
985
|
-
*/
|
|
986
|
-
var tryCatchK = function (f) { return function () {
|
|
987
|
-
var a = [];
|
|
988
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
989
|
-
a[_i] = arguments[_i];
|
|
990
|
-
}
|
|
991
|
-
return exports.tryCatch(function () { return f.apply(void 0, a); });
|
|
992
|
-
}; };
|
|
993
|
-
exports.tryCatchK = tryCatchK;
|
|
994
|
-
/**
|
|
995
|
-
* Returns a *smart constructor* from a function that returns a nullable value.
|
|
996
|
-
*
|
|
997
|
-
* @example
|
|
998
|
-
* import { fromNullableK, none, some } from 'fp-ts/Option'
|
|
999
|
-
*
|
|
1000
|
-
* const f = (s: string): number | undefined => {
|
|
1001
|
-
* const n = parseFloat(s)
|
|
1002
|
-
* return isNaN(n) ? undefined : n
|
|
1003
|
-
* }
|
|
1004
|
-
*
|
|
1005
|
-
* const g = fromNullableK(f)
|
|
1006
|
-
*
|
|
1007
|
-
* assert.deepStrictEqual(g('1'), some(1))
|
|
1008
|
-
* assert.deepStrictEqual(g('a'), none)
|
|
1009
|
-
*
|
|
1010
|
-
* @category interop
|
|
1011
|
-
* @since 2.9.0
|
|
1012
|
-
*/
|
|
1013
|
-
var fromNullableK = function (f) { return _function.flow(f, exports.fromNullable); };
|
|
1014
|
-
exports.fromNullableK = fromNullableK;
|
|
1015
|
-
/**
|
|
1016
|
-
* This is `chain` + `fromNullable`, useful when working with optional values.
|
|
1017
|
-
*
|
|
1018
|
-
* @example
|
|
1019
|
-
* import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'
|
|
1020
|
-
* import { pipe } from 'fp-ts/function'
|
|
1021
|
-
*
|
|
1022
|
-
* interface Employee {
|
|
1023
|
-
* readonly company?: {
|
|
1024
|
-
* readonly address?: {
|
|
1025
|
-
* readonly street?: {
|
|
1026
|
-
* readonly name?: string
|
|
1027
|
-
* }
|
|
1028
|
-
* }
|
|
1029
|
-
* }
|
|
1030
|
-
* }
|
|
1031
|
-
*
|
|
1032
|
-
* const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
|
|
1033
|
-
*
|
|
1034
|
-
* assert.deepStrictEqual(
|
|
1035
|
-
* pipe(
|
|
1036
|
-
* fromNullable(employee1.company),
|
|
1037
|
-
* chainNullableK(company => company.address),
|
|
1038
|
-
* chainNullableK(address => address.street),
|
|
1039
|
-
* chainNullableK(street => street.name)
|
|
1040
|
-
* ),
|
|
1041
|
-
* some('high street')
|
|
1042
|
-
* )
|
|
1043
|
-
*
|
|
1044
|
-
* const employee2: Employee = { company: { address: { street: {} } } }
|
|
1045
|
-
*
|
|
1046
|
-
* assert.deepStrictEqual(
|
|
1047
|
-
* pipe(
|
|
1048
|
-
* fromNullable(employee2.company),
|
|
1049
|
-
* chainNullableK(company => company.address),
|
|
1050
|
-
* chainNullableK(address => address.street),
|
|
1051
|
-
* chainNullableK(street => street.name)
|
|
1052
|
-
* ),
|
|
1053
|
-
* none
|
|
1054
|
-
* )
|
|
1055
|
-
*
|
|
1056
|
-
* @category interop
|
|
1057
|
-
* @since 2.9.0
|
|
1058
|
-
*/
|
|
1059
|
-
var chainNullableK = function (f) { return function (ma) {
|
|
1060
|
-
return exports.isNone(ma) ? exports.none : exports.fromNullable(f(ma.value));
|
|
1061
|
-
}; };
|
|
1062
|
-
exports.chainNullableK = chainNullableK;
|
|
1063
|
-
/**
|
|
1064
|
-
* Extracts the value out of the structure, if it exists. Otherwise returns `null`.
|
|
1065
|
-
*
|
|
1066
|
-
* @example
|
|
1067
|
-
* import { some, none, toNullable } from 'fp-ts/Option'
|
|
1068
|
-
* import { pipe } from 'fp-ts/function'
|
|
1069
|
-
*
|
|
1070
|
-
* assert.strictEqual(
|
|
1071
|
-
* pipe(
|
|
1072
|
-
* some(1),
|
|
1073
|
-
* toNullable
|
|
1074
|
-
* ),
|
|
1075
|
-
* 1
|
|
1076
|
-
* )
|
|
1077
|
-
* assert.strictEqual(
|
|
1078
|
-
* pipe(
|
|
1079
|
-
* none,
|
|
1080
|
-
* toNullable
|
|
1081
|
-
* ),
|
|
1082
|
-
* null
|
|
1083
|
-
* )
|
|
1084
|
-
*
|
|
1085
|
-
* @category interop
|
|
1086
|
-
* @since 2.0.0
|
|
1087
|
-
*/
|
|
1088
|
-
exports.toNullable =
|
|
1089
|
-
/*#__PURE__*/
|
|
1090
|
-
exports.match(_function.constNull, _function.identity);
|
|
1091
|
-
/**
|
|
1092
|
-
* Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
|
|
1093
|
-
*
|
|
1094
|
-
* @example
|
|
1095
|
-
* import { some, none, toUndefined } from 'fp-ts/Option'
|
|
1096
|
-
* import { pipe } from 'fp-ts/function'
|
|
1097
|
-
*
|
|
1098
|
-
* assert.strictEqual(
|
|
1099
|
-
* pipe(
|
|
1100
|
-
* some(1),
|
|
1101
|
-
* toUndefined
|
|
1102
|
-
* ),
|
|
1103
|
-
* 1
|
|
1104
|
-
* )
|
|
1105
|
-
* assert.strictEqual(
|
|
1106
|
-
* pipe(
|
|
1107
|
-
* none,
|
|
1108
|
-
* toUndefined
|
|
1109
|
-
* ),
|
|
1110
|
-
* undefined
|
|
1111
|
-
* )
|
|
1112
|
-
*
|
|
1113
|
-
* @category interop
|
|
1114
|
-
* @since 2.0.0
|
|
1115
|
-
*/
|
|
1116
|
-
exports.toUndefined =
|
|
1117
|
-
/*#__PURE__*/
|
|
1118
|
-
exports.match(_function.constUndefined, _function.identity);
|
|
1119
|
-
function elem(E) {
|
|
1120
|
-
return function (a, ma) {
|
|
1121
|
-
if (ma === undefined) {
|
|
1122
|
-
var elemE_1 = elem(E);
|
|
1123
|
-
return function (ma) { return elemE_1(a, ma); };
|
|
1124
|
-
}
|
|
1125
|
-
return exports.isNone(ma) ? false : E.equals(a, ma.value);
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
exports.elem = elem;
|
|
1129
|
-
/**
|
|
1130
|
-
* Returns `true` if the predicate is satisfied by the wrapped value
|
|
1131
|
-
*
|
|
1132
|
-
* @example
|
|
1133
|
-
* import { some, none, exists } from 'fp-ts/Option'
|
|
1134
|
-
* import { pipe } from 'fp-ts/function'
|
|
1135
|
-
*
|
|
1136
|
-
* assert.strictEqual(
|
|
1137
|
-
* pipe(
|
|
1138
|
-
* some(1),
|
|
1139
|
-
* exists(n => n > 0)
|
|
1140
|
-
* ),
|
|
1141
|
-
* true
|
|
1142
|
-
* )
|
|
1143
|
-
* assert.strictEqual(
|
|
1144
|
-
* pipe(
|
|
1145
|
-
* some(1),
|
|
1146
|
-
* exists(n => n > 1)
|
|
1147
|
-
* ),
|
|
1148
|
-
* false
|
|
1149
|
-
* )
|
|
1150
|
-
* assert.strictEqual(
|
|
1151
|
-
* pipe(
|
|
1152
|
-
* none,
|
|
1153
|
-
* exists(n => n > 0)
|
|
1154
|
-
* ),
|
|
1155
|
-
* false
|
|
1156
|
-
* )
|
|
1157
|
-
*
|
|
1158
|
-
* @since 2.0.0
|
|
1159
|
-
*/
|
|
1160
|
-
var exists = function (predicate) { return function (ma) {
|
|
1161
|
-
return exports.isNone(ma) ? false : predicate(ma.value);
|
|
1162
|
-
}; };
|
|
1163
|
-
exports.exists = exists;
|
|
1164
|
-
// -------------------------------------------------------------------------------------
|
|
1165
|
-
// do notation
|
|
1166
|
-
// -------------------------------------------------------------------------------------
|
|
1167
|
-
/**
|
|
1168
|
-
* @since 2.9.0
|
|
1169
|
-
*/
|
|
1170
|
-
exports.Do =
|
|
1171
|
-
/*#__PURE__*/
|
|
1172
|
-
exports.of(_.emptyRecord);
|
|
1173
|
-
/**
|
|
1174
|
-
* @since 2.8.0
|
|
1175
|
-
*/
|
|
1176
|
-
exports.bindTo =
|
|
1177
|
-
/*#__PURE__*/
|
|
1178
|
-
Functor.bindTo(exports.Functor);
|
|
1179
|
-
/**
|
|
1180
|
-
* @since 2.8.0
|
|
1181
|
-
*/
|
|
1182
|
-
exports.bind =
|
|
1183
|
-
/*#__PURE__*/
|
|
1184
|
-
Chain.bind(exports.Chain);
|
|
1185
|
-
// -------------------------------------------------------------------------------------
|
|
1186
|
-
// pipeable sequence S
|
|
1187
|
-
// -------------------------------------------------------------------------------------
|
|
1188
|
-
/**
|
|
1189
|
-
* @since 2.8.0
|
|
1190
|
-
*/
|
|
1191
|
-
exports.apS =
|
|
1192
|
-
/*#__PURE__*/
|
|
1193
|
-
Apply.apS(exports.Apply);
|
|
1194
|
-
// -------------------------------------------------------------------------------------
|
|
1195
|
-
// sequence T
|
|
1196
|
-
// -------------------------------------------------------------------------------------
|
|
1197
|
-
/**
|
|
1198
|
-
* @since 2.11.0
|
|
1199
|
-
*/
|
|
1200
|
-
exports.ApT =
|
|
1201
|
-
/*#__PURE__*/
|
|
1202
|
-
exports.of(_.emptyReadonlyArray);
|
|
1203
|
-
// -------------------------------------------------------------------------------------
|
|
1204
|
-
// array utils
|
|
1205
|
-
// -------------------------------------------------------------------------------------
|
|
1206
|
-
/**
|
|
1207
|
-
* Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.
|
|
1208
|
-
*
|
|
1209
|
-
* @since 2.11.0
|
|
1210
|
-
*/
|
|
1211
|
-
var traverseReadonlyNonEmptyArrayWithIndex = function (f) { return function (as) {
|
|
1212
|
-
var o = f(0, _.head(as));
|
|
1213
|
-
if (exports.isNone(o)) {
|
|
1214
|
-
return exports.none;
|
|
1215
|
-
}
|
|
1216
|
-
var out = [o.value];
|
|
1217
|
-
for (var i = 1; i < as.length; i++) {
|
|
1218
|
-
var o_1 = f(i, as[i]);
|
|
1219
|
-
if (exports.isNone(o_1)) {
|
|
1220
|
-
return exports.none;
|
|
1221
|
-
}
|
|
1222
|
-
out.push(o_1.value);
|
|
1223
|
-
}
|
|
1224
|
-
return exports.some(out);
|
|
1225
|
-
}; };
|
|
1226
|
-
exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex;
|
|
1227
|
-
/**
|
|
1228
|
-
* Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
|
|
1229
|
-
*
|
|
1230
|
-
* @since 2.11.0
|
|
1231
|
-
*/
|
|
1232
|
-
var traverseReadonlyArrayWithIndex = function (f) {
|
|
1233
|
-
var g = exports.traverseReadonlyNonEmptyArrayWithIndex(f);
|
|
1234
|
-
return function (as) { return (_.isNonEmpty(as) ? g(as) : exports.ApT); };
|
|
1235
|
-
};
|
|
1236
|
-
exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex;
|
|
1237
|
-
/**
|
|
1238
|
-
* @since 2.9.0
|
|
1239
|
-
*/
|
|
1240
|
-
exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex;
|
|
1241
|
-
/**
|
|
1242
|
-
* @since 2.9.0
|
|
1243
|
-
*/
|
|
1244
|
-
var traverseArray = function (f) {
|
|
1245
|
-
return exports.traverseReadonlyArrayWithIndex(function (_, a) { return f(a); });
|
|
1246
|
-
};
|
|
1247
|
-
exports.traverseArray = traverseArray;
|
|
1248
|
-
/**
|
|
1249
|
-
* @since 2.9.0
|
|
1250
|
-
*/
|
|
1251
|
-
exports.sequenceArray =
|
|
1252
|
-
/*#__PURE__*/
|
|
1253
|
-
exports.traverseArray(_function.identity);
|
|
1254
|
-
// -------------------------------------------------------------------------------------
|
|
1255
|
-
// deprecated
|
|
1256
|
-
// -------------------------------------------------------------------------------------
|
|
1257
|
-
// tslint:disable: deprecation
|
|
1258
|
-
/**
|
|
1259
|
-
* Use `Refinement` module instead.
|
|
1260
|
-
*
|
|
1261
|
-
* @since 2.0.0
|
|
1262
|
-
* @deprecated
|
|
1263
|
-
*/
|
|
1264
|
-
function getRefinement(getOption) {
|
|
1265
|
-
return function (a) { return exports.isSome(getOption(a)); };
|
|
1266
|
-
}
|
|
1267
|
-
exports.getRefinement = getRefinement;
|
|
1268
|
-
/**
|
|
1269
|
-
* Use [`chainNullableK`](#chainnullablek) instead.
|
|
1270
|
-
*
|
|
1271
|
-
* @category combinators
|
|
1272
|
-
* @since 2.0.0
|
|
1273
|
-
* @deprecated
|
|
1274
|
-
*/
|
|
1275
|
-
exports.mapNullable = exports.chainNullableK;
|
|
1276
|
-
/**
|
|
1277
|
-
* Use small, specific instances instead.
|
|
1278
|
-
*
|
|
1279
|
-
* @category instances
|
|
1280
|
-
* @since 2.0.0
|
|
1281
|
-
* @deprecated
|
|
1282
|
-
*/
|
|
1283
|
-
exports.option = {
|
|
1284
|
-
URI: exports.URI,
|
|
1285
|
-
map: _map,
|
|
1286
|
-
of: exports.of,
|
|
1287
|
-
ap: _ap,
|
|
1288
|
-
chain: _chain,
|
|
1289
|
-
reduce: _reduce,
|
|
1290
|
-
foldMap: _foldMap,
|
|
1291
|
-
reduceRight: _reduceRight,
|
|
1292
|
-
traverse: _traverse,
|
|
1293
|
-
sequence: exports.sequence,
|
|
1294
|
-
zero: exports.zero,
|
|
1295
|
-
alt: _alt,
|
|
1296
|
-
extend: _extend,
|
|
1297
|
-
compact: exports.compact,
|
|
1298
|
-
separate: exports.separate,
|
|
1299
|
-
filter: _filter,
|
|
1300
|
-
filterMap: _filterMap,
|
|
1301
|
-
partition: _partition,
|
|
1302
|
-
partitionMap: _partitionMap,
|
|
1303
|
-
wither: _wither,
|
|
1304
|
-
wilt: _wilt,
|
|
1305
|
-
throwError: exports.throwError
|
|
1306
|
-
};
|
|
1307
|
-
/**
|
|
1308
|
-
* Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
|
|
1309
|
-
*
|
|
1310
|
-
* @category instances
|
|
1311
|
-
* @since 2.0.0
|
|
1312
|
-
* @deprecated
|
|
1313
|
-
*/
|
|
1314
|
-
exports.getApplySemigroup =
|
|
1315
|
-
/*#__PURE__*/
|
|
1316
|
-
Apply.getApplySemigroup(exports.Apply);
|
|
1317
|
-
/**
|
|
1318
|
-
* Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.
|
|
1319
|
-
*
|
|
1320
|
-
* @category instances
|
|
1321
|
-
* @since 2.0.0
|
|
1322
|
-
* @deprecated
|
|
1323
|
-
*/
|
|
1324
|
-
exports.getApplyMonoid =
|
|
1325
|
-
/*#__PURE__*/
|
|
1326
|
-
Applicative.getApplicativeMonoid(exports.Applicative);
|
|
1327
|
-
/**
|
|
1328
|
-
* Use
|
|
1329
|
-
*
|
|
1330
|
-
* ```ts
|
|
1331
|
-
* import { first } from 'fp-ts/Semigroup'
|
|
1332
|
-
* import { getMonoid } from 'fp-ts/Option'
|
|
1333
|
-
*
|
|
1334
|
-
* getMonoid(first())
|
|
1335
|
-
* ```
|
|
1336
|
-
*
|
|
1337
|
-
* instead.
|
|
1338
|
-
*
|
|
1339
|
-
* Monoid returning the left-most non-`None` value
|
|
1340
|
-
*
|
|
1341
|
-
* | x | y | concat(x, y) |
|
|
1342
|
-
* | ------- | ------- | ------------ |
|
|
1343
|
-
* | none | none | none |
|
|
1344
|
-
* | some(a) | none | some(a) |
|
|
1345
|
-
* | none | some(b) | some(b) |
|
|
1346
|
-
* | some(a) | some(b) | some(a) |
|
|
1347
|
-
*
|
|
1348
|
-
* @example
|
|
1349
|
-
* import { getFirstMonoid, some, none } from 'fp-ts/Option'
|
|
1350
|
-
*
|
|
1351
|
-
* const M = getFirstMonoid<number>()
|
|
1352
|
-
* assert.deepStrictEqual(M.concat(none, none), none)
|
|
1353
|
-
* assert.deepStrictEqual(M.concat(some(1), none), some(1))
|
|
1354
|
-
* assert.deepStrictEqual(M.concat(none, some(2)), some(2))
|
|
1355
|
-
* assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))
|
|
1356
|
-
*
|
|
1357
|
-
* @category instances
|
|
1358
|
-
* @since 2.0.0
|
|
1359
|
-
* @deprecated
|
|
1360
|
-
*/
|
|
1361
|
-
var getFirstMonoid = function () { return exports.getMonoid(Semigroup.first()); };
|
|
1362
|
-
exports.getFirstMonoid = getFirstMonoid;
|
|
1363
|
-
/**
|
|
1364
|
-
* Use
|
|
1365
|
-
*
|
|
1366
|
-
* ```ts
|
|
1367
|
-
* import { last } from 'fp-ts/Semigroup'
|
|
1368
|
-
* import { getMonoid } from 'fp-ts/Option'
|
|
1369
|
-
*
|
|
1370
|
-
* getMonoid(last())
|
|
1371
|
-
* ```
|
|
1372
|
-
*
|
|
1373
|
-
* instead.
|
|
1374
|
-
*
|
|
1375
|
-
* Monoid returning the right-most non-`None` value
|
|
1376
|
-
*
|
|
1377
|
-
* | x | y | concat(x, y) |
|
|
1378
|
-
* | ------- | ------- | ------------ |
|
|
1379
|
-
* | none | none | none |
|
|
1380
|
-
* | some(a) | none | some(a) |
|
|
1381
|
-
* | none | some(b) | some(b) |
|
|
1382
|
-
* | some(a) | some(b) | some(b) |
|
|
1383
|
-
*
|
|
1384
|
-
* @example
|
|
1385
|
-
* import { getLastMonoid, some, none } from 'fp-ts/Option'
|
|
1386
|
-
*
|
|
1387
|
-
* const M = getLastMonoid<number>()
|
|
1388
|
-
* assert.deepStrictEqual(M.concat(none, none), none)
|
|
1389
|
-
* assert.deepStrictEqual(M.concat(some(1), none), some(1))
|
|
1390
|
-
* assert.deepStrictEqual(M.concat(none, some(2)), some(2))
|
|
1391
|
-
* assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))
|
|
1392
|
-
*
|
|
1393
|
-
* @category instances
|
|
1394
|
-
* @since 2.0.0
|
|
1395
|
-
* @deprecated
|
|
1396
|
-
*/
|
|
1397
|
-
var getLastMonoid = function () { return exports.getMonoid(Semigroup.last()); };
|
|
1398
|
-
exports.getLastMonoid = getLastMonoid;
|
|
1399
|
-
});
|
|
1400
|
-
|
|
1401
|
-
const Option$1 = /*@__PURE__*/getDefaultExportFromCjs(Option);
|
|
1402
|
-
|
|
1403
|
-
const sequenceToOption = Apply.sequenceT(Option.Apply);
|
|
1404
|
-
const checkEmpryString = (x) => x.length > 0 ? Option.some(x) : Option.none;
|
|
1405
|
-
|
|
1406
|
-
// -------------------------------------------------------------------------------------
|
|
1407
|
-
// refinements
|
|
1408
|
-
// -------------------------------------------------------------------------------------
|
|
1409
|
-
/**
|
|
1410
|
-
* @category refinements
|
|
1411
|
-
* @since 2.11.0
|
|
1412
|
-
*/
|
|
1413
|
-
var isNumber = function (u) { return typeof u === 'number'; };
|
|
1414
|
-
// -------------------------------------------------------------------------------------
|
|
1415
|
-
// instances
|
|
1416
|
-
// -------------------------------------------------------------------------------------
|
|
1417
|
-
/**
|
|
1418
|
-
* @category instances
|
|
1419
|
-
* @since 2.10.0
|
|
1420
|
-
*/
|
|
1421
|
-
var Eq = {
|
|
1422
|
-
equals: function (first, second) { return first === second; }
|
|
1423
|
-
};
|
|
1424
|
-
/**
|
|
1425
|
-
* @category instances
|
|
1426
|
-
* @since 2.10.0
|
|
1427
|
-
*/
|
|
1428
|
-
var Ord = {
|
|
1429
|
-
equals: Eq.equals,
|
|
1430
|
-
compare: function (first, second) { return (first < second ? -1 : first > second ? 1 : 0); }
|
|
1431
|
-
};
|
|
1432
|
-
/**
|
|
1433
|
-
* @category instances
|
|
1434
|
-
* @since 2.10.0
|
|
1435
|
-
*/
|
|
1436
|
-
var Bounded = {
|
|
1437
|
-
equals: Eq.equals,
|
|
1438
|
-
compare: Ord.compare,
|
|
1439
|
-
top: Infinity,
|
|
1440
|
-
bottom: -Infinity
|
|
1441
|
-
};
|
|
1442
|
-
/**
|
|
1443
|
-
* @category instances
|
|
1444
|
-
* @since 2.10.0
|
|
1445
|
-
*/
|
|
1446
|
-
var Show = {
|
|
1447
|
-
show: function (n) { return JSON.stringify(n); }
|
|
1448
|
-
};
|
|
1449
|
-
/**
|
|
1450
|
-
* @category instances
|
|
1451
|
-
* @since 2.11.0
|
|
1452
|
-
*/
|
|
1453
|
-
var MagmaSub = {
|
|
1454
|
-
concat: function (first, second) { return first - second; }
|
|
1455
|
-
};
|
|
1456
|
-
/**
|
|
1457
|
-
* `number` semigroup under addition.
|
|
1458
|
-
*
|
|
1459
|
-
* @example
|
|
1460
|
-
* import { SemigroupSum } from 'fp-ts/number'
|
|
1461
|
-
*
|
|
1462
|
-
* assert.deepStrictEqual(SemigroupSum.concat(2, 3), 5)
|
|
1463
|
-
*
|
|
1464
|
-
* @category instances
|
|
1465
|
-
* @since 2.10.0
|
|
1466
|
-
*/
|
|
1467
|
-
var SemigroupSum = {
|
|
1468
|
-
concat: function (first, second) { return first + second; }
|
|
1469
|
-
};
|
|
1470
|
-
/**
|
|
1471
|
-
* `number` semigroup under multiplication.
|
|
1472
|
-
*
|
|
1473
|
-
* @example
|
|
1474
|
-
* import { SemigroupProduct } from 'fp-ts/number'
|
|
1475
|
-
*
|
|
1476
|
-
* assert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6)
|
|
1477
|
-
*
|
|
1478
|
-
* @category instances
|
|
1479
|
-
* @since 2.10.0
|
|
1480
|
-
*/
|
|
1481
|
-
var SemigroupProduct = {
|
|
1482
|
-
concat: function (first, second) { return first * second; }
|
|
1483
|
-
};
|
|
1484
|
-
/**
|
|
1485
|
-
* `number` monoid under addition.
|
|
1486
|
-
*
|
|
1487
|
-
* The `empty` value is `0`.
|
|
1488
|
-
*
|
|
1489
|
-
* @example
|
|
1490
|
-
* import { MonoidSum } from 'fp-ts/number'
|
|
1491
|
-
*
|
|
1492
|
-
* assert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2)
|
|
1493
|
-
*
|
|
1494
|
-
* @category instances
|
|
1495
|
-
* @since 2.10.0
|
|
1496
|
-
*/
|
|
1497
|
-
var MonoidSum = {
|
|
1498
|
-
concat: SemigroupSum.concat,
|
|
1499
|
-
empty: 0
|
|
1500
|
-
};
|
|
1501
|
-
/**
|
|
1502
|
-
* `number` monoid under multiplication.
|
|
1503
|
-
*
|
|
1504
|
-
* The `empty` value is `1`.
|
|
1505
|
-
*
|
|
1506
|
-
* @example
|
|
1507
|
-
* import { MonoidProduct } from 'fp-ts/number'
|
|
1508
|
-
*
|
|
1509
|
-
* assert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2)
|
|
1510
|
-
*
|
|
1511
|
-
* @category instances
|
|
1512
|
-
* @since 2.10.0
|
|
1513
|
-
*/
|
|
1514
|
-
var MonoidProduct = {
|
|
1515
|
-
concat: SemigroupProduct.concat,
|
|
1516
|
-
empty: 1
|
|
1517
|
-
};
|
|
1518
|
-
/**
|
|
1519
|
-
* @category instances
|
|
1520
|
-
* @since 2.10.0
|
|
1521
|
-
*/
|
|
1522
|
-
var Field = {
|
|
1523
|
-
add: SemigroupSum.concat,
|
|
1524
|
-
zero: 0,
|
|
1525
|
-
mul: SemigroupProduct.concat,
|
|
1526
|
-
one: 1,
|
|
1527
|
-
sub: MagmaSub.concat,
|
|
1528
|
-
degree: function (_) { return 1; },
|
|
1529
|
-
div: function (first, second) { return first / second; },
|
|
1530
|
-
mod: function (first, second) { return first % second; }
|
|
1531
|
-
};
|
|
1532
|
-
|
|
1533
|
-
export { Applicative as A, Option as O, Predicate as P, Ord as a, sequenceToOption as s };
|