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,4370 +0,0 @@
|
|
|
1
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
-
|
|
3
|
-
function getDefaultExportFromCjs (x) {
|
|
4
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function createCommonjsModule(fn, basedir, module) {
|
|
8
|
-
return module = {
|
|
9
|
-
path: basedir,
|
|
10
|
-
exports: {},
|
|
11
|
-
require: function (path, base) {
|
|
12
|
-
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
|
|
13
|
-
}
|
|
14
|
-
}, fn(module, module.exports), module.exports;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getDefaultExportFromNamespaceIfPresent (n) {
|
|
18
|
-
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getDefaultExportFromNamespaceIfNotNamed (n) {
|
|
22
|
-
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getAugmentedNamespace(n) {
|
|
26
|
-
if (n.__esModule) return n;
|
|
27
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
28
|
-
Object.keys(n).forEach(function (k) {
|
|
29
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
30
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return n[k];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
return a;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function commonjsRequire () {
|
|
41
|
-
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var _function = createCommonjsModule(function (module, exports) {
|
|
45
|
-
"use strict";
|
|
46
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.getEndomorphismMonoid = exports.not = exports.SK = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.unsafeCoerce = exports.identity = exports.apply = exports.getRing = exports.getSemiring = exports.getMonoid = exports.getSemigroup = exports.getBooleanAlgebra = void 0;
|
|
48
|
-
// -------------------------------------------------------------------------------------
|
|
49
|
-
// instances
|
|
50
|
-
// -------------------------------------------------------------------------------------
|
|
51
|
-
/**
|
|
52
|
-
* @category instances
|
|
53
|
-
* @since 2.10.0
|
|
54
|
-
*/
|
|
55
|
-
var getBooleanAlgebra = function (B) { return function () { return ({
|
|
56
|
-
meet: function (x, y) { return function (a) { return B.meet(x(a), y(a)); }; },
|
|
57
|
-
join: function (x, y) { return function (a) { return B.join(x(a), y(a)); }; },
|
|
58
|
-
zero: function () { return B.zero; },
|
|
59
|
-
one: function () { return B.one; },
|
|
60
|
-
implies: function (x, y) { return function (a) { return B.implies(x(a), y(a)); }; },
|
|
61
|
-
not: function (x) { return function (a) { return B.not(x(a)); }; }
|
|
62
|
-
}); }; };
|
|
63
|
-
exports.getBooleanAlgebra = getBooleanAlgebra;
|
|
64
|
-
/**
|
|
65
|
-
* Unary functions form a semigroup as long as you can provide a semigroup for the codomain.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* import { Predicate, getSemigroup } from 'fp-ts/function'
|
|
69
|
-
* import * as B from 'fp-ts/boolean'
|
|
70
|
-
*
|
|
71
|
-
* const f: Predicate<number> = (n) => n <= 2
|
|
72
|
-
* const g: Predicate<number> = (n) => n >= 0
|
|
73
|
-
*
|
|
74
|
-
* const S1 = getSemigroup(B.SemigroupAll)<number>()
|
|
75
|
-
*
|
|
76
|
-
* assert.deepStrictEqual(S1.concat(f, g)(1), true)
|
|
77
|
-
* assert.deepStrictEqual(S1.concat(f, g)(3), false)
|
|
78
|
-
*
|
|
79
|
-
* const S2 = getSemigroup(B.SemigroupAny)<number>()
|
|
80
|
-
*
|
|
81
|
-
* assert.deepStrictEqual(S2.concat(f, g)(1), true)
|
|
82
|
-
* assert.deepStrictEqual(S2.concat(f, g)(3), true)
|
|
83
|
-
*
|
|
84
|
-
* @category instances
|
|
85
|
-
* @since 2.10.0
|
|
86
|
-
*/
|
|
87
|
-
var getSemigroup = function (S) { return function () { return ({
|
|
88
|
-
concat: function (f, g) { return function (a) { return S.concat(f(a), g(a)); }; }
|
|
89
|
-
}); }; };
|
|
90
|
-
exports.getSemigroup = getSemigroup;
|
|
91
|
-
/**
|
|
92
|
-
* Unary functions form a monoid as long as you can provide a monoid for the codomain.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* import { Predicate } from 'fp-ts/Predicate'
|
|
96
|
-
* import { getMonoid } from 'fp-ts/function'
|
|
97
|
-
* import * as B from 'fp-ts/boolean'
|
|
98
|
-
*
|
|
99
|
-
* const f: Predicate<number> = (n) => n <= 2
|
|
100
|
-
* const g: Predicate<number> = (n) => n >= 0
|
|
101
|
-
*
|
|
102
|
-
* const M1 = getMonoid(B.MonoidAll)<number>()
|
|
103
|
-
*
|
|
104
|
-
* assert.deepStrictEqual(M1.concat(f, g)(1), true)
|
|
105
|
-
* assert.deepStrictEqual(M1.concat(f, g)(3), false)
|
|
106
|
-
*
|
|
107
|
-
* const M2 = getMonoid(B.MonoidAny)<number>()
|
|
108
|
-
*
|
|
109
|
-
* assert.deepStrictEqual(M2.concat(f, g)(1), true)
|
|
110
|
-
* assert.deepStrictEqual(M2.concat(f, g)(3), true)
|
|
111
|
-
*
|
|
112
|
-
* @category instances
|
|
113
|
-
* @since 2.10.0
|
|
114
|
-
*/
|
|
115
|
-
var getMonoid = function (M) {
|
|
116
|
-
var getSemigroupM = exports.getSemigroup(M);
|
|
117
|
-
return function () { return ({
|
|
118
|
-
concat: getSemigroupM().concat,
|
|
119
|
-
empty: function () { return M.empty; }
|
|
120
|
-
}); };
|
|
121
|
-
};
|
|
122
|
-
exports.getMonoid = getMonoid;
|
|
123
|
-
/**
|
|
124
|
-
* @category instances
|
|
125
|
-
* @since 2.10.0
|
|
126
|
-
*/
|
|
127
|
-
var getSemiring = function (S) { return ({
|
|
128
|
-
add: function (f, g) { return function (x) { return S.add(f(x), g(x)); }; },
|
|
129
|
-
zero: function () { return S.zero; },
|
|
130
|
-
mul: function (f, g) { return function (x) { return S.mul(f(x), g(x)); }; },
|
|
131
|
-
one: function () { return S.one; }
|
|
132
|
-
}); };
|
|
133
|
-
exports.getSemiring = getSemiring;
|
|
134
|
-
/**
|
|
135
|
-
* @category instances
|
|
136
|
-
* @since 2.10.0
|
|
137
|
-
*/
|
|
138
|
-
var getRing = function (R) {
|
|
139
|
-
var S = exports.getSemiring(R);
|
|
140
|
-
return {
|
|
141
|
-
add: S.add,
|
|
142
|
-
mul: S.mul,
|
|
143
|
-
one: S.one,
|
|
144
|
-
zero: S.zero,
|
|
145
|
-
sub: function (f, g) { return function (x) { return R.sub(f(x), g(x)); }; }
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
exports.getRing = getRing;
|
|
149
|
-
// -------------------------------------------------------------------------------------
|
|
150
|
-
// utils
|
|
151
|
-
// -------------------------------------------------------------------------------------
|
|
152
|
-
/**
|
|
153
|
-
* @since 2.11.0
|
|
154
|
-
*/
|
|
155
|
-
var apply = function (a) { return function (f) { return f(a); }; };
|
|
156
|
-
exports.apply = apply;
|
|
157
|
-
/**
|
|
158
|
-
* @since 2.0.0
|
|
159
|
-
*/
|
|
160
|
-
function identity(a) {
|
|
161
|
-
return a;
|
|
162
|
-
}
|
|
163
|
-
exports.identity = identity;
|
|
164
|
-
/**
|
|
165
|
-
* @since 2.0.0
|
|
166
|
-
*/
|
|
167
|
-
exports.unsafeCoerce = identity;
|
|
168
|
-
/**
|
|
169
|
-
* @since 2.0.0
|
|
170
|
-
*/
|
|
171
|
-
function constant(a) {
|
|
172
|
-
return function () { return a; };
|
|
173
|
-
}
|
|
174
|
-
exports.constant = constant;
|
|
175
|
-
/**
|
|
176
|
-
* A thunk that returns always `true`.
|
|
177
|
-
*
|
|
178
|
-
* @since 2.0.0
|
|
179
|
-
*/
|
|
180
|
-
exports.constTrue =
|
|
181
|
-
/*#__PURE__*/
|
|
182
|
-
constant(true);
|
|
183
|
-
/**
|
|
184
|
-
* A thunk that returns always `false`.
|
|
185
|
-
*
|
|
186
|
-
* @since 2.0.0
|
|
187
|
-
*/
|
|
188
|
-
exports.constFalse =
|
|
189
|
-
/*#__PURE__*/
|
|
190
|
-
constant(false);
|
|
191
|
-
/**
|
|
192
|
-
* A thunk that returns always `null`.
|
|
193
|
-
*
|
|
194
|
-
* @since 2.0.0
|
|
195
|
-
*/
|
|
196
|
-
exports.constNull =
|
|
197
|
-
/*#__PURE__*/
|
|
198
|
-
constant(null);
|
|
199
|
-
/**
|
|
200
|
-
* A thunk that returns always `undefined`.
|
|
201
|
-
*
|
|
202
|
-
* @since 2.0.0
|
|
203
|
-
*/
|
|
204
|
-
exports.constUndefined =
|
|
205
|
-
/*#__PURE__*/
|
|
206
|
-
constant(undefined);
|
|
207
|
-
/**
|
|
208
|
-
* A thunk that returns always `void`.
|
|
209
|
-
*
|
|
210
|
-
* @since 2.0.0
|
|
211
|
-
*/
|
|
212
|
-
exports.constVoid = exports.constUndefined;
|
|
213
|
-
/**
|
|
214
|
-
* Flips the order of the arguments of a function of two arguments.
|
|
215
|
-
*
|
|
216
|
-
* @since 2.0.0
|
|
217
|
-
*/
|
|
218
|
-
function flip(f) {
|
|
219
|
-
return function (b, a) { return f(a, b); };
|
|
220
|
-
}
|
|
221
|
-
exports.flip = flip;
|
|
222
|
-
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
|
|
223
|
-
switch (arguments.length) {
|
|
224
|
-
case 1:
|
|
225
|
-
return ab;
|
|
226
|
-
case 2:
|
|
227
|
-
return function () {
|
|
228
|
-
return bc(ab.apply(this, arguments));
|
|
229
|
-
};
|
|
230
|
-
case 3:
|
|
231
|
-
return function () {
|
|
232
|
-
return cd(bc(ab.apply(this, arguments)));
|
|
233
|
-
};
|
|
234
|
-
case 4:
|
|
235
|
-
return function () {
|
|
236
|
-
return de(cd(bc(ab.apply(this, arguments))));
|
|
237
|
-
};
|
|
238
|
-
case 5:
|
|
239
|
-
return function () {
|
|
240
|
-
return ef(de(cd(bc(ab.apply(this, arguments)))));
|
|
241
|
-
};
|
|
242
|
-
case 6:
|
|
243
|
-
return function () {
|
|
244
|
-
return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
|
|
245
|
-
};
|
|
246
|
-
case 7:
|
|
247
|
-
return function () {
|
|
248
|
-
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
|
|
249
|
-
};
|
|
250
|
-
case 8:
|
|
251
|
-
return function () {
|
|
252
|
-
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
|
|
253
|
-
};
|
|
254
|
-
case 9:
|
|
255
|
-
return function () {
|
|
256
|
-
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
exports.flow = flow;
|
|
262
|
-
/**
|
|
263
|
-
* @since 2.0.0
|
|
264
|
-
*/
|
|
265
|
-
function tuple() {
|
|
266
|
-
var t = [];
|
|
267
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
268
|
-
t[_i] = arguments[_i];
|
|
269
|
-
}
|
|
270
|
-
return t;
|
|
271
|
-
}
|
|
272
|
-
exports.tuple = tuple;
|
|
273
|
-
/**
|
|
274
|
-
* @since 2.0.0
|
|
275
|
-
*/
|
|
276
|
-
function increment(n) {
|
|
277
|
-
return n + 1;
|
|
278
|
-
}
|
|
279
|
-
exports.increment = increment;
|
|
280
|
-
/**
|
|
281
|
-
* @since 2.0.0
|
|
282
|
-
*/
|
|
283
|
-
function decrement(n) {
|
|
284
|
-
return n - 1;
|
|
285
|
-
}
|
|
286
|
-
exports.decrement = decrement;
|
|
287
|
-
/**
|
|
288
|
-
* @since 2.0.0
|
|
289
|
-
*/
|
|
290
|
-
function absurd(_) {
|
|
291
|
-
throw new Error('Called `absurd` function which should be uncallable');
|
|
292
|
-
}
|
|
293
|
-
exports.absurd = absurd;
|
|
294
|
-
/**
|
|
295
|
-
* Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* import { tupled } from 'fp-ts/function'
|
|
299
|
-
*
|
|
300
|
-
* const add = tupled((x: number, y: number): number => x + y)
|
|
301
|
-
*
|
|
302
|
-
* assert.strictEqual(add([1, 2]), 3)
|
|
303
|
-
*
|
|
304
|
-
* @since 2.4.0
|
|
305
|
-
*/
|
|
306
|
-
function tupled(f) {
|
|
307
|
-
return function (a) { return f.apply(void 0, a); };
|
|
308
|
-
}
|
|
309
|
-
exports.tupled = tupled;
|
|
310
|
-
/**
|
|
311
|
-
* Inverse function of `tupled`
|
|
312
|
-
*
|
|
313
|
-
* @since 2.4.0
|
|
314
|
-
*/
|
|
315
|
-
function untupled(f) {
|
|
316
|
-
return function () {
|
|
317
|
-
var a = [];
|
|
318
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
319
|
-
a[_i] = arguments[_i];
|
|
320
|
-
}
|
|
321
|
-
return f(a);
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
exports.untupled = untupled;
|
|
325
|
-
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
326
|
-
switch (arguments.length) {
|
|
327
|
-
case 1:
|
|
328
|
-
return a;
|
|
329
|
-
case 2:
|
|
330
|
-
return ab(a);
|
|
331
|
-
case 3:
|
|
332
|
-
return bc(ab(a));
|
|
333
|
-
case 4:
|
|
334
|
-
return cd(bc(ab(a)));
|
|
335
|
-
case 5:
|
|
336
|
-
return de(cd(bc(ab(a))));
|
|
337
|
-
case 6:
|
|
338
|
-
return ef(de(cd(bc(ab(a)))));
|
|
339
|
-
case 7:
|
|
340
|
-
return fg(ef(de(cd(bc(ab(a))))));
|
|
341
|
-
case 8:
|
|
342
|
-
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
343
|
-
case 9:
|
|
344
|
-
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
345
|
-
default:
|
|
346
|
-
var ret = arguments[0];
|
|
347
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
348
|
-
ret = arguments[i](ret);
|
|
349
|
-
}
|
|
350
|
-
return ret;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
exports.pipe = pipe;
|
|
354
|
-
/**
|
|
355
|
-
* Type hole simulation
|
|
356
|
-
*
|
|
357
|
-
* @since 2.7.0
|
|
358
|
-
*/
|
|
359
|
-
exports.hole = absurd;
|
|
360
|
-
/**
|
|
361
|
-
* @since 2.11.0
|
|
362
|
-
*/
|
|
363
|
-
var SK = function (_, b) { return b; };
|
|
364
|
-
exports.SK = SK;
|
|
365
|
-
/**
|
|
366
|
-
* Use `Predicate` module instead.
|
|
367
|
-
*
|
|
368
|
-
* @since 2.0.0
|
|
369
|
-
* @deprecated
|
|
370
|
-
*/
|
|
371
|
-
function not(predicate) {
|
|
372
|
-
return function (a) { return !predicate(a); };
|
|
373
|
-
}
|
|
374
|
-
exports.not = not;
|
|
375
|
-
/**
|
|
376
|
-
* Use `Endomorphism` module instead.
|
|
377
|
-
*
|
|
378
|
-
* @category instances
|
|
379
|
-
* @since 2.10.0
|
|
380
|
-
* @deprecated
|
|
381
|
-
*/
|
|
382
|
-
var getEndomorphismMonoid = function () { return ({
|
|
383
|
-
concat: function (first, second) { return flow(first, second); },
|
|
384
|
-
empty: identity
|
|
385
|
-
}); };
|
|
386
|
-
exports.getEndomorphismMonoid = getEndomorphismMonoid;
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const _function$1 = /*@__PURE__*/getDefaultExportFromCjs(_function);
|
|
390
|
-
|
|
391
|
-
var Apply = createCommonjsModule(function (module, exports) {
|
|
392
|
-
"use strict";
|
|
393
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
394
|
-
exports.sequenceS = exports.sequenceT = exports.getApplySemigroup = exports.apS = exports.apSecond = exports.apFirst = exports.ap = void 0;
|
|
395
|
-
|
|
396
|
-
function ap(F, G) {
|
|
397
|
-
return function (fa) { return function (fab) {
|
|
398
|
-
return F.ap(F.map(fab, function (gab) { return function (ga) { return G.ap(gab, ga); }; }), fa);
|
|
399
|
-
}; };
|
|
400
|
-
}
|
|
401
|
-
exports.ap = ap;
|
|
402
|
-
function apFirst(A) {
|
|
403
|
-
return function (second) { return function (first) {
|
|
404
|
-
return A.ap(A.map(first, function (a) { return function () { return a; }; }), second);
|
|
405
|
-
}; };
|
|
406
|
-
}
|
|
407
|
-
exports.apFirst = apFirst;
|
|
408
|
-
function apSecond(A) {
|
|
409
|
-
return function (second) { return function (first) {
|
|
410
|
-
return A.ap(A.map(first, function () { return function (b) { return b; }; }), second);
|
|
411
|
-
}; };
|
|
412
|
-
}
|
|
413
|
-
exports.apSecond = apSecond;
|
|
414
|
-
function apS(F) {
|
|
415
|
-
return function (name, fb) { return function (fa) {
|
|
416
|
-
return F.ap(F.map(fa, function (a) { return function (b) {
|
|
417
|
-
var _a;
|
|
418
|
-
return Object.assign({}, a, (_a = {}, _a[name] = b, _a));
|
|
419
|
-
}; }), fb);
|
|
420
|
-
}; };
|
|
421
|
-
}
|
|
422
|
-
exports.apS = apS;
|
|
423
|
-
function getApplySemigroup(F) {
|
|
424
|
-
return function (S) { return ({
|
|
425
|
-
concat: function (first, second) {
|
|
426
|
-
return F.ap(F.map(first, function (x) { return function (y) { return S.concat(x, y); }; }), second);
|
|
427
|
-
}
|
|
428
|
-
}); };
|
|
429
|
-
}
|
|
430
|
-
exports.getApplySemigroup = getApplySemigroup;
|
|
431
|
-
function curried(f, n, acc) {
|
|
432
|
-
return function (x) {
|
|
433
|
-
var combined = Array(acc.length + 1);
|
|
434
|
-
for (var i = 0; i < acc.length; i++) {
|
|
435
|
-
combined[i] = acc[i];
|
|
436
|
-
}
|
|
437
|
-
combined[acc.length] = x;
|
|
438
|
-
return n === 0 ? f.apply(null, combined) : curried(f, n - 1, combined);
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
var tupleConstructors = {
|
|
442
|
-
1: function (a) { return [a]; },
|
|
443
|
-
2: function (a) { return function (b) { return [a, b]; }; },
|
|
444
|
-
3: function (a) { return function (b) { return function (c) { return [a, b, c]; }; }; },
|
|
445
|
-
4: function (a) { return function (b) { return function (c) { return function (d) { return [a, b, c, d]; }; }; }; },
|
|
446
|
-
5: function (a) { return function (b) { return function (c) { return function (d) { return function (e) { return [a, b, c, d, e]; }; }; }; }; }
|
|
447
|
-
};
|
|
448
|
-
function getTupleConstructor(len) {
|
|
449
|
-
if (!tupleConstructors.hasOwnProperty(len)) {
|
|
450
|
-
tupleConstructors[len] = curried(_function.tuple, len - 1, []);
|
|
451
|
-
}
|
|
452
|
-
return tupleConstructors[len];
|
|
453
|
-
}
|
|
454
|
-
function sequenceT(F) {
|
|
455
|
-
return function () {
|
|
456
|
-
var args = [];
|
|
457
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
458
|
-
args[_i] = arguments[_i];
|
|
459
|
-
}
|
|
460
|
-
var len = args.length;
|
|
461
|
-
var f = getTupleConstructor(len);
|
|
462
|
-
var fas = F.map(args[0], f);
|
|
463
|
-
for (var i = 1; i < len; i++) {
|
|
464
|
-
fas = F.ap(fas, args[i]);
|
|
465
|
-
}
|
|
466
|
-
return fas;
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
exports.sequenceT = sequenceT;
|
|
470
|
-
function getRecordConstructor(keys) {
|
|
471
|
-
var len = keys.length;
|
|
472
|
-
switch (len) {
|
|
473
|
-
case 1:
|
|
474
|
-
return function (a) {
|
|
475
|
-
var _a;
|
|
476
|
-
return (_a = {}, _a[keys[0]] = a, _a);
|
|
477
|
-
};
|
|
478
|
-
case 2:
|
|
479
|
-
return function (a) { return function (b) {
|
|
480
|
-
var _a;
|
|
481
|
-
return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a);
|
|
482
|
-
}; };
|
|
483
|
-
case 3:
|
|
484
|
-
return function (a) { return function (b) { return function (c) {
|
|
485
|
-
var _a;
|
|
486
|
-
return (_a = {}, _a[keys[0]] = a, _a[keys[1]] = b, _a[keys[2]] = c, _a);
|
|
487
|
-
}; }; };
|
|
488
|
-
case 4:
|
|
489
|
-
return function (a) { return function (b) { return function (c) { return function (d) {
|
|
490
|
-
var _a;
|
|
491
|
-
return (_a = {},
|
|
492
|
-
_a[keys[0]] = a,
|
|
493
|
-
_a[keys[1]] = b,
|
|
494
|
-
_a[keys[2]] = c,
|
|
495
|
-
_a[keys[3]] = d,
|
|
496
|
-
_a);
|
|
497
|
-
}; }; }; };
|
|
498
|
-
case 5:
|
|
499
|
-
return function (a) { return function (b) { return function (c) { return function (d) { return function (e) {
|
|
500
|
-
var _a;
|
|
501
|
-
return (_a = {},
|
|
502
|
-
_a[keys[0]] = a,
|
|
503
|
-
_a[keys[1]] = b,
|
|
504
|
-
_a[keys[2]] = c,
|
|
505
|
-
_a[keys[3]] = d,
|
|
506
|
-
_a[keys[4]] = e,
|
|
507
|
-
_a);
|
|
508
|
-
}; }; }; }; };
|
|
509
|
-
default:
|
|
510
|
-
return curried(function () {
|
|
511
|
-
var args = [];
|
|
512
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
513
|
-
args[_i] = arguments[_i];
|
|
514
|
-
}
|
|
515
|
-
var r = {};
|
|
516
|
-
for (var i = 0; i < len; i++) {
|
|
517
|
-
r[keys[i]] = args[i];
|
|
518
|
-
}
|
|
519
|
-
return r;
|
|
520
|
-
}, len - 1, []);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function sequenceS(F) {
|
|
524
|
-
return function (r) {
|
|
525
|
-
var keys = Object.keys(r);
|
|
526
|
-
var len = keys.length;
|
|
527
|
-
var f = getRecordConstructor(keys);
|
|
528
|
-
var fr = F.map(r[keys[0]], f);
|
|
529
|
-
for (var i = 1; i < len; i++) {
|
|
530
|
-
fr = F.ap(fr, r[keys[i]]);
|
|
531
|
-
}
|
|
532
|
-
return fr;
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
exports.sequenceS = sequenceS;
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
const Apply$1 = /*@__PURE__*/getDefaultExportFromCjs(Apply);
|
|
539
|
-
|
|
540
|
-
var Functor = createCommonjsModule(function (module, exports) {
|
|
541
|
-
"use strict";
|
|
542
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
543
|
-
exports.getFunctorComposition = exports.bindTo = exports.flap = exports.map = void 0;
|
|
544
|
-
/**
|
|
545
|
-
* A `Functor` is a type constructor which supports a mapping operation `map`.
|
|
546
|
-
*
|
|
547
|
-
* `map` can be used to turn functions `a -> b` into functions `f a -> f b` whose argument and return types use the type
|
|
548
|
-
* constructor `f` to represent some computational context.
|
|
549
|
-
*
|
|
550
|
-
* Instances must satisfy the following laws:
|
|
551
|
-
*
|
|
552
|
-
* 1. Identity: `F.map(fa, a => a) <-> fa`
|
|
553
|
-
* 2. Composition: `F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)`
|
|
554
|
-
*
|
|
555
|
-
* @since 2.0.0
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
function map(F, G) {
|
|
559
|
-
return function (f) { return function (fa) { return F.map(fa, function (ga) { return G.map(ga, f); }); }; };
|
|
560
|
-
}
|
|
561
|
-
exports.map = map;
|
|
562
|
-
function flap(F) {
|
|
563
|
-
return function (a) { return function (fab) { return F.map(fab, function (f) { return f(a); }); }; };
|
|
564
|
-
}
|
|
565
|
-
exports.flap = flap;
|
|
566
|
-
function bindTo(F) {
|
|
567
|
-
return function (name) { return function (fa) { return F.map(fa, function (a) {
|
|
568
|
-
var _a;
|
|
569
|
-
return (_a = {}, _a[name] = a, _a);
|
|
570
|
-
}); }; };
|
|
571
|
-
}
|
|
572
|
-
exports.bindTo = bindTo;
|
|
573
|
-
/** @deprecated */
|
|
574
|
-
function getFunctorComposition(F, G) {
|
|
575
|
-
var _map = map(F, G);
|
|
576
|
-
return {
|
|
577
|
-
map: function (fga, f) { return _function.pipe(fga, _map(f)); }
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
exports.getFunctorComposition = getFunctorComposition;
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
const Functor$1 = /*@__PURE__*/getDefaultExportFromCjs(Functor);
|
|
584
|
-
|
|
585
|
-
var Chain = createCommonjsModule(function (module, exports) {
|
|
586
|
-
"use strict";
|
|
587
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
588
|
-
exports.bind = exports.chainFirst = void 0;
|
|
589
|
-
function chainFirst(M) {
|
|
590
|
-
return function (f) { return function (first) { return M.chain(first, function (a) { return M.map(f(a), function () { return a; }); }); }; };
|
|
591
|
-
}
|
|
592
|
-
exports.chainFirst = chainFirst;
|
|
593
|
-
function bind(M) {
|
|
594
|
-
return function (name, f) { return function (ma) { return M.chain(ma, function (a) { return M.map(f(a), function (b) {
|
|
595
|
-
var _a;
|
|
596
|
-
return Object.assign({}, a, (_a = {}, _a[name] = b, _a));
|
|
597
|
-
}); }); }; };
|
|
598
|
-
}
|
|
599
|
-
exports.bind = bind;
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
const Chain$1 = /*@__PURE__*/getDefaultExportFromCjs(Chain);
|
|
603
|
-
|
|
604
|
-
var internal = createCommonjsModule(function (module, exports) {
|
|
605
|
-
"use strict";
|
|
606
|
-
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from) {
|
|
607
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
608
|
-
to[j] = from[i];
|
|
609
|
-
return to;
|
|
610
|
-
};
|
|
611
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
612
|
-
exports.fromReadonlyNonEmptyArray = exports.has = exports.emptyRecord = exports.emptyReadonlyArray = exports.tail = exports.head = exports.isNonEmpty = exports.singleton = exports.right = exports.left = exports.isRight = exports.isLeft = exports.some = exports.none = exports.isSome = exports.isNone = void 0;
|
|
613
|
-
// -------------------------------------------------------------------------------------
|
|
614
|
-
// Option
|
|
615
|
-
// -------------------------------------------------------------------------------------
|
|
616
|
-
/** @internal */
|
|
617
|
-
var isNone = function (fa) { return fa._tag === 'None'; };
|
|
618
|
-
exports.isNone = isNone;
|
|
619
|
-
/** @internal */
|
|
620
|
-
var isSome = function (fa) { return fa._tag === 'Some'; };
|
|
621
|
-
exports.isSome = isSome;
|
|
622
|
-
/** @internal */
|
|
623
|
-
exports.none = { _tag: 'None' };
|
|
624
|
-
/** @internal */
|
|
625
|
-
var some = function (a) { return ({ _tag: 'Some', value: a }); };
|
|
626
|
-
exports.some = some;
|
|
627
|
-
// -------------------------------------------------------------------------------------
|
|
628
|
-
// Either
|
|
629
|
-
// -------------------------------------------------------------------------------------
|
|
630
|
-
/** @internal */
|
|
631
|
-
var isLeft = function (ma) { return ma._tag === 'Left'; };
|
|
632
|
-
exports.isLeft = isLeft;
|
|
633
|
-
/** @internal */
|
|
634
|
-
var isRight = function (ma) { return ma._tag === 'Right'; };
|
|
635
|
-
exports.isRight = isRight;
|
|
636
|
-
/** @internal */
|
|
637
|
-
var left = function (e) { return ({ _tag: 'Left', left: e }); };
|
|
638
|
-
exports.left = left;
|
|
639
|
-
/** @internal */
|
|
640
|
-
var right = function (a) { return ({ _tag: 'Right', right: a }); };
|
|
641
|
-
exports.right = right;
|
|
642
|
-
// -------------------------------------------------------------------------------------
|
|
643
|
-
// ReadonlyNonEmptyArray
|
|
644
|
-
// -------------------------------------------------------------------------------------
|
|
645
|
-
/** @internal */
|
|
646
|
-
var singleton = function (a) { return [a]; };
|
|
647
|
-
exports.singleton = singleton;
|
|
648
|
-
/** @internal */
|
|
649
|
-
var isNonEmpty = function (as) { return as.length > 0; };
|
|
650
|
-
exports.isNonEmpty = isNonEmpty;
|
|
651
|
-
/** @internal */
|
|
652
|
-
var head = function (as) { return as[0]; };
|
|
653
|
-
exports.head = head;
|
|
654
|
-
/** @internal */
|
|
655
|
-
var tail = function (as) { return as.slice(1); };
|
|
656
|
-
exports.tail = tail;
|
|
657
|
-
// -------------------------------------------------------------------------------------
|
|
658
|
-
// empty
|
|
659
|
-
// -------------------------------------------------------------------------------------
|
|
660
|
-
/** @internal */
|
|
661
|
-
exports.emptyReadonlyArray = [];
|
|
662
|
-
/** @internal */
|
|
663
|
-
exports.emptyRecord = {};
|
|
664
|
-
// -------------------------------------------------------------------------------------
|
|
665
|
-
// Record
|
|
666
|
-
// -------------------------------------------------------------------------------------
|
|
667
|
-
/** @internal */
|
|
668
|
-
exports.has = Object.prototype.hasOwnProperty;
|
|
669
|
-
// -------------------------------------------------------------------------------------
|
|
670
|
-
// NonEmptyArray
|
|
671
|
-
// -------------------------------------------------------------------------------------
|
|
672
|
-
/** @internal */
|
|
673
|
-
var fromReadonlyNonEmptyArray = function (as) { return __spreadArray([as[0]], as.slice(1)); };
|
|
674
|
-
exports.fromReadonlyNonEmptyArray = fromReadonlyNonEmptyArray;
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
const internal$1 = /*@__PURE__*/getDefaultExportFromCjs(internal);
|
|
678
|
-
|
|
679
|
-
var FromEither = createCommonjsModule(function (module, exports) {
|
|
680
|
-
"use strict";
|
|
681
|
-
/**
|
|
682
|
-
* The `FromEither` type class represents those data types which support errors.
|
|
683
|
-
*
|
|
684
|
-
* @since 2.10.0
|
|
685
|
-
*/
|
|
686
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
687
|
-
if (k2 === undefined) k2 = k;
|
|
688
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
689
|
-
}) : (function(o, m, k, k2) {
|
|
690
|
-
if (k2 === undefined) k2 = k;
|
|
691
|
-
o[k2] = m[k];
|
|
692
|
-
}));
|
|
693
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
694
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
695
|
-
}) : function(o, v) {
|
|
696
|
-
o["default"] = v;
|
|
697
|
-
});
|
|
698
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
699
|
-
if (mod && mod.__esModule) return mod;
|
|
700
|
-
var result = {};
|
|
701
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
702
|
-
__setModuleDefault(result, mod);
|
|
703
|
-
return result;
|
|
704
|
-
};
|
|
705
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
706
|
-
exports.filterOrElse = exports.chainEitherK = exports.fromEitherK = exports.chainOptionK = exports.fromOptionK = exports.fromPredicate = exports.fromOption = void 0;
|
|
707
|
-
|
|
708
|
-
var _ = __importStar(internal);
|
|
709
|
-
function fromOption(F) {
|
|
710
|
-
return function (onNone) { return function (ma) { return F.fromEither(_.isNone(ma) ? _.left(onNone()) : _.right(ma.value)); }; };
|
|
711
|
-
}
|
|
712
|
-
exports.fromOption = fromOption;
|
|
713
|
-
function fromPredicate(F) {
|
|
714
|
-
return function (predicate, onFalse) { return function (a) {
|
|
715
|
-
return F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a)));
|
|
716
|
-
}; };
|
|
717
|
-
}
|
|
718
|
-
exports.fromPredicate = fromPredicate;
|
|
719
|
-
function fromOptionK(F) {
|
|
720
|
-
var fromOptionF = fromOption(F);
|
|
721
|
-
return function (onNone) {
|
|
722
|
-
var from = fromOptionF(onNone);
|
|
723
|
-
return function (f) { return _function.flow(f, from); };
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
exports.fromOptionK = fromOptionK;
|
|
727
|
-
function chainOptionK(F, M) {
|
|
728
|
-
var fromOptionKF = fromOptionK(F);
|
|
729
|
-
return function (onNone) {
|
|
730
|
-
var from = fromOptionKF(onNone);
|
|
731
|
-
return function (f) { return function (ma) { return M.chain(ma, from(f)); }; };
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
exports.chainOptionK = chainOptionK;
|
|
735
|
-
function fromEitherK(F) {
|
|
736
|
-
return function (f) { return _function.flow(f, F.fromEither); };
|
|
737
|
-
}
|
|
738
|
-
exports.fromEitherK = fromEitherK;
|
|
739
|
-
function chainEitherK(F, M) {
|
|
740
|
-
var fromEitherKF = fromEitherK(F);
|
|
741
|
-
return function (f) { return function (ma) { return M.chain(ma, fromEitherKF(f)); }; };
|
|
742
|
-
}
|
|
743
|
-
exports.chainEitherK = chainEitherK;
|
|
744
|
-
function filterOrElse(F, M) {
|
|
745
|
-
return function (predicate, onFalse) { return function (ma) {
|
|
746
|
-
return M.chain(ma, function (a) { return F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a))); });
|
|
747
|
-
}; };
|
|
748
|
-
}
|
|
749
|
-
exports.filterOrElse = filterOrElse;
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
const FromEither$1 = /*@__PURE__*/getDefaultExportFromCjs(FromEither);
|
|
753
|
-
|
|
754
|
-
var Magma = createCommonjsModule(function (module, exports) {
|
|
755
|
-
"use strict";
|
|
756
|
-
/**
|
|
757
|
-
* A `Magma` is a pair `(A, concat)` in which `A` is a non-empty set and `concat` is a binary operation on `A`
|
|
758
|
-
*
|
|
759
|
-
* See [Semigroup](https://gcanti.github.io/fp-ts/modules/Semigroup.ts.html) for some instances.
|
|
760
|
-
*
|
|
761
|
-
* @since 2.0.0
|
|
762
|
-
*/
|
|
763
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
764
|
-
exports.concatAll = exports.endo = exports.filterSecond = exports.filterFirst = exports.reverse = void 0;
|
|
765
|
-
// -------------------------------------------------------------------------------------
|
|
766
|
-
// combinators
|
|
767
|
-
// -------------------------------------------------------------------------------------
|
|
768
|
-
/**
|
|
769
|
-
* The dual of a `Magma`, obtained by swapping the arguments of `concat`.
|
|
770
|
-
*
|
|
771
|
-
* @example
|
|
772
|
-
* import { reverse, concatAll } from 'fp-ts/Magma'
|
|
773
|
-
* import * as N from 'fp-ts/number'
|
|
774
|
-
*
|
|
775
|
-
* const subAll = concatAll(reverse(N.MagmaSub))(0)
|
|
776
|
-
*
|
|
777
|
-
* assert.deepStrictEqual(subAll([1, 2, 3]), 2)
|
|
778
|
-
*
|
|
779
|
-
* @category combinators
|
|
780
|
-
* @since 2.11.0
|
|
781
|
-
*/
|
|
782
|
-
var reverse = function (M) { return ({
|
|
783
|
-
concat: function (first, second) { return M.concat(second, first); }
|
|
784
|
-
}); };
|
|
785
|
-
exports.reverse = reverse;
|
|
786
|
-
/**
|
|
787
|
-
* @category combinators
|
|
788
|
-
* @since 2.11.0
|
|
789
|
-
*/
|
|
790
|
-
var filterFirst = function (predicate) { return function (M) { return ({
|
|
791
|
-
concat: function (first, second) { return (predicate(first) ? M.concat(first, second) : second); }
|
|
792
|
-
}); }; };
|
|
793
|
-
exports.filterFirst = filterFirst;
|
|
794
|
-
/**
|
|
795
|
-
* @category combinators
|
|
796
|
-
* @since 2.11.0
|
|
797
|
-
*/
|
|
798
|
-
var filterSecond = function (predicate) { return function (M) { return ({
|
|
799
|
-
concat: function (first, second) { return (predicate(second) ? M.concat(first, second) : first); }
|
|
800
|
-
}); }; };
|
|
801
|
-
exports.filterSecond = filterSecond;
|
|
802
|
-
/**
|
|
803
|
-
* @category combinators
|
|
804
|
-
* @since 2.11.0
|
|
805
|
-
*/
|
|
806
|
-
var endo = function (f) { return function (M) { return ({
|
|
807
|
-
concat: function (first, second) { return M.concat(f(first), f(second)); }
|
|
808
|
-
}); }; };
|
|
809
|
-
exports.endo = endo;
|
|
810
|
-
// -------------------------------------------------------------------------------------
|
|
811
|
-
// utils
|
|
812
|
-
// -------------------------------------------------------------------------------------
|
|
813
|
-
/**
|
|
814
|
-
* Given a sequence of `as`, concat them and return the total.
|
|
815
|
-
*
|
|
816
|
-
* If `as` is empty, return the provided `startWith` value.
|
|
817
|
-
*
|
|
818
|
-
* @example
|
|
819
|
-
* import { concatAll } from 'fp-ts/Magma'
|
|
820
|
-
* import * as N from 'fp-ts/number'
|
|
821
|
-
*
|
|
822
|
-
* const subAll = concatAll(N.MagmaSub)(0)
|
|
823
|
-
*
|
|
824
|
-
* assert.deepStrictEqual(subAll([1, 2, 3]), -6)
|
|
825
|
-
*
|
|
826
|
-
* @since 2.11.0
|
|
827
|
-
*/
|
|
828
|
-
var concatAll = function (M) { return function (startWith) { return function (as) {
|
|
829
|
-
return as.reduce(function (a, acc) { return M.concat(a, acc); }, startWith);
|
|
830
|
-
}; }; };
|
|
831
|
-
exports.concatAll = concatAll;
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
const Magma$1 = /*@__PURE__*/getDefaultExportFromCjs(Magma);
|
|
835
|
-
|
|
836
|
-
var Eq = createCommonjsModule(function (module, exports) {
|
|
837
|
-
"use strict";
|
|
838
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
839
|
-
exports.eqDate = exports.eqNumber = exports.eqString = exports.eqBoolean = exports.eq = exports.strictEqual = exports.getStructEq = exports.getTupleEq = exports.Contravariant = exports.getMonoid = exports.getSemigroup = exports.eqStrict = exports.URI = exports.contramap = exports.tuple = exports.struct = exports.fromEquals = void 0;
|
|
840
|
-
|
|
841
|
-
// -------------------------------------------------------------------------------------
|
|
842
|
-
// constructors
|
|
843
|
-
// -------------------------------------------------------------------------------------
|
|
844
|
-
/**
|
|
845
|
-
* @category constructors
|
|
846
|
-
* @since 2.0.0
|
|
847
|
-
*/
|
|
848
|
-
var fromEquals = function (equals) { return ({
|
|
849
|
-
equals: function (x, y) { return x === y || equals(x, y); }
|
|
850
|
-
}); };
|
|
851
|
-
exports.fromEquals = fromEquals;
|
|
852
|
-
// -------------------------------------------------------------------------------------
|
|
853
|
-
// combinators
|
|
854
|
-
// -------------------------------------------------------------------------------------
|
|
855
|
-
/**
|
|
856
|
-
* @category combinators
|
|
857
|
-
* @since 2.10.0
|
|
858
|
-
*/
|
|
859
|
-
var struct = function (eqs) {
|
|
860
|
-
return exports.fromEquals(function (first, second) {
|
|
861
|
-
for (var key in eqs) {
|
|
862
|
-
if (!eqs[key].equals(first[key], second[key])) {
|
|
863
|
-
return false;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
return true;
|
|
867
|
-
});
|
|
868
|
-
};
|
|
869
|
-
exports.struct = struct;
|
|
870
|
-
/**
|
|
871
|
-
* Given a tuple of `Eq`s returns a `Eq` for the tuple
|
|
872
|
-
*
|
|
873
|
-
* @example
|
|
874
|
-
* import { tuple } from 'fp-ts/Eq'
|
|
875
|
-
* import * as S from 'fp-ts/string'
|
|
876
|
-
* import * as N from 'fp-ts/number'
|
|
877
|
-
* import * as B from 'fp-ts/boolean'
|
|
878
|
-
*
|
|
879
|
-
* const E = tuple(S.Eq, N.Eq, B.Eq)
|
|
880
|
-
* assert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true)
|
|
881
|
-
* assert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false)
|
|
882
|
-
* assert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false)
|
|
883
|
-
* assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)
|
|
884
|
-
*
|
|
885
|
-
* @category combinators
|
|
886
|
-
* @since 2.10.0
|
|
887
|
-
*/
|
|
888
|
-
var tuple = function () {
|
|
889
|
-
var eqs = [];
|
|
890
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
891
|
-
eqs[_i] = arguments[_i];
|
|
892
|
-
}
|
|
893
|
-
return exports.fromEquals(function (first, second) { return eqs.every(function (E, i) { return E.equals(first[i], second[i]); }); });
|
|
894
|
-
};
|
|
895
|
-
exports.tuple = tuple;
|
|
896
|
-
// -------------------------------------------------------------------------------------
|
|
897
|
-
// non-pipeables
|
|
898
|
-
// -------------------------------------------------------------------------------------
|
|
899
|
-
/* istanbul ignore next */
|
|
900
|
-
var contramap_ = function (fa, f) { return _function.pipe(fa, exports.contramap(f)); };
|
|
901
|
-
// -------------------------------------------------------------------------------------
|
|
902
|
-
// type class members
|
|
903
|
-
// -------------------------------------------------------------------------------------
|
|
904
|
-
/**
|
|
905
|
-
* @category Contravariant
|
|
906
|
-
* @since 2.0.0
|
|
907
|
-
*/
|
|
908
|
-
var contramap = function (f) { return function (fa) {
|
|
909
|
-
return exports.fromEquals(function (x, y) { return fa.equals(f(x), f(y)); });
|
|
910
|
-
}; };
|
|
911
|
-
exports.contramap = contramap;
|
|
912
|
-
// -------------------------------------------------------------------------------------
|
|
913
|
-
// instances
|
|
914
|
-
// -------------------------------------------------------------------------------------
|
|
915
|
-
/**
|
|
916
|
-
* @category instances
|
|
917
|
-
* @since 2.0.0
|
|
918
|
-
*/
|
|
919
|
-
exports.URI = 'Eq';
|
|
920
|
-
/**
|
|
921
|
-
* @category instances
|
|
922
|
-
* @since 2.5.0
|
|
923
|
-
*/
|
|
924
|
-
exports.eqStrict = {
|
|
925
|
-
equals: function (a, b) { return a === b; }
|
|
926
|
-
};
|
|
927
|
-
var empty = {
|
|
928
|
-
equals: function () { return true; }
|
|
929
|
-
};
|
|
930
|
-
/**
|
|
931
|
-
* @category instances
|
|
932
|
-
* @since 2.10.0
|
|
933
|
-
*/
|
|
934
|
-
var getSemigroup = function () { return ({
|
|
935
|
-
concat: function (x, y) { return exports.fromEquals(function (a, b) { return x.equals(a, b) && y.equals(a, b); }); }
|
|
936
|
-
}); };
|
|
937
|
-
exports.getSemigroup = getSemigroup;
|
|
938
|
-
/**
|
|
939
|
-
* @category instances
|
|
940
|
-
* @since 2.6.0
|
|
941
|
-
*/
|
|
942
|
-
var getMonoid = function () { return ({
|
|
943
|
-
concat: exports.getSemigroup().concat,
|
|
944
|
-
empty: empty
|
|
945
|
-
}); };
|
|
946
|
-
exports.getMonoid = getMonoid;
|
|
947
|
-
/**
|
|
948
|
-
* @category instances
|
|
949
|
-
* @since 2.7.0
|
|
950
|
-
*/
|
|
951
|
-
exports.Contravariant = {
|
|
952
|
-
URI: exports.URI,
|
|
953
|
-
contramap: contramap_
|
|
954
|
-
};
|
|
955
|
-
// -------------------------------------------------------------------------------------
|
|
956
|
-
// deprecated
|
|
957
|
-
// -------------------------------------------------------------------------------------
|
|
958
|
-
/**
|
|
959
|
-
* Use [`tuple`](#tuple) instead.
|
|
960
|
-
*
|
|
961
|
-
* @category combinators
|
|
962
|
-
* @since 2.0.0
|
|
963
|
-
* @deprecated
|
|
964
|
-
*/
|
|
965
|
-
exports.getTupleEq = exports.tuple;
|
|
966
|
-
/**
|
|
967
|
-
* Use [`struct`](#struct) instead.
|
|
968
|
-
*
|
|
969
|
-
* @category combinators
|
|
970
|
-
* @since 2.0.0
|
|
971
|
-
* @deprecated
|
|
972
|
-
*/
|
|
973
|
-
exports.getStructEq = exports.struct;
|
|
974
|
-
/**
|
|
975
|
-
* Use [`eqStrict`](#eqstrict) instead
|
|
976
|
-
*
|
|
977
|
-
* @since 2.0.0
|
|
978
|
-
* @deprecated
|
|
979
|
-
*/
|
|
980
|
-
exports.strictEqual = exports.eqStrict.equals;
|
|
981
|
-
/**
|
|
982
|
-
* Use small, specific instances instead.
|
|
983
|
-
*
|
|
984
|
-
* @category instances
|
|
985
|
-
* @since 2.0.0
|
|
986
|
-
* @deprecated
|
|
987
|
-
*/
|
|
988
|
-
exports.eq = exports.Contravariant;
|
|
989
|
-
/**
|
|
990
|
-
* Use [`Eq`](./boolean.ts.html#eq) instead.
|
|
991
|
-
*
|
|
992
|
-
* @category instances
|
|
993
|
-
* @since 2.0.0
|
|
994
|
-
* @deprecated
|
|
995
|
-
*/
|
|
996
|
-
exports.eqBoolean = exports.eqStrict;
|
|
997
|
-
/**
|
|
998
|
-
* Use [`Eq`](./string.ts.html#eq) instead.
|
|
999
|
-
*
|
|
1000
|
-
* @category instances
|
|
1001
|
-
* @since 2.0.0
|
|
1002
|
-
* @deprecated
|
|
1003
|
-
*/
|
|
1004
|
-
exports.eqString = exports.eqStrict;
|
|
1005
|
-
/**
|
|
1006
|
-
* Use [`Eq`](./number.ts.html#eq) instead.
|
|
1007
|
-
*
|
|
1008
|
-
* @category instances
|
|
1009
|
-
* @since 2.0.0
|
|
1010
|
-
* @deprecated
|
|
1011
|
-
*/
|
|
1012
|
-
exports.eqNumber = exports.eqStrict;
|
|
1013
|
-
/**
|
|
1014
|
-
* Use [`Eq`](./Date.ts.html#eq) instead.
|
|
1015
|
-
*
|
|
1016
|
-
* @category instances
|
|
1017
|
-
* @since 2.0.0
|
|
1018
|
-
* @deprecated
|
|
1019
|
-
*/
|
|
1020
|
-
exports.eqDate = {
|
|
1021
|
-
equals: function (first, second) { return first.valueOf() === second.valueOf(); }
|
|
1022
|
-
};
|
|
1023
|
-
});
|
|
1024
|
-
|
|
1025
|
-
const Eq$1 = /*@__PURE__*/getDefaultExportFromCjs(Eq);
|
|
1026
|
-
|
|
1027
|
-
var Ord = createCommonjsModule(function (module, exports) {
|
|
1028
|
-
"use strict";
|
|
1029
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1030
|
-
exports.ordDate = exports.ordNumber = exports.ordString = exports.ordBoolean = exports.ord = exports.getDualOrd = exports.getTupleOrd = exports.between = exports.clamp = exports.max = exports.min = exports.geq = exports.leq = exports.gt = exports.lt = exports.equals = exports.trivial = exports.Contravariant = exports.getMonoid = exports.getSemigroup = exports.URI = exports.contramap = exports.reverse = exports.tuple = exports.fromCompare = exports.equalsDefault = void 0;
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
// -------------------------------------------------------------------------------------
|
|
1034
|
-
// defaults
|
|
1035
|
-
// -------------------------------------------------------------------------------------
|
|
1036
|
-
/**
|
|
1037
|
-
* @category defaults
|
|
1038
|
-
* @since 2.10.0
|
|
1039
|
-
*/
|
|
1040
|
-
var equalsDefault = function (compare) { return function (first, second) {
|
|
1041
|
-
return first === second || compare(first, second) === 0;
|
|
1042
|
-
}; };
|
|
1043
|
-
exports.equalsDefault = equalsDefault;
|
|
1044
|
-
// -------------------------------------------------------------------------------------
|
|
1045
|
-
// constructors
|
|
1046
|
-
// -------------------------------------------------------------------------------------
|
|
1047
|
-
/**
|
|
1048
|
-
* @category constructors
|
|
1049
|
-
* @since 2.0.0
|
|
1050
|
-
*/
|
|
1051
|
-
var fromCompare = function (compare) { return ({
|
|
1052
|
-
equals: exports.equalsDefault(compare),
|
|
1053
|
-
compare: function (first, second) { return (first === second ? 0 : compare(first, second)); }
|
|
1054
|
-
}); };
|
|
1055
|
-
exports.fromCompare = fromCompare;
|
|
1056
|
-
// -------------------------------------------------------------------------------------
|
|
1057
|
-
// combinators
|
|
1058
|
-
// -------------------------------------------------------------------------------------
|
|
1059
|
-
/**
|
|
1060
|
-
* Given a tuple of `Ord`s returns an `Ord` for the tuple.
|
|
1061
|
-
*
|
|
1062
|
-
* @example
|
|
1063
|
-
* import { tuple } from 'fp-ts/Ord'
|
|
1064
|
-
* import * as B from 'fp-ts/boolean'
|
|
1065
|
-
* import * as S from 'fp-ts/string'
|
|
1066
|
-
* import * as N from 'fp-ts/number'
|
|
1067
|
-
*
|
|
1068
|
-
* const O = tuple(S.Ord, N.Ord, B.Ord)
|
|
1069
|
-
* assert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1)
|
|
1070
|
-
* assert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1)
|
|
1071
|
-
* assert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1)
|
|
1072
|
-
*
|
|
1073
|
-
* @category combinators
|
|
1074
|
-
* @since 2.10.0
|
|
1075
|
-
*/
|
|
1076
|
-
var tuple = function () {
|
|
1077
|
-
var ords = [];
|
|
1078
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1079
|
-
ords[_i] = arguments[_i];
|
|
1080
|
-
}
|
|
1081
|
-
return exports.fromCompare(function (first, second) {
|
|
1082
|
-
var i = 0;
|
|
1083
|
-
for (; i < ords.length - 1; i++) {
|
|
1084
|
-
var r = ords[i].compare(first[i], second[i]);
|
|
1085
|
-
if (r !== 0) {
|
|
1086
|
-
return r;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
return ords[i].compare(first[i], second[i]);
|
|
1090
|
-
});
|
|
1091
|
-
};
|
|
1092
|
-
exports.tuple = tuple;
|
|
1093
|
-
/**
|
|
1094
|
-
* @category combinators
|
|
1095
|
-
* @since 2.10.0
|
|
1096
|
-
*/
|
|
1097
|
-
var reverse = function (O) { return exports.fromCompare(function (first, second) { return O.compare(second, first); }); };
|
|
1098
|
-
exports.reverse = reverse;
|
|
1099
|
-
// -------------------------------------------------------------------------------------
|
|
1100
|
-
// non-pipeables
|
|
1101
|
-
// -------------------------------------------------------------------------------------
|
|
1102
|
-
/* istanbul ignore next */
|
|
1103
|
-
var contramap_ = function (fa, f) { return _function.pipe(fa, exports.contramap(f)); };
|
|
1104
|
-
// -------------------------------------------------------------------------------------
|
|
1105
|
-
// type class members
|
|
1106
|
-
// -------------------------------------------------------------------------------------
|
|
1107
|
-
/**
|
|
1108
|
-
* @category Contravariant
|
|
1109
|
-
* @since 2.0.0
|
|
1110
|
-
*/
|
|
1111
|
-
var contramap = function (f) { return function (fa) {
|
|
1112
|
-
return exports.fromCompare(function (first, second) { return fa.compare(f(first), f(second)); });
|
|
1113
|
-
}; };
|
|
1114
|
-
exports.contramap = contramap;
|
|
1115
|
-
// -------------------------------------------------------------------------------------
|
|
1116
|
-
// instances
|
|
1117
|
-
// -------------------------------------------------------------------------------------
|
|
1118
|
-
/**
|
|
1119
|
-
* @category instances
|
|
1120
|
-
* @since 2.0.0
|
|
1121
|
-
*/
|
|
1122
|
-
exports.URI = 'Ord';
|
|
1123
|
-
/**
|
|
1124
|
-
* @category instances
|
|
1125
|
-
* @since 2.0.0
|
|
1126
|
-
*/
|
|
1127
|
-
var getSemigroup = function () { return ({
|
|
1128
|
-
concat: function (first, second) {
|
|
1129
|
-
return exports.fromCompare(function (a, b) {
|
|
1130
|
-
var ox = first.compare(a, b);
|
|
1131
|
-
return ox !== 0 ? ox : second.compare(a, b);
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
}); };
|
|
1135
|
-
exports.getSemigroup = getSemigroup;
|
|
1136
|
-
/**
|
|
1137
|
-
* Returns a `Monoid` such that:
|
|
1138
|
-
*
|
|
1139
|
-
* - its `concat(ord1, ord2)` operation will order first by `ord1`, and then by `ord2`
|
|
1140
|
-
* - its `empty` value is an `Ord` that always considers compared elements equal
|
|
1141
|
-
*
|
|
1142
|
-
* @example
|
|
1143
|
-
* import { sort } from 'fp-ts/Array'
|
|
1144
|
-
* import { contramap, reverse, getMonoid } from 'fp-ts/Ord'
|
|
1145
|
-
* import * as S from 'fp-ts/string'
|
|
1146
|
-
* import * as B from 'fp-ts/boolean'
|
|
1147
|
-
* import { pipe } from 'fp-ts/function'
|
|
1148
|
-
* import { concatAll } from 'fp-ts/Monoid'
|
|
1149
|
-
* import * as N from 'fp-ts/number'
|
|
1150
|
-
*
|
|
1151
|
-
* interface User {
|
|
1152
|
-
* readonly id: number
|
|
1153
|
-
* readonly name: string
|
|
1154
|
-
* readonly age: number
|
|
1155
|
-
* readonly rememberMe: boolean
|
|
1156
|
-
* }
|
|
1157
|
-
*
|
|
1158
|
-
* const byName = pipe(
|
|
1159
|
-
* S.Ord,
|
|
1160
|
-
* contramap((p: User) => p.name)
|
|
1161
|
-
* )
|
|
1162
|
-
*
|
|
1163
|
-
* const byAge = pipe(
|
|
1164
|
-
* N.Ord,
|
|
1165
|
-
* contramap((p: User) => p.age)
|
|
1166
|
-
* )
|
|
1167
|
-
*
|
|
1168
|
-
* const byRememberMe = pipe(
|
|
1169
|
-
* B.Ord,
|
|
1170
|
-
* contramap((p: User) => p.rememberMe)
|
|
1171
|
-
* )
|
|
1172
|
-
*
|
|
1173
|
-
* const M = getMonoid<User>()
|
|
1174
|
-
*
|
|
1175
|
-
* const users: Array<User> = [
|
|
1176
|
-
* { id: 1, name: 'Guido', age: 47, rememberMe: false },
|
|
1177
|
-
* { id: 2, name: 'Guido', age: 46, rememberMe: true },
|
|
1178
|
-
* { id: 3, name: 'Giulio', age: 44, rememberMe: false },
|
|
1179
|
-
* { id: 4, name: 'Giulio', age: 44, rememberMe: true }
|
|
1180
|
-
* ]
|
|
1181
|
-
*
|
|
1182
|
-
* // sort by name, then by age, then by `rememberMe`
|
|
1183
|
-
* const O1 = concatAll(M)([byName, byAge, byRememberMe])
|
|
1184
|
-
* assert.deepStrictEqual(sort(O1)(users), [
|
|
1185
|
-
* { id: 3, name: 'Giulio', age: 44, rememberMe: false },
|
|
1186
|
-
* { id: 4, name: 'Giulio', age: 44, rememberMe: true },
|
|
1187
|
-
* { id: 2, name: 'Guido', age: 46, rememberMe: true },
|
|
1188
|
-
* { id: 1, name: 'Guido', age: 47, rememberMe: false }
|
|
1189
|
-
* ])
|
|
1190
|
-
*
|
|
1191
|
-
* // now `rememberMe = true` first, then by name, then by age
|
|
1192
|
-
* const O2 = concatAll(M)([reverse(byRememberMe), byName, byAge])
|
|
1193
|
-
* assert.deepStrictEqual(sort(O2)(users), [
|
|
1194
|
-
* { id: 4, name: 'Giulio', age: 44, rememberMe: true },
|
|
1195
|
-
* { id: 2, name: 'Guido', age: 46, rememberMe: true },
|
|
1196
|
-
* { id: 3, name: 'Giulio', age: 44, rememberMe: false },
|
|
1197
|
-
* { id: 1, name: 'Guido', age: 47, rememberMe: false }
|
|
1198
|
-
* ])
|
|
1199
|
-
*
|
|
1200
|
-
* @category instances
|
|
1201
|
-
* @since 2.4.0
|
|
1202
|
-
*/
|
|
1203
|
-
var getMonoid = function () { return ({
|
|
1204
|
-
concat: exports.getSemigroup().concat,
|
|
1205
|
-
empty: exports.fromCompare(function () { return 0; })
|
|
1206
|
-
}); };
|
|
1207
|
-
exports.getMonoid = getMonoid;
|
|
1208
|
-
/**
|
|
1209
|
-
* @category instances
|
|
1210
|
-
* @since 2.7.0
|
|
1211
|
-
*/
|
|
1212
|
-
exports.Contravariant = {
|
|
1213
|
-
URI: exports.URI,
|
|
1214
|
-
contramap: contramap_
|
|
1215
|
-
};
|
|
1216
|
-
// -------------------------------------------------------------------------------------
|
|
1217
|
-
// utils
|
|
1218
|
-
// -------------------------------------------------------------------------------------
|
|
1219
|
-
/**
|
|
1220
|
-
* @since 2.11.0
|
|
1221
|
-
*/
|
|
1222
|
-
exports.trivial = {
|
|
1223
|
-
equals: _function.constTrue,
|
|
1224
|
-
compare:
|
|
1225
|
-
/*#__PURE__*/
|
|
1226
|
-
_function.constant(0)
|
|
1227
|
-
};
|
|
1228
|
-
/**
|
|
1229
|
-
* @since 2.11.0
|
|
1230
|
-
*/
|
|
1231
|
-
var equals = function (O) { return function (second) { return function (first) {
|
|
1232
|
-
return first === second || O.compare(first, second) === 0;
|
|
1233
|
-
}; }; };
|
|
1234
|
-
exports.equals = equals;
|
|
1235
|
-
// TODO: curry in v3
|
|
1236
|
-
/**
|
|
1237
|
-
* Test whether one value is _strictly less than_ another
|
|
1238
|
-
*
|
|
1239
|
-
* @since 2.0.0
|
|
1240
|
-
*/
|
|
1241
|
-
var lt = function (O) { return function (first, second) { return O.compare(first, second) === -1; }; };
|
|
1242
|
-
exports.lt = lt;
|
|
1243
|
-
// TODO: curry in v3
|
|
1244
|
-
/**
|
|
1245
|
-
* Test whether one value is _strictly greater than_ another
|
|
1246
|
-
*
|
|
1247
|
-
* @since 2.0.0
|
|
1248
|
-
*/
|
|
1249
|
-
var gt = function (O) { return function (first, second) { return O.compare(first, second) === 1; }; };
|
|
1250
|
-
exports.gt = gt;
|
|
1251
|
-
// TODO: curry in v3
|
|
1252
|
-
/**
|
|
1253
|
-
* Test whether one value is _non-strictly less than_ another
|
|
1254
|
-
*
|
|
1255
|
-
* @since 2.0.0
|
|
1256
|
-
*/
|
|
1257
|
-
var leq = function (O) { return function (first, second) { return O.compare(first, second) !== 1; }; };
|
|
1258
|
-
exports.leq = leq;
|
|
1259
|
-
// TODO: curry in v3
|
|
1260
|
-
/**
|
|
1261
|
-
* Test whether one value is _non-strictly greater than_ another
|
|
1262
|
-
*
|
|
1263
|
-
* @since 2.0.0
|
|
1264
|
-
*/
|
|
1265
|
-
var geq = function (O) { return function (first, second) { return O.compare(first, second) !== -1; }; };
|
|
1266
|
-
exports.geq = geq;
|
|
1267
|
-
// TODO: curry in v3
|
|
1268
|
-
/**
|
|
1269
|
-
* Take the minimum of two values. If they are considered equal, the first argument is chosen
|
|
1270
|
-
*
|
|
1271
|
-
* @since 2.0.0
|
|
1272
|
-
*/
|
|
1273
|
-
var min = function (O) { return function (first, second) {
|
|
1274
|
-
return first === second || O.compare(first, second) < 1 ? first : second;
|
|
1275
|
-
}; };
|
|
1276
|
-
exports.min = min;
|
|
1277
|
-
// TODO: curry in v3
|
|
1278
|
-
/**
|
|
1279
|
-
* Take the maximum of two values. If they are considered equal, the first argument is chosen
|
|
1280
|
-
*
|
|
1281
|
-
* @since 2.0.0
|
|
1282
|
-
*/
|
|
1283
|
-
var max = function (O) { return function (first, second) {
|
|
1284
|
-
return first === second || O.compare(first, second) > -1 ? first : second;
|
|
1285
|
-
}; };
|
|
1286
|
-
exports.max = max;
|
|
1287
|
-
/**
|
|
1288
|
-
* Clamp a value between a minimum and a maximum
|
|
1289
|
-
*
|
|
1290
|
-
* @since 2.0.0
|
|
1291
|
-
*/
|
|
1292
|
-
var clamp = function (O) {
|
|
1293
|
-
var minO = exports.min(O);
|
|
1294
|
-
var maxO = exports.max(O);
|
|
1295
|
-
return function (low, hi) { return function (a) { return maxO(minO(a, hi), low); }; };
|
|
1296
|
-
};
|
|
1297
|
-
exports.clamp = clamp;
|
|
1298
|
-
/**
|
|
1299
|
-
* Test whether a value is between a minimum and a maximum (inclusive)
|
|
1300
|
-
*
|
|
1301
|
-
* @since 2.0.0
|
|
1302
|
-
*/
|
|
1303
|
-
var between = function (O) {
|
|
1304
|
-
var ltO = exports.lt(O);
|
|
1305
|
-
var gtO = exports.gt(O);
|
|
1306
|
-
return function (low, hi) { return function (a) { return (ltO(a, low) || gtO(a, hi) ? false : true); }; };
|
|
1307
|
-
};
|
|
1308
|
-
exports.between = between;
|
|
1309
|
-
// -------------------------------------------------------------------------------------
|
|
1310
|
-
// deprecated
|
|
1311
|
-
// -------------------------------------------------------------------------------------
|
|
1312
|
-
// tslint:disable: deprecation
|
|
1313
|
-
/**
|
|
1314
|
-
* Use [`tuple`](#tuple) instead.
|
|
1315
|
-
*
|
|
1316
|
-
* @category combinators
|
|
1317
|
-
* @since 2.0.0
|
|
1318
|
-
* @deprecated
|
|
1319
|
-
*/
|
|
1320
|
-
exports.getTupleOrd = exports.tuple;
|
|
1321
|
-
/**
|
|
1322
|
-
* Use [`reverse`](#reverse) instead.
|
|
1323
|
-
*
|
|
1324
|
-
* @category combinators
|
|
1325
|
-
* @since 2.0.0
|
|
1326
|
-
* @deprecated
|
|
1327
|
-
*/
|
|
1328
|
-
exports.getDualOrd = exports.reverse;
|
|
1329
|
-
/**
|
|
1330
|
-
* Use [`Contravariant`](#contravariant) instead.
|
|
1331
|
-
*
|
|
1332
|
-
* @category instances
|
|
1333
|
-
* @since 2.0.0
|
|
1334
|
-
* @deprecated
|
|
1335
|
-
*/
|
|
1336
|
-
exports.ord = exports.Contravariant;
|
|
1337
|
-
// default compare for primitive types
|
|
1338
|
-
function compare(first, second) {
|
|
1339
|
-
return first < second ? -1 : first > second ? 1 : 0;
|
|
1340
|
-
}
|
|
1341
|
-
var strictOrd = {
|
|
1342
|
-
equals: Eq.eqStrict.equals,
|
|
1343
|
-
compare: compare
|
|
1344
|
-
};
|
|
1345
|
-
/**
|
|
1346
|
-
* Use [`Ord`](./boolean.ts.html#ord) instead.
|
|
1347
|
-
*
|
|
1348
|
-
* @category instances
|
|
1349
|
-
* @since 2.0.0
|
|
1350
|
-
* @deprecated
|
|
1351
|
-
*/
|
|
1352
|
-
exports.ordBoolean = strictOrd;
|
|
1353
|
-
/**
|
|
1354
|
-
* Use [`Ord`](./string.ts.html#ord) instead.
|
|
1355
|
-
*
|
|
1356
|
-
* @category instances
|
|
1357
|
-
* @since 2.0.0
|
|
1358
|
-
* @deprecated
|
|
1359
|
-
*/
|
|
1360
|
-
exports.ordString = strictOrd;
|
|
1361
|
-
/**
|
|
1362
|
-
* Use [`Ord`](./number.ts.html#ord) instead.
|
|
1363
|
-
*
|
|
1364
|
-
* @category instances
|
|
1365
|
-
* @since 2.0.0
|
|
1366
|
-
* @deprecated
|
|
1367
|
-
*/
|
|
1368
|
-
exports.ordNumber = strictOrd;
|
|
1369
|
-
/**
|
|
1370
|
-
* Use [`Ord`](./Date.ts.html#ord) instead.
|
|
1371
|
-
*
|
|
1372
|
-
* @category instances
|
|
1373
|
-
* @since 2.0.0
|
|
1374
|
-
* @deprecated
|
|
1375
|
-
*/
|
|
1376
|
-
exports.ordDate =
|
|
1377
|
-
/*#__PURE__*/
|
|
1378
|
-
_function.pipe(exports.ordNumber,
|
|
1379
|
-
/*#__PURE__*/
|
|
1380
|
-
exports.contramap(function (date) { return date.valueOf(); }));
|
|
1381
|
-
});
|
|
1382
|
-
|
|
1383
|
-
const Ord$1 = /*@__PURE__*/getDefaultExportFromCjs(Ord);
|
|
1384
|
-
|
|
1385
|
-
var Semigroup = createCommonjsModule(function (module, exports) {
|
|
1386
|
-
"use strict";
|
|
1387
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1388
|
-
if (k2 === undefined) k2 = k;
|
|
1389
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1390
|
-
}) : (function(o, m, k, k2) {
|
|
1391
|
-
if (k2 === undefined) k2 = k;
|
|
1392
|
-
o[k2] = m[k];
|
|
1393
|
-
}));
|
|
1394
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1395
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1396
|
-
}) : function(o, v) {
|
|
1397
|
-
o["default"] = v;
|
|
1398
|
-
});
|
|
1399
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
1400
|
-
if (mod && mod.__esModule) return mod;
|
|
1401
|
-
var result = {};
|
|
1402
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1403
|
-
__setModuleDefault(result, mod);
|
|
1404
|
-
return result;
|
|
1405
|
-
};
|
|
1406
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1407
|
-
exports.semigroupProduct = exports.semigroupSum = exports.semigroupString = exports.getFunctionSemigroup = exports.semigroupAny = exports.semigroupAll = exports.fold = exports.getIntercalateSemigroup = exports.getMeetSemigroup = exports.getJoinSemigroup = exports.getDualSemigroup = exports.getStructSemigroup = exports.getTupleSemigroup = exports.getFirstSemigroup = exports.getLastSemigroup = exports.getObjectSemigroup = exports.semigroupVoid = exports.concatAll = exports.last = exports.first = exports.intercalate = exports.tuple = exports.struct = exports.reverse = exports.constant = exports.max = exports.min = void 0;
|
|
1408
|
-
/**
|
|
1409
|
-
* If a type `A` can form a `Semigroup` it has an **associative** binary operation.
|
|
1410
|
-
*
|
|
1411
|
-
* ```ts
|
|
1412
|
-
* interface Semigroup<A> {
|
|
1413
|
-
* readonly concat: (x: A, y: A) => A
|
|
1414
|
-
* }
|
|
1415
|
-
* ```
|
|
1416
|
-
*
|
|
1417
|
-
* Associativity means the following equality must hold for any choice of `x`, `y`, and `z`.
|
|
1418
|
-
*
|
|
1419
|
-
* ```ts
|
|
1420
|
-
* concat(x, concat(y, z)) = concat(concat(x, y), z)
|
|
1421
|
-
* ```
|
|
1422
|
-
*
|
|
1423
|
-
* A common example of a semigroup is the type `string` with the operation `+`.
|
|
1424
|
-
*
|
|
1425
|
-
* ```ts
|
|
1426
|
-
* import { Semigroup } from 'fp-ts/Semigroup'
|
|
1427
|
-
*
|
|
1428
|
-
* const semigroupString: Semigroup<string> = {
|
|
1429
|
-
* concat: (x, y) => x + y
|
|
1430
|
-
* }
|
|
1431
|
-
*
|
|
1432
|
-
* const x = 'x'
|
|
1433
|
-
* const y = 'y'
|
|
1434
|
-
* const z = 'z'
|
|
1435
|
-
*
|
|
1436
|
-
* semigroupString.concat(x, y) // 'xy'
|
|
1437
|
-
*
|
|
1438
|
-
* semigroupString.concat(x, semigroupString.concat(y, z)) // 'xyz'
|
|
1439
|
-
*
|
|
1440
|
-
* semigroupString.concat(semigroupString.concat(x, y), z) // 'xyz'
|
|
1441
|
-
* ```
|
|
1442
|
-
*
|
|
1443
|
-
* *Adapted from https://typelevel.org/cats*
|
|
1444
|
-
*
|
|
1445
|
-
* @since 2.0.0
|
|
1446
|
-
*/
|
|
1447
|
-
|
|
1448
|
-
var _ = __importStar(internal);
|
|
1449
|
-
var M = __importStar(Magma);
|
|
1450
|
-
var Or = __importStar(Ord);
|
|
1451
|
-
// -------------------------------------------------------------------------------------
|
|
1452
|
-
// constructors
|
|
1453
|
-
// -------------------------------------------------------------------------------------
|
|
1454
|
-
/**
|
|
1455
|
-
* Get a semigroup where `concat` will return the minimum, based on the provided order.
|
|
1456
|
-
*
|
|
1457
|
-
* @example
|
|
1458
|
-
* import * as N from 'fp-ts/number'
|
|
1459
|
-
* import * as S from 'fp-ts/Semigroup'
|
|
1460
|
-
*
|
|
1461
|
-
* const S1 = S.min(N.Ord)
|
|
1462
|
-
*
|
|
1463
|
-
* assert.deepStrictEqual(S1.concat(1, 2), 1)
|
|
1464
|
-
*
|
|
1465
|
-
* @category constructors
|
|
1466
|
-
* @since 2.10.0
|
|
1467
|
-
*/
|
|
1468
|
-
var min = function (O) { return ({
|
|
1469
|
-
concat: Or.min(O)
|
|
1470
|
-
}); };
|
|
1471
|
-
exports.min = min;
|
|
1472
|
-
/**
|
|
1473
|
-
* Get a semigroup where `concat` will return the maximum, based on the provided order.
|
|
1474
|
-
*
|
|
1475
|
-
* @example
|
|
1476
|
-
* import * as N from 'fp-ts/number'
|
|
1477
|
-
* import * as S from 'fp-ts/Semigroup'
|
|
1478
|
-
*
|
|
1479
|
-
* const S1 = S.max(N.Ord)
|
|
1480
|
-
*
|
|
1481
|
-
* assert.deepStrictEqual(S1.concat(1, 2), 2)
|
|
1482
|
-
*
|
|
1483
|
-
* @category constructors
|
|
1484
|
-
* @since 2.10.0
|
|
1485
|
-
*/
|
|
1486
|
-
var max = function (O) { return ({
|
|
1487
|
-
concat: Or.max(O)
|
|
1488
|
-
}); };
|
|
1489
|
-
exports.max = max;
|
|
1490
|
-
/**
|
|
1491
|
-
* @category constructors
|
|
1492
|
-
* @since 2.10.0
|
|
1493
|
-
*/
|
|
1494
|
-
var constant = function (a) { return ({
|
|
1495
|
-
concat: function () { return a; }
|
|
1496
|
-
}); };
|
|
1497
|
-
exports.constant = constant;
|
|
1498
|
-
// -------------------------------------------------------------------------------------
|
|
1499
|
-
// combinators
|
|
1500
|
-
// -------------------------------------------------------------------------------------
|
|
1501
|
-
/**
|
|
1502
|
-
* The dual of a `Semigroup`, obtained by swapping the arguments of `concat`.
|
|
1503
|
-
*
|
|
1504
|
-
* @example
|
|
1505
|
-
* import { reverse } from 'fp-ts/Semigroup'
|
|
1506
|
-
* import * as S from 'fp-ts/string'
|
|
1507
|
-
*
|
|
1508
|
-
* assert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba')
|
|
1509
|
-
*
|
|
1510
|
-
* @category combinators
|
|
1511
|
-
* @since 2.10.0
|
|
1512
|
-
*/
|
|
1513
|
-
exports.reverse = M.reverse;
|
|
1514
|
-
/**
|
|
1515
|
-
* Given a struct of semigroups returns a semigroup for the struct.
|
|
1516
|
-
*
|
|
1517
|
-
* @example
|
|
1518
|
-
* import { struct } from 'fp-ts/Semigroup'
|
|
1519
|
-
* import * as N from 'fp-ts/number'
|
|
1520
|
-
*
|
|
1521
|
-
* interface Point {
|
|
1522
|
-
* readonly x: number
|
|
1523
|
-
* readonly y: number
|
|
1524
|
-
* }
|
|
1525
|
-
*
|
|
1526
|
-
* const S = struct<Point>({
|
|
1527
|
-
* x: N.SemigroupSum,
|
|
1528
|
-
* y: N.SemigroupSum
|
|
1529
|
-
* })
|
|
1530
|
-
*
|
|
1531
|
-
* assert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })
|
|
1532
|
-
*
|
|
1533
|
-
* @category combinators
|
|
1534
|
-
* @since 2.10.0
|
|
1535
|
-
*/
|
|
1536
|
-
var struct = function (semigroups) { return ({
|
|
1537
|
-
concat: function (first, second) {
|
|
1538
|
-
var r = {};
|
|
1539
|
-
for (var k in semigroups) {
|
|
1540
|
-
if (_.has.call(semigroups, k)) {
|
|
1541
|
-
r[k] = semigroups[k].concat(first[k], second[k]);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
return r;
|
|
1545
|
-
}
|
|
1546
|
-
}); };
|
|
1547
|
-
exports.struct = struct;
|
|
1548
|
-
/**
|
|
1549
|
-
* Given a tuple of semigroups returns a semigroup for the tuple.
|
|
1550
|
-
*
|
|
1551
|
-
* @example
|
|
1552
|
-
* import { tuple } from 'fp-ts/Semigroup'
|
|
1553
|
-
* import * as B from 'fp-ts/boolean'
|
|
1554
|
-
* import * as N from 'fp-ts/number'
|
|
1555
|
-
* import * as S from 'fp-ts/string'
|
|
1556
|
-
*
|
|
1557
|
-
* const S1 = tuple(S.Semigroup, N.SemigroupSum)
|
|
1558
|
-
* assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])
|
|
1559
|
-
*
|
|
1560
|
-
* const S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)
|
|
1561
|
-
* assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])
|
|
1562
|
-
*
|
|
1563
|
-
* @category combinators
|
|
1564
|
-
* @since 2.10.0
|
|
1565
|
-
*/
|
|
1566
|
-
var tuple = function () {
|
|
1567
|
-
var semigroups = [];
|
|
1568
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1569
|
-
semigroups[_i] = arguments[_i];
|
|
1570
|
-
}
|
|
1571
|
-
return ({
|
|
1572
|
-
concat: function (first, second) { return semigroups.map(function (s, i) { return s.concat(first[i], second[i]); }); }
|
|
1573
|
-
});
|
|
1574
|
-
};
|
|
1575
|
-
exports.tuple = tuple;
|
|
1576
|
-
/**
|
|
1577
|
-
* Between each pair of elements insert `middle`.
|
|
1578
|
-
*
|
|
1579
|
-
* @example
|
|
1580
|
-
* import { intercalate } from 'fp-ts/Semigroup'
|
|
1581
|
-
* import * as S from 'fp-ts/string'
|
|
1582
|
-
* import { pipe } from 'fp-ts/function'
|
|
1583
|
-
*
|
|
1584
|
-
* const S1 = pipe(S.Semigroup, intercalate(' + '))
|
|
1585
|
-
*
|
|
1586
|
-
* assert.strictEqual(S1.concat('a', 'b'), 'a + b')
|
|
1587
|
-
*
|
|
1588
|
-
* @category combinators
|
|
1589
|
-
* @since 2.10.0
|
|
1590
|
-
*/
|
|
1591
|
-
var intercalate = function (middle) { return function (S) { return ({
|
|
1592
|
-
concat: function (x, y) { return S.concat(x, S.concat(middle, y)); }
|
|
1593
|
-
}); }; };
|
|
1594
|
-
exports.intercalate = intercalate;
|
|
1595
|
-
// -------------------------------------------------------------------------------------
|
|
1596
|
-
// instances
|
|
1597
|
-
// -------------------------------------------------------------------------------------
|
|
1598
|
-
/**
|
|
1599
|
-
* Always return the first argument.
|
|
1600
|
-
*
|
|
1601
|
-
* @example
|
|
1602
|
-
* import * as S from 'fp-ts/Semigroup'
|
|
1603
|
-
*
|
|
1604
|
-
* assert.deepStrictEqual(S.first<number>().concat(1, 2), 1)
|
|
1605
|
-
*
|
|
1606
|
-
* @category instances
|
|
1607
|
-
* @since 2.10.0
|
|
1608
|
-
*/
|
|
1609
|
-
var first = function () { return ({ concat: _function.identity }); };
|
|
1610
|
-
exports.first = first;
|
|
1611
|
-
/**
|
|
1612
|
-
* Always return the last argument.
|
|
1613
|
-
*
|
|
1614
|
-
* @example
|
|
1615
|
-
* import * as S from 'fp-ts/Semigroup'
|
|
1616
|
-
*
|
|
1617
|
-
* assert.deepStrictEqual(S.last<number>().concat(1, 2), 2)
|
|
1618
|
-
*
|
|
1619
|
-
* @category instances
|
|
1620
|
-
* @since 2.10.0
|
|
1621
|
-
*/
|
|
1622
|
-
var last = function () { return ({ concat: function (_, y) { return y; } }); };
|
|
1623
|
-
exports.last = last;
|
|
1624
|
-
// -------------------------------------------------------------------------------------
|
|
1625
|
-
// utils
|
|
1626
|
-
// -------------------------------------------------------------------------------------
|
|
1627
|
-
/**
|
|
1628
|
-
* Given a sequence of `as`, concat them and return the total.
|
|
1629
|
-
*
|
|
1630
|
-
* If `as` is empty, return the provided `startWith` value.
|
|
1631
|
-
*
|
|
1632
|
-
* @example
|
|
1633
|
-
* import { concatAll } from 'fp-ts/Semigroup'
|
|
1634
|
-
* import * as N from 'fp-ts/number'
|
|
1635
|
-
*
|
|
1636
|
-
* const sum = concatAll(N.SemigroupSum)(0)
|
|
1637
|
-
*
|
|
1638
|
-
* assert.deepStrictEqual(sum([1, 2, 3]), 6)
|
|
1639
|
-
* assert.deepStrictEqual(sum([]), 0)
|
|
1640
|
-
*
|
|
1641
|
-
* @since 2.10.0
|
|
1642
|
-
*/
|
|
1643
|
-
exports.concatAll = M.concatAll;
|
|
1644
|
-
// -------------------------------------------------------------------------------------
|
|
1645
|
-
// deprecated
|
|
1646
|
-
// -------------------------------------------------------------------------------------
|
|
1647
|
-
/**
|
|
1648
|
-
* Use `void` module instead.
|
|
1649
|
-
*
|
|
1650
|
-
* @category instances
|
|
1651
|
-
* @since 2.0.0
|
|
1652
|
-
* @deprecated
|
|
1653
|
-
*/
|
|
1654
|
-
exports.semigroupVoid = exports.constant(undefined);
|
|
1655
|
-
/**
|
|
1656
|
-
* Use [`getAssignSemigroup`](./struct.ts.html#getAssignSemigroup) instead.
|
|
1657
|
-
*
|
|
1658
|
-
* @category instances
|
|
1659
|
-
* @since 2.0.0
|
|
1660
|
-
* @deprecated
|
|
1661
|
-
*/
|
|
1662
|
-
var getObjectSemigroup = function () { return ({
|
|
1663
|
-
concat: function (first, second) { return Object.assign({}, first, second); }
|
|
1664
|
-
}); };
|
|
1665
|
-
exports.getObjectSemigroup = getObjectSemigroup;
|
|
1666
|
-
/**
|
|
1667
|
-
* Use [`last`](#last) instead.
|
|
1668
|
-
*
|
|
1669
|
-
* @category instances
|
|
1670
|
-
* @since 2.0.0
|
|
1671
|
-
* @deprecated
|
|
1672
|
-
*/
|
|
1673
|
-
exports.getLastSemigroup = exports.last;
|
|
1674
|
-
/**
|
|
1675
|
-
* Use [`first`](#first) instead.
|
|
1676
|
-
*
|
|
1677
|
-
* @category instances
|
|
1678
|
-
* @since 2.0.0
|
|
1679
|
-
* @deprecated
|
|
1680
|
-
*/
|
|
1681
|
-
exports.getFirstSemigroup = exports.first;
|
|
1682
|
-
/**
|
|
1683
|
-
* Use [`tuple`](#tuple) instead.
|
|
1684
|
-
*
|
|
1685
|
-
* @category combinators
|
|
1686
|
-
* @since 2.0.0
|
|
1687
|
-
* @deprecated
|
|
1688
|
-
*/
|
|
1689
|
-
exports.getTupleSemigroup = exports.tuple;
|
|
1690
|
-
/**
|
|
1691
|
-
* Use [`struct`](#struct) instead.
|
|
1692
|
-
*
|
|
1693
|
-
* @category combinators
|
|
1694
|
-
* @since 2.0.0
|
|
1695
|
-
* @deprecated
|
|
1696
|
-
*/
|
|
1697
|
-
exports.getStructSemigroup = exports.struct;
|
|
1698
|
-
/**
|
|
1699
|
-
* Use [`reverse`](#reverse) instead.
|
|
1700
|
-
*
|
|
1701
|
-
* @category combinators
|
|
1702
|
-
* @since 2.0.0
|
|
1703
|
-
* @deprecated
|
|
1704
|
-
*/
|
|
1705
|
-
exports.getDualSemigroup = exports.reverse;
|
|
1706
|
-
/**
|
|
1707
|
-
* Use [`max`](#max) instead.
|
|
1708
|
-
*
|
|
1709
|
-
* @category constructors
|
|
1710
|
-
* @since 2.0.0
|
|
1711
|
-
* @deprecated
|
|
1712
|
-
*/
|
|
1713
|
-
exports.getJoinSemigroup = exports.max;
|
|
1714
|
-
/**
|
|
1715
|
-
* Use [`min`](#min) instead.
|
|
1716
|
-
*
|
|
1717
|
-
* @category constructors
|
|
1718
|
-
* @since 2.0.0
|
|
1719
|
-
* @deprecated
|
|
1720
|
-
*/
|
|
1721
|
-
exports.getMeetSemigroup = exports.min;
|
|
1722
|
-
/**
|
|
1723
|
-
* Use [`intercalate`](#intercalate) instead.
|
|
1724
|
-
*
|
|
1725
|
-
* @category combinators
|
|
1726
|
-
* @since 2.5.0
|
|
1727
|
-
* @deprecated
|
|
1728
|
-
*/
|
|
1729
|
-
exports.getIntercalateSemigroup = exports.intercalate;
|
|
1730
|
-
function fold(S) {
|
|
1731
|
-
var concatAllS = exports.concatAll(S);
|
|
1732
|
-
return function (startWith, as) { return (as === undefined ? concatAllS(startWith) : concatAllS(startWith)(as)); };
|
|
1733
|
-
}
|
|
1734
|
-
exports.fold = fold;
|
|
1735
|
-
/**
|
|
1736
|
-
* Use [`SemigroupAll`](./boolean.ts.html#SemigroupAll) instead.
|
|
1737
|
-
*
|
|
1738
|
-
* @category instances
|
|
1739
|
-
* @since 2.0.0
|
|
1740
|
-
* @deprecated
|
|
1741
|
-
*/
|
|
1742
|
-
exports.semigroupAll = {
|
|
1743
|
-
concat: function (x, y) { return x && y; }
|
|
1744
|
-
};
|
|
1745
|
-
/**
|
|
1746
|
-
* Use [`SemigroupAny`](./boolean.ts.html#SemigroupAny) instead.
|
|
1747
|
-
*
|
|
1748
|
-
* @category instances
|
|
1749
|
-
* @since 2.0.0
|
|
1750
|
-
* @deprecated
|
|
1751
|
-
*/
|
|
1752
|
-
exports.semigroupAny = {
|
|
1753
|
-
concat: function (x, y) { return x || y; }
|
|
1754
|
-
};
|
|
1755
|
-
/**
|
|
1756
|
-
* Use [`getSemigroup`](./function.ts.html#getSemigroup) instead.
|
|
1757
|
-
*
|
|
1758
|
-
* @category instances
|
|
1759
|
-
* @since 2.0.0
|
|
1760
|
-
* @deprecated
|
|
1761
|
-
*/
|
|
1762
|
-
exports.getFunctionSemigroup = _function.getSemigroup;
|
|
1763
|
-
/**
|
|
1764
|
-
* Use [`Semigroup`](./string.ts.html#Semigroup) instead.
|
|
1765
|
-
*
|
|
1766
|
-
* @category instances
|
|
1767
|
-
* @since 2.0.0
|
|
1768
|
-
* @deprecated
|
|
1769
|
-
*/
|
|
1770
|
-
exports.semigroupString = {
|
|
1771
|
-
concat: function (x, y) { return x + y; }
|
|
1772
|
-
};
|
|
1773
|
-
/**
|
|
1774
|
-
* Use [`SemigroupSum`](./number.ts.html#SemigroupSum) instead.
|
|
1775
|
-
*
|
|
1776
|
-
* @category instances
|
|
1777
|
-
* @since 2.0.0
|
|
1778
|
-
* @deprecated
|
|
1779
|
-
*/
|
|
1780
|
-
exports.semigroupSum = {
|
|
1781
|
-
concat: function (x, y) { return x + y; }
|
|
1782
|
-
};
|
|
1783
|
-
/**
|
|
1784
|
-
* Use [`SemigroupProduct`](./number.ts.html#SemigroupProduct) instead.
|
|
1785
|
-
*
|
|
1786
|
-
* @category instances
|
|
1787
|
-
* @since 2.0.0
|
|
1788
|
-
* @deprecated
|
|
1789
|
-
*/
|
|
1790
|
-
exports.semigroupProduct = {
|
|
1791
|
-
concat: function (x, y) { return x * y; }
|
|
1792
|
-
};
|
|
1793
|
-
});
|
|
1794
|
-
|
|
1795
|
-
const Semigroup$1 = /*@__PURE__*/getDefaultExportFromCjs(Semigroup);
|
|
1796
|
-
|
|
1797
|
-
var Separated = createCommonjsModule(function (module, exports) {
|
|
1798
|
-
"use strict";
|
|
1799
|
-
/**
|
|
1800
|
-
* ```ts
|
|
1801
|
-
* interface Separated<E, A> {
|
|
1802
|
-
* readonly left: E
|
|
1803
|
-
* readonly right: A
|
|
1804
|
-
* }
|
|
1805
|
-
* ```
|
|
1806
|
-
*
|
|
1807
|
-
* Represents a result of separating a whole into two parts.
|
|
1808
|
-
*
|
|
1809
|
-
* @since 2.10.0
|
|
1810
|
-
*/
|
|
1811
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1812
|
-
exports.right = exports.left = exports.flap = exports.Functor = exports.Bifunctor = exports.URI = exports.bimap = exports.mapLeft = exports.map = exports.separated = void 0;
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
// -------------------------------------------------------------------------------------
|
|
1816
|
-
// constructors
|
|
1817
|
-
// -------------------------------------------------------------------------------------
|
|
1818
|
-
/**
|
|
1819
|
-
* @category constructors
|
|
1820
|
-
* @since 2.10.0
|
|
1821
|
-
*/
|
|
1822
|
-
var separated = function (left, right) { return ({ left: left, right: right }); };
|
|
1823
|
-
exports.separated = separated;
|
|
1824
|
-
// -------------------------------------------------------------------------------------
|
|
1825
|
-
// non-pipeables
|
|
1826
|
-
// -------------------------------------------------------------------------------------
|
|
1827
|
-
var _map = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
|
|
1828
|
-
var _mapLeft = function (fa, f) { return _function.pipe(fa, exports.mapLeft(f)); };
|
|
1829
|
-
var _bimap = function (fa, g, f) { return _function.pipe(fa, exports.bimap(g, f)); };
|
|
1830
|
-
// -------------------------------------------------------------------------------------
|
|
1831
|
-
// type class members
|
|
1832
|
-
// -------------------------------------------------------------------------------------
|
|
1833
|
-
/**
|
|
1834
|
-
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
|
|
1835
|
-
* use the type constructor `F` to represent some computational context.
|
|
1836
|
-
*
|
|
1837
|
-
* @category Functor
|
|
1838
|
-
* @since 2.10.0
|
|
1839
|
-
*/
|
|
1840
|
-
var map = function (f) { return function (fa) {
|
|
1841
|
-
return exports.separated(exports.left(fa), f(exports.right(fa)));
|
|
1842
|
-
}; };
|
|
1843
|
-
exports.map = map;
|
|
1844
|
-
/**
|
|
1845
|
-
* Map a function over the first type argument of a bifunctor.
|
|
1846
|
-
*
|
|
1847
|
-
* @category Bifunctor
|
|
1848
|
-
* @since 2.10.0
|
|
1849
|
-
*/
|
|
1850
|
-
var mapLeft = function (f) { return function (fa) {
|
|
1851
|
-
return exports.separated(f(exports.left(fa)), exports.right(fa));
|
|
1852
|
-
}; };
|
|
1853
|
-
exports.mapLeft = mapLeft;
|
|
1854
|
-
/**
|
|
1855
|
-
* Map a pair of functions over the two type arguments of the bifunctor.
|
|
1856
|
-
*
|
|
1857
|
-
* @category Bifunctor
|
|
1858
|
-
* @since 2.10.0
|
|
1859
|
-
*/
|
|
1860
|
-
var bimap = function (f, g) { return function (fa) {
|
|
1861
|
-
return exports.separated(f(exports.left(fa)), g(exports.right(fa)));
|
|
1862
|
-
}; };
|
|
1863
|
-
exports.bimap = bimap;
|
|
1864
|
-
// -------------------------------------------------------------------------------------
|
|
1865
|
-
// instances
|
|
1866
|
-
// -------------------------------------------------------------------------------------
|
|
1867
|
-
/**
|
|
1868
|
-
* @category instances
|
|
1869
|
-
* @since 2.10.0
|
|
1870
|
-
*/
|
|
1871
|
-
exports.URI = 'Separated';
|
|
1872
|
-
/**
|
|
1873
|
-
* @category instances
|
|
1874
|
-
* @since 2.10.0
|
|
1875
|
-
*/
|
|
1876
|
-
exports.Bifunctor = {
|
|
1877
|
-
URI: exports.URI,
|
|
1878
|
-
mapLeft: _mapLeft,
|
|
1879
|
-
bimap: _bimap
|
|
1880
|
-
};
|
|
1881
|
-
/**
|
|
1882
|
-
* @category instances
|
|
1883
|
-
* @since 2.10.0
|
|
1884
|
-
*/
|
|
1885
|
-
exports.Functor = {
|
|
1886
|
-
URI: exports.URI,
|
|
1887
|
-
map: _map
|
|
1888
|
-
};
|
|
1889
|
-
/**
|
|
1890
|
-
* Derivable from `Functor`.
|
|
1891
|
-
*
|
|
1892
|
-
* @category combinators
|
|
1893
|
-
* @since 2.10.0
|
|
1894
|
-
*/
|
|
1895
|
-
exports.flap =
|
|
1896
|
-
/*#__PURE__*/
|
|
1897
|
-
Functor.flap(exports.Functor);
|
|
1898
|
-
// -------------------------------------------------------------------------------------
|
|
1899
|
-
// utils
|
|
1900
|
-
// -------------------------------------------------------------------------------------
|
|
1901
|
-
/**
|
|
1902
|
-
* @since 2.10.0
|
|
1903
|
-
*/
|
|
1904
|
-
var left = function (s) { return s.left; };
|
|
1905
|
-
exports.left = left;
|
|
1906
|
-
/**
|
|
1907
|
-
* @since 2.10.0
|
|
1908
|
-
*/
|
|
1909
|
-
var right = function (s) { return s.right; };
|
|
1910
|
-
exports.right = right;
|
|
1911
|
-
});
|
|
1912
|
-
|
|
1913
|
-
const Separated$1 = /*@__PURE__*/getDefaultExportFromCjs(Separated);
|
|
1914
|
-
|
|
1915
|
-
var Witherable = createCommonjsModule(function (module, exports) {
|
|
1916
|
-
"use strict";
|
|
1917
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1918
|
-
if (k2 === undefined) k2 = k;
|
|
1919
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1920
|
-
}) : (function(o, m, k, k2) {
|
|
1921
|
-
if (k2 === undefined) k2 = k;
|
|
1922
|
-
o[k2] = m[k];
|
|
1923
|
-
}));
|
|
1924
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1925
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1926
|
-
}) : function(o, v) {
|
|
1927
|
-
o["default"] = v;
|
|
1928
|
-
});
|
|
1929
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
1930
|
-
if (mod && mod.__esModule) return mod;
|
|
1931
|
-
var result = {};
|
|
1932
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1933
|
-
__setModuleDefault(result, mod);
|
|
1934
|
-
return result;
|
|
1935
|
-
};
|
|
1936
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1937
|
-
exports.filterE = exports.witherDefault = exports.wiltDefault = void 0;
|
|
1938
|
-
var _ = __importStar(internal);
|
|
1939
|
-
function wiltDefault(T, C) {
|
|
1940
|
-
return function (F) {
|
|
1941
|
-
var traverseF = T.traverse(F);
|
|
1942
|
-
return function (wa, f) { return F.map(traverseF(wa, f), C.separate); };
|
|
1943
|
-
};
|
|
1944
|
-
}
|
|
1945
|
-
exports.wiltDefault = wiltDefault;
|
|
1946
|
-
function witherDefault(T, C) {
|
|
1947
|
-
return function (F) {
|
|
1948
|
-
var traverseF = T.traverse(F);
|
|
1949
|
-
return function (wa, f) { return F.map(traverseF(wa, f), C.compact); };
|
|
1950
|
-
};
|
|
1951
|
-
}
|
|
1952
|
-
exports.witherDefault = witherDefault;
|
|
1953
|
-
function filterE(W) {
|
|
1954
|
-
return function (F) {
|
|
1955
|
-
var witherF = W.wither(F);
|
|
1956
|
-
return function (predicate) { return function (ga) { return witherF(ga, function (a) { return F.map(predicate(a), function (b) { return (b ? _.some(a) : _.none); }); }); }; };
|
|
1957
|
-
};
|
|
1958
|
-
}
|
|
1959
|
-
exports.filterE = filterE;
|
|
1960
|
-
});
|
|
1961
|
-
|
|
1962
|
-
const Witherable$1 = /*@__PURE__*/getDefaultExportFromCjs(Witherable);
|
|
1963
|
-
|
|
1964
|
-
var Zero = createCommonjsModule(function (module, exports) {
|
|
1965
|
-
"use strict";
|
|
1966
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1967
|
-
exports.guard = void 0;
|
|
1968
|
-
function guard(F, P) {
|
|
1969
|
-
return function (b) { return (b ? P.of(undefined) : F.zero()); };
|
|
1970
|
-
}
|
|
1971
|
-
exports.guard = guard;
|
|
1972
|
-
});
|
|
1973
|
-
|
|
1974
|
-
const Zero$1 = /*@__PURE__*/getDefaultExportFromCjs(Zero);
|
|
1975
|
-
|
|
1976
|
-
var ReadonlyNonEmptyArray = createCommonjsModule(function (module, exports) {
|
|
1977
|
-
"use strict";
|
|
1978
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1979
|
-
if (k2 === undefined) k2 = k;
|
|
1980
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1981
|
-
}) : (function(o, m, k, k2) {
|
|
1982
|
-
if (k2 === undefined) k2 = k;
|
|
1983
|
-
o[k2] = m[k];
|
|
1984
|
-
}));
|
|
1985
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1986
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1987
|
-
}) : function(o, v) {
|
|
1988
|
-
o["default"] = v;
|
|
1989
|
-
});
|
|
1990
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
1991
|
-
if (mod && mod.__esModule) return mod;
|
|
1992
|
-
var result = {};
|
|
1993
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1994
|
-
__setModuleDefault(result, mod);
|
|
1995
|
-
return result;
|
|
1996
|
-
};
|
|
1997
|
-
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from) {
|
|
1998
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
1999
|
-
to[j] = from[i];
|
|
2000
|
-
return to;
|
|
2001
|
-
};
|
|
2002
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2003
|
-
exports.reduceRight = exports.foldMap = exports.reduce = exports.mapWithIndex = exports.map = exports.flatten = exports.duplicate = exports.extend = exports.chain = exports.ap = exports.alt = exports.altW = exports.of = exports.chunksOf = exports.splitAt = exports.chop = exports.chainWithIndex = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = exports.modifyAt = exports.updateAt = exports.sort = exports.groupBy = exports.group = exports.reverse = exports.concat = exports.concatW = exports.fromArray = exports.unappend = exports.unprepend = exports.range = exports.replicate = exports.makeBy = exports.fromReadonlyArray = exports.rotate = exports.union = exports.sortBy = exports.uniq = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.append = exports.appendW = exports.prepend = exports.prependW = exports.isOutOfBound = exports.isNonEmpty = exports.empty = void 0;
|
|
2004
|
-
exports.uncons = exports.filterWithIndex = exports.filter = exports.groupSort = exports.updateLast = exports.modifyLast = exports.updateHead = exports.modifyHead = exports.matchRight = exports.matchLeft = exports.concatAll = exports.max = exports.min = exports.init = exports.last = exports.tail = exports.head = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.chainFirst = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getUnionSemigroup = exports.getEq = exports.getSemigroup = exports.getShow = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.foldMapWithIndex = exports.reduceWithIndex = void 0;
|
|
2005
|
-
exports.readonlyNonEmptyArray = exports.fold = exports.prependToAll = exports.insertAt = exports.snoc = exports.cons = exports.unsnoc = void 0;
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
var _ = __importStar(internal);
|
|
2012
|
-
|
|
2013
|
-
var Se = __importStar(Semigroup);
|
|
2014
|
-
// -------------------------------------------------------------------------------------
|
|
2015
|
-
// internal
|
|
2016
|
-
// -------------------------------------------------------------------------------------
|
|
2017
|
-
/**
|
|
2018
|
-
* @internal
|
|
2019
|
-
*/
|
|
2020
|
-
exports.empty = _.emptyReadonlyArray;
|
|
2021
|
-
/**
|
|
2022
|
-
* @internal
|
|
2023
|
-
*/
|
|
2024
|
-
exports.isNonEmpty = _.isNonEmpty;
|
|
2025
|
-
/**
|
|
2026
|
-
* @internal
|
|
2027
|
-
*/
|
|
2028
|
-
var isOutOfBound = function (i, as) { return i < 0 || i >= as.length; };
|
|
2029
|
-
exports.isOutOfBound = isOutOfBound;
|
|
2030
|
-
/**
|
|
2031
|
-
* @internal
|
|
2032
|
-
*/
|
|
2033
|
-
var prependW = function (head) { return function (tail) { return __spreadArray([head], tail); }; };
|
|
2034
|
-
exports.prependW = prependW;
|
|
2035
|
-
/**
|
|
2036
|
-
* @internal
|
|
2037
|
-
*/
|
|
2038
|
-
exports.prepend = exports.prependW;
|
|
2039
|
-
/**
|
|
2040
|
-
* @internal
|
|
2041
|
-
*/
|
|
2042
|
-
var appendW = function (end) { return function (init) { return __spreadArray(__spreadArray([], init), [end]); }; };
|
|
2043
|
-
exports.appendW = appendW;
|
|
2044
|
-
/**
|
|
2045
|
-
* @internal
|
|
2046
|
-
*/
|
|
2047
|
-
exports.append = exports.appendW;
|
|
2048
|
-
/**
|
|
2049
|
-
* @internal
|
|
2050
|
-
*/
|
|
2051
|
-
var unsafeInsertAt = function (i, a, as) {
|
|
2052
|
-
if (exports.isNonEmpty(as)) {
|
|
2053
|
-
var xs = _.fromReadonlyNonEmptyArray(as);
|
|
2054
|
-
xs.splice(i, 0, a);
|
|
2055
|
-
return xs;
|
|
2056
|
-
}
|
|
2057
|
-
return [a];
|
|
2058
|
-
};
|
|
2059
|
-
exports.unsafeInsertAt = unsafeInsertAt;
|
|
2060
|
-
/**
|
|
2061
|
-
* @internal
|
|
2062
|
-
*/
|
|
2063
|
-
var unsafeUpdateAt = function (i, a, as) {
|
|
2064
|
-
if (as[i] === a) {
|
|
2065
|
-
return as;
|
|
2066
|
-
}
|
|
2067
|
-
else {
|
|
2068
|
-
var xs = _.fromReadonlyNonEmptyArray(as);
|
|
2069
|
-
xs[i] = a;
|
|
2070
|
-
return xs;
|
|
2071
|
-
}
|
|
2072
|
-
};
|
|
2073
|
-
exports.unsafeUpdateAt = unsafeUpdateAt;
|
|
2074
|
-
/**
|
|
2075
|
-
* Remove duplicates from a `ReadonlyNonEmptyArray`, keeping the first occurrence of an element.
|
|
2076
|
-
*
|
|
2077
|
-
* @example
|
|
2078
|
-
* import { uniq } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2079
|
-
* import * as N from 'fp-ts/number'
|
|
2080
|
-
*
|
|
2081
|
-
* assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])
|
|
2082
|
-
*
|
|
2083
|
-
* @category combinators
|
|
2084
|
-
* @since 2.11.0
|
|
2085
|
-
*/
|
|
2086
|
-
var uniq = function (E) { return function (as) {
|
|
2087
|
-
if (as.length === 1) {
|
|
2088
|
-
return as;
|
|
2089
|
-
}
|
|
2090
|
-
var out = [exports.head(as)];
|
|
2091
|
-
var rest = exports.tail(as);
|
|
2092
|
-
var _loop_1 = function (a) {
|
|
2093
|
-
if (out.every(function (o) { return !E.equals(o, a); })) {
|
|
2094
|
-
out.push(a);
|
|
2095
|
-
}
|
|
2096
|
-
};
|
|
2097
|
-
for (var _i = 0, rest_1 = rest; _i < rest_1.length; _i++) {
|
|
2098
|
-
var a = rest_1[_i];
|
|
2099
|
-
_loop_1(a);
|
|
2100
|
-
}
|
|
2101
|
-
return out;
|
|
2102
|
-
}; };
|
|
2103
|
-
exports.uniq = uniq;
|
|
2104
|
-
/**
|
|
2105
|
-
* Sort the elements of a `ReadonlyNonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,
|
|
2106
|
-
* etc...
|
|
2107
|
-
*
|
|
2108
|
-
* @example
|
|
2109
|
-
* import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2110
|
-
* import { contramap } from 'fp-ts/Ord'
|
|
2111
|
-
* import * as S from 'fp-ts/string'
|
|
2112
|
-
* import * as N from 'fp-ts/number'
|
|
2113
|
-
* import { pipe } from 'fp-ts/function'
|
|
2114
|
-
*
|
|
2115
|
-
* interface Person {
|
|
2116
|
-
* name: string
|
|
2117
|
-
* age: number
|
|
2118
|
-
* }
|
|
2119
|
-
*
|
|
2120
|
-
* const byName = pipe(S.Ord, contramap((p: Person) => p.name))
|
|
2121
|
-
*
|
|
2122
|
-
* const byAge = pipe(N.Ord, contramap((p: Person) => p.age))
|
|
2123
|
-
*
|
|
2124
|
-
* const sortByNameByAge = RNEA.sortBy([byName, byAge])
|
|
2125
|
-
*
|
|
2126
|
-
* const persons: RNEA.ReadonlyNonEmptyArray<Person> = [
|
|
2127
|
-
* { name: 'a', age: 1 },
|
|
2128
|
-
* { name: 'b', age: 3 },
|
|
2129
|
-
* { name: 'c', age: 2 },
|
|
2130
|
-
* { name: 'b', age: 2 }
|
|
2131
|
-
* ]
|
|
2132
|
-
*
|
|
2133
|
-
* assert.deepStrictEqual(sortByNameByAge(persons), [
|
|
2134
|
-
* { name: 'a', age: 1 },
|
|
2135
|
-
* { name: 'b', age: 2 },
|
|
2136
|
-
* { name: 'b', age: 3 },
|
|
2137
|
-
* { name: 'c', age: 2 }
|
|
2138
|
-
* ])
|
|
2139
|
-
*
|
|
2140
|
-
* @category combinators
|
|
2141
|
-
* @since 2.11.0
|
|
2142
|
-
*/
|
|
2143
|
-
var sortBy = function (ords) {
|
|
2144
|
-
if (exports.isNonEmpty(ords)) {
|
|
2145
|
-
var M = Ord.getMonoid();
|
|
2146
|
-
return exports.sort(ords.reduce(M.concat, M.empty));
|
|
2147
|
-
}
|
|
2148
|
-
return _function.identity;
|
|
2149
|
-
};
|
|
2150
|
-
exports.sortBy = sortBy;
|
|
2151
|
-
/**
|
|
2152
|
-
* @category combinators
|
|
2153
|
-
* @since 2.11.0
|
|
2154
|
-
*/
|
|
2155
|
-
var union = function (E) {
|
|
2156
|
-
var uniqE = exports.uniq(E);
|
|
2157
|
-
return function (second) { return function (first) { return uniqE(_function.pipe(first, concat(second))); }; };
|
|
2158
|
-
};
|
|
2159
|
-
exports.union = union;
|
|
2160
|
-
/**
|
|
2161
|
-
* Rotate a `ReadonlyNonEmptyArray` by `n` steps.
|
|
2162
|
-
*
|
|
2163
|
-
* @example
|
|
2164
|
-
* import { rotate } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2165
|
-
*
|
|
2166
|
-
* assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
|
|
2167
|
-
* assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])
|
|
2168
|
-
*
|
|
2169
|
-
* @category combinators
|
|
2170
|
-
* @since 2.11.0
|
|
2171
|
-
*/
|
|
2172
|
-
var rotate = function (n) { return function (as) {
|
|
2173
|
-
var len = as.length;
|
|
2174
|
-
var m = Math.round(n) % len;
|
|
2175
|
-
if (exports.isOutOfBound(Math.abs(m), as) || m === 0) {
|
|
2176
|
-
return as;
|
|
2177
|
-
}
|
|
2178
|
-
if (m < 0) {
|
|
2179
|
-
var _a = exports.splitAt(-m)(as), f = _a[0], s = _a[1];
|
|
2180
|
-
return _function.pipe(s, concat(f));
|
|
2181
|
-
}
|
|
2182
|
-
else {
|
|
2183
|
-
return exports.rotate(m - len)(as);
|
|
2184
|
-
}
|
|
2185
|
-
}; };
|
|
2186
|
-
exports.rotate = rotate;
|
|
2187
|
-
// -------------------------------------------------------------------------------------
|
|
2188
|
-
// constructors
|
|
2189
|
-
// -------------------------------------------------------------------------------------
|
|
2190
|
-
/**
|
|
2191
|
-
* Return a `ReadonlyNonEmptyArray` from a `ReadonlyArray` returning `none` if the input is empty.
|
|
2192
|
-
*
|
|
2193
|
-
* @category constructors
|
|
2194
|
-
* @since 2.5.0
|
|
2195
|
-
*/
|
|
2196
|
-
var fromReadonlyArray = function (as) {
|
|
2197
|
-
return exports.isNonEmpty(as) ? _.some(as) : _.none;
|
|
2198
|
-
};
|
|
2199
|
-
exports.fromReadonlyArray = fromReadonlyArray;
|
|
2200
|
-
/**
|
|
2201
|
-
* Return a `ReadonlyNonEmptyArray` of length `n` with element `i` initialized with `f(i)`.
|
|
2202
|
-
*
|
|
2203
|
-
* **Note**. `n` is normalized to a natural number.
|
|
2204
|
-
*
|
|
2205
|
-
* @example
|
|
2206
|
-
* import { makeBy } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2207
|
-
* import { pipe } from 'fp-ts/function'
|
|
2208
|
-
*
|
|
2209
|
-
* const double = (n: number): number => n * 2
|
|
2210
|
-
* assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])
|
|
2211
|
-
*
|
|
2212
|
-
* @category constructors
|
|
2213
|
-
* @since 2.11.0
|
|
2214
|
-
*/
|
|
2215
|
-
var makeBy = function (f) { return function (n) {
|
|
2216
|
-
var j = Math.max(0, Math.floor(n));
|
|
2217
|
-
var out = [f(0)];
|
|
2218
|
-
for (var i = 1; i < j; i++) {
|
|
2219
|
-
out.push(f(i));
|
|
2220
|
-
}
|
|
2221
|
-
return out;
|
|
2222
|
-
}; };
|
|
2223
|
-
exports.makeBy = makeBy;
|
|
2224
|
-
/**
|
|
2225
|
-
* Create a `ReadonlyNonEmptyArray` containing a value repeated the specified number of times.
|
|
2226
|
-
*
|
|
2227
|
-
* **Note**. `n` is normalized to a natural number.
|
|
2228
|
-
*
|
|
2229
|
-
* @example
|
|
2230
|
-
* import { replicate } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2231
|
-
* import { pipe } from 'fp-ts/function'
|
|
2232
|
-
*
|
|
2233
|
-
* assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])
|
|
2234
|
-
*
|
|
2235
|
-
* @category constructors
|
|
2236
|
-
* @since 2.11.0
|
|
2237
|
-
*/
|
|
2238
|
-
var replicate = function (a) { return exports.makeBy(function () { return a; }); };
|
|
2239
|
-
exports.replicate = replicate;
|
|
2240
|
-
/**
|
|
2241
|
-
* Create a `ReadonlyNonEmptyArray` containing a range of integers, including both endpoints.
|
|
2242
|
-
*
|
|
2243
|
-
* @example
|
|
2244
|
-
* import { range } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2245
|
-
*
|
|
2246
|
-
* assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])
|
|
2247
|
-
*
|
|
2248
|
-
* @category constructors
|
|
2249
|
-
* @since 2.11.0
|
|
2250
|
-
*/
|
|
2251
|
-
var range = function (start, end) {
|
|
2252
|
-
return start <= end ? exports.makeBy(function (i) { return start + i; })(end - start + 1) : [start];
|
|
2253
|
-
};
|
|
2254
|
-
exports.range = range;
|
|
2255
|
-
// -------------------------------------------------------------------------------------
|
|
2256
|
-
// destructors
|
|
2257
|
-
// -------------------------------------------------------------------------------------
|
|
2258
|
-
/**
|
|
2259
|
-
* Return the tuple of the `head` and the `tail`.
|
|
2260
|
-
*
|
|
2261
|
-
* @example
|
|
2262
|
-
* import { unprepend } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2263
|
-
*
|
|
2264
|
-
* assert.deepStrictEqual(unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])
|
|
2265
|
-
*
|
|
2266
|
-
* @category destructors
|
|
2267
|
-
* @since 2.9.0
|
|
2268
|
-
*/
|
|
2269
|
-
var unprepend = function (as) { return [exports.head(as), exports.tail(as)]; };
|
|
2270
|
-
exports.unprepend = unprepend;
|
|
2271
|
-
/**
|
|
2272
|
-
* Return the tuple of the `init` and the `last`.
|
|
2273
|
-
*
|
|
2274
|
-
* @example
|
|
2275
|
-
* import { unappend } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2276
|
-
*
|
|
2277
|
-
* assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])
|
|
2278
|
-
*
|
|
2279
|
-
* @category destructors
|
|
2280
|
-
* @since 2.9.0
|
|
2281
|
-
*/
|
|
2282
|
-
var unappend = function (as) { return [exports.init(as), exports.last(as)]; };
|
|
2283
|
-
exports.unappend = unappend;
|
|
2284
|
-
// -------------------------------------------------------------------------------------
|
|
2285
|
-
// interop
|
|
2286
|
-
// -------------------------------------------------------------------------------------
|
|
2287
|
-
/**
|
|
2288
|
-
* @category interop
|
|
2289
|
-
* @since 2.5.0
|
|
2290
|
-
*/
|
|
2291
|
-
var fromArray = function (as) { return exports.fromReadonlyArray(as.slice()); };
|
|
2292
|
-
exports.fromArray = fromArray;
|
|
2293
|
-
function concatW(second) {
|
|
2294
|
-
return function (first) { return first.concat(second); };
|
|
2295
|
-
}
|
|
2296
|
-
exports.concatW = concatW;
|
|
2297
|
-
function concat(x, y) {
|
|
2298
|
-
return y ? x.concat(y) : function (y) { return y.concat(x); };
|
|
2299
|
-
}
|
|
2300
|
-
exports.concat = concat;
|
|
2301
|
-
/**
|
|
2302
|
-
* @category combinators
|
|
2303
|
-
* @since 2.5.0
|
|
2304
|
-
*/
|
|
2305
|
-
var reverse = function (as) {
|
|
2306
|
-
return as.length === 1 ? as : __spreadArray([exports.last(as)], as.slice(0, -1).reverse());
|
|
2307
|
-
};
|
|
2308
|
-
exports.reverse = reverse;
|
|
2309
|
-
function group(E) {
|
|
2310
|
-
return function (as) {
|
|
2311
|
-
var len = as.length;
|
|
2312
|
-
if (len === 0) {
|
|
2313
|
-
return exports.empty;
|
|
2314
|
-
}
|
|
2315
|
-
var out = [];
|
|
2316
|
-
var head = as[0];
|
|
2317
|
-
var nea = [head];
|
|
2318
|
-
for (var i = 1; i < len; i++) {
|
|
2319
|
-
var a = as[i];
|
|
2320
|
-
if (E.equals(a, head)) {
|
|
2321
|
-
nea.push(a);
|
|
2322
|
-
}
|
|
2323
|
-
else {
|
|
2324
|
-
out.push(nea);
|
|
2325
|
-
head = a;
|
|
2326
|
-
nea = [head];
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
out.push(nea);
|
|
2330
|
-
return out;
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
exports.group = group;
|
|
2334
|
-
/**
|
|
2335
|
-
* Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning
|
|
2336
|
-
* function on each element, and grouping the results according to values returned
|
|
2337
|
-
*
|
|
2338
|
-
* @example
|
|
2339
|
-
* import { groupBy } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2340
|
-
*
|
|
2341
|
-
* assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {
|
|
2342
|
-
* '1': ['a', 'b'],
|
|
2343
|
-
* '2': ['ab']
|
|
2344
|
-
* })
|
|
2345
|
-
*
|
|
2346
|
-
* @category combinators
|
|
2347
|
-
* @since 2.5.0
|
|
2348
|
-
*/
|
|
2349
|
-
var groupBy = function (f) { return function (as) {
|
|
2350
|
-
var out = {};
|
|
2351
|
-
for (var _i = 0, as_1 = as; _i < as_1.length; _i++) {
|
|
2352
|
-
var a = as_1[_i];
|
|
2353
|
-
var k = f(a);
|
|
2354
|
-
if (out.hasOwnProperty(k)) {
|
|
2355
|
-
out[k].push(a);
|
|
2356
|
-
}
|
|
2357
|
-
else {
|
|
2358
|
-
out[k] = [a];
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return out;
|
|
2362
|
-
}; };
|
|
2363
|
-
exports.groupBy = groupBy;
|
|
2364
|
-
/**
|
|
2365
|
-
* @category combinators
|
|
2366
|
-
* @since 2.5.0
|
|
2367
|
-
*/
|
|
2368
|
-
var sort = function (O) { return function (as) {
|
|
2369
|
-
return as.length === 1 ? as : as.slice().sort(O.compare);
|
|
2370
|
-
}; };
|
|
2371
|
-
exports.sort = sort;
|
|
2372
|
-
/**
|
|
2373
|
-
* @category combinators
|
|
2374
|
-
* @since 2.5.0
|
|
2375
|
-
*/
|
|
2376
|
-
var updateAt = function (i, a) {
|
|
2377
|
-
return exports.modifyAt(i, function () { return a; });
|
|
2378
|
-
};
|
|
2379
|
-
exports.updateAt = updateAt;
|
|
2380
|
-
/**
|
|
2381
|
-
* @category combinators
|
|
2382
|
-
* @since 2.5.0
|
|
2383
|
-
*/
|
|
2384
|
-
var modifyAt = function (i, f) { return function (as) { return (exports.isOutOfBound(i, as) ? _.none : _.some(exports.unsafeUpdateAt(i, f(as[i]), as))); }; };
|
|
2385
|
-
exports.modifyAt = modifyAt;
|
|
2386
|
-
/**
|
|
2387
|
-
* @category combinators
|
|
2388
|
-
* @since 2.5.1
|
|
2389
|
-
*/
|
|
2390
|
-
var zipWith = function (as, bs, f) {
|
|
2391
|
-
var cs = [f(as[0], bs[0])];
|
|
2392
|
-
var len = Math.min(as.length, bs.length);
|
|
2393
|
-
for (var i = 1; i < len; i++) {
|
|
2394
|
-
cs[i] = f(as[i], bs[i]);
|
|
2395
|
-
}
|
|
2396
|
-
return cs;
|
|
2397
|
-
};
|
|
2398
|
-
exports.zipWith = zipWith;
|
|
2399
|
-
function zip(as, bs) {
|
|
2400
|
-
if (bs === undefined) {
|
|
2401
|
-
return function (bs) { return zip(bs, as); };
|
|
2402
|
-
}
|
|
2403
|
-
return exports.zipWith(as, bs, function (a, b) { return [a, b]; });
|
|
2404
|
-
}
|
|
2405
|
-
exports.zip = zip;
|
|
2406
|
-
/**
|
|
2407
|
-
* @category combinators
|
|
2408
|
-
* @since 2.5.1
|
|
2409
|
-
*/
|
|
2410
|
-
var unzip = function (abs) {
|
|
2411
|
-
var fa = [abs[0][0]];
|
|
2412
|
-
var fb = [abs[0][1]];
|
|
2413
|
-
for (var i = 1; i < abs.length; i++) {
|
|
2414
|
-
fa[i] = abs[i][0];
|
|
2415
|
-
fb[i] = abs[i][1];
|
|
2416
|
-
}
|
|
2417
|
-
return [fa, fb];
|
|
2418
|
-
};
|
|
2419
|
-
exports.unzip = unzip;
|
|
2420
|
-
/**
|
|
2421
|
-
* Prepend an element to every member of a `ReadonlyNonEmptyArray`.
|
|
2422
|
-
*
|
|
2423
|
-
* @example
|
|
2424
|
-
* import { prependAll } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2425
|
-
*
|
|
2426
|
-
* assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])
|
|
2427
|
-
*
|
|
2428
|
-
* @category combinators
|
|
2429
|
-
* @since 2.10.0
|
|
2430
|
-
*/
|
|
2431
|
-
var prependAll = function (middle) { return function (as) {
|
|
2432
|
-
var out = [middle, as[0]];
|
|
2433
|
-
for (var i = 1; i < as.length; i++) {
|
|
2434
|
-
out.push(middle, as[i]);
|
|
2435
|
-
}
|
|
2436
|
-
return out;
|
|
2437
|
-
}; };
|
|
2438
|
-
exports.prependAll = prependAll;
|
|
2439
|
-
/**
|
|
2440
|
-
* Places an element in between members of a `ReadonlyNonEmptyArray`.
|
|
2441
|
-
*
|
|
2442
|
-
* @example
|
|
2443
|
-
* import { intersperse } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2444
|
-
*
|
|
2445
|
-
* assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])
|
|
2446
|
-
*
|
|
2447
|
-
* @category combinators
|
|
2448
|
-
* @since 2.9.0
|
|
2449
|
-
*/
|
|
2450
|
-
var intersperse = function (middle) { return function (as) {
|
|
2451
|
-
var rest = exports.tail(as);
|
|
2452
|
-
return exports.isNonEmpty(rest) ? _function.pipe(rest, exports.prependAll(middle), exports.prepend(exports.head(as))) : as;
|
|
2453
|
-
}; };
|
|
2454
|
-
exports.intersperse = intersperse;
|
|
2455
|
-
/**
|
|
2456
|
-
* @category combinators
|
|
2457
|
-
* @since 2.10.0
|
|
2458
|
-
*/
|
|
2459
|
-
var chainWithIndex = function (f) { return function (as) {
|
|
2460
|
-
var out = _.fromReadonlyNonEmptyArray(f(0, exports.head(as)));
|
|
2461
|
-
for (var i = 1; i < as.length; i++) {
|
|
2462
|
-
out.push.apply(out, f(i, as[i]));
|
|
2463
|
-
}
|
|
2464
|
-
return out;
|
|
2465
|
-
}; };
|
|
2466
|
-
exports.chainWithIndex = chainWithIndex;
|
|
2467
|
-
/**
|
|
2468
|
-
* A useful recursion pattern for processing a `ReadonlyNonEmptyArray` to produce a new `ReadonlyNonEmptyArray`, often used for "chopping" up the input
|
|
2469
|
-
* `ReadonlyNonEmptyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyNonEmptyArray` and produce a
|
|
2470
|
-
* value and the tail of the `ReadonlyNonEmptyArray`.
|
|
2471
|
-
*
|
|
2472
|
-
* @category combinators
|
|
2473
|
-
* @since 2.10.0
|
|
2474
|
-
*/
|
|
2475
|
-
var chop = function (f) { return function (as) {
|
|
2476
|
-
var _a = f(as), b = _a[0], rest = _a[1];
|
|
2477
|
-
var out = [b];
|
|
2478
|
-
var next = rest;
|
|
2479
|
-
while (exports.isNonEmpty(next)) {
|
|
2480
|
-
var _b = f(next), b_1 = _b[0], rest_2 = _b[1];
|
|
2481
|
-
out.push(b_1);
|
|
2482
|
-
next = rest_2;
|
|
2483
|
-
}
|
|
2484
|
-
return out;
|
|
2485
|
-
}; };
|
|
2486
|
-
exports.chop = chop;
|
|
2487
|
-
/**
|
|
2488
|
-
* Splits a `ReadonlyNonEmptyArray` into two pieces, the first piece has max `n` elements.
|
|
2489
|
-
*
|
|
2490
|
-
* @category combinators
|
|
2491
|
-
* @since 2.10.0
|
|
2492
|
-
*/
|
|
2493
|
-
var splitAt = function (n) { return function (as) {
|
|
2494
|
-
var m = Math.max(1, n);
|
|
2495
|
-
return m >= as.length ? [as, exports.empty] : [_function.pipe(as.slice(1, m), exports.prepend(exports.head(as))), as.slice(m)];
|
|
2496
|
-
}; };
|
|
2497
|
-
exports.splitAt = splitAt;
|
|
2498
|
-
/**
|
|
2499
|
-
* Splits a `ReadonlyNonEmptyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of
|
|
2500
|
-
* the `ReadonlyNonEmptyArray`.
|
|
2501
|
-
*
|
|
2502
|
-
* @category combinators
|
|
2503
|
-
* @since 2.10.0
|
|
2504
|
-
*/
|
|
2505
|
-
var chunksOf = function (n) { return exports.chop(exports.splitAt(n)); };
|
|
2506
|
-
exports.chunksOf = chunksOf;
|
|
2507
|
-
// -------------------------------------------------------------------------------------
|
|
2508
|
-
// non-pipeables
|
|
2509
|
-
// -------------------------------------------------------------------------------------
|
|
2510
|
-
var _map = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
|
|
2511
|
-
/* istanbul ignore next */
|
|
2512
|
-
var _mapWithIndex = function (fa, f) { return _function.pipe(fa, exports.mapWithIndex(f)); };
|
|
2513
|
-
var _ap = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
|
|
2514
|
-
var _chain = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
|
|
2515
|
-
/* istanbul ignore next */
|
|
2516
|
-
var _extend = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
|
|
2517
|
-
/* istanbul ignore next */
|
|
2518
|
-
var _reduce = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
|
|
2519
|
-
/* istanbul ignore next */
|
|
2520
|
-
var _foldMap = function (M) {
|
|
2521
|
-
var foldMapM = exports.foldMap(M);
|
|
2522
|
-
return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
|
|
2523
|
-
};
|
|
2524
|
-
/* istanbul ignore next */
|
|
2525
|
-
var _reduceRight = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
|
|
2526
|
-
/* istanbul ignore next */
|
|
2527
|
-
var _traverse = function (F) {
|
|
2528
|
-
var traverseF = exports.traverse(F);
|
|
2529
|
-
return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
|
|
2530
|
-
};
|
|
2531
|
-
/* istanbul ignore next */
|
|
2532
|
-
var _alt = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
|
|
2533
|
-
/* istanbul ignore next */
|
|
2534
|
-
var _reduceWithIndex = function (fa, b, f) {
|
|
2535
|
-
return _function.pipe(fa, exports.reduceWithIndex(b, f));
|
|
2536
|
-
};
|
|
2537
|
-
/* istanbul ignore next */
|
|
2538
|
-
var _foldMapWithIndex = function (M) {
|
|
2539
|
-
var foldMapWithIndexM = exports.foldMapWithIndex(M);
|
|
2540
|
-
return function (fa, f) { return _function.pipe(fa, foldMapWithIndexM(f)); };
|
|
2541
|
-
};
|
|
2542
|
-
/* istanbul ignore next */
|
|
2543
|
-
var _reduceRightWithIndex = function (fa, b, f) {
|
|
2544
|
-
return _function.pipe(fa, exports.reduceRightWithIndex(b, f));
|
|
2545
|
-
};
|
|
2546
|
-
/* istanbul ignore next */
|
|
2547
|
-
var _traverseWithIndex = function (F) {
|
|
2548
|
-
var traverseWithIndexF = exports.traverseWithIndex(F);
|
|
2549
|
-
return function (ta, f) { return _function.pipe(ta, traverseWithIndexF(f)); };
|
|
2550
|
-
};
|
|
2551
|
-
// -------------------------------------------------------------------------------------
|
|
2552
|
-
// type class members
|
|
2553
|
-
// -------------------------------------------------------------------------------------
|
|
2554
|
-
/**
|
|
2555
|
-
* @category Pointed
|
|
2556
|
-
* @since 2.5.0
|
|
2557
|
-
*/
|
|
2558
|
-
exports.of = _.singleton;
|
|
2559
|
-
/**
|
|
2560
|
-
* Less strict version of [`alt`](#alt).
|
|
2561
|
-
*
|
|
2562
|
-
* @category Alt
|
|
2563
|
-
* @since 2.9.0
|
|
2564
|
-
*/
|
|
2565
|
-
var altW = function (that) { return function (as) { return _function.pipe(as, concatW(that())); }; };
|
|
2566
|
-
exports.altW = altW;
|
|
2567
|
-
/**
|
|
2568
|
-
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
|
|
2569
|
-
* types of kind `* -> *`.
|
|
2570
|
-
*
|
|
2571
|
-
* @category Alt
|
|
2572
|
-
* @since 2.6.2
|
|
2573
|
-
*/
|
|
2574
|
-
exports.alt = exports.altW;
|
|
2575
|
-
/**
|
|
2576
|
-
* @category Apply
|
|
2577
|
-
* @since 2.5.0
|
|
2578
|
-
*/
|
|
2579
|
-
var ap = function (as) { return exports.chain(function (f) { return _function.pipe(as, exports.map(f)); }); };
|
|
2580
|
-
exports.ap = ap;
|
|
2581
|
-
/**
|
|
2582
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation.
|
|
2583
|
-
*
|
|
2584
|
-
* @category Monad
|
|
2585
|
-
* @since 2.5.0
|
|
2586
|
-
*/
|
|
2587
|
-
var chain = function (f) { return exports.chainWithIndex(function (_, a) { return f(a); }); };
|
|
2588
|
-
exports.chain = chain;
|
|
2589
|
-
/**
|
|
2590
|
-
* @category Extend
|
|
2591
|
-
* @since 2.5.0
|
|
2592
|
-
*/
|
|
2593
|
-
var extend = function (f) { return function (as) {
|
|
2594
|
-
var next = exports.tail(as);
|
|
2595
|
-
var out = [f(as)];
|
|
2596
|
-
while (exports.isNonEmpty(next)) {
|
|
2597
|
-
out.push(f(next));
|
|
2598
|
-
next = exports.tail(next);
|
|
2599
|
-
}
|
|
2600
|
-
return out;
|
|
2601
|
-
}; };
|
|
2602
|
-
exports.extend = extend;
|
|
2603
|
-
/**
|
|
2604
|
-
* Derivable from `Extend`.
|
|
2605
|
-
*
|
|
2606
|
-
* @category combinators
|
|
2607
|
-
* @since 2.5.0
|
|
2608
|
-
*/
|
|
2609
|
-
exports.duplicate =
|
|
2610
|
-
/*#__PURE__*/
|
|
2611
|
-
exports.extend(_function.identity);
|
|
2612
|
-
/**
|
|
2613
|
-
* Derivable from `Chain`.
|
|
2614
|
-
*
|
|
2615
|
-
* @category combinators
|
|
2616
|
-
* @since 2.5.0
|
|
2617
|
-
*/
|
|
2618
|
-
exports.flatten =
|
|
2619
|
-
/*#__PURE__*/
|
|
2620
|
-
exports.chain(_function.identity);
|
|
2621
|
-
/**
|
|
2622
|
-
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
|
|
2623
|
-
* use the type constructor `F` to represent some computational context.
|
|
2624
|
-
*
|
|
2625
|
-
* @category Functor
|
|
2626
|
-
* @since 2.5.0
|
|
2627
|
-
*/
|
|
2628
|
-
var map = function (f) {
|
|
2629
|
-
return exports.mapWithIndex(function (_, a) { return f(a); });
|
|
2630
|
-
};
|
|
2631
|
-
exports.map = map;
|
|
2632
|
-
/**
|
|
2633
|
-
* @category FunctorWithIndex
|
|
2634
|
-
* @since 2.5.0
|
|
2635
|
-
*/
|
|
2636
|
-
var mapWithIndex = function (f) { return function (as) {
|
|
2637
|
-
var out = [f(0, exports.head(as))];
|
|
2638
|
-
for (var i = 1; i < as.length; i++) {
|
|
2639
|
-
out.push(f(i, as[i]));
|
|
2640
|
-
}
|
|
2641
|
-
return out;
|
|
2642
|
-
}; };
|
|
2643
|
-
exports.mapWithIndex = mapWithIndex;
|
|
2644
|
-
/**
|
|
2645
|
-
* @category Foldable
|
|
2646
|
-
* @since 2.5.0
|
|
2647
|
-
*/
|
|
2648
|
-
var reduce = function (b, f) {
|
|
2649
|
-
return exports.reduceWithIndex(b, function (_, b, a) { return f(b, a); });
|
|
2650
|
-
};
|
|
2651
|
-
exports.reduce = reduce;
|
|
2652
|
-
/**
|
|
2653
|
-
* **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.
|
|
2654
|
-
*
|
|
2655
|
-
* @category Foldable
|
|
2656
|
-
* @since 2.5.0
|
|
2657
|
-
*/
|
|
2658
|
-
var foldMap = function (S) { return function (f) { return function (as) {
|
|
2659
|
-
return as.slice(1).reduce(function (s, a) { return S.concat(s, f(a)); }, f(as[0]));
|
|
2660
|
-
}; }; };
|
|
2661
|
-
exports.foldMap = foldMap;
|
|
2662
|
-
/**
|
|
2663
|
-
* @category Foldable
|
|
2664
|
-
* @since 2.5.0
|
|
2665
|
-
*/
|
|
2666
|
-
var reduceRight = function (b, f) {
|
|
2667
|
-
return exports.reduceRightWithIndex(b, function (_, b, a) { return f(b, a); });
|
|
2668
|
-
};
|
|
2669
|
-
exports.reduceRight = reduceRight;
|
|
2670
|
-
/**
|
|
2671
|
-
* @category FoldableWithIndex
|
|
2672
|
-
* @since 2.5.0
|
|
2673
|
-
*/
|
|
2674
|
-
var reduceWithIndex = function (b, f) { return function (as) {
|
|
2675
|
-
return as.reduce(function (b, a, i) { return f(i, b, a); }, b);
|
|
2676
|
-
}; };
|
|
2677
|
-
exports.reduceWithIndex = reduceWithIndex;
|
|
2678
|
-
/**
|
|
2679
|
-
* **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.
|
|
2680
|
-
*
|
|
2681
|
-
* @category FoldableWithIndex
|
|
2682
|
-
* @since 2.5.0
|
|
2683
|
-
*/
|
|
2684
|
-
var foldMapWithIndex = function (S) { return function (f) { return function (as) { return as.slice(1).reduce(function (s, a, i) { return S.concat(s, f(i + 1, a)); }, f(0, as[0])); }; }; };
|
|
2685
|
-
exports.foldMapWithIndex = foldMapWithIndex;
|
|
2686
|
-
/**
|
|
2687
|
-
* @category FoldableWithIndex
|
|
2688
|
-
* @since 2.5.0
|
|
2689
|
-
*/
|
|
2690
|
-
var reduceRightWithIndex = function (b, f) { return function (as) { return as.reduceRight(function (b, a, i) { return f(i, a, b); }, b); }; };
|
|
2691
|
-
exports.reduceRightWithIndex = reduceRightWithIndex;
|
|
2692
|
-
/**
|
|
2693
|
-
* @category Traversable
|
|
2694
|
-
* @since 2.6.3
|
|
2695
|
-
*/
|
|
2696
|
-
var traverse = function (F) {
|
|
2697
|
-
var traverseWithIndexF = exports.traverseWithIndex(F);
|
|
2698
|
-
return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); };
|
|
2699
|
-
};
|
|
2700
|
-
exports.traverse = traverse;
|
|
2701
|
-
/**
|
|
2702
|
-
* @category Traversable
|
|
2703
|
-
* @since 2.6.3
|
|
2704
|
-
*/
|
|
2705
|
-
var sequence = function (F) { return exports.traverseWithIndex(F)(_function.SK); };
|
|
2706
|
-
exports.sequence = sequence;
|
|
2707
|
-
/**
|
|
2708
|
-
* @category TraversableWithIndex
|
|
2709
|
-
* @since 2.6.3
|
|
2710
|
-
*/
|
|
2711
|
-
var traverseWithIndex = function (F) { return function (f) { return function (as) {
|
|
2712
|
-
var out = F.map(f(0, exports.head(as)), exports.of);
|
|
2713
|
-
for (var i = 1; i < as.length; i++) {
|
|
2714
|
-
out = F.ap(F.map(out, function (bs) { return function (b) { return _function.pipe(bs, exports.append(b)); }; }), f(i, as[i]));
|
|
2715
|
-
}
|
|
2716
|
-
return out;
|
|
2717
|
-
}; }; };
|
|
2718
|
-
exports.traverseWithIndex = traverseWithIndex;
|
|
2719
|
-
/**
|
|
2720
|
-
* @category Comonad
|
|
2721
|
-
* @since 2.6.3
|
|
2722
|
-
*/
|
|
2723
|
-
exports.extract = _.head;
|
|
2724
|
-
// -------------------------------------------------------------------------------------
|
|
2725
|
-
// instances
|
|
2726
|
-
// -------------------------------------------------------------------------------------
|
|
2727
|
-
/**
|
|
2728
|
-
* @category instances
|
|
2729
|
-
* @since 2.5.0
|
|
2730
|
-
*/
|
|
2731
|
-
exports.URI = 'ReadonlyNonEmptyArray';
|
|
2732
|
-
/**
|
|
2733
|
-
* @category instances
|
|
2734
|
-
* @since 2.5.0
|
|
2735
|
-
*/
|
|
2736
|
-
var getShow = function (S) { return ({
|
|
2737
|
-
show: function (as) { return "[" + as.map(S.show).join(', ') + "]"; }
|
|
2738
|
-
}); };
|
|
2739
|
-
exports.getShow = getShow;
|
|
2740
|
-
/**
|
|
2741
|
-
* Builds a `Semigroup` instance for `ReadonlyNonEmptyArray`
|
|
2742
|
-
*
|
|
2743
|
-
* @category instances
|
|
2744
|
-
* @since 2.5.0
|
|
2745
|
-
*/
|
|
2746
|
-
var getSemigroup = function () { return ({
|
|
2747
|
-
concat: concat
|
|
2748
|
-
}); };
|
|
2749
|
-
exports.getSemigroup = getSemigroup;
|
|
2750
|
-
/**
|
|
2751
|
-
* @example
|
|
2752
|
-
* import { getEq } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
2753
|
-
* import * as N from 'fp-ts/number'
|
|
2754
|
-
*
|
|
2755
|
-
* const E = getEq(N.Eq)
|
|
2756
|
-
* assert.strictEqual(E.equals([1, 2], [1, 2]), true)
|
|
2757
|
-
* assert.strictEqual(E.equals([1, 2], [1, 3]), false)
|
|
2758
|
-
*
|
|
2759
|
-
* @category instances
|
|
2760
|
-
* @since 2.5.0
|
|
2761
|
-
*/
|
|
2762
|
-
var getEq = function (E) {
|
|
2763
|
-
return Eq.fromEquals(function (xs, ys) { return xs.length === ys.length && xs.every(function (x, i) { return E.equals(x, ys[i]); }); });
|
|
2764
|
-
};
|
|
2765
|
-
exports.getEq = getEq;
|
|
2766
|
-
/**
|
|
2767
|
-
* @category combinators
|
|
2768
|
-
* @since 2.11.0
|
|
2769
|
-
*/
|
|
2770
|
-
var getUnionSemigroup = function (E) {
|
|
2771
|
-
var unionE = exports.union(E);
|
|
2772
|
-
return {
|
|
2773
|
-
concat: function (first, second) { return unionE(second)(first); }
|
|
2774
|
-
};
|
|
2775
|
-
};
|
|
2776
|
-
exports.getUnionSemigroup = getUnionSemigroup;
|
|
2777
|
-
/**
|
|
2778
|
-
* @category instances
|
|
2779
|
-
* @since 2.7.0
|
|
2780
|
-
*/
|
|
2781
|
-
exports.Functor = {
|
|
2782
|
-
URI: exports.URI,
|
|
2783
|
-
map: _map
|
|
2784
|
-
};
|
|
2785
|
-
/**
|
|
2786
|
-
* Derivable from `Functor`.
|
|
2787
|
-
*
|
|
2788
|
-
* @category combinators
|
|
2789
|
-
* @since 2.10.0
|
|
2790
|
-
*/
|
|
2791
|
-
exports.flap =
|
|
2792
|
-
/*#__PURE__*/
|
|
2793
|
-
Functor.flap(exports.Functor);
|
|
2794
|
-
/**
|
|
2795
|
-
* @category instances
|
|
2796
|
-
* @since 2.10.0
|
|
2797
|
-
*/
|
|
2798
|
-
exports.Pointed = {
|
|
2799
|
-
URI: exports.URI,
|
|
2800
|
-
of: exports.of
|
|
2801
|
-
};
|
|
2802
|
-
/**
|
|
2803
|
-
* @category instances
|
|
2804
|
-
* @since 2.7.0
|
|
2805
|
-
*/
|
|
2806
|
-
exports.FunctorWithIndex = {
|
|
2807
|
-
URI: exports.URI,
|
|
2808
|
-
map: _map,
|
|
2809
|
-
mapWithIndex: _mapWithIndex
|
|
2810
|
-
};
|
|
2811
|
-
/**
|
|
2812
|
-
* @category instances
|
|
2813
|
-
* @since 2.10.0
|
|
2814
|
-
*/
|
|
2815
|
-
exports.Apply = {
|
|
2816
|
-
URI: exports.URI,
|
|
2817
|
-
map: _map,
|
|
2818
|
-
ap: _ap
|
|
2819
|
-
};
|
|
2820
|
-
/**
|
|
2821
|
-
* Combine two effectful actions, keeping only the result of the first.
|
|
2822
|
-
*
|
|
2823
|
-
* Derivable from `Apply`.
|
|
2824
|
-
*
|
|
2825
|
-
* @category combinators
|
|
2826
|
-
* @since 2.5.0
|
|
2827
|
-
*/
|
|
2828
|
-
exports.apFirst =
|
|
2829
|
-
/*#__PURE__*/
|
|
2830
|
-
Apply.apFirst(exports.Apply);
|
|
2831
|
-
/**
|
|
2832
|
-
* Combine two effectful actions, keeping only the result of the second.
|
|
2833
|
-
*
|
|
2834
|
-
* Derivable from `Apply`.
|
|
2835
|
-
*
|
|
2836
|
-
* @category combinators
|
|
2837
|
-
* @since 2.5.0
|
|
2838
|
-
*/
|
|
2839
|
-
exports.apSecond =
|
|
2840
|
-
/*#__PURE__*/
|
|
2841
|
-
Apply.apSecond(exports.Apply);
|
|
2842
|
-
/**
|
|
2843
|
-
* @category instances
|
|
2844
|
-
* @since 2.7.0
|
|
2845
|
-
*/
|
|
2846
|
-
exports.Applicative = {
|
|
2847
|
-
URI: exports.URI,
|
|
2848
|
-
map: _map,
|
|
2849
|
-
ap: _ap,
|
|
2850
|
-
of: exports.of
|
|
2851
|
-
};
|
|
2852
|
-
/**
|
|
2853
|
-
* @category instances
|
|
2854
|
-
* @since 2.10.0
|
|
2855
|
-
*/
|
|
2856
|
-
exports.Chain = {
|
|
2857
|
-
URI: exports.URI,
|
|
2858
|
-
map: _map,
|
|
2859
|
-
ap: _ap,
|
|
2860
|
-
chain: _chain
|
|
2861
|
-
};
|
|
2862
|
-
/**
|
|
2863
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation and
|
|
2864
|
-
* keeping only the result of the first.
|
|
2865
|
-
*
|
|
2866
|
-
* Derivable from `Chain`.
|
|
2867
|
-
*
|
|
2868
|
-
* @category combinators
|
|
2869
|
-
* @since 2.5.0
|
|
2870
|
-
*/
|
|
2871
|
-
exports.chainFirst =
|
|
2872
|
-
/*#__PURE__*/
|
|
2873
|
-
Chain.chainFirst(exports.Chain);
|
|
2874
|
-
/**
|
|
2875
|
-
* @category instances
|
|
2876
|
-
* @since 2.7.0
|
|
2877
|
-
*/
|
|
2878
|
-
exports.Monad = {
|
|
2879
|
-
URI: exports.URI,
|
|
2880
|
-
map: _map,
|
|
2881
|
-
ap: _ap,
|
|
2882
|
-
of: exports.of,
|
|
2883
|
-
chain: _chain
|
|
2884
|
-
};
|
|
2885
|
-
/**
|
|
2886
|
-
* @category instances
|
|
2887
|
-
* @since 2.7.0
|
|
2888
|
-
*/
|
|
2889
|
-
exports.Foldable = {
|
|
2890
|
-
URI: exports.URI,
|
|
2891
|
-
reduce: _reduce,
|
|
2892
|
-
foldMap: _foldMap,
|
|
2893
|
-
reduceRight: _reduceRight
|
|
2894
|
-
};
|
|
2895
|
-
/**
|
|
2896
|
-
* @category instances
|
|
2897
|
-
* @since 2.7.0
|
|
2898
|
-
*/
|
|
2899
|
-
exports.FoldableWithIndex = {
|
|
2900
|
-
URI: exports.URI,
|
|
2901
|
-
reduce: _reduce,
|
|
2902
|
-
foldMap: _foldMap,
|
|
2903
|
-
reduceRight: _reduceRight,
|
|
2904
|
-
reduceWithIndex: _reduceWithIndex,
|
|
2905
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
2906
|
-
reduceRightWithIndex: _reduceRightWithIndex
|
|
2907
|
-
};
|
|
2908
|
-
/**
|
|
2909
|
-
* @category instances
|
|
2910
|
-
* @since 2.7.0
|
|
2911
|
-
*/
|
|
2912
|
-
exports.Traversable = {
|
|
2913
|
-
URI: exports.URI,
|
|
2914
|
-
map: _map,
|
|
2915
|
-
reduce: _reduce,
|
|
2916
|
-
foldMap: _foldMap,
|
|
2917
|
-
reduceRight: _reduceRight,
|
|
2918
|
-
traverse: _traverse,
|
|
2919
|
-
sequence: exports.sequence
|
|
2920
|
-
};
|
|
2921
|
-
/**
|
|
2922
|
-
* @category instances
|
|
2923
|
-
* @since 2.7.0
|
|
2924
|
-
*/
|
|
2925
|
-
exports.TraversableWithIndex = {
|
|
2926
|
-
URI: exports.URI,
|
|
2927
|
-
map: _map,
|
|
2928
|
-
mapWithIndex: _mapWithIndex,
|
|
2929
|
-
reduce: _reduce,
|
|
2930
|
-
foldMap: _foldMap,
|
|
2931
|
-
reduceRight: _reduceRight,
|
|
2932
|
-
traverse: _traverse,
|
|
2933
|
-
sequence: exports.sequence,
|
|
2934
|
-
reduceWithIndex: _reduceWithIndex,
|
|
2935
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
2936
|
-
reduceRightWithIndex: _reduceRightWithIndex,
|
|
2937
|
-
traverseWithIndex: _traverseWithIndex
|
|
2938
|
-
};
|
|
2939
|
-
/**
|
|
2940
|
-
* @category instances
|
|
2941
|
-
* @since 2.7.0
|
|
2942
|
-
*/
|
|
2943
|
-
exports.Alt = {
|
|
2944
|
-
URI: exports.URI,
|
|
2945
|
-
map: _map,
|
|
2946
|
-
alt: _alt
|
|
2947
|
-
};
|
|
2948
|
-
/**
|
|
2949
|
-
* @category instances
|
|
2950
|
-
* @since 2.7.0
|
|
2951
|
-
*/
|
|
2952
|
-
exports.Comonad = {
|
|
2953
|
-
URI: exports.URI,
|
|
2954
|
-
map: _map,
|
|
2955
|
-
extend: _extend,
|
|
2956
|
-
extract: exports.extract
|
|
2957
|
-
};
|
|
2958
|
-
// -------------------------------------------------------------------------------------
|
|
2959
|
-
// do notation
|
|
2960
|
-
// -------------------------------------------------------------------------------------
|
|
2961
|
-
/**
|
|
2962
|
-
* @since 2.9.0
|
|
2963
|
-
*/
|
|
2964
|
-
exports.Do =
|
|
2965
|
-
/*#__PURE__*/
|
|
2966
|
-
exports.of(_.emptyRecord);
|
|
2967
|
-
/**
|
|
2968
|
-
* @since 2.8.0
|
|
2969
|
-
*/
|
|
2970
|
-
exports.bindTo =
|
|
2971
|
-
/*#__PURE__*/
|
|
2972
|
-
Functor.bindTo(exports.Functor);
|
|
2973
|
-
/**
|
|
2974
|
-
* @since 2.8.0
|
|
2975
|
-
*/
|
|
2976
|
-
exports.bind =
|
|
2977
|
-
/*#__PURE__*/
|
|
2978
|
-
Chain.bind(exports.Chain);
|
|
2979
|
-
// -------------------------------------------------------------------------------------
|
|
2980
|
-
// pipeable sequence S
|
|
2981
|
-
// -------------------------------------------------------------------------------------
|
|
2982
|
-
/**
|
|
2983
|
-
* @since 2.8.0
|
|
2984
|
-
*/
|
|
2985
|
-
exports.apS =
|
|
2986
|
-
/*#__PURE__*/
|
|
2987
|
-
Apply.apS(exports.Apply);
|
|
2988
|
-
// -------------------------------------------------------------------------------------
|
|
2989
|
-
// utils
|
|
2990
|
-
// -------------------------------------------------------------------------------------
|
|
2991
|
-
/**
|
|
2992
|
-
* @since 2.5.0
|
|
2993
|
-
*/
|
|
2994
|
-
exports.head = exports.extract;
|
|
2995
|
-
/**
|
|
2996
|
-
* @since 2.5.0
|
|
2997
|
-
*/
|
|
2998
|
-
exports.tail = _.tail;
|
|
2999
|
-
/**
|
|
3000
|
-
* @since 2.5.0
|
|
3001
|
-
*/
|
|
3002
|
-
var last = function (as) { return as[as.length - 1]; };
|
|
3003
|
-
exports.last = last;
|
|
3004
|
-
/**
|
|
3005
|
-
* Get all but the last element of a non empty array, creating a new array.
|
|
3006
|
-
*
|
|
3007
|
-
* @example
|
|
3008
|
-
* import { init } from 'fp-ts/ReadonlyNonEmptyArray'
|
|
3009
|
-
*
|
|
3010
|
-
* assert.deepStrictEqual(init([1, 2, 3]), [1, 2])
|
|
3011
|
-
* assert.deepStrictEqual(init([1]), [])
|
|
3012
|
-
*
|
|
3013
|
-
* @since 2.5.0
|
|
3014
|
-
*/
|
|
3015
|
-
var init = function (as) { return as.slice(0, -1); };
|
|
3016
|
-
exports.init = init;
|
|
3017
|
-
/**
|
|
3018
|
-
* @since 2.5.0
|
|
3019
|
-
*/
|
|
3020
|
-
var min = function (O) {
|
|
3021
|
-
var S = Se.min(O);
|
|
3022
|
-
return function (as) { return as.reduce(S.concat); };
|
|
3023
|
-
};
|
|
3024
|
-
exports.min = min;
|
|
3025
|
-
/**
|
|
3026
|
-
* @since 2.5.0
|
|
3027
|
-
*/
|
|
3028
|
-
var max = function (O) {
|
|
3029
|
-
var S = Se.max(O);
|
|
3030
|
-
return function (as) { return as.reduce(S.concat); };
|
|
3031
|
-
};
|
|
3032
|
-
exports.max = max;
|
|
3033
|
-
/**
|
|
3034
|
-
* @since 2.10.0
|
|
3035
|
-
*/
|
|
3036
|
-
var concatAll = function (S) { return function (as) { return as.reduce(S.concat); }; };
|
|
3037
|
-
exports.concatAll = concatAll;
|
|
3038
|
-
/**
|
|
3039
|
-
* Break a `ReadonlyArray` into its first element and remaining elements.
|
|
3040
|
-
*
|
|
3041
|
-
* @category destructors
|
|
3042
|
-
* @since 2.11.0
|
|
3043
|
-
*/
|
|
3044
|
-
var matchLeft = function (f) { return function (as) {
|
|
3045
|
-
return f(exports.head(as), exports.tail(as));
|
|
3046
|
-
}; };
|
|
3047
|
-
exports.matchLeft = matchLeft;
|
|
3048
|
-
/**
|
|
3049
|
-
* Break a `ReadonlyArray` into its initial elements and the last element.
|
|
3050
|
-
*
|
|
3051
|
-
* @category destructors
|
|
3052
|
-
* @since 2.11.0
|
|
3053
|
-
*/
|
|
3054
|
-
var matchRight = function (f) { return function (as) {
|
|
3055
|
-
return f(exports.init(as), exports.last(as));
|
|
3056
|
-
}; };
|
|
3057
|
-
exports.matchRight = matchRight;
|
|
3058
|
-
/**
|
|
3059
|
-
* Apply a function to the head, creating a new `ReadonlyNonEmptyArray`.
|
|
3060
|
-
*
|
|
3061
|
-
* @since 2.11.0
|
|
3062
|
-
*/
|
|
3063
|
-
var modifyHead = function (f) { return function (as) { return __spreadArray([
|
|
3064
|
-
f(exports.head(as))
|
|
3065
|
-
], exports.tail(as)); }; };
|
|
3066
|
-
exports.modifyHead = modifyHead;
|
|
3067
|
-
/**
|
|
3068
|
-
* Change the head, creating a new `ReadonlyNonEmptyArray`.
|
|
3069
|
-
*
|
|
3070
|
-
* @category combinators
|
|
3071
|
-
* @since 2.11.0
|
|
3072
|
-
*/
|
|
3073
|
-
var updateHead = function (a) { return exports.modifyHead(function () { return a; }); };
|
|
3074
|
-
exports.updateHead = updateHead;
|
|
3075
|
-
/**
|
|
3076
|
-
* Apply a function to the last element, creating a new `ReadonlyNonEmptyArray`.
|
|
3077
|
-
*
|
|
3078
|
-
* @since 2.11.0
|
|
3079
|
-
*/
|
|
3080
|
-
var modifyLast = function (f) { return function (as) {
|
|
3081
|
-
return _function.pipe(exports.init(as), exports.append(f(exports.last(as))));
|
|
3082
|
-
}; };
|
|
3083
|
-
exports.modifyLast = modifyLast;
|
|
3084
|
-
/**
|
|
3085
|
-
* Change the last element, creating a new `ReadonlyNonEmptyArray`.
|
|
3086
|
-
*
|
|
3087
|
-
* @category combinators
|
|
3088
|
-
* @since 2.11.0
|
|
3089
|
-
*/
|
|
3090
|
-
var updateLast = function (a) { return exports.modifyLast(function () { return a; }); };
|
|
3091
|
-
exports.updateLast = updateLast;
|
|
3092
|
-
function groupSort(O) {
|
|
3093
|
-
var sortO = exports.sort(O);
|
|
3094
|
-
var groupO = group(O);
|
|
3095
|
-
return function (as) { return (exports.isNonEmpty(as) ? groupO(sortO(as)) : exports.empty); };
|
|
3096
|
-
}
|
|
3097
|
-
exports.groupSort = groupSort;
|
|
3098
|
-
function filter(predicate) {
|
|
3099
|
-
return exports.filterWithIndex(function (_, a) { return predicate(a); });
|
|
3100
|
-
}
|
|
3101
|
-
exports.filter = filter;
|
|
3102
|
-
/**
|
|
3103
|
-
* Use [`filterWithIndex`](./ReadonlyArray.ts.html#filterwithindex) instead.
|
|
3104
|
-
*
|
|
3105
|
-
* @category combinators
|
|
3106
|
-
* @since 2.5.0
|
|
3107
|
-
* @deprecated
|
|
3108
|
-
*/
|
|
3109
|
-
var filterWithIndex = function (predicate) { return function (as) { return exports.fromReadonlyArray(as.filter(function (a, i) { return predicate(i, a); })); }; };
|
|
3110
|
-
exports.filterWithIndex = filterWithIndex;
|
|
3111
|
-
/**
|
|
3112
|
-
* Use [`unprepend`](#unprepend) instead.
|
|
3113
|
-
*
|
|
3114
|
-
* @category destructors
|
|
3115
|
-
* @since 2.10.0
|
|
3116
|
-
* @deprecated
|
|
3117
|
-
*/
|
|
3118
|
-
exports.uncons = exports.unprepend;
|
|
3119
|
-
/**
|
|
3120
|
-
* Use [`unappend`](#unappend) instead.
|
|
3121
|
-
*
|
|
3122
|
-
* @category destructors
|
|
3123
|
-
* @since 2.10.0
|
|
3124
|
-
* @deprecated
|
|
3125
|
-
*/
|
|
3126
|
-
exports.unsnoc = exports.unappend;
|
|
3127
|
-
function cons(head, tail) {
|
|
3128
|
-
return tail === undefined ? exports.prepend(head) : _function.pipe(tail, exports.prepend(head));
|
|
3129
|
-
}
|
|
3130
|
-
exports.cons = cons;
|
|
3131
|
-
/**
|
|
3132
|
-
* Use [`append`](./ReadonlyArray.ts.html#append) instead.
|
|
3133
|
-
*
|
|
3134
|
-
* @category constructors
|
|
3135
|
-
* @since 2.5.0
|
|
3136
|
-
* @deprecated
|
|
3137
|
-
*/
|
|
3138
|
-
var snoc = function (init, end) { return _function.pipe(init, concat([end])); };
|
|
3139
|
-
exports.snoc = snoc;
|
|
3140
|
-
/**
|
|
3141
|
-
* Use [`insertAt`](./ReadonlyArray.ts.html#insertat) instead.
|
|
3142
|
-
*
|
|
3143
|
-
* @category combinators
|
|
3144
|
-
* @since 2.5.0
|
|
3145
|
-
* @deprecated
|
|
3146
|
-
*/
|
|
3147
|
-
var insertAt = function (i, a) { return function (as) {
|
|
3148
|
-
return i < 0 || i > as.length ? _.none : _.some(exports.unsafeInsertAt(i, a, as));
|
|
3149
|
-
}; };
|
|
3150
|
-
exports.insertAt = insertAt;
|
|
3151
|
-
/**
|
|
3152
|
-
* Use [`prependAll`](#prependall) instead.
|
|
3153
|
-
*
|
|
3154
|
-
* @category combinators
|
|
3155
|
-
* @since 2.9.0
|
|
3156
|
-
* @deprecated
|
|
3157
|
-
*/
|
|
3158
|
-
exports.prependToAll = exports.prependAll;
|
|
3159
|
-
/**
|
|
3160
|
-
* Use [`concatAll`](#concatall) instead.
|
|
3161
|
-
*
|
|
3162
|
-
* @since 2.5.0
|
|
3163
|
-
* @deprecated
|
|
3164
|
-
*/
|
|
3165
|
-
exports.fold = exports.concatAll;
|
|
3166
|
-
/**
|
|
3167
|
-
* Use small, specific instances instead.
|
|
3168
|
-
*
|
|
3169
|
-
* @category instances
|
|
3170
|
-
* @since 2.5.0
|
|
3171
|
-
* @deprecated
|
|
3172
|
-
*/
|
|
3173
|
-
exports.readonlyNonEmptyArray = {
|
|
3174
|
-
URI: exports.URI,
|
|
3175
|
-
of: exports.of,
|
|
3176
|
-
map: _map,
|
|
3177
|
-
mapWithIndex: _mapWithIndex,
|
|
3178
|
-
ap: _ap,
|
|
3179
|
-
chain: _chain,
|
|
3180
|
-
extend: _extend,
|
|
3181
|
-
extract: exports.extract,
|
|
3182
|
-
reduce: _reduce,
|
|
3183
|
-
foldMap: _foldMap,
|
|
3184
|
-
reduceRight: _reduceRight,
|
|
3185
|
-
traverse: _traverse,
|
|
3186
|
-
sequence: exports.sequence,
|
|
3187
|
-
reduceWithIndex: _reduceWithIndex,
|
|
3188
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
3189
|
-
reduceRightWithIndex: _reduceRightWithIndex,
|
|
3190
|
-
traverseWithIndex: _traverseWithIndex,
|
|
3191
|
-
alt: _alt
|
|
3192
|
-
};
|
|
3193
|
-
});
|
|
3194
|
-
|
|
3195
|
-
const ReadonlyNonEmptyArray$1 = /*@__PURE__*/getDefaultExportFromCjs(ReadonlyNonEmptyArray);
|
|
3196
|
-
|
|
3197
|
-
var NonEmptyArray = createCommonjsModule(function (module, exports) {
|
|
3198
|
-
"use strict";
|
|
3199
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3200
|
-
if (k2 === undefined) k2 = k;
|
|
3201
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3202
|
-
}) : (function(o, m, k, k2) {
|
|
3203
|
-
if (k2 === undefined) k2 = k;
|
|
3204
|
-
o[k2] = m[k];
|
|
3205
|
-
}));
|
|
3206
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
3207
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3208
|
-
}) : function(o, v) {
|
|
3209
|
-
o["default"] = v;
|
|
3210
|
-
});
|
|
3211
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
3212
|
-
if (mod && mod.__esModule) return mod;
|
|
3213
|
-
var result = {};
|
|
3214
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
3215
|
-
__setModuleDefault(result, mod);
|
|
3216
|
-
return result;
|
|
3217
|
-
};
|
|
3218
|
-
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from) {
|
|
3219
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
3220
|
-
to[j] = from[i];
|
|
3221
|
-
return to;
|
|
3222
|
-
};
|
|
3223
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3224
|
-
exports.mapWithIndex = exports.map = exports.flatten = exports.duplicate = exports.extend = exports.chain = exports.ap = exports.alt = exports.altW = exports.chunksOf = exports.splitAt = exports.chop = exports.chainWithIndex = exports.foldMap = exports.foldMapWithIndex = exports.intersperse = exports.prependAll = exports.unzip = exports.zip = exports.zipWith = exports.of = exports.copy = exports.modifyAt = exports.updateAt = exports.insertAt = exports.sort = exports.groupBy = exports.group = exports.reverse = exports.concat = exports.concatW = exports.unappend = exports.unprepend = exports.range = exports.replicate = exports.makeBy = exports.fromArray = exports.fromReadonlyNonEmptyArray = exports.rotate = exports.union = exports.sortBy = exports.uniq = exports.unsafeUpdateAt = exports.unsafeInsertAt = exports.append = exports.appendW = exports.prepend = exports.prependW = exports.isOutOfBound = exports.isNonEmpty = void 0;
|
|
3225
|
-
exports.filterWithIndex = exports.filter = exports.groupSort = exports.updateLast = exports.modifyLast = exports.updateHead = exports.modifyHead = exports.matchRight = exports.matchLeft = exports.concatAll = exports.max = exports.min = exports.init = exports.last = exports.tail = exports.head = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.Comonad = exports.Alt = exports.TraversableWithIndex = exports.Traversable = exports.FoldableWithIndex = exports.Foldable = exports.Monad = exports.chainFirst = exports.Chain = exports.Applicative = exports.apSecond = exports.apFirst = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.flap = exports.Functor = exports.getUnionSemigroup = exports.getEq = exports.getSemigroup = exports.getShow = exports.URI = exports.extract = exports.traverseWithIndex = exports.sequence = exports.traverse = exports.reduceRightWithIndex = exports.reduceRight = exports.reduceWithIndex = exports.reduce = void 0;
|
|
3226
|
-
exports.nonEmptyArray = exports.fold = exports.prependToAll = exports.snoc = exports.cons = exports.unsnoc = exports.uncons = void 0;
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
var _ = __importStar(internal);
|
|
3232
|
-
|
|
3233
|
-
var RNEA = __importStar(ReadonlyNonEmptyArray);
|
|
3234
|
-
// -------------------------------------------------------------------------------------
|
|
3235
|
-
// internal
|
|
3236
|
-
// -------------------------------------------------------------------------------------
|
|
3237
|
-
/**
|
|
3238
|
-
* @internal
|
|
3239
|
-
*/
|
|
3240
|
-
var isNonEmpty = function (as) { return as.length > 0; };
|
|
3241
|
-
exports.isNonEmpty = isNonEmpty;
|
|
3242
|
-
/**
|
|
3243
|
-
* @internal
|
|
3244
|
-
*/
|
|
3245
|
-
var isOutOfBound = function (i, as) { return i < 0 || i >= as.length; };
|
|
3246
|
-
exports.isOutOfBound = isOutOfBound;
|
|
3247
|
-
/**
|
|
3248
|
-
* @internal
|
|
3249
|
-
*/
|
|
3250
|
-
var prependW = function (head) { return function (tail) { return __spreadArray([head], tail); }; };
|
|
3251
|
-
exports.prependW = prependW;
|
|
3252
|
-
/**
|
|
3253
|
-
* @internal
|
|
3254
|
-
*/
|
|
3255
|
-
exports.prepend = exports.prependW;
|
|
3256
|
-
/**
|
|
3257
|
-
* @internal
|
|
3258
|
-
*/
|
|
3259
|
-
var appendW = function (end) { return function (init) { return __spreadArray(__spreadArray([], init), [end]); }; };
|
|
3260
|
-
exports.appendW = appendW;
|
|
3261
|
-
/**
|
|
3262
|
-
* @internal
|
|
3263
|
-
*/
|
|
3264
|
-
exports.append = exports.appendW;
|
|
3265
|
-
/**
|
|
3266
|
-
* @internal
|
|
3267
|
-
*/
|
|
3268
|
-
var unsafeInsertAt = function (i, a, as) {
|
|
3269
|
-
if (exports.isNonEmpty(as)) {
|
|
3270
|
-
var xs = exports.fromReadonlyNonEmptyArray(as);
|
|
3271
|
-
xs.splice(i, 0, a);
|
|
3272
|
-
return xs;
|
|
3273
|
-
}
|
|
3274
|
-
return [a];
|
|
3275
|
-
};
|
|
3276
|
-
exports.unsafeInsertAt = unsafeInsertAt;
|
|
3277
|
-
/**
|
|
3278
|
-
* @internal
|
|
3279
|
-
*/
|
|
3280
|
-
var unsafeUpdateAt = function (i, a, as) {
|
|
3281
|
-
var xs = exports.fromReadonlyNonEmptyArray(as);
|
|
3282
|
-
xs[i] = a;
|
|
3283
|
-
return xs;
|
|
3284
|
-
};
|
|
3285
|
-
exports.unsafeUpdateAt = unsafeUpdateAt;
|
|
3286
|
-
/**
|
|
3287
|
-
* Remove duplicates from a `NonEmptyArray`, keeping the first occurrence of an element.
|
|
3288
|
-
*
|
|
3289
|
-
* @example
|
|
3290
|
-
* import { uniq } from 'fp-ts/NonEmptyArray'
|
|
3291
|
-
* import * as N from 'fp-ts/number'
|
|
3292
|
-
*
|
|
3293
|
-
* assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])
|
|
3294
|
-
*
|
|
3295
|
-
* @category combinators
|
|
3296
|
-
* @since 2.11.0
|
|
3297
|
-
*/
|
|
3298
|
-
var uniq = function (E) { return function (as) {
|
|
3299
|
-
if (as.length === 1) {
|
|
3300
|
-
return exports.copy(as);
|
|
3301
|
-
}
|
|
3302
|
-
var out = [exports.head(as)];
|
|
3303
|
-
var rest = exports.tail(as);
|
|
3304
|
-
var _loop_1 = function (a) {
|
|
3305
|
-
if (out.every(function (o) { return !E.equals(o, a); })) {
|
|
3306
|
-
out.push(a);
|
|
3307
|
-
}
|
|
3308
|
-
};
|
|
3309
|
-
for (var _i = 0, rest_1 = rest; _i < rest_1.length; _i++) {
|
|
3310
|
-
var a = rest_1[_i];
|
|
3311
|
-
_loop_1(a);
|
|
3312
|
-
}
|
|
3313
|
-
return out;
|
|
3314
|
-
}; };
|
|
3315
|
-
exports.uniq = uniq;
|
|
3316
|
-
/**
|
|
3317
|
-
* Sort the elements of a `NonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,
|
|
3318
|
-
* etc...
|
|
3319
|
-
*
|
|
3320
|
-
* @example
|
|
3321
|
-
* import * as NEA from 'fp-ts/NonEmptyArray'
|
|
3322
|
-
* import { contramap } from 'fp-ts/Ord'
|
|
3323
|
-
* import * as S from 'fp-ts/string'
|
|
3324
|
-
* import * as N from 'fp-ts/number'
|
|
3325
|
-
* import { pipe } from 'fp-ts/function'
|
|
3326
|
-
*
|
|
3327
|
-
* interface Person {
|
|
3328
|
-
* name: string
|
|
3329
|
-
* age: number
|
|
3330
|
-
* }
|
|
3331
|
-
*
|
|
3332
|
-
* const byName = pipe(S.Ord, contramap((p: Person) => p.name))
|
|
3333
|
-
*
|
|
3334
|
-
* const byAge = pipe(N.Ord, contramap((p: Person) => p.age))
|
|
3335
|
-
*
|
|
3336
|
-
* const sortByNameByAge = NEA.sortBy([byName, byAge])
|
|
3337
|
-
*
|
|
3338
|
-
* const persons: NEA.NonEmptyArray<Person> = [
|
|
3339
|
-
* { name: 'a', age: 1 },
|
|
3340
|
-
* { name: 'b', age: 3 },
|
|
3341
|
-
* { name: 'c', age: 2 },
|
|
3342
|
-
* { name: 'b', age: 2 }
|
|
3343
|
-
* ]
|
|
3344
|
-
*
|
|
3345
|
-
* assert.deepStrictEqual(sortByNameByAge(persons), [
|
|
3346
|
-
* { name: 'a', age: 1 },
|
|
3347
|
-
* { name: 'b', age: 2 },
|
|
3348
|
-
* { name: 'b', age: 3 },
|
|
3349
|
-
* { name: 'c', age: 2 }
|
|
3350
|
-
* ])
|
|
3351
|
-
*
|
|
3352
|
-
* @category combinators
|
|
3353
|
-
* @since 2.11.0
|
|
3354
|
-
*/
|
|
3355
|
-
var sortBy = function (ords) {
|
|
3356
|
-
if (exports.isNonEmpty(ords)) {
|
|
3357
|
-
var M = Ord.getMonoid();
|
|
3358
|
-
return exports.sort(ords.reduce(M.concat, M.empty));
|
|
3359
|
-
}
|
|
3360
|
-
return exports.copy;
|
|
3361
|
-
};
|
|
3362
|
-
exports.sortBy = sortBy;
|
|
3363
|
-
/**
|
|
3364
|
-
* @category combinators
|
|
3365
|
-
* @since 2.11.0
|
|
3366
|
-
*/
|
|
3367
|
-
var union = function (E) {
|
|
3368
|
-
var uniqE = exports.uniq(E);
|
|
3369
|
-
return function (second) { return function (first) { return uniqE(_function.pipe(first, concat(second))); }; };
|
|
3370
|
-
};
|
|
3371
|
-
exports.union = union;
|
|
3372
|
-
/**
|
|
3373
|
-
* Rotate a `NonEmptyArray` by `n` steps.
|
|
3374
|
-
*
|
|
3375
|
-
* @example
|
|
3376
|
-
* import { rotate } from 'fp-ts/NonEmptyArray'
|
|
3377
|
-
*
|
|
3378
|
-
* assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])
|
|
3379
|
-
* assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])
|
|
3380
|
-
*
|
|
3381
|
-
* @category combinators
|
|
3382
|
-
* @since 2.11.0
|
|
3383
|
-
*/
|
|
3384
|
-
var rotate = function (n) { return function (as) {
|
|
3385
|
-
var len = as.length;
|
|
3386
|
-
var m = Math.round(n) % len;
|
|
3387
|
-
if (exports.isOutOfBound(Math.abs(m), as) || m === 0) {
|
|
3388
|
-
return exports.copy(as);
|
|
3389
|
-
}
|
|
3390
|
-
if (m < 0) {
|
|
3391
|
-
var _a = exports.splitAt(-m)(as), f = _a[0], s = _a[1];
|
|
3392
|
-
return _function.pipe(s, concat(f));
|
|
3393
|
-
}
|
|
3394
|
-
else {
|
|
3395
|
-
return exports.rotate(m - len)(as);
|
|
3396
|
-
}
|
|
3397
|
-
}; };
|
|
3398
|
-
exports.rotate = rotate;
|
|
3399
|
-
// -------------------------------------------------------------------------------------
|
|
3400
|
-
// constructors
|
|
3401
|
-
// -------------------------------------------------------------------------------------
|
|
3402
|
-
/**
|
|
3403
|
-
* @category constructors
|
|
3404
|
-
* @since 2.10.0
|
|
3405
|
-
*/
|
|
3406
|
-
exports.fromReadonlyNonEmptyArray = _.fromReadonlyNonEmptyArray;
|
|
3407
|
-
/**
|
|
3408
|
-
* Builds a `NonEmptyArray` from an `Array` returning `none` if `as` is an empty array
|
|
3409
|
-
*
|
|
3410
|
-
* @category constructors
|
|
3411
|
-
* @since 2.0.0
|
|
3412
|
-
*/
|
|
3413
|
-
var fromArray = function (as) { return (exports.isNonEmpty(as) ? _.some(as) : _.none); };
|
|
3414
|
-
exports.fromArray = fromArray;
|
|
3415
|
-
/**
|
|
3416
|
-
* Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.
|
|
3417
|
-
*
|
|
3418
|
-
* **Note**. `n` is normalized to a natural number.
|
|
3419
|
-
*
|
|
3420
|
-
* @example
|
|
3421
|
-
* import { makeBy } from 'fp-ts/NonEmptyArray'
|
|
3422
|
-
* import { pipe } from 'fp-ts/function'
|
|
3423
|
-
*
|
|
3424
|
-
* const double = (n: number): number => n * 2
|
|
3425
|
-
* assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])
|
|
3426
|
-
*
|
|
3427
|
-
* @category constructors
|
|
3428
|
-
* @since 2.11.0
|
|
3429
|
-
*/
|
|
3430
|
-
var makeBy = function (f) { return function (n) {
|
|
3431
|
-
var j = Math.max(0, Math.floor(n));
|
|
3432
|
-
var out = [f(0)];
|
|
3433
|
-
for (var i = 1; i < j; i++) {
|
|
3434
|
-
out.push(f(i));
|
|
3435
|
-
}
|
|
3436
|
-
return out;
|
|
3437
|
-
}; };
|
|
3438
|
-
exports.makeBy = makeBy;
|
|
3439
|
-
/**
|
|
3440
|
-
* Create a `NonEmptyArray` containing a value repeated the specified number of times.
|
|
3441
|
-
*
|
|
3442
|
-
* **Note**. `n` is normalized to a natural number.
|
|
3443
|
-
*
|
|
3444
|
-
* @example
|
|
3445
|
-
* import { replicate } from 'fp-ts/NonEmptyArray'
|
|
3446
|
-
* import { pipe } from 'fp-ts/function'
|
|
3447
|
-
*
|
|
3448
|
-
* assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])
|
|
3449
|
-
*
|
|
3450
|
-
* @category constructors
|
|
3451
|
-
* @since 2.11.0
|
|
3452
|
-
*/
|
|
3453
|
-
var replicate = function (a) { return exports.makeBy(function () { return a; }); };
|
|
3454
|
-
exports.replicate = replicate;
|
|
3455
|
-
/**
|
|
3456
|
-
* Create a `NonEmptyArray` containing a range of integers, including both endpoints.
|
|
3457
|
-
*
|
|
3458
|
-
* @example
|
|
3459
|
-
* import { range } from 'fp-ts/NonEmptyArray'
|
|
3460
|
-
*
|
|
3461
|
-
* assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])
|
|
3462
|
-
*
|
|
3463
|
-
* @category constructors
|
|
3464
|
-
* @since 2.11.0
|
|
3465
|
-
*/
|
|
3466
|
-
var range = function (start, end) {
|
|
3467
|
-
return start <= end ? exports.makeBy(function (i) { return start + i; })(end - start + 1) : [start];
|
|
3468
|
-
};
|
|
3469
|
-
exports.range = range;
|
|
3470
|
-
// -------------------------------------------------------------------------------------
|
|
3471
|
-
// destructors
|
|
3472
|
-
// -------------------------------------------------------------------------------------
|
|
3473
|
-
/**
|
|
3474
|
-
* Return the tuple of the `head` and the `tail`.
|
|
3475
|
-
*
|
|
3476
|
-
* @example
|
|
3477
|
-
* import { unprepend } from 'fp-ts/NonEmptyArray'
|
|
3478
|
-
*
|
|
3479
|
-
* assert.deepStrictEqual(unprepend([1, 2, 3]), [1, [2, 3]])
|
|
3480
|
-
*
|
|
3481
|
-
* @category destructors
|
|
3482
|
-
* @since 2.9.0
|
|
3483
|
-
*/
|
|
3484
|
-
var unprepend = function (as) { return [exports.head(as), exports.tail(as)]; };
|
|
3485
|
-
exports.unprepend = unprepend;
|
|
3486
|
-
/**
|
|
3487
|
-
* Return the tuple of the `init` and the `last`.
|
|
3488
|
-
*
|
|
3489
|
-
* @example
|
|
3490
|
-
* import { unappend } from 'fp-ts/NonEmptyArray'
|
|
3491
|
-
*
|
|
3492
|
-
* assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])
|
|
3493
|
-
*
|
|
3494
|
-
* @category destructors
|
|
3495
|
-
* @since 2.9.0
|
|
3496
|
-
*/
|
|
3497
|
-
var unappend = function (as) { return [exports.init(as), exports.last(as)]; };
|
|
3498
|
-
exports.unappend = unappend;
|
|
3499
|
-
function concatW(second) {
|
|
3500
|
-
return function (first) { return first.concat(second); };
|
|
3501
|
-
}
|
|
3502
|
-
exports.concatW = concatW;
|
|
3503
|
-
function concat(x, y) {
|
|
3504
|
-
return y ? x.concat(y) : function (y) { return y.concat(x); };
|
|
3505
|
-
}
|
|
3506
|
-
exports.concat = concat;
|
|
3507
|
-
/**
|
|
3508
|
-
* @category combinators
|
|
3509
|
-
* @since 2.0.0
|
|
3510
|
-
*/
|
|
3511
|
-
var reverse = function (as) { return __spreadArray([exports.last(as)], as.slice(0, -1).reverse()); };
|
|
3512
|
-
exports.reverse = reverse;
|
|
3513
|
-
function group(E) {
|
|
3514
|
-
return function (as) {
|
|
3515
|
-
var len = as.length;
|
|
3516
|
-
if (len === 0) {
|
|
3517
|
-
return [];
|
|
3518
|
-
}
|
|
3519
|
-
var out = [];
|
|
3520
|
-
var head = as[0];
|
|
3521
|
-
var nea = [head];
|
|
3522
|
-
for (var i = 1; i < len; i++) {
|
|
3523
|
-
var a = as[i];
|
|
3524
|
-
if (E.equals(a, head)) {
|
|
3525
|
-
nea.push(a);
|
|
3526
|
-
}
|
|
3527
|
-
else {
|
|
3528
|
-
out.push(nea);
|
|
3529
|
-
head = a;
|
|
3530
|
-
nea = [head];
|
|
3531
|
-
}
|
|
3532
|
-
}
|
|
3533
|
-
out.push(nea);
|
|
3534
|
-
return out;
|
|
3535
|
-
};
|
|
3536
|
-
}
|
|
3537
|
-
exports.group = group;
|
|
3538
|
-
/**
|
|
3539
|
-
* Splits an array into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning
|
|
3540
|
-
* function on each element, and grouping the results according to values returned
|
|
3541
|
-
*
|
|
3542
|
-
* @example
|
|
3543
|
-
* import { groupBy } from 'fp-ts/NonEmptyArray'
|
|
3544
|
-
*
|
|
3545
|
-
* assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {
|
|
3546
|
-
* '1': ['a', 'b'],
|
|
3547
|
-
* '2': ['ab']
|
|
3548
|
-
* })
|
|
3549
|
-
*
|
|
3550
|
-
* @category combinators
|
|
3551
|
-
* @since 2.0.0
|
|
3552
|
-
*/
|
|
3553
|
-
var groupBy = function (f) { return function (as) {
|
|
3554
|
-
var out = {};
|
|
3555
|
-
for (var _i = 0, as_1 = as; _i < as_1.length; _i++) {
|
|
3556
|
-
var a = as_1[_i];
|
|
3557
|
-
var k = f(a);
|
|
3558
|
-
if (out.hasOwnProperty(k)) {
|
|
3559
|
-
out[k].push(a);
|
|
3560
|
-
}
|
|
3561
|
-
else {
|
|
3562
|
-
out[k] = [a];
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
return out;
|
|
3566
|
-
}; };
|
|
3567
|
-
exports.groupBy = groupBy;
|
|
3568
|
-
/**
|
|
3569
|
-
* @category combinators
|
|
3570
|
-
* @since 2.0.0
|
|
3571
|
-
*/
|
|
3572
|
-
var sort = function (O) { return function (as) {
|
|
3573
|
-
return as.slice().sort(O.compare);
|
|
3574
|
-
}; };
|
|
3575
|
-
exports.sort = sort;
|
|
3576
|
-
/**
|
|
3577
|
-
* @category combinators
|
|
3578
|
-
* @since 2.0.0
|
|
3579
|
-
*/
|
|
3580
|
-
var insertAt = function (i, a) { return function (as) {
|
|
3581
|
-
return i < 0 || i > as.length ? _.none : _.some(exports.unsafeInsertAt(i, a, as));
|
|
3582
|
-
}; };
|
|
3583
|
-
exports.insertAt = insertAt;
|
|
3584
|
-
/**
|
|
3585
|
-
* @category combinators
|
|
3586
|
-
* @since 2.0.0
|
|
3587
|
-
*/
|
|
3588
|
-
var updateAt = function (i, a) {
|
|
3589
|
-
return exports.modifyAt(i, function () { return a; });
|
|
3590
|
-
};
|
|
3591
|
-
exports.updateAt = updateAt;
|
|
3592
|
-
/**
|
|
3593
|
-
* @category combinators
|
|
3594
|
-
* @since 2.0.0
|
|
3595
|
-
*/
|
|
3596
|
-
var modifyAt = function (i, f) { return function (as) {
|
|
3597
|
-
return exports.isOutOfBound(i, as) ? _.none : _.some(exports.unsafeUpdateAt(i, f(as[i]), as));
|
|
3598
|
-
}; };
|
|
3599
|
-
exports.modifyAt = modifyAt;
|
|
3600
|
-
/**
|
|
3601
|
-
* @category combinators
|
|
3602
|
-
* @since 2.0.0
|
|
3603
|
-
*/
|
|
3604
|
-
exports.copy = exports.fromReadonlyNonEmptyArray;
|
|
3605
|
-
/**
|
|
3606
|
-
* @category Pointed
|
|
3607
|
-
* @since 2.0.0
|
|
3608
|
-
*/
|
|
3609
|
-
var of = function (a) { return [a]; };
|
|
3610
|
-
exports.of = of;
|
|
3611
|
-
/**
|
|
3612
|
-
* @category combinators
|
|
3613
|
-
* @since 2.5.1
|
|
3614
|
-
*/
|
|
3615
|
-
var zipWith = function (as, bs, f) {
|
|
3616
|
-
var cs = [f(as[0], bs[0])];
|
|
3617
|
-
var len = Math.min(as.length, bs.length);
|
|
3618
|
-
for (var i = 1; i < len; i++) {
|
|
3619
|
-
cs[i] = f(as[i], bs[i]);
|
|
3620
|
-
}
|
|
3621
|
-
return cs;
|
|
3622
|
-
};
|
|
3623
|
-
exports.zipWith = zipWith;
|
|
3624
|
-
function zip(as, bs) {
|
|
3625
|
-
if (bs === undefined) {
|
|
3626
|
-
return function (bs) { return zip(bs, as); };
|
|
3627
|
-
}
|
|
3628
|
-
return exports.zipWith(as, bs, function (a, b) { return [a, b]; });
|
|
3629
|
-
}
|
|
3630
|
-
exports.zip = zip;
|
|
3631
|
-
/**
|
|
3632
|
-
* @category combinators
|
|
3633
|
-
* @since 2.5.1
|
|
3634
|
-
*/
|
|
3635
|
-
var unzip = function (abs) {
|
|
3636
|
-
var fa = [abs[0][0]];
|
|
3637
|
-
var fb = [abs[0][1]];
|
|
3638
|
-
for (var i = 1; i < abs.length; i++) {
|
|
3639
|
-
fa[i] = abs[i][0];
|
|
3640
|
-
fb[i] = abs[i][1];
|
|
3641
|
-
}
|
|
3642
|
-
return [fa, fb];
|
|
3643
|
-
};
|
|
3644
|
-
exports.unzip = unzip;
|
|
3645
|
-
/**
|
|
3646
|
-
* Prepend an element to every member of an array
|
|
3647
|
-
*
|
|
3648
|
-
* @example
|
|
3649
|
-
* import { prependAll } from 'fp-ts/NonEmptyArray'
|
|
3650
|
-
*
|
|
3651
|
-
* assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])
|
|
3652
|
-
*
|
|
3653
|
-
* @category combinators
|
|
3654
|
-
* @since 2.10.0
|
|
3655
|
-
*/
|
|
3656
|
-
var prependAll = function (middle) { return function (as) {
|
|
3657
|
-
var out = [middle, as[0]];
|
|
3658
|
-
for (var i = 1; i < as.length; i++) {
|
|
3659
|
-
out.push(middle, as[i]);
|
|
3660
|
-
}
|
|
3661
|
-
return out;
|
|
3662
|
-
}; };
|
|
3663
|
-
exports.prependAll = prependAll;
|
|
3664
|
-
/**
|
|
3665
|
-
* Places an element in between members of an array
|
|
3666
|
-
*
|
|
3667
|
-
* @example
|
|
3668
|
-
* import { intersperse } from 'fp-ts/NonEmptyArray'
|
|
3669
|
-
*
|
|
3670
|
-
* assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])
|
|
3671
|
-
*
|
|
3672
|
-
* @category combinators
|
|
3673
|
-
* @since 2.9.0
|
|
3674
|
-
*/
|
|
3675
|
-
var intersperse = function (middle) { return function (as) {
|
|
3676
|
-
var rest = exports.tail(as);
|
|
3677
|
-
return exports.isNonEmpty(rest) ? _function.pipe(rest, exports.prependAll(middle), exports.prepend(exports.head(as))) : exports.copy(as);
|
|
3678
|
-
}; };
|
|
3679
|
-
exports.intersperse = intersperse;
|
|
3680
|
-
/**
|
|
3681
|
-
* @category combinators
|
|
3682
|
-
* @since 2.0.0
|
|
3683
|
-
*/
|
|
3684
|
-
exports.foldMapWithIndex = RNEA.foldMapWithIndex;
|
|
3685
|
-
/**
|
|
3686
|
-
* @category combinators
|
|
3687
|
-
* @since 2.0.0
|
|
3688
|
-
*/
|
|
3689
|
-
exports.foldMap = RNEA.foldMap;
|
|
3690
|
-
/**
|
|
3691
|
-
* @category combinators
|
|
3692
|
-
* @since 2.10.0
|
|
3693
|
-
*/
|
|
3694
|
-
var chainWithIndex = function (f) { return function (as) {
|
|
3695
|
-
var out = exports.fromReadonlyNonEmptyArray(f(0, exports.head(as)));
|
|
3696
|
-
for (var i = 1; i < as.length; i++) {
|
|
3697
|
-
out.push.apply(out, f(i, as[i]));
|
|
3698
|
-
}
|
|
3699
|
-
return out;
|
|
3700
|
-
}; };
|
|
3701
|
-
exports.chainWithIndex = chainWithIndex;
|
|
3702
|
-
/**
|
|
3703
|
-
* @category combinators
|
|
3704
|
-
* @since 2.10.0
|
|
3705
|
-
*/
|
|
3706
|
-
var chop = function (f) { return function (as) {
|
|
3707
|
-
var _a = f(as), b = _a[0], rest = _a[1];
|
|
3708
|
-
var out = [b];
|
|
3709
|
-
var next = rest;
|
|
3710
|
-
while (exports.isNonEmpty(next)) {
|
|
3711
|
-
var _b = f(next), b_1 = _b[0], rest_2 = _b[1];
|
|
3712
|
-
out.push(b_1);
|
|
3713
|
-
next = rest_2;
|
|
3714
|
-
}
|
|
3715
|
-
return out;
|
|
3716
|
-
}; };
|
|
3717
|
-
exports.chop = chop;
|
|
3718
|
-
/**
|
|
3719
|
-
* Splits a `NonEmptyArray` into two pieces, the first piece has max `n` elements.
|
|
3720
|
-
*
|
|
3721
|
-
* @category combinators
|
|
3722
|
-
* @since 2.10.0
|
|
3723
|
-
*/
|
|
3724
|
-
var splitAt = function (n) { return function (as) {
|
|
3725
|
-
var m = Math.max(1, n);
|
|
3726
|
-
return m >= as.length ? [exports.copy(as), []] : [_function.pipe(as.slice(1, m), exports.prepend(exports.head(as))), as.slice(m)];
|
|
3727
|
-
}; };
|
|
3728
|
-
exports.splitAt = splitAt;
|
|
3729
|
-
/**
|
|
3730
|
-
* @category combinators
|
|
3731
|
-
* @since 2.10.0
|
|
3732
|
-
*/
|
|
3733
|
-
var chunksOf = function (n) { return exports.chop(exports.splitAt(n)); };
|
|
3734
|
-
exports.chunksOf = chunksOf;
|
|
3735
|
-
// -------------------------------------------------------------------------------------
|
|
3736
|
-
// non-pipeables
|
|
3737
|
-
// -------------------------------------------------------------------------------------
|
|
3738
|
-
/* istanbul ignore next */
|
|
3739
|
-
var _map = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
|
|
3740
|
-
/* istanbul ignore next */
|
|
3741
|
-
var _mapWithIndex = function (fa, f) { return _function.pipe(fa, exports.mapWithIndex(f)); };
|
|
3742
|
-
/* istanbul ignore next */
|
|
3743
|
-
var _ap = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
|
|
3744
|
-
/* istanbul ignore next */
|
|
3745
|
-
var _chain = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
|
|
3746
|
-
/* istanbul ignore next */
|
|
3747
|
-
var _extend = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
|
|
3748
|
-
/* istanbul ignore next */
|
|
3749
|
-
var _reduce = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
|
|
3750
|
-
/* istanbul ignore next */
|
|
3751
|
-
var _foldMap = function (M) {
|
|
3752
|
-
var foldMapM = exports.foldMap(M);
|
|
3753
|
-
return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
|
|
3754
|
-
};
|
|
3755
|
-
/* istanbul ignore next */
|
|
3756
|
-
var _reduceRight = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
|
|
3757
|
-
/* istanbul ignore next */
|
|
3758
|
-
var _traverse = function (F) {
|
|
3759
|
-
var traverseF = exports.traverse(F);
|
|
3760
|
-
return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
|
|
3761
|
-
};
|
|
3762
|
-
/* istanbul ignore next */
|
|
3763
|
-
var _alt = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
|
|
3764
|
-
/* istanbul ignore next */
|
|
3765
|
-
var _reduceWithIndex = function (fa, b, f) {
|
|
3766
|
-
return _function.pipe(fa, exports.reduceWithIndex(b, f));
|
|
3767
|
-
};
|
|
3768
|
-
/* istanbul ignore next */
|
|
3769
|
-
var _foldMapWithIndex = function (M) {
|
|
3770
|
-
var foldMapWithIndexM = exports.foldMapWithIndex(M);
|
|
3771
|
-
return function (fa, f) { return _function.pipe(fa, foldMapWithIndexM(f)); };
|
|
3772
|
-
};
|
|
3773
|
-
/* istanbul ignore next */
|
|
3774
|
-
var _reduceRightWithIndex = function (fa, b, f) {
|
|
3775
|
-
return _function.pipe(fa, exports.reduceRightWithIndex(b, f));
|
|
3776
|
-
};
|
|
3777
|
-
/* istanbul ignore next */
|
|
3778
|
-
var _traverseWithIndex = function (F) {
|
|
3779
|
-
var traverseWithIndexF = exports.traverseWithIndex(F);
|
|
3780
|
-
return function (ta, f) { return _function.pipe(ta, traverseWithIndexF(f)); };
|
|
3781
|
-
};
|
|
3782
|
-
// -------------------------------------------------------------------------------------
|
|
3783
|
-
// type class members
|
|
3784
|
-
// -------------------------------------------------------------------------------------
|
|
3785
|
-
/**
|
|
3786
|
-
* Less strict version of [`alt`](#alt).
|
|
3787
|
-
*
|
|
3788
|
-
* @category Alt
|
|
3789
|
-
* @since 2.9.0
|
|
3790
|
-
*/
|
|
3791
|
-
var altW = function (that) { return function (as) {
|
|
3792
|
-
return _function.pipe(as, concatW(that()));
|
|
3793
|
-
}; };
|
|
3794
|
-
exports.altW = altW;
|
|
3795
|
-
/**
|
|
3796
|
-
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
|
|
3797
|
-
* types of kind `* -> *`.
|
|
3798
|
-
*
|
|
3799
|
-
* @category Alt
|
|
3800
|
-
* @since 2.6.2
|
|
3801
|
-
*/
|
|
3802
|
-
exports.alt = exports.altW;
|
|
3803
|
-
/**
|
|
3804
|
-
* Apply a function to an argument under a type constructor.
|
|
3805
|
-
*
|
|
3806
|
-
* @category Apply
|
|
3807
|
-
* @since 2.0.0
|
|
3808
|
-
*/
|
|
3809
|
-
var ap = function (as) {
|
|
3810
|
-
return exports.chain(function (f) { return _function.pipe(as, exports.map(f)); });
|
|
3811
|
-
};
|
|
3812
|
-
exports.ap = ap;
|
|
3813
|
-
/**
|
|
3814
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation.
|
|
3815
|
-
*
|
|
3816
|
-
* @category Monad
|
|
3817
|
-
* @since 2.0.0
|
|
3818
|
-
*/
|
|
3819
|
-
var chain = function (f) {
|
|
3820
|
-
return exports.chainWithIndex(function (_, a) { return f(a); });
|
|
3821
|
-
};
|
|
3822
|
-
exports.chain = chain;
|
|
3823
|
-
/**
|
|
3824
|
-
* @category Extend
|
|
3825
|
-
* @since 2.0.0
|
|
3826
|
-
*/
|
|
3827
|
-
var extend = function (f) { return function (as) {
|
|
3828
|
-
var next = exports.tail(as);
|
|
3829
|
-
var out = [f(as)];
|
|
3830
|
-
while (exports.isNonEmpty(next)) {
|
|
3831
|
-
out.push(f(next));
|
|
3832
|
-
next = exports.tail(next);
|
|
3833
|
-
}
|
|
3834
|
-
return out;
|
|
3835
|
-
}; };
|
|
3836
|
-
exports.extend = extend;
|
|
3837
|
-
/**
|
|
3838
|
-
* Derivable from `Extend`.
|
|
3839
|
-
*
|
|
3840
|
-
* @category combinators
|
|
3841
|
-
* @since 2.5.0
|
|
3842
|
-
*/
|
|
3843
|
-
exports.duplicate =
|
|
3844
|
-
/*#__PURE__*/
|
|
3845
|
-
exports.extend(_function.identity);
|
|
3846
|
-
/**
|
|
3847
|
-
* Derivable from `Chain`.
|
|
3848
|
-
*
|
|
3849
|
-
* @category combinators
|
|
3850
|
-
* @since 2.5.0
|
|
3851
|
-
*/
|
|
3852
|
-
exports.flatten =
|
|
3853
|
-
/*#__PURE__*/
|
|
3854
|
-
exports.chain(_function.identity);
|
|
3855
|
-
/**
|
|
3856
|
-
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
|
|
3857
|
-
* use the type constructor `F` to represent some computational context.
|
|
3858
|
-
*
|
|
3859
|
-
* @category Functor
|
|
3860
|
-
* @since 2.0.0
|
|
3861
|
-
*/
|
|
3862
|
-
var map = function (f) { return exports.mapWithIndex(function (_, a) { return f(a); }); };
|
|
3863
|
-
exports.map = map;
|
|
3864
|
-
/**
|
|
3865
|
-
* @category FunctorWithIndex
|
|
3866
|
-
* @since 2.0.0
|
|
3867
|
-
*/
|
|
3868
|
-
var mapWithIndex = function (f) { return function (as) {
|
|
3869
|
-
var out = [f(0, exports.head(as))];
|
|
3870
|
-
for (var i = 1; i < as.length; i++) {
|
|
3871
|
-
out.push(f(i, as[i]));
|
|
3872
|
-
}
|
|
3873
|
-
return out;
|
|
3874
|
-
}; };
|
|
3875
|
-
exports.mapWithIndex = mapWithIndex;
|
|
3876
|
-
/**
|
|
3877
|
-
* @category Foldable
|
|
3878
|
-
* @since 2.0.0
|
|
3879
|
-
*/
|
|
3880
|
-
exports.reduce = RNEA.reduce;
|
|
3881
|
-
/**
|
|
3882
|
-
* @category FoldableWithIndex
|
|
3883
|
-
* @since 2.0.0
|
|
3884
|
-
*/
|
|
3885
|
-
exports.reduceWithIndex = RNEA.reduceWithIndex;
|
|
3886
|
-
/**
|
|
3887
|
-
* @category Foldable
|
|
3888
|
-
* @since 2.0.0
|
|
3889
|
-
*/
|
|
3890
|
-
exports.reduceRight = RNEA.reduceRight;
|
|
3891
|
-
/**
|
|
3892
|
-
* @category FoldableWithIndex
|
|
3893
|
-
* @since 2.0.0
|
|
3894
|
-
*/
|
|
3895
|
-
exports.reduceRightWithIndex = RNEA.reduceRightWithIndex;
|
|
3896
|
-
/**
|
|
3897
|
-
* @since 2.6.3
|
|
3898
|
-
*/
|
|
3899
|
-
var traverse = function (F) {
|
|
3900
|
-
var traverseWithIndexF = exports.traverseWithIndex(F);
|
|
3901
|
-
return function (f) { return traverseWithIndexF(function (_, a) { return f(a); }); };
|
|
3902
|
-
};
|
|
3903
|
-
exports.traverse = traverse;
|
|
3904
|
-
/**
|
|
3905
|
-
* @since 2.6.3
|
|
3906
|
-
*/
|
|
3907
|
-
var sequence = function (F) { return exports.traverseWithIndex(F)(function (_, a) { return a; }); };
|
|
3908
|
-
exports.sequence = sequence;
|
|
3909
|
-
/**
|
|
3910
|
-
* @since 2.6.3
|
|
3911
|
-
*/
|
|
3912
|
-
var traverseWithIndex = function (F) { return function (f) { return function (as) {
|
|
3913
|
-
var out = F.map(f(0, exports.head(as)), exports.of);
|
|
3914
|
-
for (var i = 1; i < as.length; i++) {
|
|
3915
|
-
out = F.ap(F.map(out, function (bs) { return function (b) { return _function.pipe(bs, exports.append(b)); }; }), f(i, as[i]));
|
|
3916
|
-
}
|
|
3917
|
-
return out;
|
|
3918
|
-
}; }; };
|
|
3919
|
-
exports.traverseWithIndex = traverseWithIndex;
|
|
3920
|
-
/**
|
|
3921
|
-
* @since 2.7.0
|
|
3922
|
-
*/
|
|
3923
|
-
exports.extract = RNEA.head;
|
|
3924
|
-
// -------------------------------------------------------------------------------------
|
|
3925
|
-
// instances
|
|
3926
|
-
// -------------------------------------------------------------------------------------
|
|
3927
|
-
/**
|
|
3928
|
-
* @category instances
|
|
3929
|
-
* @since 2.0.0
|
|
3930
|
-
*/
|
|
3931
|
-
exports.URI = 'NonEmptyArray';
|
|
3932
|
-
/**
|
|
3933
|
-
* @category instances
|
|
3934
|
-
* @since 2.0.0
|
|
3935
|
-
*/
|
|
3936
|
-
exports.getShow = RNEA.getShow;
|
|
3937
|
-
/**
|
|
3938
|
-
* Builds a `Semigroup` instance for `NonEmptyArray`
|
|
3939
|
-
*
|
|
3940
|
-
* @category instances
|
|
3941
|
-
* @since 2.0.0
|
|
3942
|
-
*/
|
|
3943
|
-
var getSemigroup = function () { return ({
|
|
3944
|
-
concat: concat
|
|
3945
|
-
}); };
|
|
3946
|
-
exports.getSemigroup = getSemigroup;
|
|
3947
|
-
/**
|
|
3948
|
-
* @example
|
|
3949
|
-
* import { getEq } from 'fp-ts/NonEmptyArray'
|
|
3950
|
-
* import * as N from 'fp-ts/number'
|
|
3951
|
-
*
|
|
3952
|
-
* const E = getEq(N.Eq)
|
|
3953
|
-
* assert.strictEqual(E.equals([1, 2], [1, 2]), true)
|
|
3954
|
-
* assert.strictEqual(E.equals([1, 2], [1, 3]), false)
|
|
3955
|
-
*
|
|
3956
|
-
* @category instances
|
|
3957
|
-
* @since 2.0.0
|
|
3958
|
-
*/
|
|
3959
|
-
exports.getEq = RNEA.getEq;
|
|
3960
|
-
/**
|
|
3961
|
-
* @category combinators
|
|
3962
|
-
* @since 2.11.0
|
|
3963
|
-
*/
|
|
3964
|
-
var getUnionSemigroup = function (E) {
|
|
3965
|
-
var unionE = exports.union(E);
|
|
3966
|
-
return {
|
|
3967
|
-
concat: function (first, second) { return unionE(second)(first); }
|
|
3968
|
-
};
|
|
3969
|
-
};
|
|
3970
|
-
exports.getUnionSemigroup = getUnionSemigroup;
|
|
3971
|
-
/**
|
|
3972
|
-
* @category instances
|
|
3973
|
-
* @since 2.7.0
|
|
3974
|
-
*/
|
|
3975
|
-
exports.Functor = {
|
|
3976
|
-
URI: exports.URI,
|
|
3977
|
-
map: _map
|
|
3978
|
-
};
|
|
3979
|
-
/**
|
|
3980
|
-
* Derivable from `Functor`.
|
|
3981
|
-
*
|
|
3982
|
-
* @category combinators
|
|
3983
|
-
* @since 2.10.0
|
|
3984
|
-
*/
|
|
3985
|
-
exports.flap =
|
|
3986
|
-
/*#__PURE__*/
|
|
3987
|
-
Functor.flap(exports.Functor);
|
|
3988
|
-
/**
|
|
3989
|
-
* @category instances
|
|
3990
|
-
* @since 2.10.0
|
|
3991
|
-
*/
|
|
3992
|
-
exports.Pointed = {
|
|
3993
|
-
URI: exports.URI,
|
|
3994
|
-
of: exports.of
|
|
3995
|
-
};
|
|
3996
|
-
/**
|
|
3997
|
-
* @category instances
|
|
3998
|
-
* @since 2.7.0
|
|
3999
|
-
*/
|
|
4000
|
-
exports.FunctorWithIndex = {
|
|
4001
|
-
URI: exports.URI,
|
|
4002
|
-
map: _map,
|
|
4003
|
-
mapWithIndex: _mapWithIndex
|
|
4004
|
-
};
|
|
4005
|
-
/**
|
|
4006
|
-
* @category instances
|
|
4007
|
-
* @since 2.10.0
|
|
4008
|
-
*/
|
|
4009
|
-
exports.Apply = {
|
|
4010
|
-
URI: exports.URI,
|
|
4011
|
-
map: _map,
|
|
4012
|
-
ap: _ap
|
|
4013
|
-
};
|
|
4014
|
-
/**
|
|
4015
|
-
* Combine two effectful actions, keeping only the result of the first.
|
|
4016
|
-
*
|
|
4017
|
-
* Derivable from `Apply`.
|
|
4018
|
-
*
|
|
4019
|
-
* @category combinators
|
|
4020
|
-
* @since 2.5.0
|
|
4021
|
-
*/
|
|
4022
|
-
exports.apFirst =
|
|
4023
|
-
/*#__PURE__*/
|
|
4024
|
-
Apply.apFirst(exports.Apply);
|
|
4025
|
-
/**
|
|
4026
|
-
* Combine two effectful actions, keeping only the result of the second.
|
|
4027
|
-
*
|
|
4028
|
-
* Derivable from `Apply`.
|
|
4029
|
-
*
|
|
4030
|
-
* @category combinators
|
|
4031
|
-
* @since 2.5.0
|
|
4032
|
-
*/
|
|
4033
|
-
exports.apSecond =
|
|
4034
|
-
/*#__PURE__*/
|
|
4035
|
-
Apply.apSecond(exports.Apply);
|
|
4036
|
-
/**
|
|
4037
|
-
* @category instances
|
|
4038
|
-
* @since 2.7.0
|
|
4039
|
-
*/
|
|
4040
|
-
exports.Applicative = {
|
|
4041
|
-
URI: exports.URI,
|
|
4042
|
-
map: _map,
|
|
4043
|
-
ap: _ap,
|
|
4044
|
-
of: exports.of
|
|
4045
|
-
};
|
|
4046
|
-
/**
|
|
4047
|
-
* @category instances
|
|
4048
|
-
* @since 2.10.0
|
|
4049
|
-
*/
|
|
4050
|
-
exports.Chain = {
|
|
4051
|
-
URI: exports.URI,
|
|
4052
|
-
map: _map,
|
|
4053
|
-
ap: _ap,
|
|
4054
|
-
chain: _chain
|
|
4055
|
-
};
|
|
4056
|
-
/**
|
|
4057
|
-
* Composes computations in sequence, using the return value of one computation to determine the next computation and
|
|
4058
|
-
* keeping only the result of the first.
|
|
4059
|
-
*
|
|
4060
|
-
* Derivable from `Chain`.
|
|
4061
|
-
*
|
|
4062
|
-
* @category combinators
|
|
4063
|
-
* @since 2.5.0
|
|
4064
|
-
*/
|
|
4065
|
-
exports.chainFirst =
|
|
4066
|
-
/*#__PURE__*/
|
|
4067
|
-
Chain.chainFirst(exports.Chain);
|
|
4068
|
-
/**
|
|
4069
|
-
* @category instances
|
|
4070
|
-
* @since 2.7.0
|
|
4071
|
-
*/
|
|
4072
|
-
exports.Monad = {
|
|
4073
|
-
URI: exports.URI,
|
|
4074
|
-
map: _map,
|
|
4075
|
-
ap: _ap,
|
|
4076
|
-
of: exports.of,
|
|
4077
|
-
chain: _chain
|
|
4078
|
-
};
|
|
4079
|
-
/**
|
|
4080
|
-
* @category instances
|
|
4081
|
-
* @since 2.7.0
|
|
4082
|
-
*/
|
|
4083
|
-
exports.Foldable = {
|
|
4084
|
-
URI: exports.URI,
|
|
4085
|
-
reduce: _reduce,
|
|
4086
|
-
foldMap: _foldMap,
|
|
4087
|
-
reduceRight: _reduceRight
|
|
4088
|
-
};
|
|
4089
|
-
/**
|
|
4090
|
-
* @category instances
|
|
4091
|
-
* @since 2.7.0
|
|
4092
|
-
*/
|
|
4093
|
-
exports.FoldableWithIndex = {
|
|
4094
|
-
URI: exports.URI,
|
|
4095
|
-
reduce: _reduce,
|
|
4096
|
-
foldMap: _foldMap,
|
|
4097
|
-
reduceRight: _reduceRight,
|
|
4098
|
-
reduceWithIndex: _reduceWithIndex,
|
|
4099
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
4100
|
-
reduceRightWithIndex: _reduceRightWithIndex
|
|
4101
|
-
};
|
|
4102
|
-
/**
|
|
4103
|
-
* @category instances
|
|
4104
|
-
* @since 2.7.0
|
|
4105
|
-
*/
|
|
4106
|
-
exports.Traversable = {
|
|
4107
|
-
URI: exports.URI,
|
|
4108
|
-
map: _map,
|
|
4109
|
-
reduce: _reduce,
|
|
4110
|
-
foldMap: _foldMap,
|
|
4111
|
-
reduceRight: _reduceRight,
|
|
4112
|
-
traverse: _traverse,
|
|
4113
|
-
sequence: exports.sequence
|
|
4114
|
-
};
|
|
4115
|
-
/**
|
|
4116
|
-
* @category instances
|
|
4117
|
-
* @since 2.7.0
|
|
4118
|
-
*/
|
|
4119
|
-
exports.TraversableWithIndex = {
|
|
4120
|
-
URI: exports.URI,
|
|
4121
|
-
map: _map,
|
|
4122
|
-
mapWithIndex: _mapWithIndex,
|
|
4123
|
-
reduce: _reduce,
|
|
4124
|
-
foldMap: _foldMap,
|
|
4125
|
-
reduceRight: _reduceRight,
|
|
4126
|
-
traverse: _traverse,
|
|
4127
|
-
sequence: exports.sequence,
|
|
4128
|
-
reduceWithIndex: _reduceWithIndex,
|
|
4129
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
4130
|
-
reduceRightWithIndex: _reduceRightWithIndex,
|
|
4131
|
-
traverseWithIndex: _traverseWithIndex
|
|
4132
|
-
};
|
|
4133
|
-
/**
|
|
4134
|
-
* @category instances
|
|
4135
|
-
* @since 2.7.0
|
|
4136
|
-
*/
|
|
4137
|
-
exports.Alt = {
|
|
4138
|
-
URI: exports.URI,
|
|
4139
|
-
map: _map,
|
|
4140
|
-
alt: _alt
|
|
4141
|
-
};
|
|
4142
|
-
/**
|
|
4143
|
-
* @category instances
|
|
4144
|
-
* @since 2.7.0
|
|
4145
|
-
*/
|
|
4146
|
-
exports.Comonad = {
|
|
4147
|
-
URI: exports.URI,
|
|
4148
|
-
map: _map,
|
|
4149
|
-
extend: _extend,
|
|
4150
|
-
extract: exports.extract
|
|
4151
|
-
};
|
|
4152
|
-
// -------------------------------------------------------------------------------------
|
|
4153
|
-
// do notation
|
|
4154
|
-
// -------------------------------------------------------------------------------------
|
|
4155
|
-
/**
|
|
4156
|
-
* @since 2.9.0
|
|
4157
|
-
*/
|
|
4158
|
-
exports.Do =
|
|
4159
|
-
/*#__PURE__*/
|
|
4160
|
-
exports.of(_.emptyRecord);
|
|
4161
|
-
/**
|
|
4162
|
-
* @since 2.8.0
|
|
4163
|
-
*/
|
|
4164
|
-
exports.bindTo =
|
|
4165
|
-
/*#__PURE__*/
|
|
4166
|
-
Functor.bindTo(exports.Functor);
|
|
4167
|
-
/**
|
|
4168
|
-
* @since 2.8.0
|
|
4169
|
-
*/
|
|
4170
|
-
exports.bind =
|
|
4171
|
-
/*#__PURE__*/
|
|
4172
|
-
Chain.bind(exports.Chain);
|
|
4173
|
-
// -------------------------------------------------------------------------------------
|
|
4174
|
-
// pipeable sequence S
|
|
4175
|
-
// -------------------------------------------------------------------------------------
|
|
4176
|
-
/**
|
|
4177
|
-
* @since 2.8.0
|
|
4178
|
-
*/
|
|
4179
|
-
exports.apS =
|
|
4180
|
-
/*#__PURE__*/
|
|
4181
|
-
Apply.apS(exports.Apply);
|
|
4182
|
-
// -------------------------------------------------------------------------------------
|
|
4183
|
-
// utils
|
|
4184
|
-
// -------------------------------------------------------------------------------------
|
|
4185
|
-
/**
|
|
4186
|
-
* @since 2.0.0
|
|
4187
|
-
*/
|
|
4188
|
-
exports.head = RNEA.head;
|
|
4189
|
-
/**
|
|
4190
|
-
* @since 2.0.0
|
|
4191
|
-
*/
|
|
4192
|
-
var tail = function (as) { return as.slice(1); };
|
|
4193
|
-
exports.tail = tail;
|
|
4194
|
-
/**
|
|
4195
|
-
* @since 2.0.0
|
|
4196
|
-
*/
|
|
4197
|
-
exports.last = RNEA.last;
|
|
4198
|
-
/**
|
|
4199
|
-
* Get all but the last element of a non empty array, creating a new array.
|
|
4200
|
-
*
|
|
4201
|
-
* @example
|
|
4202
|
-
* import { init } from 'fp-ts/NonEmptyArray'
|
|
4203
|
-
*
|
|
4204
|
-
* assert.deepStrictEqual(init([1, 2, 3]), [1, 2])
|
|
4205
|
-
* assert.deepStrictEqual(init([1]), [])
|
|
4206
|
-
*
|
|
4207
|
-
* @since 2.2.0
|
|
4208
|
-
*/
|
|
4209
|
-
var init = function (as) { return as.slice(0, -1); };
|
|
4210
|
-
exports.init = init;
|
|
4211
|
-
/**
|
|
4212
|
-
* @since 2.0.0
|
|
4213
|
-
*/
|
|
4214
|
-
exports.min = RNEA.min;
|
|
4215
|
-
/**
|
|
4216
|
-
* @since 2.0.0
|
|
4217
|
-
*/
|
|
4218
|
-
exports.max = RNEA.max;
|
|
4219
|
-
/**
|
|
4220
|
-
* @since 2.10.0
|
|
4221
|
-
*/
|
|
4222
|
-
var concatAll = function (S) { return function (as) { return as.reduce(S.concat); }; };
|
|
4223
|
-
exports.concatAll = concatAll;
|
|
4224
|
-
/**
|
|
4225
|
-
* Break an `Array` into its first element and remaining elements.
|
|
4226
|
-
*
|
|
4227
|
-
* @category destructors
|
|
4228
|
-
* @since 2.11.0
|
|
4229
|
-
*/
|
|
4230
|
-
var matchLeft = function (f) { return function (as) { return f(exports.head(as), exports.tail(as)); }; };
|
|
4231
|
-
exports.matchLeft = matchLeft;
|
|
4232
|
-
/**
|
|
4233
|
-
* Break an `Array` into its initial elements and the last element.
|
|
4234
|
-
*
|
|
4235
|
-
* @category destructors
|
|
4236
|
-
* @since 2.11.0
|
|
4237
|
-
*/
|
|
4238
|
-
var matchRight = function (f) { return function (as) {
|
|
4239
|
-
return f(exports.init(as), exports.last(as));
|
|
4240
|
-
}; };
|
|
4241
|
-
exports.matchRight = matchRight;
|
|
4242
|
-
/**
|
|
4243
|
-
* Apply a function to the head, creating a new `NonEmptyArray`.
|
|
4244
|
-
*
|
|
4245
|
-
* @since 2.11.0
|
|
4246
|
-
*/
|
|
4247
|
-
var modifyHead = function (f) { return function (as) { return __spreadArray([
|
|
4248
|
-
f(exports.head(as))
|
|
4249
|
-
], exports.tail(as)); }; };
|
|
4250
|
-
exports.modifyHead = modifyHead;
|
|
4251
|
-
/**
|
|
4252
|
-
* Change the head, creating a new `NonEmptyArray`.
|
|
4253
|
-
*
|
|
4254
|
-
* @category combinators
|
|
4255
|
-
* @since 2.11.0
|
|
4256
|
-
*/
|
|
4257
|
-
var updateHead = function (a) { return exports.modifyHead(function () { return a; }); };
|
|
4258
|
-
exports.updateHead = updateHead;
|
|
4259
|
-
/**
|
|
4260
|
-
* Apply a function to the last element, creating a new `NonEmptyArray`.
|
|
4261
|
-
*
|
|
4262
|
-
* @since 2.11.0
|
|
4263
|
-
*/
|
|
4264
|
-
var modifyLast = function (f) { return function (as) {
|
|
4265
|
-
return _function.pipe(exports.init(as), exports.append(f(exports.last(as))));
|
|
4266
|
-
}; };
|
|
4267
|
-
exports.modifyLast = modifyLast;
|
|
4268
|
-
/**
|
|
4269
|
-
* Change the last element, creating a new `NonEmptyArray`.
|
|
4270
|
-
*
|
|
4271
|
-
* @category combinators
|
|
4272
|
-
* @since 2.11.0
|
|
4273
|
-
*/
|
|
4274
|
-
var updateLast = function (a) { return exports.modifyLast(function () { return a; }); };
|
|
4275
|
-
exports.updateLast = updateLast;
|
|
4276
|
-
function groupSort(O) {
|
|
4277
|
-
var sortO = exports.sort(O);
|
|
4278
|
-
var groupO = group(O);
|
|
4279
|
-
return function (as) { return (exports.isNonEmpty(as) ? groupO(sortO(as)) : []); };
|
|
4280
|
-
}
|
|
4281
|
-
exports.groupSort = groupSort;
|
|
4282
|
-
function filter(predicate) {
|
|
4283
|
-
return exports.filterWithIndex(function (_, a) { return predicate(a); });
|
|
4284
|
-
}
|
|
4285
|
-
exports.filter = filter;
|
|
4286
|
-
/**
|
|
4287
|
-
* Use [`filterWithIndex`](./Array.ts.html#filterwithindex) instead.
|
|
4288
|
-
*
|
|
4289
|
-
* @category combinators
|
|
4290
|
-
* @since 2.0.0
|
|
4291
|
-
* @deprecated
|
|
4292
|
-
*/
|
|
4293
|
-
var filterWithIndex = function (predicate) { return function (as) { return exports.fromArray(as.filter(function (a, i) { return predicate(i, a); })); }; };
|
|
4294
|
-
exports.filterWithIndex = filterWithIndex;
|
|
4295
|
-
/**
|
|
4296
|
-
* Use [`unprepend`](#unprepend) instead.
|
|
4297
|
-
*
|
|
4298
|
-
* @category destructors
|
|
4299
|
-
* @since 2.9.0
|
|
4300
|
-
* @deprecated
|
|
4301
|
-
*/
|
|
4302
|
-
exports.uncons = exports.unprepend;
|
|
4303
|
-
/**
|
|
4304
|
-
* Use [`unappend`](#unappend) instead.
|
|
4305
|
-
*
|
|
4306
|
-
* @category destructors
|
|
4307
|
-
* @since 2.9.0
|
|
4308
|
-
* @deprecated
|
|
4309
|
-
*/
|
|
4310
|
-
exports.unsnoc = exports.unappend;
|
|
4311
|
-
function cons(head, tail) {
|
|
4312
|
-
return tail === undefined ? exports.prepend(head) : _function.pipe(tail, exports.prepend(head));
|
|
4313
|
-
}
|
|
4314
|
-
exports.cons = cons;
|
|
4315
|
-
/**
|
|
4316
|
-
* Use [`append`](./Array.ts.html#append) instead.
|
|
4317
|
-
*
|
|
4318
|
-
* @category constructors
|
|
4319
|
-
* @since 2.0.0
|
|
4320
|
-
* @deprecated
|
|
4321
|
-
*/
|
|
4322
|
-
var snoc = function (init, end) { return _function.pipe(init, exports.append(end)); };
|
|
4323
|
-
exports.snoc = snoc;
|
|
4324
|
-
/**
|
|
4325
|
-
* Use [`prependAll`](#prependall) instead.
|
|
4326
|
-
*
|
|
4327
|
-
* @category combinators
|
|
4328
|
-
* @since 2.9.0
|
|
4329
|
-
* @deprecated
|
|
4330
|
-
*/
|
|
4331
|
-
exports.prependToAll = exports.prependAll;
|
|
4332
|
-
/**
|
|
4333
|
-
* Use [`concatAll`](#concatall) instead.
|
|
4334
|
-
*
|
|
4335
|
-
* @since 2.5.0
|
|
4336
|
-
* @deprecated
|
|
4337
|
-
*/
|
|
4338
|
-
exports.fold = RNEA.concatAll;
|
|
4339
|
-
/**
|
|
4340
|
-
* Use small, specific instances instead.
|
|
4341
|
-
*
|
|
4342
|
-
* @category instances
|
|
4343
|
-
* @since 2.0.0
|
|
4344
|
-
* @deprecated
|
|
4345
|
-
*/
|
|
4346
|
-
exports.nonEmptyArray = {
|
|
4347
|
-
URI: exports.URI,
|
|
4348
|
-
of: exports.of,
|
|
4349
|
-
map: _map,
|
|
4350
|
-
mapWithIndex: _mapWithIndex,
|
|
4351
|
-
ap: _ap,
|
|
4352
|
-
chain: _chain,
|
|
4353
|
-
extend: _extend,
|
|
4354
|
-
extract: exports.extract,
|
|
4355
|
-
reduce: _reduce,
|
|
4356
|
-
foldMap: _foldMap,
|
|
4357
|
-
reduceRight: _reduceRight,
|
|
4358
|
-
traverse: _traverse,
|
|
4359
|
-
sequence: exports.sequence,
|
|
4360
|
-
reduceWithIndex: _reduceWithIndex,
|
|
4361
|
-
foldMapWithIndex: _foldMapWithIndex,
|
|
4362
|
-
reduceRightWithIndex: _reduceRightWithIndex,
|
|
4363
|
-
traverseWithIndex: _traverseWithIndex,
|
|
4364
|
-
alt: _alt
|
|
4365
|
-
};
|
|
4366
|
-
});
|
|
4367
|
-
|
|
4368
|
-
const NonEmptyArray$1 = /*@__PURE__*/getDefaultExportFromCjs(NonEmptyArray);
|
|
4369
|
-
|
|
4370
|
-
export { Apply as A, Chain as C, Eq as E, Functor as F, NonEmptyArray as N, Ord as O, ReadonlyNonEmptyArray as R, Separated as S, Witherable as W, Zero as Z, _function as _, commonjsGlobal as a, FromEither as b, createCommonjsModule as c, Semigroup as d, getDefaultExportFromCjs as g, internal as i };
|