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.9.1 to 0.10.0

13

Either.d.ts

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

import type * as Data from "@effect/data/Data";
import type { SourceLocation, Trace } from "@effect/data/Debug";
import type { LazyArg } from "@effect/data/Function";

@@ -41,2 +42,3 @@ import * as Gen from "@effect/data/Gen";

readonly left: E;
traced<E, A>(this: Either<E, A>, trace: Trace): Either<E, A> | TracedEither<E, A>;
}

@@ -50,4 +52,15 @@ /**

readonly right: A;
traced<E, A>(this: Either<E, A>, trace: Trace): Either<E, A> | TracedEither<E, A>;
}
/**
* @since 1.0.0
* @category models
*/
export interface TracedEither<E, A> {
readonly _tag: "Traced";
readonly i0: Either<E, A> | TracedEither<E, A>;
readonly trace: SourceLocation;
traced(this: TracedEither<E, A>, trace: Trace): TracedEither<E, A>;
}
/**
* @category type lambdas

@@ -54,0 +67,0 @@ * @since 1.0.0

82

internal/Either.js

@@ -6,5 +6,7 @@ "use strict";

});
exports.right = exports.left = exports.isRight = exports.isLeft = exports.getRight = exports.getLeft = exports.fromOption = void 0;
var Data = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Data"));
exports.right = exports.left = exports.isRight = exports.isLeft = exports.isEither = exports.getRight = exports.getLeft = exports.fromOption = exports.Right = exports.Left = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var _Function = /*#__PURE__*/require("@effect/data/Function");
var Hash = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Hash"));
var option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/internal/Option"));

@@ -16,4 +18,68 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

*/
var _a, _b;
/** @internal */
const effectVariance = {
_R: _ => _,
_E: _ => _,
_A: _ => _
};
const EffectTypeId = /*#__PURE__*/Symbol.for("@effect/io/Effect");
/** @internal */
class Right {
[(_a = EffectTypeId, Equal.symbol)](that) {
return isEither(that) && isRight(that) && that.i0 === this.i0;
}
[Hash.symbol]() {
return Hash.hash(this.i0);
}
get right() {
return this.i0;
}
constructor(i0) {
this.i0 = i0;
this._tag = "Right";
this.i1 = undefined;
this.i2 = undefined;
this.trace = undefined;
this[_a] = effectVariance;
}
traced(trace) {
if (trace) {
return (0, _Debug.makeTraced)(this, trace);
}
return this;
}
}
/** @internal */
exports.Right = Right;
class Left {
[(_b = EffectTypeId, Equal.symbol)](that) {
return isEither(that) && isLeft(that) && that.i0 === this.i0;
}
[Hash.symbol]() {
return Hash.hash(this.i0);
}
get left() {
return this.i0;
}
constructor(i0) {
this.i0 = i0;
this._tag = "Left";
this.i1 = undefined;
this.i2 = undefined;
this.trace = undefined;
this[_b] = effectVariance;
}
traced(trace) {
if (trace) {
return (0, _Debug.makeTraced)(this, trace);
}
return this;
}
}
/** @internal */
exports.Left = Left;
const isEither = input => typeof input === "object" && input != null && "_tag" in input && (input["_tag"] === "Left" || input["_tag"] === "Right") && Equal.isEqual(input);
/** @internal */
exports.isEither = isEither;
const isLeft = ma => ma._tag === "Left";

@@ -25,12 +91,6 @@ /** @internal */

exports.isRight = isRight;
const left = e => Data.struct({
_tag: "Left",
left: e
});
const left = e => new Left(e);
/** @internal */
exports.left = left;
const right = a => Data.struct({
_tag: "Right",
right: a
});
const right = a => new Right(a);
/** @internal */

@@ -37,0 +97,0 @@ exports.right = right;

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

});
exports.some = exports.none = exports.isSome = exports.isNone = void 0;
var Data = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Data"));
exports.some = exports.none = exports.isSome = exports.isOption = exports.isNone = exports.Some = exports.None = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var Hash = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Hash"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -14,4 +16,65 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

*/
var _a, _b;
/** @internal */
const effectVariance = {
_R: _ => _,
_E: _ => _,
_A: _ => _
};
const EffectTypeId = /*#__PURE__*/Symbol.for("@effect/io/Effect");
/** @internal */
class Some {
[(_a = EffectTypeId, Equal.symbol)](that) {
return isOption(that) && isSome(that) && that.i0 === this.i0;
}
[Hash.symbol]() {
return Hash.hash(this.i0);
}
get value() {
return this.i0;
}
constructor(i0) {
this.i0 = i0;
this._tag = "Some";
this.i1 = undefined;
this.i2 = undefined;
this.trace = undefined;
this[_a] = effectVariance;
}
traced(trace) {
if (trace) {
return (0, _Debug.makeTraced)(this, trace);
}
return this;
}
}
/** @internal */
exports.Some = Some;
class None {
constructor() {
this._tag = "None";
this.i0 = undefined;
this.i1 = undefined;
this.i2 = undefined;
this.trace = undefined;
this[_b] = effectVariance;
}
[(_b = EffectTypeId, Equal.symbol)](that) {
return isOption(that) && isNone(that);
}
[Hash.symbol]() {
return Hash.hash(this._tag);
}
traced(trace) {
if (trace) {
return (0, _Debug.makeTraced)(this, trace);
}
return this;
}
}
/** @internal */
exports.None = None;
const isOption = input => typeof input === "object" && input != null && "_tag" in input && (input["_tag"] === "None" || input["_tag"] === "Some") && Equal.isEqual(input);
/** @internal */
exports.isOption = isOption;
const isNone = fa => fa._tag === "None";

@@ -23,12 +86,7 @@ /** @internal */

exports.isSome = isSome;
const none = /*#__PURE__*/Data.struct({
_tag: "None"
});
const none = /*#__PURE__*/new None();
/** @internal */
exports.none = none;
const some = a => Data.struct({
_tag: "Some",
value: a
});
const some = a => new Some(a);
exports.some = some;
//# sourceMappingURL=Option.js.map

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

import type * as Data from "@effect/data/Data";
import type { SourceLocation, Trace } from "@effect/data/Debug";
import type { Either } from "@effect/data/Either";

@@ -43,2 +44,3 @@ import type { LazyArg } from "@effect/data/Function";

readonly _tag: "None";
traced(this: Option<never>, trace: Trace): Option<never> | TracedOption<never>;
}

@@ -52,4 +54,15 @@ /**

readonly value: A;
traced(this: Option<A>, trace: Trace): Option<A> | TracedOption<A>;
}
/**
* @since 1.0.0
* @category models
*/
export interface TracedOption<A> {
readonly _tag: "Traced";
readonly i0: Option<A> | TracedOption<A>;
readonly trace: SourceLocation;
traced(this: TracedOption<A>, trace: Trace): TracedOption<A>;
}
/**
* @category type lambdas

@@ -56,0 +69,0 @@ * @since 1.0.0

2

package.json
{
"name": "@effect/data",
"version": "0.9.1",
"version": "0.10.0",
"license": "MIT",

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

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

import type * as Data from "@effect/data/Data"
import type { SourceLocation, Trace } from "@effect/data/Debug"
import * as Equal from "@effect/data/Equal"

@@ -52,2 +53,6 @@ import type { LazyArg } from "@effect/data/Function"

readonly left: E
traced<E, A>(
this: Either<E, A>,
trace: Trace
): Either<E, A> | TracedEither<E, A>
}

@@ -62,5 +67,23 @@

readonly right: A
traced<E, A>(
this: Either<E, A>,
trace: Trace
): Either<E, A> | TracedEither<E, A>
}
/**
* @since 1.0.0
* @category models
*/
export interface TracedEither<E, A> {
readonly _tag: "Traced"
readonly i0: Either<E, A> | TracedEither<E, A>
readonly trace: SourceLocation
traced(
this: TracedEither<E, A>,
trace: Trace
): TracedEither<E, A>
}
/**
* @category type lambdas

@@ -67,0 +90,0 @@ * @since 1.0.0

@@ -5,5 +5,8 @@ /**

import * as Data from "@effect/data/Data"
import type { Either, Left, Right } from "@effect/data/Either"
import type { Trace } from "@effect/data/Debug"
import { makeTraced } from "@effect/data/Debug"
import type * as Either from "@effect/data/Either"
import * as Equal from "@effect/data/Equal"
import { dual } from "@effect/data/Function"
import * as Hash from "@effect/data/Hash"
import * as option from "@effect/data/internal/Option"

@@ -13,16 +16,82 @@ import type { Option } from "@effect/data/Option"

/** @internal */
export const isLeft = <E, A>(ma: Either<E, A>): ma is Left<E> => ma._tag === "Left"
const effectVariance = {
_R: (_: never) => _,
_E: (_: never) => _,
_A: (_: never) => _
}
const EffectTypeId = Symbol.for("@effect/io/Effect")
/** @internal */
export const isRight = <E, A>(ma: Either<E, A>): ma is Right<A> => ma._tag === "Right"
export class Right<A> implements Either.Right<A> {
readonly _tag = "Right"
public i1 = undefined
public i2 = undefined
public trace = undefined;
[EffectTypeId] = effectVariance;
[Equal.symbol](this: this, that: unknown) {
return isEither(that) && isRight(that) && (that as unknown as Right<A>).i0 === this.i0
}
[Hash.symbol](this: this) {
return Hash.hash(this.i0)
}
get right() {
return this.i0
}
constructor(readonly i0: A) {
}
traced<E, A>(this: Either.Either<E, A>, trace: Trace): Either.TracedEither<E, A> | Either.Either<E, A> {
if (trace) {
return makeTraced(this, trace)
}
return this
}
}
/** @internal */
export const left = <E>(e: E): Either<E, never> => Data.struct({ _tag: "Left", left: e })
export class Left<A> implements Either.Left<A> {
readonly _tag = "Left"
public i1 = undefined
public i2 = undefined
public trace = undefined;
[EffectTypeId] = effectVariance;
[Equal.symbol](this: this, that: unknown) {
return isEither(that) && isLeft(that) && (that as unknown as Left<A>).i0 === this.i0
}
[Hash.symbol](this: this) {
return Hash.hash(this.i0)
}
get left() {
return this.i0
}
constructor(readonly i0: A) {
}
traced<E, A>(this: Either.Either<E, A>, trace: Trace): Either.TracedEither<E, A> | Either.Either<E, A> {
if (trace) {
return makeTraced(this, trace)
}
return this
}
}
/** @internal */
export const right = <A>(a: A): Either<never, A> => Data.struct({ _tag: "Right", right: a })
export const isEither = (input: unknown): input is Either.Either<unknown, unknown> =>
typeof input === "object" && input != null && "_tag" in input &&
(input["_tag"] === "Left" || input["_tag"] === "Right") && Equal.isEqual(input)
/** @internal */
export const isLeft = <E, A>(ma: Either.Either<E, A>): ma is Either.Left<E> => ma._tag === "Left"
/** @internal */
export const isRight = <E, A>(ma: Either.Either<E, A>): ma is Either.Right<A> => ma._tag === "Right"
/** @internal */
export const left = <E>(e: E): Either.Either<E, never> => new Left(e)
/** @internal */
export const right = <A>(a: A): Either.Either<never, A> => new Right(a)
/** @internal */
export const getLeft = <E, A>(
self: Either<E, A>
self: Either.Either<E, A>
): Option<E> => (isRight(self) ? option.none : option.some(self.left))

@@ -32,3 +101,3 @@

export const getRight = <E, A>(
self: Either<E, A>
self: Either.Either<E, A>
): Option<A> => (isLeft(self) ? option.none : option.some(self.right))

@@ -39,3 +108,4 @@

2,
<A, E>(self: Option<A>, onNone: () => E): Either<E, A> => option.isNone(self) ? left(onNone()) : right(self.value)
<A, E>(self: Option<A>, onNone: () => E): Either.Either<E, A> =>
option.isNone(self) ? left(onNone()) : right(self.value)
)

@@ -5,15 +5,80 @@ /**

import * as Data from "@effect/data/Data"
import type { None, Option, Some } from "@effect/data/Option"
import type { Trace } from "@effect/data/Debug"
import { makeTraced } from "@effect/data/Debug"
import * as Equal from "@effect/data/Equal"
import * as Hash from "@effect/data/Hash"
import type * as Option from "@effect/data/Option"
/** @internal */
export const isNone = <A>(fa: Option<A>): fa is None => fa._tag === "None"
const effectVariance = {
_R: (_: never) => _,
_E: (_: never) => _,
_A: (_: never) => _
}
const EffectTypeId = Symbol.for("@effect/io/Effect")
/** @internal */
export const isSome = <A>(fa: Option<A>): fa is Some<A> => fa._tag === "Some"
export class Some<A> implements Option.Some<A> {
readonly _tag = "Some"
public i1 = undefined
public i2 = undefined
public trace = undefined;
[EffectTypeId] = effectVariance;
[Equal.symbol](this: this, that: unknown) {
return isOption(that) && isSome(that) && (that as Some<A>).i0 === this.i0
}
[Hash.symbol](this: this) {
return Hash.hash(this.i0)
}
get value() {
return this.i0
}
constructor(readonly i0: A) {
}
traced(this: this, trace: Trace): Option.TracedOption<A> | this {
if (trace) {
return makeTraced(this, trace)
}
return this
}
}
/** @internal */
export const none: Option<never> = Data.struct({ _tag: "None" })
export class None implements Option.None {
readonly _tag = "None"
public i0 = undefined
public i1 = undefined
public i2 = undefined
public trace = undefined;
[EffectTypeId] = effectVariance;
[Equal.symbol](this: this, that: unknown) {
return isOption(that) && isNone(that)
}
[Hash.symbol](this: this) {
return Hash.hash(this._tag)
}
traced(this: this, trace: Trace): Option.TracedOption<never> | this {
if (trace) {
return makeTraced(this, trace)
}
return this
}
}
/** @internal */
export const some = <A>(a: A): Option<A> => Data.struct({ _tag: "Some", value: a })
export const isOption = (input: unknown): input is Option.Option<unknown> =>
typeof input === "object" && input != null && "_tag" in input &&
(input["_tag"] === "None" || input["_tag"] === "Some") && Equal.isEqual(input)
/** @internal */
export const isNone = <A>(fa: Option.Option<A>): fa is Option.None => fa._tag === "None"
/** @internal */
export const isSome = <A>(fa: Option.Option<A>): fa is Option.Some<A> => fa._tag === "Some"
/** @internal */
export const none: Option.Option<never> = new None()
/** @internal */
export const some = <A>(a: A): Option.Option<A> => new Some(a)

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

import type * as Data from "@effect/data/Data"
import type { SourceLocation, Trace } from "@effect/data/Debug"
import type { Either } from "@effect/data/Either"

@@ -55,2 +56,6 @@ import * as Equal from "@effect/data/Equal"

readonly _tag: "None"
traced(
this: Option<never>,
trace: Trace
): Option<never> | TracedOption<never>
}

@@ -65,5 +70,23 @@

readonly value: A
traced(
this: Option<A>,
trace: Trace
): Option<A> | TracedOption<A>
}
/**
* @since 1.0.0
* @category models
*/
export interface TracedOption<A> {
readonly _tag: "Traced"
readonly i0: Option<A> | TracedOption<A>
readonly trace: SourceLocation
traced(
this: TracedOption<A>,
trace: Trace
): TracedOption<A>
}
/**
* @category type lambdas

@@ -70,0 +93,0 @@ * @since 1.0.0

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