@fncts/base 0.0.40 → 0.0.41
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/_cjs/collection/AsyncIterable/api.cjs +384 -0
- package/_cjs/collection/AsyncIterable/api.cjs.map +1 -0
- package/_cjs/collection/AsyncIterable/definition.cjs +2 -0
- package/_cjs/collection/AsyncIterable/definition.cjs.map +1 -0
- package/_cjs/collection/{compat/Array.cjs → AsyncIterable.cjs} +3 -3
- package/_cjs/collection/AsyncIterable.cjs.map +1 -0
- package/_cjs/collection/Iterable/api/traverseConc.cjs +1 -2
- package/_cjs/collection/Iterable/api/traverseConc.cjs.map +1 -1
- package/_cjs/collection/Iterable/api.cjs +180 -137
- package/_cjs/collection/Iterable/api.cjs.map +1 -1
- package/_cjs/collection/Iterable/constructors.cjs.map +1 -1
- package/_cjs/collection/compat/ArrayLike/api.cjs +1 -2
- package/_cjs/collection/compat/ArrayLike/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/api/makeBy.cjs +1 -2
- package/_cjs/collection/immutable/Conc/api/makeBy.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/api/replicate.cjs +1 -2
- package/_cjs/collection/immutable/Conc/api/replicate.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/api.cjs +1 -2
- package/_cjs/collection/immutable/Conc/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/constructors.cjs +3 -4
- package/_cjs/collection/immutable/Conc/constructors.cjs.map +1 -1
- package/_cjs/collection/immutable/Conc/definition.cjs +3 -3
- package/_cjs/collection/immutable/Conc/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Dictionary/api.cjs +1 -2
- package/_cjs/collection/immutable/Dictionary/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Dictionary/definition.cjs +1 -2
- package/_cjs/collection/immutable/Dictionary/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/api.cjs +1 -2
- package/_cjs/collection/immutable/HashMap/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/definition.cjs +1 -2
- package/_cjs/collection/immutable/HashMap/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/HashMap/internal.cjs +1 -2
- package/_cjs/collection/immutable/HashMap/internal.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/api.cjs +1 -2
- package/_cjs/collection/immutable/HashSet/api.cjs.map +1 -1
- package/_cjs/collection/immutable/HashSet/definition.cjs +1 -2
- package/_cjs/collection/immutable/HashSet/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/List/api/foldLeft.cjs +1 -2
- package/_cjs/collection/immutable/List/api/foldLeft.cjs.map +1 -1
- package/_cjs/collection/immutable/List/api/unsafeTail.cjs +1 -2
- package/_cjs/collection/immutable/List/api/unsafeTail.cjs.map +1 -1
- package/_cjs/collection/immutable/List/api.cjs +3 -4
- package/_cjs/collection/immutable/List/api.cjs.map +1 -1
- package/_cjs/collection/immutable/List/constructors.cjs +1 -2
- package/_cjs/collection/immutable/List/constructors.cjs.map +1 -1
- package/_cjs/collection/immutable/List/definition.cjs +1 -2
- package/_cjs/collection/immutable/List/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Queue/api.cjs +1 -2
- package/_cjs/collection/immutable/Queue/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Queue/constructors.cjs +1 -2
- package/_cjs/collection/immutable/Queue/constructors.cjs.map +1 -1
- package/_cjs/collection/immutable/Queue/definition.cjs +1 -2
- package/_cjs/collection/immutable/Queue/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/Queue/guards.cjs +1 -2
- package/_cjs/collection/immutable/Queue/guards.cjs.map +1 -1
- package/_cjs/collection/immutable/ReadonlyArray/api/chunksOf.cjs +18 -0
- package/_cjs/collection/immutable/ReadonlyArray/api/chunksOf.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyArray/api/splitAt.cjs +15 -0
- package/_cjs/collection/immutable/ReadonlyArray/api/splitAt.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyArray/api/splitWhere.cjs +26 -0
- package/_cjs/collection/immutable/ReadonlyArray/api/splitWhere.cjs.map +1 -0
- package/_cjs/collection/immutable/{ImmutableArray → ReadonlyArray}/api.cjs +562 -538
- package/_cjs/collection/immutable/ReadonlyArray/api.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyArray/constructors.cjs +55 -0
- package/_cjs/collection/immutable/ReadonlyArray/constructors.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyArray/definition.cjs.map +1 -0
- package/_cjs/collection/immutable/{ImmutableArray → ReadonlyArray}/instances.cjs +5 -7
- package/_cjs/collection/immutable/ReadonlyArray/instances.cjs.map +1 -0
- package/_cjs/collection/immutable/{ImmutableArray.cjs → ReadonlyArray.cjs} +8 -19
- package/_cjs/collection/immutable/ReadonlyArray.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/api.cjs +472 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/api.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/constructors.cjs +79 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/constructors.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/definition.cjs +2 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/definition.cjs.map +1 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/destructors.cjs +49 -0
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/destructors.cjs.map +1 -0
- package/_cjs/collection/immutable/{ImmutableNonEmptyArray → ReadonlyNonEmptyArray}/instances.cjs +3 -4
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray/instances.cjs.map +1 -0
- package/_cjs/collection/immutable/{ImmutableNonEmptyArray.cjs → ReadonlyNonEmptyArray.cjs} +6 -6
- package/_cjs/collection/immutable/ReadonlyNonEmptyArray.cjs.map +1 -0
- package/_cjs/collection/immutable/RoseTree/api.cjs +1 -2
- package/_cjs/collection/immutable/RoseTree/api.cjs.map +1 -1
- package/_cjs/collection/immutable/RoseTree/definition.cjs +1 -2
- package/_cjs/collection/immutable/RoseTree/definition.cjs.map +1 -1
- package/_cjs/collection/immutable/SortedMap/api.cjs +1 -2
- package/_cjs/collection/immutable/SortedMap/api.cjs.map +1 -1
- package/_cjs/collection/immutable/SortedMap/iterator.cjs +1 -2
- package/_cjs/collection/immutable/SortedMap/iterator.cjs.map +1 -1
- package/_cjs/collection/immutable/Vector/api.cjs +229 -230
- package/_cjs/collection/immutable/Vector/api.cjs.map +1 -1
- package/_cjs/collection/immutable/Vector/definition.cjs +1 -2
- package/_cjs/collection/immutable/Vector/definition.cjs.map +1 -1
- package/_cjs/collection/mutable/ArrayDeque.cjs +1 -2
- package/_cjs/collection/mutable/ArrayDeque.cjs.map +1 -1
- package/_cjs/collection/mutable/HashMap.cjs +1 -2
- package/_cjs/collection/mutable/HashMap.cjs.map +1 -1
- package/_cjs/collection/mutable/HashSet.cjs +1 -2
- package/_cjs/collection/mutable/HashSet.cjs.map +1 -1
- package/_cjs/collection/mutable/ListBuffer.cjs +1 -2
- package/_cjs/collection/mutable/ListBuffer.cjs.map +1 -1
- package/_cjs/collection/weak/IterableWeakMap.cjs +1 -2
- package/_cjs/collection/weak/IterableWeakMap.cjs.map +1 -1
- package/_cjs/control/Eval/api.cjs +89 -41
- package/_cjs/control/Eval/api.cjs.map +1 -1
- package/_cjs/control/Eval/constructors.cjs +5 -1
- package/_cjs/control/Eval/constructors.cjs.map +1 -1
- package/_cjs/control/Eval/instance.cjs +1 -2
- package/_cjs/control/Eval/instance.cjs.map +1 -1
- package/_cjs/control/Eval/run.cjs +1 -2
- package/_cjs/control/Eval/run.cjs.map +1 -1
- package/_cjs/control/Pure/api.cjs +1 -2
- package/_cjs/control/Pure/api.cjs.map +1 -1
- package/_cjs/control/Pure/definition.cjs +1 -2
- package/_cjs/control/Pure/definition.cjs.map +1 -1
- package/_cjs/control/Pure/instances.cjs +1 -2
- package/_cjs/control/Pure/instances.cjs.map +1 -1
- package/_cjs/control/Pure/runtime.cjs +15 -10
- package/_cjs/control/Pure/runtime.cjs.map +1 -1
- package/_cjs/data/CaseClass.cjs +11 -14
- package/_cjs/data/CaseClass.cjs.map +1 -1
- package/_cjs/data/Cause/api/fold.cjs +33 -34
- package/_cjs/data/Cause/api/fold.cjs.map +1 -1
- package/_cjs/data/Cause/api/isEmpty.cjs +1 -2
- package/_cjs/data/Cause/api/isEmpty.cjs.map +1 -1
- package/_cjs/data/Cause/api/linearize.cjs +1 -2
- package/_cjs/data/Cause/api/linearize.cjs.map +1 -1
- package/_cjs/data/Cause/api/prettyPrint.cjs +1 -2
- package/_cjs/data/Cause/api/prettyPrint.cjs.map +1 -1
- package/_cjs/data/Cause/api/unified.cjs +1 -2
- package/_cjs/data/Cause/api/unified.cjs.map +1 -1
- package/_cjs/data/Cause/api.cjs +1 -2
- package/_cjs/data/Cause/api.cjs.map +1 -1
- package/_cjs/data/Cause/definition.cjs +1 -2
- package/_cjs/data/Cause/definition.cjs.map +1 -1
- package/_cjs/data/Const/api.cjs +7 -7
- package/_cjs/data/Const/api.cjs.map +1 -1
- package/_cjs/data/Const/instances.cjs +12 -13
- package/_cjs/data/Const/instances.cjs.map +1 -1
- package/_cjs/data/Data.cjs +1 -2
- package/_cjs/data/Data.cjs.map +1 -1
- package/_cjs/data/Datum/api.cjs +110 -113
- package/_cjs/data/Datum/api.cjs.map +1 -1
- package/_cjs/data/Datum/definition.cjs +1 -2
- package/_cjs/data/Datum/definition.cjs.map +1 -1
- package/_cjs/data/Datum/instances.cjs +1 -2
- package/_cjs/data/Datum/instances.cjs.map +1 -1
- package/_cjs/data/Datum.cjs +39 -0
- package/_cjs/data/Datum.cjs.map +1 -0
- package/_cjs/data/DatumEither/api.cjs +56 -57
- package/_cjs/data/DatumEither/api.cjs.map +1 -1
- package/_cjs/data/Duration/api.cjs +1 -2
- package/_cjs/data/Duration/api.cjs.map +1 -1
- package/_cjs/data/Duration/definition.cjs +1 -2
- package/_cjs/data/Duration/definition.cjs.map +1 -1
- package/_cjs/data/Either/api/align.cjs +1 -2
- package/_cjs/data/Either/api/align.cjs.map +1 -1
- package/_cjs/data/Either/api/alignWith.cjs +1 -2
- package/_cjs/data/Either/api/alignWith.cjs.map +1 -1
- package/_cjs/data/Either/api.cjs +53 -55
- package/_cjs/data/Either/api.cjs.map +1 -1
- package/_cjs/data/Either/constructors.cjs +21 -22
- package/_cjs/data/Either/constructors.cjs.map +1 -1
- package/_cjs/data/Either/definition.cjs +1 -2
- package/_cjs/data/Either/definition.cjs.map +1 -1
- package/_cjs/data/Either/instances.cjs +1 -2
- package/_cjs/data/Either/instances.cjs.map +1 -1
- package/_cjs/data/EitherT/api.cjs +28 -29
- package/_cjs/data/EitherT/api.cjs.map +1 -1
- package/_cjs/data/Environment/api.cjs +1 -2
- package/_cjs/data/Environment/api.cjs.map +1 -1
- package/_cjs/data/Environment/definition.cjs +1 -2
- package/_cjs/data/Environment/definition.cjs.map +1 -1
- package/_cjs/data/EnvironmentPatch.cjs +2 -3
- package/_cjs/data/EnvironmentPatch.cjs.map +1 -1
- package/_cjs/data/Eq/api.cjs +189 -5
- package/_cjs/data/Eq/api.cjs.map +1 -1
- package/_cjs/data/Eq/derivations.cjs +10 -21
- package/_cjs/data/Eq/derivations.cjs.map +1 -1
- package/_cjs/data/Equatable/api.cjs +1 -2
- package/_cjs/data/Equatable/api.cjs.map +1 -1
- package/_cjs/data/Equatable/definition.cjs +1 -2
- package/_cjs/data/Equatable/definition.cjs.map +1 -1
- package/_cjs/data/Exit/api.cjs +90 -80
- package/_cjs/data/Exit/api.cjs.map +1 -1
- package/_cjs/data/Exit/constructors.cjs +1 -2
- package/_cjs/data/Exit/constructors.cjs.map +1 -1
- package/_cjs/data/Exit/definition.cjs +1 -2
- package/_cjs/data/Exit/definition.cjs.map +1 -1
- package/_cjs/data/FiberId/api.cjs +1 -2
- package/_cjs/data/FiberId/api.cjs.map +1 -1
- package/_cjs/data/FiberId/definition.cjs +1 -2
- package/_cjs/data/FiberId/definition.cjs.map +1 -1
- package/_cjs/data/Guard/api.cjs +13 -17
- package/_cjs/data/Guard/api.cjs.map +1 -1
- package/_cjs/data/HashEq.cjs +1 -2
- package/_cjs/data/HashEq.cjs.map +1 -1
- package/_cjs/data/Hashable/definition.cjs +1 -2
- package/_cjs/data/Hashable/definition.cjs.map +1 -1
- package/_cjs/data/Hashable/hash.cjs +1 -2
- package/_cjs/data/Hashable/hash.cjs.map +1 -1
- package/_cjs/data/Identity/api.cjs +1 -2
- package/_cjs/data/Identity/api.cjs.map +1 -1
- package/_cjs/data/Identity/definition.cjs +1 -2
- package/_cjs/data/Identity/definition.cjs.map +1 -1
- package/_cjs/data/Identity/instances.cjs +1 -2
- package/_cjs/data/Identity/instances.cjs.map +1 -1
- package/_cjs/data/Interval.cjs +1 -2
- package/_cjs/data/Interval.cjs.map +1 -1
- package/_cjs/data/Intervals.cjs +1 -2
- package/_cjs/data/Intervals.cjs.map +1 -1
- package/_cjs/data/Maybe/api.cjs +73 -60
- package/_cjs/data/Maybe/api.cjs.map +1 -1
- package/_cjs/data/Maybe/constructors.cjs +37 -38
- package/_cjs/data/Maybe/constructors.cjs.map +1 -1
- package/_cjs/data/Maybe/definition.cjs +1 -2
- package/_cjs/data/Maybe/definition.cjs.map +1 -1
- package/_cjs/data/Maybe/instances.cjs +1 -2
- package/_cjs/data/Maybe/instances.cjs.map +1 -1
- package/_cjs/data/Newtype.cjs +1 -2
- package/_cjs/data/Newtype.cjs.map +1 -1
- package/_cjs/data/Ord/api.cjs +1 -2
- package/_cjs/data/Ord/api.cjs.map +1 -1
- package/_cjs/data/Ord/definition.cjs +1 -2
- package/_cjs/data/Ord/definition.cjs.map +1 -1
- package/_cjs/data/Ord/instances.cjs +1 -2
- package/_cjs/data/Ord/instances.cjs.map +1 -1
- package/_cjs/data/Showable/definition.cjs +1 -2
- package/_cjs/data/Showable/definition.cjs.map +1 -1
- package/_cjs/data/Showable/show.cjs +1 -2
- package/_cjs/data/Showable/show.cjs.map +1 -1
- package/_cjs/data/Showable/styles.cjs +1 -2
- package/_cjs/data/Showable/styles.cjs.map +1 -1
- package/_cjs/data/Showable/util.cjs +1 -2
- package/_cjs/data/Showable/util.cjs.map +1 -1
- package/_cjs/data/Struct/api.cjs +5 -7
- package/_cjs/data/Struct/api.cjs.map +1 -1
- package/_cjs/data/Struct/definition.cjs +1 -2
- package/_cjs/data/Struct/definition.cjs.map +1 -1
- package/_cjs/data/Tag/constructors.cjs +1 -2
- package/_cjs/data/Tag/constructors.cjs.map +1 -1
- package/_cjs/data/Tag/definition.cjs +1 -2
- package/_cjs/data/Tag/definition.cjs.map +1 -1
- package/_cjs/data/These/api.cjs +86 -87
- package/_cjs/data/These/api.cjs.map +1 -1
- package/_cjs/data/These/constructors.cjs +1 -2
- package/_cjs/data/These/constructors.cjs.map +1 -1
- package/_cjs/data/These/definition.cjs +1 -2
- package/_cjs/data/These/definition.cjs.map +1 -1
- package/_cjs/data/These/destructors.cjs +1 -2
- package/_cjs/data/These/destructors.cjs.map +1 -1
- package/_cjs/data/These/instances.cjs +1 -2
- package/_cjs/data/These/instances.cjs.map +1 -1
- package/_cjs/data/Trace/api.cjs +1 -2
- package/_cjs/data/Trace/api.cjs.map +1 -1
- package/_cjs/data/Trace/constructors.cjs +1 -2
- package/_cjs/data/Trace/constructors.cjs.map +1 -1
- package/_cjs/data/Zipped.cjs +1 -2
- package/_cjs/data/Zipped.cjs.map +1 -1
- package/_cjs/data/bigint/instances.cjs +1 -2
- package/_cjs/data/bigint/instances.cjs.map +1 -1
- package/_cjs/data/boolean/instances.cjs +1 -2
- package/_cjs/data/boolean/instances.cjs.map +1 -1
- package/_cjs/data/exceptions/IOError.cjs +1 -2
- package/_cjs/data/exceptions/IOError.cjs.map +1 -1
- package/_cjs/data/exceptions/InterruptedException.cjs +1 -2
- package/_cjs/data/exceptions/InterruptedException.cjs.map +1 -1
- package/_cjs/data/number/instances.cjs +1 -2
- package/_cjs/data/number/instances.cjs.map +1 -1
- package/_cjs/data/object/instances.cjs +1 -2
- package/_cjs/data/object/instances.cjs.map +1 -1
- package/_cjs/data/string/api.cjs +1 -2
- package/_cjs/data/string/api.cjs.map +1 -1
- package/_cjs/data/string/instances.cjs +1 -2
- package/_cjs/data/string/instances.cjs.map +1 -1
- package/_cjs/internal/Stack.cjs +7 -2
- package/_cjs/internal/Stack.cjs.map +1 -1
- package/_cjs/optics/At/api.cjs +1 -2
- package/_cjs/optics/At/api.cjs.map +1 -1
- package/_cjs/optics/At/definition.cjs +1 -2
- package/_cjs/optics/At/definition.cjs.map +1 -1
- package/_cjs/optics/Index/api.cjs +3 -4
- package/_cjs/optics/Index/api.cjs.map +1 -1
- package/_cjs/optics/Iso/api.cjs +1 -2
- package/_cjs/optics/Iso/api.cjs.map +1 -1
- package/_cjs/optics/Iso/definition.cjs +1 -2
- package/_cjs/optics/Iso/definition.cjs.map +1 -1
- package/_cjs/optics/Lens/api.cjs +2 -3
- package/_cjs/optics/Lens/api.cjs.map +1 -1
- package/_cjs/optics/Lens/definition.cjs +1 -2
- package/_cjs/optics/Lens/definition.cjs.map +1 -1
- package/_cjs/optics/Optional/api/compose.cjs +1 -2
- package/_cjs/optics/Optional/api/compose.cjs.map +1 -1
- package/_cjs/optics/Optional/api/focus.cjs +1 -2
- package/_cjs/optics/Optional/api/focus.cjs.map +1 -1
- package/_cjs/optics/Optional/api.cjs +1 -2
- package/_cjs/optics/Optional/api.cjs.map +1 -1
- package/_cjs/optics/Optional/definition.cjs +1 -2
- package/_cjs/optics/Optional/definition.cjs.map +1 -1
- package/_cjs/optics/Prism/api/compose.cjs +1 -2
- package/_cjs/optics/Prism/api/compose.cjs.map +1 -1
- package/_cjs/optics/Prism/api/focus.cjs +1 -2
- package/_cjs/optics/Prism/api/focus.cjs.map +1 -1
- package/_cjs/optics/Prism/api/fromNullable.cjs +1 -2
- package/_cjs/optics/Prism/api/fromNullable.cjs.map +1 -1
- package/_cjs/optics/Prism/api/just.cjs +1 -2
- package/_cjs/optics/Prism/api/just.cjs.map +1 -1
- package/_cjs/optics/Prism/definition.cjs +1 -2
- package/_cjs/optics/Prism/definition.cjs.map +1 -1
- package/_cjs/optics/Traversal/api/compose.cjs +1 -2
- package/_cjs/optics/Traversal/api/compose.cjs.map +1 -1
- package/_cjs/optics/Traversal/api/focus.cjs +1 -2
- package/_cjs/optics/Traversal/api/focus.cjs.map +1 -1
- package/_cjs/optics/Traversal/api/fromTraversable.cjs +1 -2
- package/_cjs/optics/Traversal/api/fromTraversable.cjs.map +1 -1
- package/_cjs/optics/Traversal/definition.cjs +1 -2
- package/_cjs/optics/Traversal/definition.cjs.map +1 -1
- package/_cjs/typeclass/ApplicativeExcept.cjs +1 -2
- package/_cjs/typeclass/ApplicativeExcept.cjs.map +1 -1
- package/_cjs/typeclass/Apply.cjs +1 -2
- package/_cjs/typeclass/Apply.cjs.map +1 -1
- package/_cjs/typeclass/Chain.cjs +1 -2
- package/_cjs/typeclass/Chain.cjs.map +1 -1
- package/_cjs/typeclass/MonadExcept.cjs +1 -2
- package/_cjs/typeclass/MonadExcept.cjs.map +1 -1
- package/_cjs/typeclass/Monoid.cjs +1 -2
- package/_cjs/typeclass/Monoid.cjs.map +1 -1
- package/_cjs/typeclass/Semialign.cjs +1 -2
- package/_cjs/typeclass/Semialign.cjs.map +1 -1
- package/_cjs/typeclass/Semigroup/api.cjs +1 -2
- package/_cjs/typeclass/Semigroup/api.cjs.map +1 -1
- package/_cjs/typeclass/Semigroup/derivations.cjs +1 -2
- package/_cjs/typeclass/Semigroup/derivations.cjs.map +1 -1
- package/_cjs/typeclass/Witherable.cjs +1 -2
- package/_cjs/typeclass/Witherable.cjs.map +1 -1
- package/_cjs/typeclass/WitherableWithIndex.cjs +1 -2
- package/_cjs/typeclass/WitherableWithIndex.cjs.map +1 -1
- package/_cjs/util/AnsiFormat.cjs +1 -2
- package/_cjs/util/AnsiFormat.cjs.map +1 -1
- package/_cjs/util/assert.cjs +1 -1
- package/_cjs/util/assert.cjs.map +1 -1
- package/_cjs/util/pattern.cjs.map +1 -1
- package/_cjs/util/rand/generator/RandomGenerator.cjs.map +1 -1
- package/_mjs/collection/AsyncIterable/api.mjs +366 -0
- package/_mjs/collection/AsyncIterable/api.mjs.map +1 -0
- package/_mjs/collection/AsyncIterable/definition.mjs +2 -0
- package/_mjs/collection/AsyncIterable/definition.mjs.map +1 -0
- package/_mjs/collection/AsyncIterable.mjs +4 -0
- package/_mjs/collection/AsyncIterable.mjs.map +1 -0
- package/_mjs/collection/Iterable/api.mjs +175 -134
- package/_mjs/collection/Iterable/api.mjs.map +1 -1
- package/_mjs/collection/Iterable/constructors.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/constructors.mjs +2 -2
- package/_mjs/collection/immutable/Conc/constructors.mjs.map +1 -1
- package/_mjs/collection/immutable/Conc/definition.mjs +1 -1
- package/_mjs/collection/immutable/Conc/definition.mjs.map +1 -1
- package/_mjs/collection/immutable/List/api.mjs +2 -2
- package/_mjs/collection/immutable/List/api.mjs.map +1 -1
- package/_mjs/collection/immutable/{ImmutableArray → ReadonlyArray}/api/chunksOf.mjs +3 -3
- package/_mjs/collection/immutable/ReadonlyArray/api/chunksOf.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray/api/splitAt.mjs +9 -0
- package/_mjs/collection/immutable/ReadonlyArray/api/splitAt.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray/api/splitWhere.mjs +19 -0
- package/_mjs/collection/immutable/ReadonlyArray/api/splitWhere.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray/api.mjs +1302 -0
- package/_mjs/collection/immutable/ReadonlyArray/api.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray/constructors.mjs +44 -0
- package/_mjs/collection/immutable/ReadonlyArray/constructors.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray/definition.mjs.map +1 -0
- package/_mjs/collection/immutable/{ImmutableArray → ReadonlyArray}/instances.mjs +4 -5
- package/_mjs/collection/immutable/ReadonlyArray/instances.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyArray.mjs +11 -0
- package/_mjs/collection/immutable/ReadonlyArray.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/api.mjs +433 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/api.mjs.map +1 -0
- package/_mjs/collection/immutable/{ImmutableNonEmptyArray → ReadonlyNonEmptyArray}/constructors.mjs +16 -15
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/constructors.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/definition.mjs +2 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/definition.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/destructors.mjs +41 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/destructors.mjs.map +1 -0
- package/_mjs/collection/immutable/{ImmutableNonEmptyArray → ReadonlyNonEmptyArray}/instances.mjs +2 -2
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray/instances.mjs.map +1 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray.mjs +7 -0
- package/_mjs/collection/immutable/ReadonlyNonEmptyArray.mjs.map +1 -0
- package/_mjs/collection/immutable/Vector/api.mjs +224 -224
- package/_mjs/collection/immutable/Vector/api.mjs.map +1 -1
- package/_mjs/control/Eval/api.mjs +83 -15
- package/_mjs/control/Eval/api.mjs.map +1 -1
- package/_mjs/control/Eval/constructors.mjs +4 -0
- package/_mjs/control/Eval/constructors.mjs.map +1 -1
- package/_mjs/control/Pure/runtime.mjs +14 -8
- package/_mjs/control/Pure/runtime.mjs.map +1 -1
- package/_mjs/data/CaseClass.mjs +10 -12
- package/_mjs/data/CaseClass.mjs.map +1 -1
- package/_mjs/data/Cause/api/fold.mjs +32 -32
- package/_mjs/data/Cause/api/fold.mjs.map +1 -1
- package/_mjs/data/Const/api.mjs +7 -7
- package/_mjs/data/Const/api.mjs.map +1 -1
- package/_mjs/data/Const/instances.mjs +11 -11
- package/_mjs/data/Const/instances.mjs.map +1 -1
- package/_mjs/data/Datum/api.mjs +107 -108
- package/_mjs/data/Datum/api.mjs.map +1 -1
- package/_mjs/data/Datum.mjs +5 -0
- package/_mjs/data/Datum.mjs.map +1 -0
- package/_mjs/data/DatumEither/api.mjs +53 -53
- package/_mjs/data/DatumEither/api.mjs.map +1 -1
- package/_mjs/data/Either/api.mjs +42 -42
- package/_mjs/data/Either/api.mjs.map +1 -1
- package/_mjs/data/Either/constructors.mjs +20 -20
- package/_mjs/data/Either/constructors.mjs.map +1 -1
- package/_mjs/data/EitherT/api.mjs +27 -27
- package/_mjs/data/EitherT/api.mjs.map +1 -1
- package/_mjs/data/Environment/api.mjs.map +1 -1
- package/_mjs/data/EnvironmentPatch.mjs +1 -1
- package/_mjs/data/Eq/api.mjs +175 -3
- package/_mjs/data/Eq/api.mjs.map +1 -1
- package/_mjs/data/Eq/derivations.mjs +8 -19
- package/_mjs/data/Eq/derivations.mjs.map +1 -1
- package/_mjs/data/Exit/api.mjs +88 -78
- package/_mjs/data/Exit/api.mjs.map +1 -1
- package/_mjs/data/Guard/api.mjs +12 -15
- package/_mjs/data/Guard/api.mjs.map +1 -1
- package/_mjs/data/Maybe/api.mjs +71 -58
- package/_mjs/data/Maybe/api.mjs.map +1 -1
- package/_mjs/data/Maybe/constructors.mjs +36 -36
- package/_mjs/data/Maybe/constructors.mjs.map +1 -1
- package/_mjs/data/Struct/api.mjs +4 -5
- package/_mjs/data/Struct/api.mjs.map +1 -1
- package/_mjs/data/These/api.mjs +85 -85
- package/_mjs/data/These/api.mjs.map +1 -1
- package/_mjs/internal/Stack.mjs +7 -2
- package/_mjs/internal/Stack.mjs.map +1 -1
- package/_mjs/optics/Index/api.mjs +2 -2
- package/_mjs/optics/Index/api.mjs.map +1 -1
- package/_mjs/optics/Lens/api.mjs +1 -1
- package/_mjs/util/assert.mjs +1 -1
- package/_mjs/util/assert.mjs.map +1 -1
- package/_mjs/util/pattern.mjs.map +1 -1
- package/_mjs/util/rand/generator/RandomGenerator.mjs.map +1 -1
- package/_src/collection/AsyncIterable/api.ts +369 -0
- package/_src/collection/AsyncIterable/definition.ts +7 -0
- package/_src/collection/AsyncIterable.ts +4 -0
- package/_src/collection/Iterable/api.ts +215 -162
- package/_src/collection/Iterable/constructors.ts +0 -2
- package/_src/collection/compat/ArrayLike/definition.ts +2 -2
- package/_src/collection/compat.ts +0 -1
- package/_src/collection/immutable/Conc/constructors.ts +1 -2
- package/_src/collection/immutable/Conc/definition.ts +7 -6
- package/_src/collection/immutable/List/api.ts +2 -2
- package/_src/collection/immutable/ReadonlyArray/api/chunksOf.ts +8 -0
- package/_src/collection/immutable/ReadonlyArray/api/splitAt.ts +8 -0
- package/_src/collection/immutable/{ImmutableArray → ReadonlyArray}/api/splitWhere.ts +3 -3
- package/_src/collection/immutable/ReadonlyArray/api.ts +1536 -0
- package/_src/collection/immutable/ReadonlyArray/constructors.ts +47 -0
- package/_src/collection/{compat/Array → immutable/ReadonlyArray}/definition.ts +8 -0
- package/_src/collection/immutable/{ImmutableArray → ReadonlyArray}/instances.ts +22 -22
- package/_src/collection/immutable/ReadonlyArray.ts +12 -0
- package/_src/collection/immutable/ReadonlyNonEmptyArray/api.ts +481 -0
- package/_src/collection/immutable/ReadonlyNonEmptyArray/constructors.ts +76 -0
- package/_src/collection/immutable/ReadonlyNonEmptyArray/definition.ts +22 -0
- package/_src/collection/immutable/ReadonlyNonEmptyArray/destructors.ts +41 -0
- package/_src/collection/immutable/{ImmutableNonEmptyArray → ReadonlyNonEmptyArray}/instances.ts +13 -13
- package/_src/collection/immutable/ReadonlyNonEmptyArray.ts +7 -0
- package/_src/collection/immutable/Vector/api.ts +310 -309
- package/_src/collection/immutable.ts +11 -11
- package/_src/collection.ts +6 -5
- package/_src/control/Eval/api.ts +109 -16
- package/_src/control/Eval/constructors.ts +5 -0
- package/_src/control/Pure/runtime.ts +8 -2
- package/_src/data/CaseClass.ts +5 -5
- package/_src/data/Cause/api/fold.ts +2 -2
- package/_src/data/Const/api.ts +8 -8
- package/_src/data/Const/instances.ts +10 -10
- package/_src/data/Datum/api.ts +113 -113
- package/_src/data/Datum.ts +5 -0
- package/_src/data/DatumEither/api.ts +41 -43
- package/_src/data/Either/api.ts +47 -47
- package/_src/data/Either/constructors.ts +14 -16
- package/_src/data/EitherT/api.ts +111 -110
- package/_src/data/Environment/api.ts +6 -3
- package/_src/data/Eq/api.ts +193 -4
- package/_src/data/Eq/derivations.ts +12 -19
- package/_src/data/Exit/api.ts +89 -77
- package/_src/data/Guard/api.ts +11 -11
- package/_src/data/Maybe/api.ts +82 -73
- package/_src/data/Maybe/constructors.ts +34 -36
- package/_src/data/Struct/api.ts +1 -1
- package/_src/data/These/api.ts +93 -92
- package/_src/data.ts +1 -0
- package/_src/global.ts +7 -12
- package/_src/internal/Stack.ts +6 -2
- package/_src/optics/Index/api.ts +1 -1
- package/_src/util/assert.ts +2 -2
- package/_src/util/pattern.ts +8 -90
- package/_src/util/rand/generator/RandomGenerator.ts +1 -0
- package/collection/AsyncIterable/api.d.ts +71 -0
- package/collection/AsyncIterable/definition.d.ts +9 -0
- package/collection/AsyncIterable.d.ts +2 -0
- package/collection/Iterable/api.d.ts +40 -25
- package/collection/compat/ArrayLike/definition.d.ts +2 -2
- package/collection/compat.d.ts +0 -1
- package/collection/immutable/Conc/definition.d.ts +1 -1
- package/collection/immutable/ReadonlyArray/api/chunksOf.d.ts +5 -0
- package/collection/immutable/ReadonlyArray/api/splitAt.d.ts +5 -0
- package/collection/immutable/ReadonlyArray/api/splitWhere.d.ts +6 -0
- package/collection/immutable/ReadonlyArray/api.d.ts +614 -0
- package/collection/immutable/ReadonlyArray/constructors.d.ts +30 -0
- package/collection/{compat/Array → immutable/ReadonlyArray}/definition.d.ts +8 -0
- package/collection/immutable/ReadonlyArray/instances.d.ts +87 -0
- package/collection/immutable/ReadonlyArray.d.ts +7 -0
- package/collection/immutable/ReadonlyNonEmptyArray/api.d.ts +186 -0
- package/collection/immutable/ReadonlyNonEmptyArray/constructors.d.ts +45 -0
- package/collection/immutable/ReadonlyNonEmptyArray/definition.d.ts +21 -0
- package/collection/immutable/ReadonlyNonEmptyArray/destructors.d.ts +31 -0
- package/collection/immutable/ReadonlyNonEmptyArray/instances.d.ts +52 -0
- package/collection/immutable/ReadonlyNonEmptyArray.d.ts +5 -0
- package/collection/immutable/Vector/api.d.ts +93 -93
- package/collection/immutable.d.ts +2 -2
- package/collection.d.ts +1 -0
- package/control/Eval/api.d.ts +27 -5
- package/control/Eval/constructors.d.ts +5 -0
- package/data/CaseClass.d.ts +2 -3
- package/data/Const/api.d.ts +5 -5
- package/data/Const/instances.d.ts +4 -4
- package/data/Datum/api.d.ts +64 -64
- package/data/Datum.d.ts +3 -0
- package/data/DatumEither/api.d.ts +25 -25
- package/data/Either/api.d.ts +24 -24
- package/data/Either/constructors.d.ts +12 -12
- package/data/EitherT/api.d.ts +16 -16
- package/data/Environment/api.d.ts +4 -2
- package/data/Eq/api.d.ts +89 -2
- package/data/Eq/derivations.d.ts +7 -0
- package/data/Exit/api.d.ts +43 -37
- package/data/Guard/api.d.ts +7 -8
- package/data/Maybe/api.d.ts +38 -33
- package/data/Maybe/constructors.d.ts +16 -16
- package/data/These/api.d.ts +26 -26
- package/data.d.ts +1 -0
- package/global.d.ts +4 -8
- package/internal/Stack.d.ts +2 -0
- package/optics/Lens/api.d.ts +1 -1
- package/package.json +3 -3
- package/util/assert.d.ts +1 -1
- package/_cjs/collection/compat/Array/api.cjs +0 -142
- package/_cjs/collection/compat/Array/api.cjs.map +0 -1
- package/_cjs/collection/compat/Array/definition.cjs.map +0 -1
- package/_cjs/collection/compat/Array.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/api/chunksOf.cjs +0 -19
- package/_cjs/collection/immutable/ImmutableArray/api/chunksOf.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/api/slice.cjs +0 -18
- package/_cjs/collection/immutable/ImmutableArray/api/slice.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/api/splitAt.cjs +0 -18
- package/_cjs/collection/immutable/ImmutableArray/api/splitAt.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/api/splitWhere.cjs +0 -28
- package/_cjs/collection/immutable/ImmutableArray/api/splitWhere.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/api.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/constructors.cjs +0 -59
- package/_cjs/collection/immutable/ImmutableArray/constructors.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/definition.cjs +0 -44
- package/_cjs/collection/immutable/ImmutableArray/definition.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray/instances.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableArray.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/api.cjs +0 -474
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/api.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/constructors.cjs +0 -79
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/constructors.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/definition.cjs +0 -36
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/definition.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/destructors.cjs +0 -53
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/destructors.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray/instances.cjs.map +0 -1
- package/_cjs/collection/immutable/ImmutableNonEmptyArray.cjs.map +0 -1
- package/_cjs/control/Eval/api/sequenceArray.cjs +0 -17
- package/_cjs/control/Eval/api/sequenceArray.cjs.map +0 -1
- package/_mjs/collection/compat/Array/api.mjs +0 -125
- package/_mjs/collection/compat/Array/api.mjs.map +0 -1
- package/_mjs/collection/compat/Array/definition.mjs.map +0 -1
- package/_mjs/collection/compat/Array.mjs +0 -4
- package/_mjs/collection/compat/Array.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/api/chunksOf.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/api/slice.mjs +0 -10
- package/_mjs/collection/immutable/ImmutableArray/api/slice.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/api/splitAt.mjs +0 -10
- package/_mjs/collection/immutable/ImmutableArray/api/splitAt.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/api/splitWhere.mjs +0 -20
- package/_mjs/collection/immutable/ImmutableArray/api/splitWhere.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/api.mjs +0 -1284
- package/_mjs/collection/immutable/ImmutableArray/api.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/constructors.mjs +0 -46
- package/_mjs/collection/immutable/ImmutableArray/constructors.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/definition.mjs +0 -35
- package/_mjs/collection/immutable/ImmutableArray/definition.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray/instances.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableArray.mjs +0 -12
- package/_mjs/collection/immutable/ImmutableArray.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/api.mjs +0 -437
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/api.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/constructors.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/definition.mjs +0 -25
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/definition.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/destructors.mjs +0 -43
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/destructors.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray/instances.mjs.map +0 -1
- package/_mjs/collection/immutable/ImmutableNonEmptyArray.mjs +0 -7
- package/_mjs/collection/immutable/ImmutableNonEmptyArray.mjs.map +0 -1
- package/_mjs/control/Eval/api/sequenceArray.mjs +0 -9
- package/_mjs/control/Eval/api/sequenceArray.mjs.map +0 -1
- package/_src/collection/compat/Array/api.ts +0 -134
- package/_src/collection/compat/Array.ts +0 -4
- package/_src/collection/immutable/ImmutableArray/api/chunksOf.ts +0 -8
- package/_src/collection/immutable/ImmutableArray/api/slice.ts +0 -8
- package/_src/collection/immutable/ImmutableArray/api/splitAt.ts +0 -8
- package/_src/collection/immutable/ImmutableArray/api.ts +0 -1526
- package/_src/collection/immutable/ImmutableArray/constructors.ts +0 -47
- package/_src/collection/immutable/ImmutableArray/definition.ts +0 -48
- package/_src/collection/immutable/ImmutableArray.ts +0 -13
- package/_src/collection/immutable/ImmutableNonEmptyArray/api.ts +0 -483
- package/_src/collection/immutable/ImmutableNonEmptyArray/constructors.ts +0 -83
- package/_src/collection/immutable/ImmutableNonEmptyArray/definition.ts +0 -47
- package/_src/collection/immutable/ImmutableNonEmptyArray/destructors.ts +0 -41
- package/_src/collection/immutable/ImmutableNonEmptyArray.ts +0 -7
- package/_src/control/Eval/api/sequenceArray.ts +0 -6
- package/collection/compat/Array/api.d.ts +0 -62
- package/collection/compat/Array.d.ts +0 -2
- package/collection/immutable/ImmutableArray/api/chunksOf.d.ts +0 -6
- package/collection/immutable/ImmutableArray/api/slice.d.ts +0 -6
- package/collection/immutable/ImmutableArray/api/splitAt.d.ts +0 -6
- package/collection/immutable/ImmutableArray/api/splitWhere.d.ts +0 -7
- package/collection/immutable/ImmutableArray/api.d.ts +0 -602
- package/collection/immutable/ImmutableArray/constructors.d.ts +0 -32
- package/collection/immutable/ImmutableArray/definition.d.ts +0 -34
- package/collection/immutable/ImmutableArray/instances.d.ts +0 -87
- package/collection/immutable/ImmutableArray.d.ts +0 -8
- package/collection/immutable/ImmutableNonEmptyArray/api.d.ts +0 -186
- package/collection/immutable/ImmutableNonEmptyArray/constructors.d.ts +0 -46
- package/collection/immutable/ImmutableNonEmptyArray/definition.d.ts +0 -40
- package/collection/immutable/ImmutableNonEmptyArray/destructors.d.ts +0 -32
- package/collection/immutable/ImmutableNonEmptyArray/instances.d.ts +0 -52
- package/collection/immutable/ImmutableNonEmptyArray.d.ts +0 -5
- package/control/Eval/api/sequenceArray.d.ts +0 -6
- /package/_cjs/collection/{compat/Array → immutable/ReadonlyArray}/definition.cjs +0 -0
- /package/_mjs/collection/{compat/Array → immutable/ReadonlyArray}/definition.mjs +0 -0
@@ -1,1526 +0,0 @@
|
|
1
|
-
import type { ImmutableArrayF } from "@fncts/base/collection/immutable/ImmutableArray/definition";
|
2
|
-
import type { Monoid } from "@fncts/base/typeclass";
|
3
|
-
|
4
|
-
import { EitherTag } from "@fncts/base/data/Either";
|
5
|
-
import { identity, pipe, tuple } from "@fncts/base/data/function";
|
6
|
-
import * as P from "@fncts/base/typeclass";
|
7
|
-
|
8
|
-
/**
|
9
|
-
* @tsplus pipeable fncts.ImmutableArray alignWith
|
10
|
-
*/
|
11
|
-
export function alignWith<A, B, C>(fb: ImmutableArray<B>, f: (_: These<A, B>) => C) {
|
12
|
-
return (self: ImmutableArray<A>): ImmutableArray<C> => {
|
13
|
-
const selfArray = self._array;
|
14
|
-
const thatArray = fb._array;
|
15
|
-
const minlen = Math.min(selfArray.length, thatArray.length);
|
16
|
-
const maxlen = Math.max(selfArray.length, thatArray.length);
|
17
|
-
const ret = Array<C>(maxlen);
|
18
|
-
for (let i = 0; i < minlen; i++) {
|
19
|
-
ret[i] = f(These.both(selfArray[i]!, thatArray[i]!));
|
20
|
-
}
|
21
|
-
if (minlen === maxlen) {
|
22
|
-
return ret.asImmutableArray;
|
23
|
-
} else if (selfArray.length > thatArray.length) {
|
24
|
-
for (let i = minlen; i < maxlen; i++) {
|
25
|
-
ret[i] = f(These.left(selfArray[i]!));
|
26
|
-
}
|
27
|
-
} else {
|
28
|
-
for (let i = minlen; i < maxlen; i++) {
|
29
|
-
ret[i] = f(These.right(thatArray[i]!));
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return ret.asImmutableArray;
|
33
|
-
};
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* @tsplus pipeable fncts.ImmutableArray align
|
38
|
-
*/
|
39
|
-
export function align<B>(fb: ImmutableArray<B>) {
|
40
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<These<A, B>> => {
|
41
|
-
return self.alignWith(fb, identity);
|
42
|
-
};
|
43
|
-
}
|
44
|
-
|
45
|
-
/**
|
46
|
-
* @tsplus pipeable fncts.ImmutableArray alt
|
47
|
-
*/
|
48
|
-
export function alt<B>(that: Lazy<ImmutableArray<B>>) {
|
49
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A | B> => {
|
50
|
-
return self.concat(that());
|
51
|
-
};
|
52
|
-
}
|
53
|
-
|
54
|
-
/**
|
55
|
-
* @tsplus pipeable fncts.ImmutableArray ap
|
56
|
-
*/
|
57
|
-
export function ap<A>(fa: ImmutableArray<A>) {
|
58
|
-
return <B>(self: ImmutableArray<(a: A) => B>): ImmutableArray<B> => {
|
59
|
-
return self.flatMap((f) => fa.map(f));
|
60
|
-
};
|
61
|
-
}
|
62
|
-
|
63
|
-
/**
|
64
|
-
* @tsplus pipeable fncts.ImmutableArray append
|
65
|
-
*/
|
66
|
-
export function append<B>(last: B) {
|
67
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A | B> => {
|
68
|
-
const selfArray = self._array;
|
69
|
-
const len = selfArray.length;
|
70
|
-
const r = Array<A | B>(len + 1);
|
71
|
-
r[len] = last;
|
72
|
-
for (let i = 0; i < len; i++) {
|
73
|
-
r[i] = selfArray[i]!;
|
74
|
-
}
|
75
|
-
return r.asImmutableArray;
|
76
|
-
};
|
77
|
-
}
|
78
|
-
|
79
|
-
/**
|
80
|
-
* @tsplus pipeable fncts.ImmutableArray crossWith
|
81
|
-
*/
|
82
|
-
export function crossWith<A, B, C>(fb: ImmutableArray<B>, f: (a: A, b: B) => C) {
|
83
|
-
return (self: ImmutableArray<A>): ImmutableArray<C> => {
|
84
|
-
return self.flatMap((a) => fb.map((b) => f(a, b)));
|
85
|
-
};
|
86
|
-
}
|
87
|
-
|
88
|
-
/**
|
89
|
-
* @tsplus pipeable fncts.ImmutableArray cross
|
90
|
-
*/
|
91
|
-
export function cross<B>(fb: ImmutableArray<B>) {
|
92
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<Zipped.Make<A, B>> => {
|
93
|
-
return self.crossWith(fb, (a, b) => Zipped(a, b));
|
94
|
-
};
|
95
|
-
}
|
96
|
-
|
97
|
-
/**
|
98
|
-
* @tsplus static fncts.ImmutableArrayOps chainRecDepthFirst
|
99
|
-
*/
|
100
|
-
export function chainRecDepthFirst<A, B>(a: A, f: (a: A) => ImmutableArray<Either<A, B>>): ImmutableArray<B> {
|
101
|
-
const buffer = f(a).slice().unsafeAsMutable;
|
102
|
-
const out: B[] = [];
|
103
|
-
|
104
|
-
while (buffer.length > 0) {
|
105
|
-
const e = buffer.shift()!;
|
106
|
-
Either.concrete(e);
|
107
|
-
if (e._tag === EitherTag.Left) {
|
108
|
-
buffer.unshift(...f(e.left));
|
109
|
-
} else {
|
110
|
-
out.push(e.right);
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
return out.asImmutableArray;
|
115
|
-
}
|
116
|
-
|
117
|
-
/**
|
118
|
-
* @tsplus static fncts.ImmutableArrayOps chainRecBreadthFirst
|
119
|
-
*/
|
120
|
-
export function chainRecBreadthFirst<A, B>(a: A, f: (a: A) => ImmutableArray<Either<A, B>>): ImmutableArray<B> {
|
121
|
-
const initial = f(a);
|
122
|
-
const buffer: Array<Either<A, B>> = [];
|
123
|
-
const out: Array<B> = [];
|
124
|
-
|
125
|
-
function go(e: Either<A, B>): void {
|
126
|
-
Either.concrete(e);
|
127
|
-
if (e._tag === "Left") {
|
128
|
-
f(e.left).forEach((v) => buffer.push(v));
|
129
|
-
} else {
|
130
|
-
out.push(e.right);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
for (const e of initial) {
|
135
|
-
go(e);
|
136
|
-
}
|
137
|
-
|
138
|
-
while (buffer.length > 0) {
|
139
|
-
go(buffer.shift()!);
|
140
|
-
}
|
141
|
-
|
142
|
-
return out.asImmutableArray;
|
143
|
-
}
|
144
|
-
|
145
|
-
/**
|
146
|
-
* @tsplus pipeable fncts.ImmutableArray flatMapWithIndex
|
147
|
-
*/
|
148
|
-
export function flatMapWithIndex<A, B>(f: (i: number, a: A) => ImmutableArray<B>) {
|
149
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
150
|
-
let outLen = 0;
|
151
|
-
const selfArray = self._array;
|
152
|
-
const len = selfArray.length;
|
153
|
-
const temp = Array<Array<B>>(len);
|
154
|
-
for (let i = 0; i < len; i++) {
|
155
|
-
const e = selfArray[i]!;
|
156
|
-
const arr = f(i, e)._array;
|
157
|
-
outLen += arr.length;
|
158
|
-
temp[i] = arr! as Array<B>;
|
159
|
-
}
|
160
|
-
const out = Array<B>(outLen);
|
161
|
-
let start = 0;
|
162
|
-
for (let i = 0; i < len; i++) {
|
163
|
-
const arr = temp[i]!;
|
164
|
-
const l = arr.length;
|
165
|
-
for (let j = 0; j < l; j++) {
|
166
|
-
out[j + start] = arr[j]!;
|
167
|
-
}
|
168
|
-
start += l;
|
169
|
-
}
|
170
|
-
return out.asImmutableArray;
|
171
|
-
};
|
172
|
-
}
|
173
|
-
|
174
|
-
/**
|
175
|
-
* @tsplus pipeable fncts.ImmutableArray flatMap
|
176
|
-
*/
|
177
|
-
export function flatMap<A, B>(f: (a: A) => ImmutableArray<B>) {
|
178
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
179
|
-
return self.flatMapWithIndex((_, a) => f(a));
|
180
|
-
};
|
181
|
-
}
|
182
|
-
|
183
|
-
/**
|
184
|
-
* @tsplus getter fncts.ImmutableArray flatten
|
185
|
-
*/
|
186
|
-
export function flatten<A>(self: ImmutableArray<ImmutableArray<A>>): ImmutableArray<A> {
|
187
|
-
return self.flatMap(identity);
|
188
|
-
}
|
189
|
-
|
190
|
-
/**
|
191
|
-
* A useful recursion pattern for processing a `Array` to produce a new `Array`,
|
192
|
-
* often used for "chopping" up the input `Array`. Typically chop is called with some function
|
193
|
-
* that will consume an initial prefix of the `Array` and produce a value and the rest of the `Array`.
|
194
|
-
*
|
195
|
-
* @tsplus pipeable fncts.ImmutableArray chop
|
196
|
-
*/
|
197
|
-
export function chop<A, B>(f: (as: ImmutableNonEmptyArray<A>) => readonly [B, ImmutableArray<A>]) {
|
198
|
-
return (as: ImmutableArray<A>): ImmutableArray<B> => {
|
199
|
-
const result: Array<B> = [];
|
200
|
-
let cs: ImmutableArray<A> = as;
|
201
|
-
while (cs.isNonEmpty()) {
|
202
|
-
const [b, c] = f(cs);
|
203
|
-
result.push(b);
|
204
|
-
cs = c;
|
205
|
-
}
|
206
|
-
return result.asImmutableArray;
|
207
|
-
};
|
208
|
-
}
|
209
|
-
|
210
|
-
/**
|
211
|
-
* @tsplus pipeable fncts.ImmutableArray collectWhile
|
212
|
-
*/
|
213
|
-
export function collectWhile<A, B>(f: (a: A) => Maybe<B>) {
|
214
|
-
return (as: ImmutableArray<A>): ImmutableArray<B> => {
|
215
|
-
const result: Array<B> = [];
|
216
|
-
for (let i = 0; i < as.length; i++) {
|
217
|
-
const o = f(as._array[i]!);
|
218
|
-
if (o.isJust()) {
|
219
|
-
result.push(o.value);
|
220
|
-
} else {
|
221
|
-
break;
|
222
|
-
}
|
223
|
-
}
|
224
|
-
return result.asImmutableArray;
|
225
|
-
};
|
226
|
-
}
|
227
|
-
|
228
|
-
function comprehensionLoop<A, R>(
|
229
|
-
scope: ImmutableArray<A>,
|
230
|
-
input: ReadonlyArray<ImmutableArray<A>>,
|
231
|
-
f: (...xs: ReadonlyArray<A>) => R,
|
232
|
-
g: (...xs: ReadonlyArray<A>) => boolean,
|
233
|
-
): Eval<ImmutableArray<R>> {
|
234
|
-
if (input.length === 0) {
|
235
|
-
return g(...scope) ? Eval.now(ImmutableArray(f(...scope))) : Eval.now(ImmutableArray.empty());
|
236
|
-
} else {
|
237
|
-
return input[0]!
|
238
|
-
.traverse(Eval.Applicative)((a) => comprehensionLoop(scope.append(a), input.slice(1), f, g))
|
239
|
-
.map((rs) => rs.flatten);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
|
243
|
-
/**
|
244
|
-
* @tsplus static fncts.ImmutableArrayOps comprehension
|
245
|
-
*/
|
246
|
-
export function comprehension<A, B, C, D, R>(
|
247
|
-
input: [ImmutableArray<A>, ImmutableArray<B>, ImmutableArray<C>, ImmutableArray<D>],
|
248
|
-
f: (a: A, b: B, c: C, d: D) => R,
|
249
|
-
g?: (a: A, b: B, c: C, d: D) => boolean,
|
250
|
-
): ImmutableArray<R>;
|
251
|
-
export function comprehension<A, B, C, R>(
|
252
|
-
input: [ImmutableArray<A>, ImmutableArray<B>, ImmutableArray<C>],
|
253
|
-
f: (a: A, b: B, c: C) => R,
|
254
|
-
g?: (a: A, b: B, c: C) => boolean,
|
255
|
-
): ImmutableArray<R>;
|
256
|
-
export function comprehension<A, B, R>(
|
257
|
-
input: [ImmutableArray<A>, ImmutableArray<B>],
|
258
|
-
f: (a: A, b: B) => R,
|
259
|
-
g?: (a: A, b: B) => boolean,
|
260
|
-
): ImmutableArray<R>;
|
261
|
-
export function comprehension<A, R>(
|
262
|
-
input: [ImmutableArray<A>],
|
263
|
-
f: (a: A) => R,
|
264
|
-
g?: (a: A) => boolean,
|
265
|
-
): ImmutableArray<R>;
|
266
|
-
export function comprehension<A, R>(
|
267
|
-
input: ReadonlyArray<ImmutableArray<A>>,
|
268
|
-
f: (...xs: ReadonlyArray<A>) => R,
|
269
|
-
g: (...xs: ReadonlyArray<A>) => boolean = () => true,
|
270
|
-
): ImmutableArray<R> {
|
271
|
-
return Eval.run(comprehensionLoop(ImmutableArray.empty(), input, f, g));
|
272
|
-
}
|
273
|
-
|
274
|
-
/**
|
275
|
-
* @tsplus pipeable fncts.ImmutableArray concat
|
276
|
-
* @tsplus pipeable-operator fncts.ImmutableArray +
|
277
|
-
*/
|
278
|
-
export function concat<B>(that: ImmutableArray<B>) {
|
279
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A | B> => {
|
280
|
-
const lenx = self._array.length;
|
281
|
-
if (lenx === 0) {
|
282
|
-
return that;
|
283
|
-
}
|
284
|
-
const leny = that._array.length;
|
285
|
-
if (leny === 0) {
|
286
|
-
return self;
|
287
|
-
}
|
288
|
-
const r = Array<A | B>(lenx + leny);
|
289
|
-
for (let i = 0; i < lenx; i++) {
|
290
|
-
r[i] = self._array[i]!;
|
291
|
-
}
|
292
|
-
for (let i = 0; i < leny; i++) {
|
293
|
-
r[i + lenx] = that._array[i]!;
|
294
|
-
}
|
295
|
-
return r.asImmutableArray;
|
296
|
-
};
|
297
|
-
}
|
298
|
-
|
299
|
-
/**
|
300
|
-
* @tsplus pipeable fncts.ImmutableArray deleteAt
|
301
|
-
*/
|
302
|
-
export function deleteAt(i: number) {
|
303
|
-
return <A>(as: ImmutableArray<A>): Maybe<ImmutableArray<A>> => {
|
304
|
-
return as.isOutOfBound(i) ? Nothing() : Just(as.unsafeDeleteAt(i));
|
305
|
-
};
|
306
|
-
}
|
307
|
-
|
308
|
-
/**
|
309
|
-
* @tsplus pipeable fncts.ImmutableArray difference
|
310
|
-
*/
|
311
|
-
export function difference<A>(ys: ImmutableArray<A>, /** @tsplus auto */ E: P.Eq<A>) {
|
312
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
313
|
-
return self.filter((a) => !ys.elem(a, E));
|
314
|
-
};
|
315
|
-
}
|
316
|
-
|
317
|
-
/**
|
318
|
-
* @tsplus pipeable fncts.ImmutableArray drop
|
319
|
-
*/
|
320
|
-
export function drop(n: number) {
|
321
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A> => {
|
322
|
-
return self.slice(n);
|
323
|
-
};
|
324
|
-
}
|
325
|
-
|
326
|
-
/**
|
327
|
-
* @tsplus pipeable fncts.ImmutableArray dropLast
|
328
|
-
*/
|
329
|
-
export function dropLast(n: number) {
|
330
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A> => {
|
331
|
-
return self.slice(0, self.length - n);
|
332
|
-
};
|
333
|
-
}
|
334
|
-
|
335
|
-
/**
|
336
|
-
* @tsplus pipeable fncts.ImmutableArray dropWhile
|
337
|
-
*/
|
338
|
-
export function dropWhile<A>(p: Predicate<A>) {
|
339
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
340
|
-
return self.slice(self.spanIndexLeft(p));
|
341
|
-
};
|
342
|
-
}
|
343
|
-
|
344
|
-
/**
|
345
|
-
* @tsplus pipeable fncts.ImmutableArray dropLastWhile
|
346
|
-
*/
|
347
|
-
export function dropLastWhile<A>(p: Predicate<A>) {
|
348
|
-
return (as: ImmutableArray<A>): ImmutableArray<A> => {
|
349
|
-
return as.slice(0, as.spanIndexRight(p) + 1);
|
350
|
-
};
|
351
|
-
}
|
352
|
-
|
353
|
-
/**
|
354
|
-
* Test if a value is a member of an array. Takes an `Eq<A>` as a single
|
355
|
-
* argument which returns the function to use to search for a value of type `A` in
|
356
|
-
* an array of type `ImmutableArray<A>`.
|
357
|
-
*
|
358
|
-
* @tsplus pipeable fncts.ImmutableArray elem
|
359
|
-
*/
|
360
|
-
export function elem<A>(a: A, /** @tsplus auto */ E: P.Eq<A>) {
|
361
|
-
return (as: ImmutableArray<A>): boolean => {
|
362
|
-
const predicate = (element: A) => E.equals(a)(element);
|
363
|
-
const len = as.length;
|
364
|
-
for (let i = 0; i < len; i++) {
|
365
|
-
if (predicate(as._array[i]!)) {
|
366
|
-
return true;
|
367
|
-
}
|
368
|
-
}
|
369
|
-
return false;
|
370
|
-
};
|
371
|
-
}
|
372
|
-
|
373
|
-
/**
|
374
|
-
* @tsplus pipeable fncts.ImmutableArray every
|
375
|
-
*/
|
376
|
-
export function every<A, B extends A>(p: Refinement<A, B>): (self: ImmutableArray<A>) => self is ImmutableArray<B>;
|
377
|
-
export function every<A>(p: Predicate<A>): (self: ImmutableArray<A>) => boolean;
|
378
|
-
export function every<A>(p: Predicate<A>) {
|
379
|
-
return (self: ImmutableArray<A>): boolean => {
|
380
|
-
return self.everyWithIndex((_, a) => p(a));
|
381
|
-
};
|
382
|
-
}
|
383
|
-
|
384
|
-
/**
|
385
|
-
* @tsplus pipeable fncts.ImmutableArray everyWithIndex
|
386
|
-
*/
|
387
|
-
export function everyWithIndex<A, B extends A>(
|
388
|
-
p: RefinementWithIndex<number, A, B>,
|
389
|
-
): (self: ImmutableArray<A>) => self is ImmutableArray<B>;
|
390
|
-
export function everyWithIndex<A>(p: PredicateWithIndex<number, A>): (self: ImmutableArray<A>) => boolean;
|
391
|
-
export function everyWithIndex<A>(p: PredicateWithIndex<number, A>) {
|
392
|
-
return (self: ImmutableArray<A>): boolean => {
|
393
|
-
let result = true;
|
394
|
-
let i = 0;
|
395
|
-
while (result && i < self.length) {
|
396
|
-
result = p(i, self._array[i]!);
|
397
|
-
i++;
|
398
|
-
}
|
399
|
-
return result;
|
400
|
-
};
|
401
|
-
}
|
402
|
-
|
403
|
-
/**
|
404
|
-
* @tsplus pipeable fncts.ImmutableArray some
|
405
|
-
*/
|
406
|
-
export function some<A>(p: Predicate<A>) {
|
407
|
-
return (self: ImmutableArray<A>): self is ImmutableNonEmptyArray<A> => {
|
408
|
-
let result = false;
|
409
|
-
let i = 0;
|
410
|
-
while (!result && i < self.length) {
|
411
|
-
result = p(self._array[i]!);
|
412
|
-
i++;
|
413
|
-
}
|
414
|
-
return result;
|
415
|
-
};
|
416
|
-
}
|
417
|
-
|
418
|
-
/**
|
419
|
-
* @tsplus pipeable fncts.ImmutableArray filter
|
420
|
-
*/
|
421
|
-
export function filter<A, B extends A>(p: Refinement<A, B>): (self: ImmutableArray<A>) => ImmutableArray<B>;
|
422
|
-
export function filter<A>(p: Predicate<A>): (self: ImmutableArray<A>) => ImmutableArray<A>;
|
423
|
-
export function filter<A>(p: Predicate<A>) {
|
424
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
425
|
-
return self.filterWithIndex((_, a) => p(a));
|
426
|
-
};
|
427
|
-
}
|
428
|
-
|
429
|
-
/**
|
430
|
-
* @tsplus pipeable fncts.ImmutableArray filterWithIndex
|
431
|
-
*/
|
432
|
-
export function filterWithIndex<A, B extends A>(
|
433
|
-
p: RefinementWithIndex<number, A, B>,
|
434
|
-
): (self: ImmutableArray<A>) => ImmutableArray<B>;
|
435
|
-
export function filterWithIndex<A>(p: PredicateWithIndex<number, A>): (self: ImmutableArray<A>) => ImmutableArray<A>;
|
436
|
-
export function filterWithIndex<A>(p: PredicateWithIndex<number, A>) {
|
437
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
438
|
-
const result: Array<A> = [];
|
439
|
-
for (let i = 0; i < self.length; i++) {
|
440
|
-
const a = self._array[i]!;
|
441
|
-
if (p(i, a)) {
|
442
|
-
result.push(a);
|
443
|
-
}
|
444
|
-
}
|
445
|
-
return result.asImmutableArray;
|
446
|
-
};
|
447
|
-
}
|
448
|
-
|
449
|
-
/**
|
450
|
-
* @tsplus pipeable fncts.ImmutableArray filterMapWithIndex
|
451
|
-
*/
|
452
|
-
export function filterMapWithIndex<A, B>(f: (i: number, a: A) => Maybe<B>) {
|
453
|
-
return (fa: ImmutableArray<A>): ImmutableArray<B> => {
|
454
|
-
const result = [];
|
455
|
-
for (let i = 0; i < fa.length; i++) {
|
456
|
-
const maybeB = f(i, fa[i]!);
|
457
|
-
if (maybeB.isJust()) {
|
458
|
-
result.push(maybeB.value);
|
459
|
-
}
|
460
|
-
}
|
461
|
-
return result.asImmutableArray;
|
462
|
-
};
|
463
|
-
}
|
464
|
-
|
465
|
-
/**
|
466
|
-
* @tsplus pipeable fncts.ImmutableArray filterMap
|
467
|
-
*/
|
468
|
-
export function filterMap<A, B>(f: (a: A) => Maybe<B>) {
|
469
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
470
|
-
return self.filterMapWithIndex((_, a) => f(a));
|
471
|
-
};
|
472
|
-
}
|
473
|
-
|
474
|
-
/**
|
475
|
-
* @tsplus pipeable fncts.ImmutableArray find
|
476
|
-
*/
|
477
|
-
export function find<A, B extends A>(p: Refinement<A, B>): (self: ImmutableArray<A>) => Maybe<B>;
|
478
|
-
export function find<A>(p: Predicate<A>): (self: ImmutableArray<A>) => Maybe<A>;
|
479
|
-
export function find<A>(p: Predicate<A>) {
|
480
|
-
return (self: ImmutableArray<A>): Maybe<A> => {
|
481
|
-
return self.findWithIndex((_, a) => p(a));
|
482
|
-
};
|
483
|
-
}
|
484
|
-
|
485
|
-
/**
|
486
|
-
* @tsplus pipeable fncts.ImmutableArray findIndex
|
487
|
-
*/
|
488
|
-
export function findIndex<A>(predicate: Predicate<A>) {
|
489
|
-
return (as: ImmutableArray<A>): Maybe<number> => {
|
490
|
-
return as.findMapWithIndex((i, a) => (predicate(a) ? Just(i) : Nothing()));
|
491
|
-
};
|
492
|
-
}
|
493
|
-
|
494
|
-
/**
|
495
|
-
* @tsplus pipeable fncts.ImmutableArray findWithIndex
|
496
|
-
*/
|
497
|
-
export function findWithIndex<A, B extends A>(
|
498
|
-
p: RefinementWithIndex<number, A, B>,
|
499
|
-
): (as: ImmutableArray<A>) => Maybe<B>;
|
500
|
-
export function findWithIndex<A>(p: PredicateWithIndex<number, A>): (as: ImmutableArray<A>) => Maybe<A>;
|
501
|
-
export function findWithIndex<A>(p: PredicateWithIndex<number, A>) {
|
502
|
-
return (as: ImmutableArray<A>): Maybe<A> => {
|
503
|
-
const len = as.length;
|
504
|
-
for (let i = 0; i < len; i++) {
|
505
|
-
if (p(i, as._array[i]!)) {
|
506
|
-
return Just(as._array[i]!);
|
507
|
-
}
|
508
|
-
}
|
509
|
-
return Nothing();
|
510
|
-
};
|
511
|
-
}
|
512
|
-
|
513
|
-
/**
|
514
|
-
* @tsplus pipeable fncts.ImmutableArray findMap
|
515
|
-
*/
|
516
|
-
export function findMap<A, B>(f: (a: A) => Maybe<B>) {
|
517
|
-
return (as: ImmutableArray<A>): Maybe<B> => {
|
518
|
-
return as.findMapWithIndex((_, a) => f(a));
|
519
|
-
};
|
520
|
-
}
|
521
|
-
|
522
|
-
/**
|
523
|
-
* @tsplus pipeable fncts.ImmutableArray findMapWithIndex
|
524
|
-
*/
|
525
|
-
export function findMapWithIndex<A, B>(f: (index: number, a: A) => Maybe<B>) {
|
526
|
-
return (as: ImmutableArray<A>): Maybe<B> => {
|
527
|
-
const len = as.length;
|
528
|
-
for (let i = 0; i < len; i++) {
|
529
|
-
const v = f(i, as._array[i]!);
|
530
|
-
if (v.isJust()) {
|
531
|
-
return v;
|
532
|
-
}
|
533
|
-
}
|
534
|
-
return Nothing();
|
535
|
-
};
|
536
|
-
}
|
537
|
-
|
538
|
-
/**
|
539
|
-
* @tsplus pipeable fncts.ImmutableArray findLast
|
540
|
-
*/
|
541
|
-
export function findLast<A, B extends A>(p: Refinement<A, B>): (as: ImmutableArray<A>) => Maybe<B>;
|
542
|
-
export function findLast<A>(p: Predicate<A>): (as: ImmutableArray<A>) => Maybe<A>;
|
543
|
-
export function findLast<A>(p: Predicate<A>) {
|
544
|
-
return (as: ImmutableArray<A>): Maybe<A> => {
|
545
|
-
const len = as.length;
|
546
|
-
for (let i = len - 1; i >= 0; i--) {
|
547
|
-
if (p(as._array[i]!)) {
|
548
|
-
return Just(as._array[i]!);
|
549
|
-
}
|
550
|
-
}
|
551
|
-
return Nothing();
|
552
|
-
};
|
553
|
-
}
|
554
|
-
|
555
|
-
/**
|
556
|
-
* @tsplus pipeable fncts.ImmutableArray findLastIndex
|
557
|
-
*/
|
558
|
-
export function findLastIndex<A>(p: Predicate<A>) {
|
559
|
-
return (self: ImmutableArray<A>): Maybe<number> => {
|
560
|
-
return self.findLastMapWithIndex((i, a) => (p(a) ? Just(i) : Nothing()));
|
561
|
-
};
|
562
|
-
}
|
563
|
-
|
564
|
-
/**
|
565
|
-
* @tsplus pipeable fncts.ImmutableArray findLastMap
|
566
|
-
*/
|
567
|
-
export function findLastMap<A, B>(f: (a: A) => Maybe<B>) {
|
568
|
-
return (as: ImmutableArray<A>): Maybe<B> => {
|
569
|
-
return as.findLastMapWithIndex((_, a) => f(a));
|
570
|
-
};
|
571
|
-
}
|
572
|
-
|
573
|
-
/**
|
574
|
-
* @tsplus pipeable fncts.ImmutableArray findLastMapWithIndex
|
575
|
-
*/
|
576
|
-
export function findLastMapWithIndex<A, B>(f: (i: number, a: A) => Maybe<B>) {
|
577
|
-
return (as: ImmutableArray<A>): Maybe<B> => {
|
578
|
-
const len = as.length;
|
579
|
-
for (let i = len - 1; i >= 0; i--) {
|
580
|
-
const v = f(i, as._array[i]!);
|
581
|
-
if (v.isJust()) {
|
582
|
-
return v;
|
583
|
-
}
|
584
|
-
}
|
585
|
-
return Nothing();
|
586
|
-
};
|
587
|
-
}
|
588
|
-
|
589
|
-
/**
|
590
|
-
* @tsplus pipeable fncts.ImmutableArray foldLeftWithIndex
|
591
|
-
* @tsplus pipeable fncts.MutableArray foldLeftWithIndex
|
592
|
-
*/
|
593
|
-
export function foldLeftWithIndex<A, B>(b: B, f: (i: number, b: B, a: A) => B) {
|
594
|
-
return (self: ImmutableArray<A>): B => {
|
595
|
-
const len = self.length;
|
596
|
-
let r = b;
|
597
|
-
for (let i = 0; i < len; i++) {
|
598
|
-
r = f(i, r, self._array[i]!);
|
599
|
-
}
|
600
|
-
return r;
|
601
|
-
};
|
602
|
-
}
|
603
|
-
|
604
|
-
/**
|
605
|
-
* @tsplus pipeable fncts.ImmutableArray foldLeft
|
606
|
-
* @tsplus pipeable fncts.MutableArray foldLeft
|
607
|
-
*/
|
608
|
-
export function foldLeft<A, B>(b: B, f: (b: B, a: A) => B) {
|
609
|
-
return (self: ImmutableArray<A>): B => {
|
610
|
-
return self.foldLeftWithIndex(b, (_, b, a) => f(b, a));
|
611
|
-
};
|
612
|
-
}
|
613
|
-
|
614
|
-
/**
|
615
|
-
* @tsplus pipeable fncts.ImmutableArray foldLeftWhile
|
616
|
-
* @tsplus pipeable fncts.MutableArray foldLeftWhile
|
617
|
-
*/
|
618
|
-
export function foldLeftWhile<A, B>(b: B, p: Predicate<B>, f: (b: B, a: A) => B) {
|
619
|
-
return (self: ImmutableArray<A>): B => {
|
620
|
-
return self.foldLeftWithIndexWhile(b, p, (_, b, a) => f(b, a));
|
621
|
-
};
|
622
|
-
}
|
623
|
-
|
624
|
-
/**
|
625
|
-
* @tsplus pipeable fncts.ImmutableArray foldLeftWithIndexWhile
|
626
|
-
* @tsplus pipeable fncts.MutableArray foldLeftWithIndexWhile
|
627
|
-
*/
|
628
|
-
export function foldLeftWithIndexWhile<A, B>(b: B, p: Predicate<B>, f: (i: number, b: B, a: A) => B) {
|
629
|
-
return (self: ImmutableArray<A>): B => {
|
630
|
-
let out = b;
|
631
|
-
let cont = p(out);
|
632
|
-
for (let i = 0; cont && i < self.length; i++) {
|
633
|
-
out = f(i, out, self._array[i]!);
|
634
|
-
cont = p(out);
|
635
|
-
}
|
636
|
-
return out;
|
637
|
-
};
|
638
|
-
}
|
639
|
-
|
640
|
-
/**
|
641
|
-
* @tsplus pipeable fncts.ImmutableArray fold
|
642
|
-
*/
|
643
|
-
export function fold<M>(/** @tsplus auto */ M: Monoid<M>) {
|
644
|
-
return (self: ImmutableArray<M>): M => {
|
645
|
-
return self.foldLeft(M.nat, (b, a) => M.combine(a)(b));
|
646
|
-
};
|
647
|
-
}
|
648
|
-
|
649
|
-
/**
|
650
|
-
* @tsplus pipeable fncts.ImmutableArray foldMapWithIndex
|
651
|
-
*/
|
652
|
-
export function foldMapWithIndex<A, M>(f: (i: number, a: A) => M, /** @tsplus auto */ M: Monoid<M>) {
|
653
|
-
return (self: ImmutableArray<A>): M => {
|
654
|
-
return self.foldLeftWithIndex(M.nat, (i, b, a) => M.combine(f(i, a))(b));
|
655
|
-
};
|
656
|
-
}
|
657
|
-
|
658
|
-
/**
|
659
|
-
* @tsplus pipeable fncts.ImmutableArray foldMap
|
660
|
-
*/
|
661
|
-
export function foldMap<A, M>(f: (a: A) => M, /** @tsplus auto */ M: Monoid<M>) {
|
662
|
-
return (self: ImmutableArray<A>): M => {
|
663
|
-
return self.foldMapWithIndex((_, a) => f(a), M);
|
664
|
-
};
|
665
|
-
}
|
666
|
-
|
667
|
-
/**
|
668
|
-
* @tsplus pipeable fncts.ImmutableArray foldRightWithIndex
|
669
|
-
*/
|
670
|
-
export function foldRightWithIndex<A, B>(b: B, f: (i: number, a: A, b: B) => B) {
|
671
|
-
return (self: ImmutableArray<A>): B => {
|
672
|
-
let r = b;
|
673
|
-
for (let i = self.length - 1; i >= 0; i--) {
|
674
|
-
r = f(i, self._array[i]!, r);
|
675
|
-
}
|
676
|
-
return r;
|
677
|
-
};
|
678
|
-
}
|
679
|
-
|
680
|
-
/**
|
681
|
-
* @tsplus pipeable fncts.ImmutableArray foldRight
|
682
|
-
*/
|
683
|
-
export function foldRight<A, B>(b: B, f: (a: A, b: B) => B) {
|
684
|
-
return (self: ImmutableArray<A>): B => {
|
685
|
-
return self.foldRightWithIndex(b, (_, a, b) => f(a, b));
|
686
|
-
};
|
687
|
-
}
|
688
|
-
|
689
|
-
/**
|
690
|
-
* @tsplus pipeable fncts.ImmutableArray foldRighWhile
|
691
|
-
*/
|
692
|
-
export function foldRightWhile<A, B>(b: B, p: Predicate<B>, f: (a: A, b: B) => B) {
|
693
|
-
return (self: ImmutableArray<A>): B => {
|
694
|
-
return self.foldRightWithIndexWhile(b, p, (_, a, b) => f(a, b));
|
695
|
-
};
|
696
|
-
}
|
697
|
-
|
698
|
-
/**
|
699
|
-
* @tsplus pipeable fncts.ImmutableArray foldRightWithIndexWhile
|
700
|
-
*/
|
701
|
-
export function foldRightWithIndexWhile<A, B>(b: B, predicate: Predicate<B>, f: (i: number, a: A, b: B) => B) {
|
702
|
-
return (self: ImmutableArray<A>): B => {
|
703
|
-
let out = b;
|
704
|
-
let cont = predicate(out);
|
705
|
-
for (let i = self.length - 1; cont && i >= 0; i--) {
|
706
|
-
out = f(i, self._array[i]!, out);
|
707
|
-
cont = predicate(out);
|
708
|
-
}
|
709
|
-
return out;
|
710
|
-
};
|
711
|
-
}
|
712
|
-
|
713
|
-
/**
|
714
|
-
* @tsplus pipeable fncts.ImmutableArray forEach
|
715
|
-
*/
|
716
|
-
export function forEach<A, B>(f: (a: A) => B) {
|
717
|
-
return (self: ImmutableArray<A>): void => {
|
718
|
-
return self.forEach(f);
|
719
|
-
};
|
720
|
-
}
|
721
|
-
|
722
|
-
/**
|
723
|
-
* @tsplus pipeable fncts.ImmutableArray get
|
724
|
-
* @tsplus pipeable fncts.MutableArray get
|
725
|
-
*/
|
726
|
-
export function get(i: number) {
|
727
|
-
return <A>(self: ImmutableArray<A>): Maybe<A> => {
|
728
|
-
return self.isOutOfBound(i) ? Nothing() : Just(self._array[i]!);
|
729
|
-
};
|
730
|
-
}
|
731
|
-
|
732
|
-
/**
|
733
|
-
* @tsplus pipeable fncts.ImmutableArray group
|
734
|
-
*/
|
735
|
-
export function group<A>(E: P.Eq<A>): (self: ImmutableArray<A>) => ImmutableArray<ImmutableNonEmptyArray<A>> {
|
736
|
-
return chop((self) => {
|
737
|
-
const h = self._array[0]!;
|
738
|
-
const out = [h];
|
739
|
-
let i = 1;
|
740
|
-
for (; i < self.length; i++) {
|
741
|
-
const a = self._array[i]!;
|
742
|
-
if (E.equals(h)(a)) {
|
743
|
-
out.push(a);
|
744
|
-
} else {
|
745
|
-
break;
|
746
|
-
}
|
747
|
-
}
|
748
|
-
return [out.unsafeAsNonEmptyArray, self.slice(i)];
|
749
|
-
});
|
750
|
-
}
|
751
|
-
|
752
|
-
/**
|
753
|
-
* @tsplus pipeable fncts.ImmutableArray groupBy
|
754
|
-
*/
|
755
|
-
export function groupBy<A>(f: (a: A) => string) {
|
756
|
-
return (self: ImmutableArray<A>): Readonly<Record<string, ImmutableNonEmptyArray<A>>> => {
|
757
|
-
const out: Record<string, NonEmptyArray<A>> = {};
|
758
|
-
for (let i = 0; i < self.length; i++) {
|
759
|
-
const a = self._array[i]!;
|
760
|
-
const k = f(a);
|
761
|
-
if (Object.prototype.hasOwnProperty.call(out, k)) {
|
762
|
-
out[k]!.push(a);
|
763
|
-
} else {
|
764
|
-
out[k] = [a];
|
765
|
-
}
|
766
|
-
}
|
767
|
-
return Dictionary.get(out).map(ImmutableNonEmptyArray.from).toRecord;
|
768
|
-
};
|
769
|
-
}
|
770
|
-
|
771
|
-
/**
|
772
|
-
* @tsplus getter fncts.ImmutableArray head
|
773
|
-
*/
|
774
|
-
export function head<A>(self: ImmutableArray<A>): Maybe<A> {
|
775
|
-
return self.isNonEmpty() ? Just(self._array[0]) : Nothing();
|
776
|
-
}
|
777
|
-
|
778
|
-
/**
|
779
|
-
* @tsplus getter fncts.ImmutableArray init
|
780
|
-
*/
|
781
|
-
export function init<A>(self: ImmutableArray<A>): Maybe<ImmutableArray<A>> {
|
782
|
-
const len = self.length;
|
783
|
-
return len === 0 ? Nothing() : Just(self.slice(0, len - 1));
|
784
|
-
}
|
785
|
-
|
786
|
-
/**
|
787
|
-
* @tsplus pipeable fncts.ImmutableArray insertAt
|
788
|
-
*/
|
789
|
-
export function insertAt<A>(i: number, a: A) {
|
790
|
-
return (self: ImmutableArray<A>): Maybe<ImmutableNonEmptyArray<A>> => {
|
791
|
-
return self.isOutOfBound(i) ? Nothing() : Just(self.unsafeInsertAt(i, a));
|
792
|
-
};
|
793
|
-
}
|
794
|
-
|
795
|
-
/**
|
796
|
-
* @tsplus pipeable fncts.ImmutableArray intersection
|
797
|
-
*/
|
798
|
-
export function intersection<A>(that: ImmutableArray<A>, /** @tsplus auto */ E: P.Eq<A>) {
|
799
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
800
|
-
return self.filter((a) => that.elem(a, E));
|
801
|
-
};
|
802
|
-
}
|
803
|
-
|
804
|
-
/**
|
805
|
-
* @tsplus pipeable fncts.ImmutableArray intersperse
|
806
|
-
*/
|
807
|
-
export function intersperse<A>(a: A) {
|
808
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
809
|
-
const len = self.length;
|
810
|
-
return len === 0 ? self : self.slice(1, len).prependAll(a).prepend(self[0]!);
|
811
|
-
};
|
812
|
-
}
|
813
|
-
|
814
|
-
/**
|
815
|
-
* @tsplus fluent fncts.ImmutableArray isEmpty
|
816
|
-
*/
|
817
|
-
export function isEmpty<A>(self: ImmutableArray<A>): boolean {
|
818
|
-
return self.length === 0;
|
819
|
-
}
|
820
|
-
|
821
|
-
/**
|
822
|
-
* @tsplus pipeable fncts.ImmutableArray isOutOfBound
|
823
|
-
*/
|
824
|
-
export function isOutOfBound(i: number) {
|
825
|
-
return <A>(self: ImmutableArray<A>): boolean => {
|
826
|
-
return i < 0 || i >= self.length;
|
827
|
-
};
|
828
|
-
}
|
829
|
-
|
830
|
-
/**
|
831
|
-
* @tsplus pipeable fncts.ImmutableArray join
|
832
|
-
*/
|
833
|
-
export function join(separator: string) {
|
834
|
-
return (self: ImmutableArray<string>): string => {
|
835
|
-
return self._array.join(separator);
|
836
|
-
};
|
837
|
-
}
|
838
|
-
|
839
|
-
/**
|
840
|
-
* @tsplus getter fncts.ImmutableArray last
|
841
|
-
*/
|
842
|
-
export function last<A>(self: ImmutableArray<A>): Maybe<A> {
|
843
|
-
return self.get(self.length - 1);
|
844
|
-
}
|
845
|
-
|
846
|
-
/**
|
847
|
-
* @tsplus getter fncts.ImmutableArray length
|
848
|
-
*/
|
849
|
-
export function length<A>(self: ImmutableArray<A>): number {
|
850
|
-
return self._array.length;
|
851
|
-
}
|
852
|
-
|
853
|
-
/**
|
854
|
-
* @tsplus getter fncts.ImmutableArray lefts
|
855
|
-
*/
|
856
|
-
export function lefts<E, A>(self: ImmutableArray<Either<E, A>>): ImmutableArray<E> {
|
857
|
-
const ls: Array<E> = [];
|
858
|
-
for (let i = 0; i < self.length; i++) {
|
859
|
-
const a = self._array[i]!;
|
860
|
-
Either.concrete(a);
|
861
|
-
if (a._tag === EitherTag.Left) {
|
862
|
-
ls.push(a.left);
|
863
|
-
}
|
864
|
-
}
|
865
|
-
return ls.asImmutableArray;
|
866
|
-
}
|
867
|
-
|
868
|
-
/**
|
869
|
-
* @tsplus pipeable fncts.ImmutableArray map
|
870
|
-
*/
|
871
|
-
export function map<A, B>(f: (a: A) => B) {
|
872
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
873
|
-
return self.mapWithIndex((_, a) => f(a));
|
874
|
-
};
|
875
|
-
}
|
876
|
-
|
877
|
-
/**
|
878
|
-
* @tsplus pipeable fncts.ImmutableArray mapAccum
|
879
|
-
*/
|
880
|
-
export function mapAccum<A, S, B>(s: S, f: (s: S, a: A) => readonly [B, S]) {
|
881
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<B>, S] => {
|
882
|
-
const bs = Array<B>(self.length);
|
883
|
-
let state = s;
|
884
|
-
for (let i = 0; i < self.length; i++) {
|
885
|
-
const result = f(state, self._array[i]!);
|
886
|
-
bs[i] = result[0];
|
887
|
-
state = result[1];
|
888
|
-
}
|
889
|
-
return [bs.asImmutableArray, state];
|
890
|
-
};
|
891
|
-
}
|
892
|
-
|
893
|
-
/**
|
894
|
-
* @tsplus pipeable fncts.ImmutableArray mapWithIndex
|
895
|
-
*/
|
896
|
-
export function mapWithIndex<A, B>(f: (i: number, a: A) => B) {
|
897
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
898
|
-
const len = self._array.length;
|
899
|
-
const bs = Array<B>(len);
|
900
|
-
for (let i = 0; i < len; i++) {
|
901
|
-
bs[i] = f(i, self._array[i]!);
|
902
|
-
}
|
903
|
-
return bs.asImmutableArray;
|
904
|
-
};
|
905
|
-
}
|
906
|
-
|
907
|
-
/**
|
908
|
-
* @tsplus pipeable fncts.ImmutableArray modifyAt
|
909
|
-
*/
|
910
|
-
export function modifyAt<A>(i: number, f: (a: A) => A) {
|
911
|
-
return (self: ImmutableArray<A>): Maybe<ImmutableArray<A>> => {
|
912
|
-
return self.isOutOfBound(i) ? Nothing() : Just(self.unsafeModifyAt(i, f));
|
913
|
-
};
|
914
|
-
}
|
915
|
-
|
916
|
-
/**
|
917
|
-
* @tsplus pipeable fncts.ImmutableArray mutate
|
918
|
-
*/
|
919
|
-
export function mutate<A>(f: (self: Array<A>) => void) {
|
920
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
921
|
-
const mut = mutableClone(self);
|
922
|
-
f(mut);
|
923
|
-
return mut.asImmutableArray;
|
924
|
-
};
|
925
|
-
}
|
926
|
-
|
927
|
-
/**
|
928
|
-
* @tsplus getter fncts.ImmutableArray mutableClone
|
929
|
-
*/
|
930
|
-
export function mutableClone<A>(self: ImmutableArray<A>): Array<A> {
|
931
|
-
return self.slice(0)._array as Array<A>;
|
932
|
-
}
|
933
|
-
|
934
|
-
/**
|
935
|
-
* @tsplus pipeable fncts.ImmutableArray partitionWithIndex
|
936
|
-
*/
|
937
|
-
export function partitionWithIndex<A, B extends A>(
|
938
|
-
p: RefinementWithIndex<number, A, B>,
|
939
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<B>];
|
940
|
-
export function partitionWithIndex<A>(
|
941
|
-
p: PredicateWithIndex<number, A>,
|
942
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<A>];
|
943
|
-
export function partitionWithIndex<A>(p: PredicateWithIndex<number, A>) {
|
944
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<A>, ImmutableArray<A>] => {
|
945
|
-
const left: Array<A> = [];
|
946
|
-
const right: Array<A> = [];
|
947
|
-
for (let i = 0; i < self.length; i++) {
|
948
|
-
const a = self._array[i]!;
|
949
|
-
if (p(i, a)) {
|
950
|
-
right.push(a);
|
951
|
-
} else {
|
952
|
-
left.push(a);
|
953
|
-
}
|
954
|
-
}
|
955
|
-
return [left.asImmutableArray, right.asImmutableArray];
|
956
|
-
};
|
957
|
-
}
|
958
|
-
|
959
|
-
/**
|
960
|
-
* @tsplus pipeable fncts.ImmutableArray partition
|
961
|
-
*/
|
962
|
-
export function partition<A, B extends A>(
|
963
|
-
p: Refinement<A, B>,
|
964
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<B>];
|
965
|
-
export function partition<A>(
|
966
|
-
p: Predicate<A>,
|
967
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<A>];
|
968
|
-
export function partition<A>(p: Predicate<A>) {
|
969
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<A>, ImmutableArray<A>] => {
|
970
|
-
return self.partitionWithIndex((_, a) => p(a));
|
971
|
-
};
|
972
|
-
}
|
973
|
-
|
974
|
-
/**
|
975
|
-
* @tsplus pipeable fncts.ImmutableArray partitionMapWithIndex
|
976
|
-
*/
|
977
|
-
export function partitionMapWithIndex<A, B, C>(f: (i: number, a: A) => Either<B, C>) {
|
978
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<B>, ImmutableArray<C>] => {
|
979
|
-
const left = [] as Array<B>;
|
980
|
-
const right = [] as Array<C>;
|
981
|
-
for (let i = 0; i < self.length; i++) {
|
982
|
-
const ea = f(i, self._array[i]!);
|
983
|
-
Either.concrete(ea);
|
984
|
-
switch (ea._tag) {
|
985
|
-
case EitherTag.Left:
|
986
|
-
left.push(ea.left);
|
987
|
-
break;
|
988
|
-
case EitherTag.Right:
|
989
|
-
right.push(ea.right);
|
990
|
-
break;
|
991
|
-
}
|
992
|
-
}
|
993
|
-
return [left.asImmutableArray, right.asImmutableArray];
|
994
|
-
};
|
995
|
-
}
|
996
|
-
|
997
|
-
/**
|
998
|
-
* @tsplus pipeable fncts.ImmutableArray partitionMap
|
999
|
-
*/
|
1000
|
-
export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
|
1001
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<B>, ImmutableArray<C>] => {
|
1002
|
-
return self.partitionMapWithIndex((_, a) => f(a));
|
1003
|
-
};
|
1004
|
-
}
|
1005
|
-
|
1006
|
-
/**
|
1007
|
-
* @tsplus pipeable fncts.ImmutableArray prepend
|
1008
|
-
*/
|
1009
|
-
export function prepend<B>(head: B) {
|
1010
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A | B> => {
|
1011
|
-
const len = self.length;
|
1012
|
-
const out = Array<A | B>(len + 1);
|
1013
|
-
out[0] = head;
|
1014
|
-
for (let i = 0; i < len; i++) {
|
1015
|
-
out[i + 1] = self._array[i]!;
|
1016
|
-
}
|
1017
|
-
return out.asImmutableArray;
|
1018
|
-
};
|
1019
|
-
}
|
1020
|
-
|
1021
|
-
/**
|
1022
|
-
* @tsplus pipeable fncts.ImmutableArray prependAll
|
1023
|
-
*/
|
1024
|
-
export function prependAll<A>(a: A) {
|
1025
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1026
|
-
const out: Array<A> = [];
|
1027
|
-
for (let i = 0; i < self.length; i++) {
|
1028
|
-
out.push(a, self._array[i]!);
|
1029
|
-
}
|
1030
|
-
return out.asImmutableArray;
|
1031
|
-
};
|
1032
|
-
}
|
1033
|
-
|
1034
|
-
/**
|
1035
|
-
* @tsplus getter fncts.ImmutableArray reverse
|
1036
|
-
*/
|
1037
|
-
export function reverse<A>(self: ImmutableArray<A>): ImmutableArray<A> {
|
1038
|
-
if (self.isEmpty()) {
|
1039
|
-
return self;
|
1040
|
-
} else if (self.length === 1) {
|
1041
|
-
return ImmutableArray(self._array[0]!);
|
1042
|
-
} else {
|
1043
|
-
const out = Array<A>(self.length);
|
1044
|
-
for (let j = 0, i = self.length - 1; i >= 0; i--, j++) {
|
1045
|
-
out[j] = self._array[i]!;
|
1046
|
-
}
|
1047
|
-
return out.asImmutableArray;
|
1048
|
-
}
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
/**
|
1052
|
-
* @tsplus getter fncts.ImmutableArray rights
|
1053
|
-
*/
|
1054
|
-
export function rights<E, A>(self: ImmutableArray<Either<E, A>>): ImmutableArray<A> {
|
1055
|
-
const rs: Array<A> = [];
|
1056
|
-
for (let i = 0; i < self.length; i++) {
|
1057
|
-
const a = self._array[i]!;
|
1058
|
-
Either.concrete(a);
|
1059
|
-
if (a._tag === EitherTag.Right) {
|
1060
|
-
rs.push(a.right);
|
1061
|
-
}
|
1062
|
-
}
|
1063
|
-
return rs.asImmutableArray;
|
1064
|
-
}
|
1065
|
-
|
1066
|
-
/**
|
1067
|
-
* @tsplus pipeable fncts.ImmutableArray rotate
|
1068
|
-
*/
|
1069
|
-
export function rotate(n: number) {
|
1070
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A> => {
|
1071
|
-
const len = self.length;
|
1072
|
-
if (n === 0 || len <= 1 || len === Math.abs(n)) {
|
1073
|
-
return self;
|
1074
|
-
} else if (n < 0) {
|
1075
|
-
return self.rotate(len + n);
|
1076
|
-
} else {
|
1077
|
-
return self.slice(-n).concat(self.slice(0, len - n));
|
1078
|
-
}
|
1079
|
-
};
|
1080
|
-
}
|
1081
|
-
|
1082
|
-
/**
|
1083
|
-
* @tsplus pipeable fncts.ImmutableArray scanLeft
|
1084
|
-
*/
|
1085
|
-
export function scanLeft<A, B>(b: B, f: (b: B, a: A) => B) {
|
1086
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
1087
|
-
const l = self.length;
|
1088
|
-
const r = Array(l + 1);
|
1089
|
-
r[0] = b;
|
1090
|
-
for (let i = 0; i < l; i++) {
|
1091
|
-
r[i + 1] = f(r[i]!, self._array[i]!);
|
1092
|
-
}
|
1093
|
-
return r.asImmutableArray;
|
1094
|
-
};
|
1095
|
-
}
|
1096
|
-
|
1097
|
-
/**
|
1098
|
-
* @tsplus pipeable fncts.ImmutableArray scanRight
|
1099
|
-
*/
|
1100
|
-
export function scanRight<A, B>(b: B, f: (a: A, b: B) => B) {
|
1101
|
-
return (self: ImmutableArray<A>): ImmutableArray<B> => {
|
1102
|
-
const l = self.length;
|
1103
|
-
const r = Array(l + 1);
|
1104
|
-
r[l] = b;
|
1105
|
-
for (let i = l - 1; i >= 0; i--) {
|
1106
|
-
r[i] = f(self._array[i]!, r[i + 1]!);
|
1107
|
-
}
|
1108
|
-
return r.asImmutableArray;
|
1109
|
-
};
|
1110
|
-
}
|
1111
|
-
|
1112
|
-
/**
|
1113
|
-
* @tsplus pipeable fncts.ImmutableArray sort
|
1114
|
-
*/
|
1115
|
-
export function sort<A>(/** @tsplus auto */ O: P.Ord<A>) {
|
1116
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1117
|
-
return self.isEmpty() || self.length === 1
|
1118
|
-
? self
|
1119
|
-
: self._array.slice().sort((a, b) => O.compare(b)(a)).asImmutableArray;
|
1120
|
-
};
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
/**
|
1124
|
-
* @tsplus pipeable fncts.ImmutableArray sortBy
|
1125
|
-
*/
|
1126
|
-
export function sortBy<A>(Os: ImmutableArray<P.Ord<A>>) {
|
1127
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1128
|
-
return self.sort(Os.fold(P.Ord.getMonoid()));
|
1129
|
-
};
|
1130
|
-
}
|
1131
|
-
|
1132
|
-
/**
|
1133
|
-
* @tsplus pipeable fncts.ImmutableArray spanLeft
|
1134
|
-
*/
|
1135
|
-
export function spanLeft<A, B extends A>(
|
1136
|
-
p: Refinement<A, B>,
|
1137
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<B>, ImmutableArray<A>];
|
1138
|
-
export function spanLeft<A>(
|
1139
|
-
p: Predicate<A>,
|
1140
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<A>];
|
1141
|
-
export function spanLeft<A>(p: Predicate<A>) {
|
1142
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<A>, ImmutableArray<A>] => {
|
1143
|
-
const i = self.spanIndexLeft(p);
|
1144
|
-
const init = Array<A>(i);
|
1145
|
-
for (let j = 0; j < i; j++) {
|
1146
|
-
init[j] = self._array[j]!;
|
1147
|
-
}
|
1148
|
-
const l = self.length;
|
1149
|
-
const rest = Array<A>(l - i);
|
1150
|
-
for (let j = i; j < l; j++) {
|
1151
|
-
rest[j - i] = self._array[j]!;
|
1152
|
-
}
|
1153
|
-
return [init.asImmutableArray, rest.asImmutableArray];
|
1154
|
-
};
|
1155
|
-
}
|
1156
|
-
|
1157
|
-
/**
|
1158
|
-
* @tsplus pipeable fncts.ImmutableArray spanRight
|
1159
|
-
*/
|
1160
|
-
export function spanRight<A, B extends A>(
|
1161
|
-
p: Refinement<A, B>,
|
1162
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<B>];
|
1163
|
-
export function spanRight<A>(
|
1164
|
-
p: Predicate<A>,
|
1165
|
-
): (self: ImmutableArray<A>) => readonly [ImmutableArray<A>, ImmutableArray<A>];
|
1166
|
-
export function spanRight<A>(p: Predicate<A>) {
|
1167
|
-
return (self: ImmutableArray<A>): readonly [ImmutableArray<A>, ImmutableArray<A>] => {
|
1168
|
-
const i = self.spanIndexRight(p);
|
1169
|
-
const l = self.length;
|
1170
|
-
const tail = Array<A>(l - i - 1);
|
1171
|
-
for (let j = l - 1; j > i; j--) {
|
1172
|
-
tail[j - i - 1] = self._array[j]!;
|
1173
|
-
}
|
1174
|
-
const rest = Array<A>(i);
|
1175
|
-
for (let j = i; j >= 0; j--) {
|
1176
|
-
rest[j] = self._array[j]!;
|
1177
|
-
}
|
1178
|
-
return [rest.asImmutableArray, tail.asImmutableArray];
|
1179
|
-
};
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
/**
|
1183
|
-
* @tsplus pipeable fncts.ImmutableArray spanIndexLeft
|
1184
|
-
*/
|
1185
|
-
export function spanIndexLeft<A>(p: Predicate<A>) {
|
1186
|
-
return (self: ImmutableArray<A>): number => {
|
1187
|
-
const l = self.length;
|
1188
|
-
let i = 0;
|
1189
|
-
for (; i < l; i++) {
|
1190
|
-
if (!p(self._array[i]!)) {
|
1191
|
-
break;
|
1192
|
-
}
|
1193
|
-
}
|
1194
|
-
return i;
|
1195
|
-
};
|
1196
|
-
}
|
1197
|
-
|
1198
|
-
/**
|
1199
|
-
* @tsplus pipeable fncts.ImmutableArray spanIndexRight
|
1200
|
-
*/
|
1201
|
-
export function spanIndexRight<A>(predicate: Predicate<A>) {
|
1202
|
-
return (as: ImmutableArray<A>): number => {
|
1203
|
-
let i = as.length - 1;
|
1204
|
-
for (; i >= 0; i--) {
|
1205
|
-
if (!predicate(as._array[i]!)) {
|
1206
|
-
break;
|
1207
|
-
}
|
1208
|
-
}
|
1209
|
-
return i;
|
1210
|
-
};
|
1211
|
-
}
|
1212
|
-
|
1213
|
-
/**
|
1214
|
-
* @tsplus getter fncts.ImmutableArray tail
|
1215
|
-
*/
|
1216
|
-
export function tail<A>(self: ImmutableArray<A>): Maybe<ImmutableArray<A>> {
|
1217
|
-
return self.isNonEmpty() ? Just(self.slice(1)) : Nothing();
|
1218
|
-
}
|
1219
|
-
|
1220
|
-
/**
|
1221
|
-
* @tsplus pipeable fncts.ImmutableArray take
|
1222
|
-
*/
|
1223
|
-
export function take(n: number) {
|
1224
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A> => {
|
1225
|
-
return self.slice(0, n);
|
1226
|
-
};
|
1227
|
-
}
|
1228
|
-
|
1229
|
-
/**
|
1230
|
-
* @tsplus pipeable fncts.ImmutableArray takeLast
|
1231
|
-
*/
|
1232
|
-
export function takeLast(n: number) {
|
1233
|
-
return <A>(as: ImmutableArray<A>): ImmutableArray<A> => {
|
1234
|
-
return isEmpty(as) ? ImmutableArray.empty() : as.slice(-n);
|
1235
|
-
};
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
/**
|
1239
|
-
* @tsplus pipeable fncts.ImmutableArray takeWhile
|
1240
|
-
*/
|
1241
|
-
export function takeWhile<A, B extends A>(p: Refinement<A, B>): (self: ImmutableArray<A>) => ImmutableArray<B>;
|
1242
|
-
export function takeWhile<A>(p: Predicate<A>): (self: ImmutableArray<A>) => ImmutableArray<A>;
|
1243
|
-
export function takeWhile<A>(p: Predicate<A>) {
|
1244
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1245
|
-
const i = self.spanIndexLeft(p);
|
1246
|
-
const init = Array<A>(i);
|
1247
|
-
for (let j = 0; j < i; j++) {
|
1248
|
-
init[j] = self._array[j]!;
|
1249
|
-
}
|
1250
|
-
return init.asImmutableArray;
|
1251
|
-
};
|
1252
|
-
}
|
1253
|
-
|
1254
|
-
/**
|
1255
|
-
* @tsplus getter fncts.ImmutableArray traverseWithIndex
|
1256
|
-
*/
|
1257
|
-
export function _traverseWithIndex<A>(
|
1258
|
-
self: ImmutableArray<A>,
|
1259
|
-
): <G extends HKT, GC = HKT.None>(
|
1260
|
-
G: P.Applicative<G, GC>,
|
1261
|
-
) => <K, Q, W, X, I, S, R, E, B>(
|
1262
|
-
f: (i: number, a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, B>,
|
1263
|
-
) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, ImmutableArray<B>>;
|
1264
|
-
export function _traverseWithIndex<A>(
|
1265
|
-
self: ImmutableArray<A>,
|
1266
|
-
): <G>(G: P.Applicative<HKT.F<G>>) => <B>(f: (i: number, a: A) => HKT.FK1<G, B>) => HKT.FK1<G, ImmutableArray<B>> {
|
1267
|
-
return (G) => (f) =>
|
1268
|
-
self.foldLeftWithIndex(G.pure(ImmutableArray.empty()), (i, fbs, a) =>
|
1269
|
-
pipe(
|
1270
|
-
fbs,
|
1271
|
-
G.zipWith(f(i, a), (bs, b) => bs.append(b)),
|
1272
|
-
),
|
1273
|
-
);
|
1274
|
-
}
|
1275
|
-
|
1276
|
-
/**
|
1277
|
-
* @tsplus getter fncts.ImmutableArray traverse
|
1278
|
-
*/
|
1279
|
-
export function _traverse<A>(
|
1280
|
-
self: ImmutableArray<A>,
|
1281
|
-
): <G extends HKT, GC = HKT.None>(
|
1282
|
-
G: P.Applicative<G, GC>,
|
1283
|
-
) => <K, Q, W, X, I, S, R, E, B>(
|
1284
|
-
f: (a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, B>,
|
1285
|
-
) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, ImmutableArray<B>> {
|
1286
|
-
return (G) => (f) => self.traverseWithIndex(G)((_, a) => f(a));
|
1287
|
-
}
|
1288
|
-
|
1289
|
-
export const traverseWithIndex: P.TraversableWithIndex<ImmutableArrayF>["traverseWithIndex"] = (G) => (f) => (self) =>
|
1290
|
-
self.traverseWithIndex(G)(f);
|
1291
|
-
|
1292
|
-
export const traverse: P.Traversable<ImmutableArrayF>["traverse"] = (G) => (f) => (self) =>
|
1293
|
-
self.traverseWithIndex(G)((_, a) => f(a));
|
1294
|
-
|
1295
|
-
/**
|
1296
|
-
* @tsplus pipeable fncts.ImmutableArray union
|
1297
|
-
*/
|
1298
|
-
export function union<A>(that: ImmutableArray<A>, /** @tsplus auto */ E: P.Eq<A>) {
|
1299
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1300
|
-
return self.concat(that.filter((a) => !self.elem(a, E)));
|
1301
|
-
};
|
1302
|
-
}
|
1303
|
-
|
1304
|
-
/**
|
1305
|
-
* @tsplus pipeable fncts.ImmutableArray uniq
|
1306
|
-
*/
|
1307
|
-
export function uniq<A>(/** @tsplus auto */ E: P.Eq<A>) {
|
1308
|
-
return (self: ImmutableArray<A>): ImmutableArray<A> => {
|
1309
|
-
if (self.length === 1) {
|
1310
|
-
return self;
|
1311
|
-
}
|
1312
|
-
const out = [] as Array<A>;
|
1313
|
-
const len = self.length;
|
1314
|
-
for (let i = 0; i < len; i++) {
|
1315
|
-
const a = self._array[i]!;
|
1316
|
-
if (!out.asImmutableArray.elem(a, E)) {
|
1317
|
-
out.push(a);
|
1318
|
-
}
|
1319
|
-
}
|
1320
|
-
return out.asImmutableArray;
|
1321
|
-
};
|
1322
|
-
}
|
1323
|
-
|
1324
|
-
/**
|
1325
|
-
* @tsplus getter fncts.ImmutableArray unprepend
|
1326
|
-
*/
|
1327
|
-
export function unprepend<A>(self: ImmutableArray<A>): Maybe<readonly [A, ImmutableArray<A>]> {
|
1328
|
-
return self.isNonEmpty() ? Just([self[0]!, self.slice(1)]) : Nothing();
|
1329
|
-
}
|
1330
|
-
|
1331
|
-
/**
|
1332
|
-
* @tsplus index fncts.ImmutableArray
|
1333
|
-
*/
|
1334
|
-
export function unsafeGet<A>(self: ImmutableArray<A>, i: number): A | undefined {
|
1335
|
-
return self._array[i];
|
1336
|
-
}
|
1337
|
-
|
1338
|
-
/**
|
1339
|
-
* @tsplus getter fncts.ImmutableArray unsafeAsMutable
|
1340
|
-
*/
|
1341
|
-
export function unsafeAsMutable<A>(self: ImmutableArray<A>): Array<A> {
|
1342
|
-
return self._array as Array<A>;
|
1343
|
-
}
|
1344
|
-
|
1345
|
-
/**
|
1346
|
-
* @tsplus pipeable fncts.ImmutableArray unsafeDeleteAt
|
1347
|
-
*/
|
1348
|
-
export function unsafeDeleteAt(i: number) {
|
1349
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<A> => {
|
1350
|
-
return self.mutate((xs) => {
|
1351
|
-
xs.splice(i, 1);
|
1352
|
-
});
|
1353
|
-
};
|
1354
|
-
}
|
1355
|
-
|
1356
|
-
/**
|
1357
|
-
* @tsplus pipeable fncts.ImmutableArray unsafeInsertAt
|
1358
|
-
*/
|
1359
|
-
export function unsafeInsertAt<A>(i: number, a: A) {
|
1360
|
-
return (as: ImmutableArray<A>): ImmutableNonEmptyArray<A> => {
|
1361
|
-
return as.mutate((xs) => {
|
1362
|
-
xs.splice(i, 0, a);
|
1363
|
-
}) as unknown as ImmutableNonEmptyArray<A>;
|
1364
|
-
};
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
/**
|
1368
|
-
* @tsplus pipeable fncts.ImmutableArray unsafeModifyAt
|
1369
|
-
*/
|
1370
|
-
export function unsafeModifyAt<A>(i: number, f: (a: A) => A) {
|
1371
|
-
return (as: ImmutableArray<A>): ImmutableArray<A> => {
|
1372
|
-
const next = f(as[i]!);
|
1373
|
-
if (as[i] === next) {
|
1374
|
-
return as;
|
1375
|
-
}
|
1376
|
-
return as.mutate((xs) => {
|
1377
|
-
xs[i] = next;
|
1378
|
-
});
|
1379
|
-
};
|
1380
|
-
}
|
1381
|
-
|
1382
|
-
/**
|
1383
|
-
* @tsplus pipeable fncts.ImmutableArray unsafeUpdateAt
|
1384
|
-
*/
|
1385
|
-
export function unsafeUpdateAt<A>(i: number, a: A) {
|
1386
|
-
return (as: ImmutableArray<A>): ImmutableArray<A> => {
|
1387
|
-
if (as[i] === a) {
|
1388
|
-
return as;
|
1389
|
-
} else {
|
1390
|
-
return as.mutate((xs) => {
|
1391
|
-
xs[i] = a;
|
1392
|
-
});
|
1393
|
-
}
|
1394
|
-
};
|
1395
|
-
}
|
1396
|
-
|
1397
|
-
/**
|
1398
|
-
* @tsplus getter fncts.ImmutableArray unzip
|
1399
|
-
*/
|
1400
|
-
export function unzip<A, B>(self: ImmutableArray<readonly [A, B]>): readonly [ImmutableArray<A>, ImmutableArray<B>] {
|
1401
|
-
const fa = Array<A>(self.length);
|
1402
|
-
const fb = Array<B>(self.length);
|
1403
|
-
|
1404
|
-
for (let i = 0; i < self.length; i++) {
|
1405
|
-
fa[i] = self._array[i]![0]!;
|
1406
|
-
fb[i] = self._array[i]![1]!;
|
1407
|
-
}
|
1408
|
-
|
1409
|
-
return [fa.asImmutableArray, fb.asImmutableArray];
|
1410
|
-
}
|
1411
|
-
|
1412
|
-
/**
|
1413
|
-
* @tsplus pipeable fncts.ImmutableArray updateAt
|
1414
|
-
*/
|
1415
|
-
export function updateAt<A>(i: number, a: A) {
|
1416
|
-
return (as: ImmutableArray<A>): Maybe<ImmutableArray<A>> => {
|
1417
|
-
return as.isOutOfBound(i) ? Nothing() : Just(as.unsafeUpdateAt(i, a));
|
1418
|
-
};
|
1419
|
-
}
|
1420
|
-
|
1421
|
-
/**
|
1422
|
-
* @tsplus getter fncts.ImmutableArray wiltWithIndex
|
1423
|
-
*/
|
1424
|
-
export function _wiltWithIndex<A>(self: ImmutableArray<A>) {
|
1425
|
-
return <G extends HKT, GC = HKT.None>(G: P.Applicative<G, GC>) =>
|
1426
|
-
<K, Q, W, X, I, S, R, E, B, B2>(
|
1427
|
-
f: (i: number, a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, Either<B, B2>>,
|
1428
|
-
): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, readonly [ImmutableArray<B>, ImmutableArray<B2>]> =>
|
1429
|
-
self
|
1430
|
-
.foldLeftWithIndex(G.pure([[] as Array<B>, [] as Array<B2>] as const), (i, fbs, a) =>
|
1431
|
-
f(i, a).pipe(
|
1432
|
-
G.zipWith(fbs, (eb, r) =>
|
1433
|
-
eb.match(
|
1434
|
-
(b1) => {
|
1435
|
-
r[0].push(b1);
|
1436
|
-
return r;
|
1437
|
-
},
|
1438
|
-
(b2) => {
|
1439
|
-
r[1].push(b2);
|
1440
|
-
return r;
|
1441
|
-
},
|
1442
|
-
),
|
1443
|
-
),
|
1444
|
-
),
|
1445
|
-
)
|
1446
|
-
.pipe(G.map(([b1s, b2s]) => [b1s.asImmutableArray, b2s.asImmutableArray]));
|
1447
|
-
}
|
1448
|
-
|
1449
|
-
/**
|
1450
|
-
* @tsplus getter fncts.ImmutableArray wilt
|
1451
|
-
*/
|
1452
|
-
export function _wilt<A>(self: ImmutableArray<A>) {
|
1453
|
-
return <G extends HKT, GC = HKT.None>(G: P.Applicative<G, GC>) =>
|
1454
|
-
<K, Q, W, X, I, S, R, E, B, B2>(
|
1455
|
-
f: (a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, Either<B, B2>>,
|
1456
|
-
): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, readonly [ImmutableArray<B>, ImmutableArray<B2>]> =>
|
1457
|
-
self.wiltWithIndex(G)((_, a) => f(a));
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
/**
|
1461
|
-
* @tsplus getter fncts.ImmutableArray witherWithIndex
|
1462
|
-
*/
|
1463
|
-
export function _witherWithIndex<A>(self: ImmutableArray<A>) {
|
1464
|
-
return <G extends HKT, GC = HKT.None>(G: P.Applicative<G, GC>) =>
|
1465
|
-
<K, Q, W, X, I, S, R, E, B>(
|
1466
|
-
f: (i: number, a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, Maybe<B>>,
|
1467
|
-
): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, ImmutableArray<B>> =>
|
1468
|
-
self
|
1469
|
-
.foldLeftWithIndex(G.pure([] as Array<B>), (i, b, a) =>
|
1470
|
-
f(i, a).pipe(
|
1471
|
-
G.zipWith(b, (maybeB, bs) => {
|
1472
|
-
if (maybeB.isJust()) {
|
1473
|
-
bs.push(maybeB.value);
|
1474
|
-
}
|
1475
|
-
return bs;
|
1476
|
-
}),
|
1477
|
-
),
|
1478
|
-
)
|
1479
|
-
.pipe(G.map((bs) => bs.asImmutableArray));
|
1480
|
-
}
|
1481
|
-
|
1482
|
-
/**
|
1483
|
-
* @tsplus getter fncts.ImmutableArray wither
|
1484
|
-
*/
|
1485
|
-
export function _wither<A>(self: ImmutableArray<A>) {
|
1486
|
-
return <G extends HKT, GC = HKT.None>(G: P.Applicative<G, GC>) =>
|
1487
|
-
<K, Q, W, X, I, S, R, E, B>(
|
1488
|
-
f: (a: A) => HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, Maybe<B>>,
|
1489
|
-
): HKT.Kind<G, GC, K, Q, W, X, I, S, R, E, ImmutableArray<B>> =>
|
1490
|
-
self.witherWithIndex(G)((_, a) => f(a));
|
1491
|
-
}
|
1492
|
-
|
1493
|
-
export const wiltWithIndex: P.WitherableWithIndex<ImmutableArrayF>["wiltWithIndex"] = (G) => (f) => (self) =>
|
1494
|
-
self.wiltWithIndex(G)(f);
|
1495
|
-
|
1496
|
-
export const wilt: P.WitherableWithIndex<ImmutableArrayF>["wilt"] = (G) => (f) => (self) =>
|
1497
|
-
self.wiltWithIndex(G)((_, a) => f(a));
|
1498
|
-
|
1499
|
-
export const witherWithIndex: P.WitherableWithIndex<ImmutableArrayF>["witherWithIndex"] = (G) => (f) => (self) =>
|
1500
|
-
self.witherWithIndex(G)(f);
|
1501
|
-
|
1502
|
-
export const wither: P.Witherable<ImmutableArrayF>["wither"] = (G) => (f) => (self) =>
|
1503
|
-
self.witherWithIndex(G)((_, a) => f(a));
|
1504
|
-
|
1505
|
-
/**
|
1506
|
-
* @tsplus pipeable fncts.ImmutableArray zip
|
1507
|
-
*/
|
1508
|
-
export function zip<B>(that: ImmutableArray<B>) {
|
1509
|
-
return <A>(self: ImmutableArray<A>): ImmutableArray<readonly [A, B]> => {
|
1510
|
-
return self.zipWith(that, tuple);
|
1511
|
-
};
|
1512
|
-
}
|
1513
|
-
|
1514
|
-
/**
|
1515
|
-
* @tsplus pipeable fncts.ImmutableArray zipWith
|
1516
|
-
*/
|
1517
|
-
export function zipWith<A, B, C>(fb: ImmutableArray<B>, f: (a: A, b: B) => C) {
|
1518
|
-
return (self: ImmutableArray<A>): ImmutableArray<C> => {
|
1519
|
-
const len = Math.min(self.length, fb.length);
|
1520
|
-
const fc = Array<C>(len);
|
1521
|
-
for (let i = 0; i < len; i++) {
|
1522
|
-
fc[i] = f(self._array[i]!, fb._array[i]!);
|
1523
|
-
}
|
1524
|
-
return fc.asImmutableArray;
|
1525
|
-
};
|
1526
|
-
}
|