Socket
Socket
Sign inDemoInstall

@effect/data

Package Overview
Dependencies
Maintainers
3
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/data - npm Package Compare versions

Comparing version 0.10.3 to 0.11.0

145

Chunk.js

@@ -62,2 +62,10 @@ "use strict";

}
case "ISlice":
{
this.length = backing.length;
this.depth = backing.chunk.depth + 1;
this.left = _empty;
this.right = _empty;
break;
}
}

@@ -122,2 +130,13 @@ }

}
case "ISlice":
{
let i = 0;
let j = initial;
while (i < self.length) {
array[j] = unsafeGet(self, i);
i += 1;
j += 1;
}
break;
}
}

@@ -234,2 +253,6 @@ };

}
case "ISlice":
{
return unsafeGet(self.backing.chunk, index + self.backing.offset);
}
}

@@ -266,3 +289,33 @@ });

} else {
return unsafeFromArray(RA.take(n)(toReadonlyArray(self)));
switch (self.backing._tag) {
case "ISlice":
{
return new ChunkImpl({
_tag: "ISlice",
chunk: self.backing.chunk,
length: n,
offset: self.backing.offset
});
}
case "IConcat":
{
if (n > self.left.length) {
return new ChunkImpl({
_tag: "IConcat",
left: self.left,
right: take(self.right, n - self.left.length)
});
}
return take(self.left, n);
}
default:
{
return new ChunkImpl({
_tag: "ISlice",
chunk: self,
offset: 0,
length: n
});
}
}
}

@@ -283,3 +336,33 @@ });

} else {
return unsafeFromArray(RA.drop(n)(toReadonlyArray(self)));
switch (self.backing._tag) {
case "ISlice":
{
return new ChunkImpl({
_tag: "ISlice",
chunk: self.backing.chunk,
offset: self.backing.offset + n,
length: self.backing.length - n
});
}
case "IConcat":
{
if (n > self.left.length) {
return drop(self.right, n - self.left.length);
}
return new ChunkImpl({
_tag: "IConcat",
left: drop(self.left, n),
right: self.right
});
}
default:
{
return new ChunkImpl({
_tag: "ISlice",
chunk: self,
offset: n,
length: self.length - n
});
}
}
}

@@ -340,3 +423,3 @@ });

if (self.left.depth >= self.right.depth) {
const nr = concat(that)(self.right);
const nr = concat(self.right, that);
return new ChunkImpl({

@@ -348,3 +431,3 @@ _tag: "IConcat",

} else {
const nrr = concat(that)(self.right.right);
const nrr = concat(self.right.right, that);
if (nrr.depth === self.depth - 3) {

@@ -376,3 +459,3 @@ const nr = new ChunkImpl({

if (that.right.depth >= that.left.depth) {
const nl = concat(that.left)(self);
const nl = concat(self, that.left);
return new ChunkImpl({

@@ -384,3 +467,3 @@ _tag: "IConcat",

} else {
const nll = concat(that.left.left)(self);
const nll = concat(self, that.left.left);
if (nll.depth === that.depth - 3) {

@@ -434,3 +517,3 @@ const nl = new ChunkImpl({

exports.correspondsTo = correspondsTo;
const filterMap = /*#__PURE__*/Dual.dual(2, (self, f) => unsafeFromArray(RA.filterMap(f)(self)));
const filterMap = /*#__PURE__*/Dual.dual(2, (self, f) => unsafeFromArray(RA.filterMap(self, f)));
/**

@@ -443,3 +526,3 @@ * Returns a filtered and mapped subset of the elements.

exports.filterMap = filterMap;
const filter = /*#__PURE__*/Dual.dual(2, (self, predicate) => unsafeFromArray(RA.filterMap(O.liftPredicate(predicate))(self)));
const filter = /*#__PURE__*/Dual.dual(2, (self, predicate) => unsafeFromArray(RA.filterMap(self, O.liftPredicate(predicate))));
/**

@@ -452,3 +535,3 @@ * Returns a filtered and mapped subset of the elements.

exports.filter = filter;
const filterMapWithIndex = /*#__PURE__*/Dual.dual(2, (self, f) => unsafeFromArray(RA.filterMap(f)(self)));
const filterMapWithIndex = /*#__PURE__*/Dual.dual(2, (self, f) => unsafeFromArray(RA.filterMap(self, f)));
/**

@@ -473,2 +556,4 @@ * Transforms all elements of the chunk for as long as the specified function returns some value

});
exports.filterMapWhile = filterMapWhile;
const elem_ = /*#__PURE__*/RA.contains( /*#__PURE__*/Equal.equivalence());
/**

@@ -480,4 +565,3 @@ * Tests whether a value is a member of a `Chunk<A>`.

*/
exports.filterMapWhile = filterMapWhile;
const elem = /*#__PURE__*/Dual.dual(2, (self, b) => RA.contains(Equal.equivalence())(b)(toReadonlyArray(self)));
const elem = /*#__PURE__*/Dual.dual(2, (self, b) => elem_(toReadonlyArray(self), b));
/**

@@ -532,3 +616,3 @@ * Filter out optional values

exports.every = every;
const findFirst = /*#__PURE__*/Dual.dual(2, (self, predicate) => RA.findFirst(predicate)(toReadonlyArray(self)));
const findFirst = /*#__PURE__*/Dual.dual(2, (self, predicate) => RA.findFirst(toReadonlyArray(self), predicate));
/**

@@ -541,3 +625,3 @@ * Find the first index for which a predicate holds

exports.findFirst = findFirst;
const findFirstIndex = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findFirstIndex(f)(toReadonlyArray(self)));
const findFirstIndex = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findFirstIndex(toReadonlyArray(self), f));
/**

@@ -550,3 +634,3 @@ * Find the first index for which a predicate holds

exports.findFirstIndex = findFirstIndex;
const findLastIndex = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findLastIndex(f)(toReadonlyArray(self)));
const findLastIndex = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findLastIndex(toReadonlyArray(self), f));
/**

@@ -559,3 +643,3 @@ * Find the last element which satisfies a predicate function

exports.findLastIndex = findLastIndex;
const findLast = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findLast(f)(toReadonlyArray(self)));
const findLast = /*#__PURE__*/Dual.dual(2, (self, f) => RA.findLast(toReadonlyArray(self), f));
/**

@@ -574,3 +658,3 @@ * Returns a chunk with the elements mapped by the specified function.

for (const k of self) {
r = concat(f(k))(r);
r = concat(r, f(k));
}

@@ -625,2 +709,4 @@ return r;

const head = /*#__PURE__*/get(0);
exports.head = head;
const intersection_ = /*#__PURE__*/RA.intersection( /*#__PURE__*/Equal.equivalence());
/**

@@ -634,4 +720,3 @@ * Creates a Chunk of unique values that are included in all given Chunks.

*/
exports.head = head;
const intersection = /*#__PURE__*/Dual.dual(2, (self, that) => unsafeFromArray(RA.intersection(Equal.equivalence())(toReadonlyArray(that))(toReadonlyArray(self))));
const intersection = /*#__PURE__*/Dual.dual(2, (self, that) => unsafeFromArray(intersection_(toReadonlyArray(self), toReadonlyArray(that))));
/**

@@ -737,3 +822,3 @@ * Determines if the chunk is empty.

exports.makeBy = makeBy;
const map = /*#__PURE__*/Dual.dual(2, (self, f) => self.backing._tag === "ISingleton" ? of(f(self.backing.a)) : unsafeFromArray(RA.map(f)(toReadonlyArray(self))));
const map = /*#__PURE__*/Dual.dual(2, (self, f) => self.backing._tag === "ISingleton" ? of(f(self.backing.a)) : unsafeFromArray(RA.map(toReadonlyArray(self), f)));
/**

@@ -835,3 +920,3 @@ * Returns an effect whose success is mapped by the specified f function.

exports.sort = sort;
const splitAt = /*#__PURE__*/Dual.dual(2, (self, n) => [take(n)(self), drop(n)(self)]);
const splitAt = /*#__PURE__*/Dual.dual(2, (self, n) => [take(self, n), drop(self, n)]);
/**

@@ -881,3 +966,3 @@ * Splits this chunk into `n` equally sized chunks.

}
return splitAt(i)(self);
return splitAt(self, i);
});

@@ -891,3 +976,3 @@ /**

exports.splitWhere = splitWhere;
const tail = self => self.length > 0 ? O.some(drop(1)(self)) : O.none();
const tail = self => self.length > 0 ? O.some(drop(self, 1)) : O.none();
/**

@@ -941,2 +1026,4 @@ * Takes the last `n` elements.

};
exports.unfold = unfold;
const union_ = /*#__PURE__*/RA.union( /*#__PURE__*/Equal.equivalence());
/**

@@ -948,4 +1035,5 @@ * Creates a Chunks of unique values, in order, from all given Chunks.

*/
exports.unfold = unfold;
const union = /*#__PURE__*/Dual.dual(2, (self, that) => unsafeFromArray(RA.union(Equal.equivalence())(toReadonlyArray(that))(toReadonlyArray(self))));
const union = /*#__PURE__*/Dual.dual(2, (self, that) => unsafeFromArray(union_(toReadonlyArray(self), toReadonlyArray(that))));
exports.union = union;
const uniq_ = /*#__PURE__*/RA.uniq( /*#__PURE__*/Equal.equivalence());
/**

@@ -957,4 +1045,3 @@ * Remove duplicates from an array, keeping the first occurrence of an element.

*/
exports.union = union;
const dedupe = self => unsafeFromArray(RA.uniq(Equal.equivalence())(toReadonlyArray(self)));
const dedupe = self => unsafeFromArray(uniq_(toReadonlyArray(self)));
/**

@@ -967,3 +1054,3 @@ * Returns the first element of this chunk.

exports.dedupe = dedupe;
const unsafeHead = self => unsafeGet(0)(self);
const unsafeHead = self => unsafeGet(self, 0);
/**

@@ -976,3 +1063,3 @@ * Returns the last element of this chunk.

exports.unsafeHead = unsafeHead;
const unsafeLast = self => unsafeGet(self.length - 1)(self);
const unsafeLast = self => unsafeGet(self, self.length - 1);
/**

@@ -1093,3 +1180,3 @@ * Takes an array of pairs and return two corresponding arrays.

exports.cross = cross;
const zipWithIndex = self => zipWithIndexOffset(0)(self);
const zipWithIndex = self => zipWithIndexOffset(self, 0);
/**

@@ -1096,0 +1183,0 @@ * Zips this chunk with the index of every element, starting from the initial

32

Either.d.ts

@@ -33,10 +33,24 @@ /**

*/
export type Either<E, A> = Left<E> | Right<A>;
export type Either<E, A> = Left<E, A> | Right<E, A>;
/**
* @category symbols
* @since 1.0.0
*/
export declare const EitherTypeId: unique symbol;
/**
* @category symbols
* @since 1.0.0
*/
export type EitherTypeId = typeof EitherTypeId;
/**
* @category models
* @since 1.0.0
*/
export interface Left<E> extends Data.Case {
export interface Left<E, A> extends Data.Case {
readonly _tag: "Left";
readonly left: E;
readonly [EitherTypeId]: {
readonly _A: (_: never) => A;
readonly _E: (_: never) => E;
};
get left(): E;
traced(this: this, trace: Trace): this | TracedEither<this["left"], never>;

@@ -48,5 +62,9 @@ }

*/
export interface Right<A> extends Data.Case {
export interface Right<E, A> extends Data.Case {
readonly _tag: "Right";
readonly right: A;
get right(): A;
readonly [EitherTypeId]: {
readonly _A: (_: never) => A;
readonly _E: (_: never) => E;
};
traced(this: this, trace: Trace): this | TracedEither<never, this["right"]>;

@@ -117,3 +135,3 @@ }

*/
export declare const isLeft: <E, A>(self: Either<E, A>) => self is Left<E>;
export declare const isLeft: <E, A>(self: Either<E, A>) => self is Left<E, A>;
/**

@@ -133,3 +151,3 @@ * Determine if a `Either` is a `Right`.

*/
export declare const isRight: <E, A>(self: Either<E, A>) => self is Right<A>;
export declare const isRight: <E, A>(self: Either<E, A>) => self is Right<E, A>;
/**

@@ -136,0 +154,0 @@ * Returns a `Refinement` from a `Either` returning function.

@@ -6,3 +6,3 @@ "use strict";

});
exports.zipWith = exports.zipRight = exports.zipLeft = exports.unit = exports.tupled = exports.tuple = exports.traverseTap = exports.traverse = exports.toRefinement = exports.toOption = exports.toArray = exports.tapError = exports.tap = exports.sum = exports.subtract = exports.struct = exports.sequence = exports.rights = exports.right = exports.reverse = exports.orElseFail = exports.orElseEither = exports.orElse = exports.multiply = exports.merge = exports.match = exports.mapLeft = exports.map = exports.liftThrowable = exports.liftPredicate = exports.liftOption = exports.liftNullable = exports.lift2 = exports.letDiscard = exports.let = exports.lefts = exports.left = exports.isRight = exports.isLeft = exports.isEither = exports.inspectRight = exports.inspectLeft = exports.getRight = exports.getOrUndefined = exports.getOrThrowWith = exports.getOrThrow = exports.getOrNull = exports.getOrElse = exports.getOptionalSemigroup = exports.getLeft = exports.getFirstRightSemigroup = exports.getFirstLeftSemigroup = exports.getFirstLeftMonoid = exports.getEquivalence = exports.gen = exports.fromOption = exports.fromNullable = exports.fromIterable = exports.flatten = exports.flatMapOption = exports.flatMapNullable = exports.flatMap = exports.flap = exports.firstRightOf = exports.filterMap = exports.filter = exports.exists = exports.divide = exports.contains = exports.composeK = exports.compact = exports.bindTo = exports.bindDiscard = exports.bind = exports.bimap = exports.asUnit = exports.as = exports.appendElement = exports.ap = exports.all = exports.Traversable = exports.SemiProduct = exports.SemiCoproduct = exports.SemiApplicative = exports.SemiAlternative = exports.Product = exports.Pointed = exports.Monad = exports.Invariant = exports.Foldable = exports.FlatMap = exports.Do = exports.Covariant = exports.Chainable = exports.Bicovariant = exports.Applicative = void 0;
exports.zipWith = exports.zipRight = exports.zipLeft = exports.unit = exports.tupled = exports.tuple = exports.traverseTap = exports.traverse = exports.toRefinement = exports.toOption = exports.toArray = exports.tapError = exports.tap = exports.sum = exports.subtract = exports.struct = exports.sequence = exports.rights = exports.right = exports.reverse = exports.orElseFail = exports.orElseEither = exports.orElse = exports.multiply = exports.merge = exports.match = exports.mapLeft = exports.map = exports.liftThrowable = exports.liftPredicate = exports.liftOption = exports.liftNullable = exports.lift2 = exports.letDiscard = exports.let = exports.lefts = exports.left = exports.isRight = exports.isLeft = exports.isEither = exports.inspectRight = exports.inspectLeft = exports.getRight = exports.getOrUndefined = exports.getOrThrowWith = exports.getOrThrow = exports.getOrNull = exports.getOrElse = exports.getOptionalSemigroup = exports.getLeft = exports.getFirstRightSemigroup = exports.getFirstLeftSemigroup = exports.getFirstLeftMonoid = exports.getEquivalence = exports.gen = exports.fromOption = exports.fromNullable = exports.fromIterable = exports.flatten = exports.flatMapOption = exports.flatMapNullable = exports.flatMap = exports.flap = exports.firstRightOf = exports.filterMap = exports.filter = exports.exists = exports.divide = exports.contains = exports.composeK = exports.compact = exports.bindTo = exports.bindDiscard = exports.bind = exports.bimap = exports.asUnit = exports.as = exports.appendElement = exports.ap = exports.all = exports.Traversable = exports.SemiProduct = exports.SemiCoproduct = exports.SemiApplicative = exports.SemiAlternative = exports.Product = exports.Pointed = exports.Monad = exports.Invariant = exports.Foldable = exports.FlatMap = exports.EitherTypeId = exports.Do = exports.Covariant = exports.Chainable = exports.Bicovariant = exports.Applicative = void 0;
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));

@@ -36,2 +36,7 @@ var _Function = /*#__PURE__*/require("@effect/data/Function");

/**
* @category symbols
* @since 1.0.0
*/
const EitherTypeId = /*#__PURE__*/Symbol.for("@effect/data/Either");
/**
* Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias

@@ -43,2 +48,3 @@ * of this structure.

*/
exports.EitherTypeId = EitherTypeId;
const right = either.right;

@@ -226,3 +232,3 @@ /**

exports.mapLeft = mapLeft;
const map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => isRight(self) ? right(f(self.right)) : self);
const map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => isRight(self) ? right(f(self.right)) : left(self.left));
exports.map = map;

@@ -300,3 +306,3 @@ const imap = /*#__PURE__*/covariant.imap(map);

exports.Pointed = Pointed;
const flatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => isLeft(self) ? self : f(self.right));
const flatMap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => isLeft(self) ? left(self.left) : f(self.right));
/**

@@ -356,6 +362,6 @@ * @category instances

exports.Monad = Monad;
const product = (self, that) => isRight(self) ? isRight(that) ? right([self.right, that.right]) : that : self;
const product = (self, that) => isRight(self) ? isRight(that) ? right([self.right, that.right]) : left(that.left) : left(self.left);
const productMany = (self, collection) => {
if (isLeft(self)) {
return self;
return left(self.left);
}

@@ -365,3 +371,3 @@ const out = [self.right];

if (isLeft(e)) {
return e;
return left(e.left);
}

@@ -407,3 +413,3 @@ out.push(e.right);

if (isLeft(e)) {
return e;
return left(e.left);
}

@@ -601,3 +607,3 @@ out.push(e.right);

exports.getOrElse = getOrElse;
const orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => isLeft(self) ? that(self.left) : self);
const orElse = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => isLeft(self) ? that(self.left) : right(self.right));
/**

@@ -611,3 +617,8 @@ * Returns an effect that will produce the value of this effect, unless it

exports.orElse = orElse;
const orElseEither = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => isLeft(self) ? map(that(self.left), right) : map(self, left));
const orElseEither = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => {
if (isLeft(self)) {
return map(that(self.left), right);
}
return map(right(self.right), left);
});
/**

@@ -844,3 +855,3 @@ * Executes this effect and returns its value, if it succeeds, but otherwise

exports.compact = compact;
const traverse = F => (0, _Function.dual)(2, (self, f) => isLeft(self) ? F.of(self) : F.map(f(self.right), right));
const traverse = F => (0, _Function.dual)(2, (self, f) => isLeft(self) ? F.of(left(self.left)) : F.map(f(self.right), right));
/**

@@ -908,3 +919,3 @@ * @category instances

const out = onLeft(self.left);
return isLeft(out) ? out : self;
return isLeft(out) ? left(out.left) : self;
});

@@ -911,0 +922,0 @@ /**

@@ -25,2 +25,3 @@ "use strict";

const EffectTypeId = /*#__PURE__*/Symbol.for("@effect/io/Effect");
const EitherTypeId = /*#__PURE__*/Symbol.for("@effect/data/Either");
/** @internal */

@@ -45,2 +46,8 @@ class Right {

}
get [EitherTypeId]() {
return {
_E: _ => _,
_A: _ => _
};
}
toJSON() {

@@ -68,2 +75,8 @@ return {

}
get [EitherTypeId]() {
return {
_E: _ => _,
_A: _ => _
};
}
get left() {

@@ -70,0 +83,0 @@ return this.i0;

@@ -23,2 +23,3 @@ "use strict";

const EffectTypeId = /*#__PURE__*/Symbol.for("@effect/io/Effect");
const OptionTypeId = /*#__PURE__*/Symbol.for("@effect/io/Option");
/** @internal */

@@ -38,2 +39,7 @@ class Some {

}
get [OptionTypeId]() {
return {
_A: _ => _
};
}
get value() {

@@ -79,2 +85,7 @@ return this.i0;

}
get [OptionTypeId]() {
return {
_A: _ => _
};
}
traced(trace) {

@@ -81,0 +92,0 @@ if (trace) {

@@ -36,9 +36,22 @@ /**

*/
export type Option<A> = None | Some<A>;
export type Option<A> = None<A> | Some<A>;
/**
* @category symbols
* @since 1.0.0
*/
export declare const OptionTypeId: unique symbol;
/**
* @category symbols
* @since 1.0.0
*/
export type OptionTypeId = typeof OptionTypeId;
/**
* @category models
* @since 1.0.0
*/
export interface None extends Data.Case {
export interface None<A> extends Data.Case {
readonly _tag: "None";
readonly [OptionTypeId]: {
readonly _A: (_: never) => A;
};
traced(this: this, trace: Trace): this | TracedOption<never>;

@@ -53,2 +66,5 @@ }

readonly value: A;
readonly [OptionTypeId]: {
readonly _A: (_: never) => A;
};
traced(this: this, trace: Trace): this | TracedOption<this["value"]>;

@@ -119,3 +135,3 @@ }

*/
export declare const isNone: <A>(self: Option<A>) => self is None;
export declare const isNone: <A>(self: Option<A>) => self is None<A>;
/**

@@ -122,0 +138,0 @@ * Determine if a `Option` is a `Some`.

@@ -6,3 +6,3 @@ "use strict";

});
exports.zipWith = exports.zipRight = exports.zipLeft = exports.unit = exports.tupled = exports.tuple = exports.traverseTap = exports.traverse = exports.toRefinement = exports.toEither = exports.toArray = exports.tap = exports.sumCompact = exports.sum = exports.subtract = exports.struct = exports.some = exports.sequence = exports.reduceCompact = exports.partitionMap = exports.orElseEither = exports.orElse = exports.none = exports.multiplyCompact = exports.multiply = exports.match = exports.map = exports.liftThrowable = exports.liftPredicate = exports.liftNullable = exports.liftEither = exports.lift2 = exports.letDiscard = exports.let = exports.isSome = exports.isOption = exports.isNone = exports.inspectSome = exports.inspectNone = exports.getRight = exports.getOrder = exports.getOrUndefined = exports.getOrThrowWith = exports.getOrThrow = exports.getOrNull = exports.getOrElse = exports.getOptionalMonoid = exports.getLeft = exports.getFirstSomeSemigroup = exports.getFailureSemigroup = exports.getFailureMonoid = exports.getEquivalence = exports.gen = exports.fromNullable = exports.fromIterable = exports.fromEither = exports.flatten = exports.flatMapNullable = exports.flatMapEither = exports.flatMap = exports.flap = exports.firstSomeOf = exports.filterMap = exports.filter = exports.exists = exports.divide = exports.contains = exports.composeK = exports.bindTo = exports.bindDiscard = exports.bind = exports.asUnit = exports.as = exports.appendElement = exports.ap = exports.all = exports.Traversable = exports.SemiProduct = exports.SemiCoproduct = exports.SemiApplicative = exports.SemiAlternative = exports.Product = exports.Pointed = exports.Monad = exports.Invariant = exports.Foldable = exports.FlatMap = exports.Filterable = exports.Do = exports.Covariant = exports.Coproduct = exports.Chainable = exports.Applicative = exports.Alternative = void 0;
exports.zipWith = exports.zipRight = exports.zipLeft = exports.unit = exports.tupled = exports.tuple = exports.traverseTap = exports.traverse = exports.toRefinement = exports.toEither = exports.toArray = exports.tap = exports.sumCompact = exports.sum = exports.subtract = exports.struct = exports.some = exports.sequence = exports.reduceCompact = exports.partitionMap = exports.orElseEither = exports.orElse = exports.none = exports.multiplyCompact = exports.multiply = exports.match = exports.map = exports.liftThrowable = exports.liftPredicate = exports.liftNullable = exports.liftEither = exports.lift2 = exports.letDiscard = exports.let = exports.isSome = exports.isOption = exports.isNone = exports.inspectSome = exports.inspectNone = exports.getRight = exports.getOrder = exports.getOrUndefined = exports.getOrThrowWith = exports.getOrThrow = exports.getOrNull = exports.getOrElse = exports.getOptionalMonoid = exports.getLeft = exports.getFirstSomeSemigroup = exports.getFailureSemigroup = exports.getFailureMonoid = exports.getEquivalence = exports.gen = exports.fromNullable = exports.fromIterable = exports.fromEither = exports.flatten = exports.flatMapNullable = exports.flatMapEither = exports.flatMap = exports.flap = exports.firstSomeOf = exports.filterMap = exports.filter = exports.exists = exports.divide = exports.contains = exports.composeK = exports.bindTo = exports.bindDiscard = exports.bind = exports.asUnit = exports.as = exports.appendElement = exports.ap = exports.all = exports.Traversable = exports.SemiProduct = exports.SemiCoproduct = exports.SemiApplicative = exports.SemiAlternative = exports.Product = exports.Pointed = exports.OptionTypeId = exports.Monad = exports.Invariant = exports.Foldable = exports.FlatMap = exports.Filterable = exports.Do = exports.Covariant = exports.Coproduct = exports.Chainable = exports.Applicative = exports.Alternative = void 0;
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));

@@ -34,2 +34,7 @@ var _Function = /*#__PURE__*/require("@effect/data/Function");

/**
* @category symbols
* @since 1.0.0
*/
const OptionTypeId = /*#__PURE__*/Symbol.for("@effect/data/Option");
/**
* Creates a new `Option` that represents the absence of a value.

@@ -40,2 +45,3 @@ *

*/
exports.OptionTypeId = OptionTypeId;
const none = () => option.none;

@@ -42,0 +48,0 @@ /**

{
"name": "@effect/data",
"version": "0.10.3",
"version": "0.11.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -13,3 +13,3 @@ # Installation

- TypeScript 4.8 or newer
- TypeScript 4.9 or newer
- The `strict` flag enabled in your `tsconfig.json` file

@@ -16,0 +16,0 @@

@@ -64,2 +64,3 @@ /**

| IEmpty
| ISlice<A>

@@ -91,2 +92,10 @@ /** @internal */

/** @internal */
interface ISlice<A> {
readonly _tag: "ISlice"
readonly chunk: Chunk<A>
readonly offset: number
readonly length: number
}
/** @internal */
const emptyArray: ReadonlyArray<never> = []

@@ -147,2 +156,9 @@

}
case "ISlice": {
this.length = backing.length
this.depth = backing.chunk.depth + 1
this.left = _empty
this.right = _empty
break
}
}

@@ -208,2 +224,12 @@ }

}
case "ISlice": {
let i = 0
let j = initial
while (i < self.length) {
array[j] = unsafeGet(self, i)
i += 1
j += 1
}
break
}
}

@@ -330,2 +356,5 @@ }

}
case "ISlice": {
return unsafeGet(self.backing.chunk, index + self.backing.offset)
}
}

@@ -380,3 +409,31 @@ })

} else {
return unsafeFromArray(RA.take(n)(toReadonlyArray(self)))
switch (self.backing._tag) {
case "ISlice": {
return new ChunkImpl({
_tag: "ISlice",
chunk: self.backing.chunk,
length: n,
offset: self.backing.offset
})
}
case "IConcat": {
if (n > self.left.length) {
return new ChunkImpl({
_tag: "IConcat",
left: self.left,
right: take(self.right, n - self.left.length)
})
}
return take(self.left, n)
}
default: {
return new ChunkImpl({
_tag: "ISlice",
chunk: self,
offset: 0,
length: n
})
}
}
}

@@ -403,3 +460,30 @@ })

} else {
return unsafeFromArray(RA.drop(n)(toReadonlyArray(self)))
switch (self.backing._tag) {
case "ISlice": {
return new ChunkImpl({
_tag: "ISlice",
chunk: self.backing.chunk,
offset: self.backing.offset + n,
length: self.backing.length - n
})
}
case "IConcat": {
if (n > self.left.length) {
return drop(self.right, n - self.left.length)
}
return new ChunkImpl({
_tag: "IConcat",
left: drop(self.left, n),
right: self.right
})
}
default: {
return new ChunkImpl({
_tag: "ISlice",
chunk: self,
offset: n,
length: self.length - n
})
}
}
}

@@ -488,6 +572,6 @@ })

if (self.left.depth >= self.right.depth) {
const nr = concat(that)(self.right)
const nr = concat(self.right, that)
return new ChunkImpl({ _tag: "IConcat", left: self.left, right: nr })
} else {
const nrr = concat(that)(self.right.right)
const nrr = concat(self.right.right, that)
if (nrr.depth === self.depth - 3) {

@@ -503,6 +587,6 @@ const nr = new ChunkImpl({ _tag: "IConcat", left: self.right.left, right: nrr })

if (that.right.depth >= that.left.depth) {
const nl = concat(that.left)(self)
const nl = concat(self, that.left)
return new ChunkImpl({ _tag: "IConcat", left: nl, right: that.right })
} else {
const nll = concat(that.left.left)(self)
const nll = concat(self, that.left.left)
if (nll.depth === that.depth - 3) {

@@ -552,3 +636,3 @@ const nl = new ChunkImpl({ _tag: "IConcat", left: nll, right: that.left.right })

<A, B>(self: Iterable<A>, f: (a: A) => Option<B>) => Chunk<B>
>(2, (self, f) => unsafeFromArray(RA.filterMap(f)(self)))
>(2, (self, f) => unsafeFromArray(RA.filterMap(self, f)))

@@ -578,3 +662,3 @@ /**

<B extends A, A = B>(self: Chunk<B>, predicate: Predicate<A>) =>
unsafeFromArray(RA.filterMap(O.liftPredicate(predicate))(self))
unsafeFromArray(RA.filterMap(self, O.liftPredicate(predicate)))
)

@@ -594,3 +678,3 @@

<A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>) => Chunk<B>
>(2, (self, f) => unsafeFromArray(RA.filterMap(f)(self)))
>(2, (self, f) => unsafeFromArray(RA.filterMap(self, f)))

@@ -622,2 +706,4 @@ /**

const elem_ = RA.contains(Equal.equivalence())
/**

@@ -635,3 +721,3 @@ * Tests whether a value is a member of a `Chunk<A>`.

<A, B>(self: Chunk<A>, b: B) => boolean
>(2, (self, b) => pipe(toReadonlyArray(self), RA.contains(Equal.equivalence())(b)))
>(2, (self, b) => elem_(toReadonlyArray(self), b))

@@ -712,3 +798,3 @@ /**

}
>(2, <A>(self: Chunk<A>, predicate: Predicate<A>) => RA.findFirst(predicate)(toReadonlyArray(self)))
>(2, <A>(self: Chunk<A>, predicate: Predicate<A>) => RA.findFirst(toReadonlyArray(self), predicate))

@@ -727,3 +813,3 @@ /**

<A>(self: Chunk<A>, f: Predicate<A>) => Option<number>
>(2, (self, f) => RA.findFirstIndex(f)(toReadonlyArray(self)))
>(2, (self, f) => RA.findFirstIndex(toReadonlyArray(self), f))

@@ -742,3 +828,3 @@ /**

<A>(self: Chunk<A>, f: Predicate<A>) => Option<number>
>(2, (self, f) => RA.findLastIndex(f)(toReadonlyArray(self)))
>(2, (self, f) => RA.findLastIndex(toReadonlyArray(self), f))

@@ -765,3 +851,3 @@ /**

}
>(2, <A>(self: Chunk<A>, f: Predicate<A>) => RA.findLast(f)(toReadonlyArray(self)))
>(2, <A>(self: Chunk<A>, f: Predicate<A>) => RA.findLast(toReadonlyArray(self), f))

@@ -786,3 +872,3 @@ /**

for (const k of self) {
r = concat(f(k))(r)
r = concat(r, f(k))
}

@@ -853,2 +939,4 @@ return r

const intersection_ = RA.intersection(Equal.equivalence<any>())
/**

@@ -869,6 +957,4 @@ * Creates a Chunk of unique values that are included in all given Chunks.

>(2, (self, that) =>
pipe(
toReadonlyArray(self),
RA.intersection(Equal.equivalence<any>())(toReadonlyArray(that)),
unsafeFromArray
unsafeFromArray(
intersection_(toReadonlyArray(self), toReadonlyArray(that))
))

@@ -1019,3 +1105,3 @@

of(f(self.backing.a)) :
unsafeFromArray(RA.map(f)(toReadonlyArray(self))))
unsafeFromArray(RA.map(toReadonlyArray(self), f)))

@@ -1226,3 +1312,3 @@ /**

<A>(self: Chunk<A>, n: number) => readonly [Chunk<A>, Chunk<A>]
>(2, (self, n) => [take(n)(self), drop(n)(self)])
>(2, (self, n) => [take(self, n), drop(self, n)])

@@ -1287,3 +1373,3 @@ /**

}
return splitAt(i)(self)
return splitAt(self, i)
})

@@ -1297,3 +1383,3 @@

*/
export const tail = <A>(self: Chunk<A>): Option<Chunk<A>> => self.length > 0 ? O.some(drop(1)(self)) : O.none()
export const tail = <A>(self: Chunk<A>): Option<Chunk<A>> => self.length > 0 ? O.some(drop(self, 1)) : O.none()

@@ -1360,2 +1446,4 @@ /**

const union_ = RA.union(Equal.equivalence<any>())
/**

@@ -1375,5 +1463,7 @@ * Creates a Chunks of unique values, in order, from all given Chunks.

unsafeFromArray(
RA.union(Equal.equivalence<A | B>())(toReadonlyArray(that))(toReadonlyArray(self))
union_(toReadonlyArray(self), toReadonlyArray(that))
))
const uniq_ = RA.uniq(Equal.equivalence<any>())
/**

@@ -1385,4 +1475,3 @@ * Remove duplicates from an array, keeping the first occurrence of an element.

*/
export const dedupe = <A>(self: Chunk<A>): Chunk<A> =>
unsafeFromArray(RA.uniq(Equal.equivalence<A>())(toReadonlyArray(self)))
export const dedupe = <A>(self: Chunk<A>): Chunk<A> => unsafeFromArray(uniq_(toReadonlyArray(self)))

@@ -1395,3 +1484,3 @@ /**

*/
export const unsafeHead = <A>(self: Chunk<A>): A => unsafeGet(0)(self)
export const unsafeHead = <A>(self: Chunk<A>): A => unsafeGet(self, 0)

@@ -1404,3 +1493,3 @@ /**

*/
export const unsafeLast = <A>(self: Chunk<A>): A => unsafeGet(self.length - 1)(self)
export const unsafeLast = <A>(self: Chunk<A>): A => unsafeGet(self, self.length - 1)

@@ -1592,3 +1681,3 @@ /**

*/
export const zipWithIndex = <A>(self: Chunk<A>): Chunk<readonly [A, number]> => zipWithIndexOffset(0)(self)
export const zipWithIndex = <A>(self: Chunk<A>): Chunk<readonly [A, number]> => zipWithIndexOffset(self, 0)

@@ -1595,0 +1684,0 @@ /**

@@ -43,11 +43,27 @@ /**

*/
export type Either<E, A> = Left<E> | Right<A>
export type Either<E, A> = Left<E, A> | Right<E, A>
/**
* @category symbols
* @since 1.0.0
*/
export const EitherTypeId = Symbol.for("@effect/data/Either")
/**
* @category symbols
* @since 1.0.0
*/
export type EitherTypeId = typeof EitherTypeId
/**
* @category models
* @since 1.0.0
*/
export interface Left<E> extends Data.Case {
export interface Left<E, A> extends Data.Case {
readonly _tag: "Left"
readonly left: E
readonly [EitherTypeId]: {
readonly _A: (_: never) => A
readonly _E: (_: never) => E
}
get left(): E
traced(

@@ -63,5 +79,9 @@ this: this,

*/
export interface Right<A> extends Data.Case {
export interface Right<E, A> extends Data.Case {
readonly _tag: "Right"
readonly right: A
get right(): A
readonly [EitherTypeId]: {
readonly _A: (_: never) => A
readonly _E: (_: never) => E
}
traced(

@@ -146,3 +166,3 @@ this: this,

*/
export const isLeft: <E, A>(self: Either<E, A>) => self is Left<E> = either.isLeft
export const isLeft: <E, A>(self: Either<E, A>) => self is Left<E, A> = either.isLeft

@@ -163,3 +183,3 @@ /**

*/
export const isRight: <E, A>(self: Either<E, A>) => self is Right<A> = either.isRight
export const isRight: <E, A>(self: Either<E, A>) => self is Right<E, A> = either.isRight

@@ -319,3 +339,3 @@ /**

2,
<E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B> => isRight(self) ? right(f(self.right)) : self
<E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B> => isRight(self) ? right(f(self.right)) : left(self.left)
)

@@ -411,3 +431,3 @@

<E1, A, E2, B>(self: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B> =>
isLeft(self) ? self : f(self.right)
isLeft(self) ? left(self.left) : f(self.right)
)

@@ -484,3 +504,3 @@

const product = <E1, A, E2, B>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, [A, B]> =>
isRight(self) ? (isRight(that) ? right([self.right, that.right]) : that) : self
isRight(self) ? (isRight(that) ? right([self.right, that.right]) : left(that.left)) : left(self.left)

@@ -492,3 +512,3 @@ const productMany = <E, A>(

if (isLeft(self)) {
return self
return left(self.left)
}

@@ -498,3 +518,3 @@ const out: [A, ...Array<A>] = [self.right]

if (isLeft(e)) {
return e
return left(e.left)
}

@@ -543,3 +563,3 @@ out.push(e.right)

if (isLeft(e)) {
return e
return left(e.left)
}

@@ -790,3 +810,3 @@ out.push(e.right)

<E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, A | B> =>
isLeft(self) ? that(self.left) : self
isLeft(self) ? that(self.left) : right(self.right)
)

@@ -806,6 +826,8 @@

2,
<E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>> =>
isLeft(self) ?
map(that(self.left), right) :
map(self, left)
<E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>> => {
if (isLeft(self)) {
return map(that(self.left), right)
}
return map(right(self.right), left)
}
)

@@ -1151,3 +1173,3 @@

isLeft(self) ?
F.of<Either<TE, B>>(self) :
F.of<Either<TE, B>>(left(self.left)) :
F.map<R, O, E, B, Either<TE, B>>(f(self.right), right))

@@ -1244,3 +1266,3 @@

const out = onLeft(self.left)
return isLeft(out) ? out : self
return isLeft(out) ? left(out.left) : self
}

@@ -1247,0 +1269,0 @@ )

@@ -22,5 +22,6 @@ /**

const EffectTypeId = Symbol.for("@effect/io/Effect")
const EitherTypeId: Either.EitherTypeId = Symbol.for("@effect/data/Either") as Either.EitherTypeId
/** @internal */
export class Right<A> implements Either.Right<A> {
export class Right<E, A> implements Either.Right<E, A> {
readonly _tag = "Right"

@@ -32,3 +33,3 @@ public i1 = undefined

[Equal.symbol](this: this, that: unknown) {
return isEither(that) && isRight(that) && Equal.equals((that as unknown as Right<A>).i0, this.i0)
return isEither(that) && isRight(that) && Equal.equals((that as unknown as Right<E, A>).i0, this.i0)
}

@@ -43,2 +44,8 @@ [Hash.symbol](this: this) {

}
get [EitherTypeId]() {
return {
_E: (_: never) => _,
_A: (_: never) => _
}
}
toJSON() {

@@ -62,3 +69,3 @@ return {

/** @internal */
export class Left<E> implements Either.Left<E> {
export class Left<E, A> implements Either.Left<E, A> {
readonly _tag = "Left"

@@ -70,3 +77,3 @@ public i1 = undefined

[Equal.symbol](this: this, that: unknown) {
return isEither(that) && isLeft(that) && Equal.equals((that as unknown as Left<E>).i0, this.i0)
return isEither(that) && isLeft(that) && Equal.equals((that as unknown as Left<E, A>).i0, this.i0)
}

@@ -76,2 +83,8 @@ [Hash.symbol](this: this) {

}
get [EitherTypeId]() {
return {
_E: (_: never) => _,
_A: (_: never) => _
}
}
get left() {

@@ -105,6 +118,6 @@ return this.i0

/** @internal */
export const isLeft = <E, A>(ma: Either.Either<E, A>): ma is Either.Left<E> => ma._tag === "Left"
export const isLeft = <E, A>(ma: Either.Either<E, A>): ma is Either.Left<E, A> => ma._tag === "Left"
/** @internal */
export const isRight = <E, A>(ma: Either.Either<E, A>): ma is Either.Right<A> => ma._tag === "Right"
export const isRight = <E, A>(ma: Either.Either<E, A>): ma is Either.Right<E, A> => ma._tag === "Right"

@@ -111,0 +124,0 @@ /** @internal */

@@ -19,2 +19,3 @@ /**

const EffectTypeId = Symbol.for("@effect/io/Effect")
const OptionTypeId: Option.OptionTypeId = Symbol.for("@effect/io/Option") as Option.OptionTypeId

@@ -40,2 +41,7 @@ /** @internal */

}
get [OptionTypeId]() {
return {
_A: (_: never) => _
}
}
get value() {

@@ -55,3 +61,3 @@ return this.i0

/** @internal */
export class None implements Option.None {
export class None<A> implements Option.None<A> {
readonly _tag = "None"

@@ -74,2 +80,7 @@ public i0 = undefined

}
get [OptionTypeId]() {
return {
_A: (_: never) => _
}
}
traced(this: this, trace: Trace): Option.TracedOption<never> | this {

@@ -89,3 +100,3 @@ if (trace) {

/** @internal */
export const isNone = <A>(fa: Option.Option<A>): fa is Option.None => fa._tag === "None"
export const isNone = <A>(fa: Option.Option<A>): fa is Option.None<A> => fa._tag === "None"

@@ -92,0 +103,0 @@ /** @internal */

@@ -47,10 +47,25 @@ /**

*/
export type Option<A> = None | Some<A>
export type Option<A> = None<A> | Some<A>
/**
* @category symbols
* @since 1.0.0
*/
export const OptionTypeId = Symbol.for("@effect/data/Option")
/**
* @category symbols
* @since 1.0.0
*/
export type OptionTypeId = typeof OptionTypeId
/**
* @category models
* @since 1.0.0
*/
export interface None extends Data.Case {
export interface None<A> extends Data.Case {
readonly _tag: "None"
readonly [OptionTypeId]: {
readonly _A: (_: never) => A
}
traced(

@@ -69,2 +84,5 @@ this: this,

readonly value: A
readonly [OptionTypeId]: {
readonly _A: (_: never) => A
}
traced(

@@ -149,3 +167,3 @@ this: this,

*/
export const isNone: <A>(self: Option<A>) => self is None = option.isNone
export const isNone: <A>(self: Option<A>) => self is None<A> = option.isNone

@@ -152,0 +170,0 @@ /**

@@ -127,2 +127,2 @@ /**

T.traversePartitionMap(F)(self, (b) =>
F.map(predicate(b), (keep) => (keep ? E.right(b) : E.left(b)))))
F.map(predicate(b), (keep): E.Either<typeof b, typeof b> => (keep ? E.right(b) : E.left(b)))))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc