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