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.15.0 to 0.15.1

73

Duration.d.ts

@@ -109,3 +109,3 @@ /**

*/
export declare const toMillis: (self: Duration) => number;
export declare const toMillis: (self: DurationInput) => number;
/**

@@ -119,3 +119,3 @@ * Get the duration in nanoseconds as a bigint.

*/
export declare const toNanos: (self: Duration) => Option.Option<bigint>;
export declare const toNanos: (self: DurationInput) => Option.Option<bigint>;
/**

@@ -129,3 +129,3 @@ * Get the duration in nanoseconds as a bigint.

*/
export declare const unsafeToNanos: (self: Duration) => bigint;
export declare const unsafeToNanos: (self: DurationInput) => bigint;
/**

@@ -135,3 +135,3 @@ * @since 1.0.0

*/
export declare const toHrTime: (self: Duration) => readonly [seconds: number, nanos: number];
export declare const toHrTime: (self: DurationInput) => readonly [seconds: number, nanos: number];
/**

@@ -145,4 +145,4 @@ * @since 1.0.0

readonly onNanos: (nanos: bigint) => B;
}): (self: Duration) => A | B;
<A, B>(self: Duration, options: {
}): (self: DurationInput) => A | B;
<A, B>(self: DurationInput, options: {
readonly onMillis: (millis: number) => A;

@@ -156,9 +156,12 @@ readonly onNanos: (nanos: bigint) => B;

*/
export declare const matchWith: (<A, B>(that: Duration, options: {
readonly onMillis: (self: number, that: number) => A;
readonly onNanos: (self: bigint, that: bigint) => B;
}) => (self: Duration) => A | B) & (<A_1, B_1>(self: Duration, that: Duration, options: {
readonly onMillis: (self: number, that: number) => A_1;
readonly onNanos: (self: bigint, that: bigint) => B_1;
}) => A_1 | B_1);
export declare const matchWith: {
<A, B>(that: DurationInput, options: {
readonly onMillis: (self: number, that: number) => A;
readonly onNanos: (self: bigint, that: bigint) => B;
}): (self: DurationInput) => A | B;
<A, B>(self: DurationInput, that: DurationInput, options: {
readonly onMillis: (self: number, that: number) => A;
readonly onNanos: (self: bigint, that: bigint) => B;
}): A | B;
};
/**

@@ -176,4 +179,4 @@ * @category instances

export declare const between: {
(minimum: Duration, maximum: Duration): (self: Duration) => boolean;
(self: Duration, minimum: Duration, maximum: Duration): boolean;
(minimum: DurationInput, maximum: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, minimum: DurationInput, maximum: DurationInput): boolean;
};

@@ -189,4 +192,4 @@ /**

export declare const min: {
(that: Duration): (self: Duration) => Duration;
(self: Duration, that: Duration): Duration;
(that: DurationInput): (self: DurationInput) => Duration;
(self: DurationInput, that: DurationInput): Duration;
};

@@ -197,4 +200,4 @@ /**

export declare const max: {
(that: Duration): (self: Duration) => Duration;
(self: Duration, that: Duration): Duration;
(that: DurationInput): (self: DurationInput) => Duration;
(self: DurationInput, that: DurationInput): Duration;
};

@@ -205,4 +208,4 @@ /**

export declare const clamp: {
(minimum: Duration, maximum: Duration): (self: Duration) => Duration;
(self: Duration, minimum: Duration, maximum: Duration): Duration;
(minimum: DurationInput, maximum: DurationInput): (self: DurationInput) => Duration;
(self: DurationInput, minimum: DurationInput, maximum: DurationInput): Duration;
};

@@ -214,4 +217,4 @@ /**

export declare const times: {
(times: number): (self: Duration) => Duration;
(self: Duration, times: number): Duration;
(times: number): (self: DurationInput) => Duration;
(self: DurationInput, times: number): Duration;
};

@@ -223,4 +226,4 @@ /**

export declare const sum: {
(that: Duration): (self: Duration) => Duration;
(self: Duration, that: Duration): Duration;
(that: DurationInput): (self: DurationInput) => Duration;
(self: DurationInput, that: DurationInput): Duration;
};

@@ -232,4 +235,4 @@ /**

export declare const lessThan: {
(that: Duration): (self: Duration) => boolean;
(self: Duration, that: Duration): boolean;
(that: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, that: DurationInput): boolean;
};

@@ -241,4 +244,4 @@ /**

export declare const lessThanOrEqualTo: {
(self: Duration, that: Duration): boolean;
(that: Duration): (self: Duration) => boolean;
(that: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, that: DurationInput): boolean;
};

@@ -250,4 +253,4 @@ /**

export declare const greaterThan: {
(that: Duration): (self: Duration) => boolean;
(self: Duration, that: Duration): boolean;
(that: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, that: DurationInput): boolean;
};

@@ -259,4 +262,4 @@ /**

export declare const greaterThanOrEqualTo: {
(self: Duration, that: Duration): boolean;
(that: Duration): (self: Duration) => boolean;
(that: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, that: DurationInput): boolean;
};

@@ -268,6 +271,6 @@ /**

export declare const equals: {
(that: Duration): (self: Duration) => boolean;
(self: Duration, that: Duration): boolean;
(that: DurationInput): (self: DurationInput) => boolean;
(self: DurationInput, that: DurationInput): boolean;
};
export {};
//# sourceMappingURL=Duration.d.ts.map

@@ -207,9 +207,10 @@ "use strict";

const toMillis = self => {
switch (self.value._tag) {
const _self = decode(self);
switch (_self.value._tag) {
case "Infinity":
return Infinity;
case "Nanos":
return Number(self.value.nanos) / 1000000;
return Number(_self.value.nanos) / 1000000;
case "Millis":
return self.value.millis;
return _self.value.millis;
}

@@ -227,9 +228,10 @@ };

const toNanos = self => {
switch (self.value._tag) {
const _self = decode(self);
switch (_self.value._tag) {
case "Infinity":
return Option.none();
case "Nanos":
return Option.some(self.value.nanos);
return Option.some(_self.value.nanos);
case "Millis":
return Option.some(BigInt(Math.round(self.value.millis * 1000000)));
return Option.some(BigInt(Math.round(_self.value.millis * 1000000)));
}

@@ -247,9 +249,10 @@ };

const unsafeToNanos = self => {
switch (self.value._tag) {
const _self = decode(self);
switch (_self.value._tag) {
case "Infinity":
throw new Error("Cannot convert infinite duration to nanos");
case "Nanos":
return self.value.nanos;
return _self.value.nanos;
case "Millis":
return BigInt(Math.round(self.value.millis * 1000000));
return BigInt(Math.round(_self.value.millis * 1000000));
}

@@ -263,9 +266,10 @@ };

const toHrTime = self => {
switch (self.value._tag) {
const _self = decode(self);
switch (_self.value._tag) {
case "Infinity":
return [Infinity, 0];
case "Nanos":
return [Number(self.value.nanos / bigint1e9), Number(self.value.nanos % bigint1e9)];
return [Number(_self.value.nanos / bigint1e9), Number(_self.value.nanos % bigint1e9)];
case "Millis":
return [Math.floor(self.value.millis / 1000), Math.round(self.value.millis % 1000 * 1000000)];
return [Math.floor(_self.value.millis / 1000), Math.round(_self.value.millis % 1000 * 1000000)];
}

@@ -278,13 +282,11 @@ };

exports.toHrTime = toHrTime;
const match = /*#__PURE__*/(0, _Function.dual)(2, (self, {
onMillis,
onNanos
}) => {
switch (self.value._tag) {
const match = /*#__PURE__*/(0, _Function.dual)(2, (self, options) => {
const _self = decode(self);
switch (_self.value._tag) {
case "Nanos":
return onNanos(self.value.nanos);
return options.onNanos(_self.value.nanos);
case "Infinity":
return onMillis(Infinity);
return options.onMillis(Infinity);
case "Millis":
return onMillis(self.value.millis);
return options.onMillis(_self.value.millis);
}

@@ -297,14 +299,13 @@ });

exports.match = match;
const matchWith = /*#__PURE__*/(0, _Function.dual)(3, (self, that, {
onMillis,
onNanos
}) => {
if (self.value._tag === "Infinity" || that.value._tag === "Infinity") {
return onMillis(toMillis(self), toMillis(that));
} else if (self.value._tag === "Nanos" || that.value._tag === "Nanos") {
const selfNanos = self.value._tag === "Nanos" ? self.value.nanos : BigInt(Math.round(self.value.millis * 1000000));
const thatNanos = that.value._tag === "Nanos" ? that.value.nanos : BigInt(Math.round(that.value.millis * 1000000));
return onNanos(selfNanos, thatNanos);
const matchWith = /*#__PURE__*/(0, _Function.dual)(3, (self, that, options) => {
const _self = decode(self);
const _that = decode(that);
if (_self.value._tag === "Infinity" || _that.value._tag === "Infinity") {
return options.onMillis(toMillis(_self), toMillis(_that));
} else if (_self.value._tag === "Nanos" || _that.value._tag === "Nanos") {
const selfNanos = _self.value._tag === "Nanos" ? _self.value.nanos : BigInt(Math.round(_self.value.millis * 1000000));
const thatNanos = _that.value._tag === "Nanos" ? _that.value.nanos : BigInt(Math.round(_that.value.millis * 1000000));
return options.onNanos(selfNanos, thatNanos);
}
return onMillis(self.value.millis, that.value.millis);
return options.onMillis(_self.value.millis, _that.value.millis);
});

@@ -327,3 +328,3 @@ /**

exports.Order = Order;
const between = /*#__PURE__*/order.between(Order);
const between = /*#__PURE__*/order.between( /*#__PURE__*/order.mapInput(Order, decode));
/**

@@ -338,19 +339,22 @@ * @category instances

});
/**
* @since 1.0.0
*/
exports.Equivalence = Equivalence;
const min = /*#__PURE__*/order.min(Order);
const _min = /*#__PURE__*/order.min(Order);
/**
* @since 1.0.0
*/
const min = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => _min(decode(self), decode(that)));
exports.min = min;
const max = /*#__PURE__*/order.max(Order);
const _max = /*#__PURE__*/order.max(Order);
/**
* @since 1.0.0
*/
const max = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => _max(decode(self), decode(that)));
exports.max = max;
const clamp = /*#__PURE__*/order.clamp(Order);
const _clamp = /*#__PURE__*/order.clamp(Order);
/**
* @since 1.0.0
*/
const clamp = /*#__PURE__*/(0, _Function.dual)(3, (self, minimum, maximum) => _clamp(decode(self), decode(minimum), decode(maximum)));
/**
* @since 1.0.0
* @category math

@@ -413,4 +417,4 @@ */

exports.greaterThanOrEqualTo = greaterThanOrEqualTo;
const equals = /*#__PURE__*/(0, _Function.dual)(2, Equivalence);
const equals = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => Equivalence(decode(self), decode(that)));
exports.equals = equals;
//# sourceMappingURL=Duration.js.map
{
"name": "@effect/data",
"version": "0.15.0",
"version": "0.15.1",
"license": "MIT",

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

@@ -237,10 +237,11 @@ /**

*/
export const toMillis = (self: Duration): number => {
switch (self.value._tag) {
export const toMillis = (self: DurationInput): number => {
const _self = decode(self)
switch (_self.value._tag) {
case "Infinity":
return Infinity
case "Nanos":
return Number(self.value.nanos) / 1_000_000
return Number(_self.value.nanos) / 1_000_000
case "Millis":
return self.value.millis
return _self.value.millis
}

@@ -257,10 +258,11 @@ }

*/
export const toNanos = (self: Duration): Option.Option<bigint> => {
switch (self.value._tag) {
export const toNanos = (self: DurationInput): Option.Option<bigint> => {
const _self = decode(self)
switch (_self.value._tag) {
case "Infinity":
return Option.none()
case "Nanos":
return Option.some(self.value.nanos)
return Option.some(_self.value.nanos)
case "Millis":
return Option.some(BigInt(Math.round(self.value.millis * 1_000_000)))
return Option.some(BigInt(Math.round(_self.value.millis * 1_000_000)))
}

@@ -277,10 +279,11 @@ }

*/
export const unsafeToNanos = (self: Duration): bigint => {
switch (self.value._tag) {
export const unsafeToNanos = (self: DurationInput): bigint => {
const _self = decode(self)
switch (_self.value._tag) {
case "Infinity":
throw new Error("Cannot convert infinite duration to nanos")
case "Nanos":
return self.value.nanos
return _self.value.nanos
case "Millis":
return BigInt(Math.round(self.value.millis * 1_000_000))
return BigInt(Math.round(_self.value.millis * 1_000_000))
}

@@ -293,4 +296,5 @@ }

*/
export const toHrTime = (self: Duration): readonly [seconds: number, nanos: number] => {
switch (self.value._tag) {
export const toHrTime = (self: DurationInput): readonly [seconds: number, nanos: number] => {
const _self = decode(self)
switch (_self.value._tag) {
case "Infinity":

@@ -300,9 +304,9 @@ return [Infinity, 0]

return [
Number(self.value.nanos / bigint1e9),
Number(self.value.nanos % bigint1e9)
Number(_self.value.nanos / bigint1e9),
Number(_self.value.nanos % bigint1e9)
]
case "Millis":
return [
Math.floor(self.value.millis / 1000),
Math.round((self.value.millis % 1000) * 1_000_000)
Math.floor(_self.value.millis / 1000),
Math.round((_self.value.millis % 1000) * 1_000_000)
]

@@ -318,31 +322,20 @@ }

<A, B>(
options: {
readonly onMillis: (millis: number) => A
readonly onNanos: (nanos: bigint) => B
}
): (self: Duration) => A | B
options: { readonly onMillis: (millis: number) => A; readonly onNanos: (nanos: bigint) => B }
): (self: DurationInput) => A | B
<A, B>(
self: Duration,
options: {
readonly onMillis: (millis: number) => A
readonly onNanos: (nanos: bigint) => B
}
self: DurationInput,
options: { readonly onMillis: (millis: number) => A; readonly onNanos: (nanos: bigint) => B }
): A | B
} = dual<
<A, B>(options: {
readonly onMillis: (millis: number) => A
readonly onNanos: (nanos: bigint) => B
}) => (self: Duration) => A | B,
<A, B>(self: Duration, options: {
readonly onMillis: (millis: number) => A
readonly onNanos: (nanos: bigint) => B
}) => A | B
>(2, (self, { onMillis, onNanos }) => {
switch (self.value._tag) {
} = dual(2, <A, B>(
self: DurationInput,
options: { readonly onMillis: (millis: number) => A; readonly onNanos: (nanos: bigint) => B }
): A | B => {
const _self = decode(self)
switch (_self.value._tag) {
case "Nanos":
return onNanos(self.value.nanos)
return options.onNanos(_self.value.nanos)
case "Infinity":
return onMillis(Infinity)
return options.onMillis(Infinity)
case "Millis":
return onMillis(self.value.millis)
return options.onMillis(_self.value.millis)
}

@@ -355,5 +348,5 @@ })

*/
export const matchWith = dual<
export const matchWith: {
<A, B>(
that: Duration,
that: DurationInput,
options: {

@@ -363,6 +356,6 @@ readonly onMillis: (self: number, that: number) => A

}
) => (self: Duration) => A | B,
): (self: DurationInput) => A | B
<A, B>(
self: Duration,
that: Duration,
self: DurationInput,
that: DurationInput,
options: {

@@ -372,26 +365,31 @@ readonly onMillis: (self: number, that: number) => A

}
) => A | B
>(3, (
self,
that,
{ onMillis, onNanos }
) => {
if (self.value._tag === "Infinity" || that.value._tag === "Infinity") {
return onMillis(
toMillis(self),
toMillis(that)
): A | B
} = dual(3, <A, B>(
self: DurationInput,
that: DurationInput,
options: {
readonly onMillis: (self: number, that: number) => A
readonly onNanos: (self: bigint, that: bigint) => B
}
): A | B => {
const _self = decode(self)
const _that = decode(that)
if (_self.value._tag === "Infinity" || _that.value._tag === "Infinity") {
return options.onMillis(
toMillis(_self),
toMillis(_that)
)
} else if (self.value._tag === "Nanos" || that.value._tag === "Nanos") {
const selfNanos = self.value._tag === "Nanos" ?
self.value.nanos :
BigInt(Math.round(self.value.millis * 1_000_000))
const thatNanos = that.value._tag === "Nanos" ?
that.value.nanos :
BigInt(Math.round(that.value.millis * 1_000_000))
return onNanos(selfNanos, thatNanos)
} else if (_self.value._tag === "Nanos" || _that.value._tag === "Nanos") {
const selfNanos = _self.value._tag === "Nanos" ?
_self.value.nanos :
BigInt(Math.round(_self.value.millis * 1_000_000))
const thatNanos = _that.value._tag === "Nanos" ?
_that.value.nanos :
BigInt(Math.round(_that.value.millis * 1_000_000))
return options.onNanos(selfNanos, thatNanos)
}
return onMillis(
self.value.millis,
that.value.millis
return options.onMillis(
_self.value.millis,
_that.value.millis
)

@@ -418,5 +416,5 @@ })

export const between: {
(minimum: Duration, maximum: Duration): (self: Duration) => boolean
(self: Duration, minimum: Duration, maximum: Duration): boolean
} = order.between(Order)
(minimum: DurationInput, maximum: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, minimum: DurationInput, maximum: DurationInput): boolean
} = order.between(order.mapInput(Order, decode))

@@ -433,2 +431,4 @@ /**

const _min = order.min(Order)
/**

@@ -438,6 +438,8 @@ * @since 1.0.0

export const min: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
} = order.min(Order)
(that: DurationInput): (self: DurationInput) => Duration
(self: DurationInput, that: DurationInput): Duration
} = dual(2, (self: DurationInput, that: DurationInput): Duration => _min(decode(self), decode(that)))
const _max = order.max(Order)
/**

@@ -447,6 +449,8 @@ * @since 1.0.0

export const max: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
} = order.max(Order)
(that: DurationInput): (self: DurationInput) => Duration
(self: DurationInput, that: DurationInput): Duration
} = dual(2, (self: DurationInput, that: DurationInput): Duration => _max(decode(self), decode(that)))
const _clamp = order.clamp(Order)
/**

@@ -456,5 +460,9 @@ * @since 1.0.0

export const clamp: {
(minimum: Duration, maximum: Duration): (self: Duration) => Duration
(self: Duration, minimum: Duration, maximum: Duration): Duration
} = order.clamp(Order)
(minimum: DurationInput, maximum: DurationInput): (self: DurationInput) => Duration
(self: DurationInput, minimum: DurationInput, maximum: DurationInput): Duration
} = dual(
3,
(self: DurationInput, minimum: DurationInput, maximum: DurationInput): Duration =>
_clamp(decode(self), decode(minimum), decode(maximum))
)

@@ -466,10 +474,7 @@ /**

export const times: {
(times: number): (self: Duration) => Duration
(self: Duration, times: number): Duration
} = dual<
(times: number) => (self: Duration) => Duration,
(self: Duration, times: number) => Duration
>(
(times: number): (self: DurationInput) => Duration
(self: DurationInput, times: number): Duration
} = dual(
2,
(self, times) =>
(self: DurationInput, times: number): Duration =>
match(self, {

@@ -486,10 +491,7 @@ onMillis: (millis) => new DurationImpl(millis * times),

export const sum: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
} = dual<
(that: Duration) => (self: Duration) => Duration,
(self: Duration, that: Duration) => Duration
>(
(that: DurationInput): (self: DurationInput) => Duration
(self: DurationInput, that: DurationInput): Duration
} = dual(
2,
(self, that) =>
(self: DurationInput, that: DurationInput): Duration =>
matchWith(self, that, {

@@ -506,10 +508,7 @@ onMillis: (self, that) => new DurationImpl(self + that),

export const lessThan: {
(that: Duration): (self: Duration) => boolean
(self: Duration, that: Duration): boolean
} = dual<
(that: Duration) => (self: Duration) => boolean,
(self: Duration, that: Duration) => boolean
>(
(that: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, that: DurationInput): boolean
} = dual(
2,
(self, that) =>
(self: DurationInput, that: DurationInput): boolean =>
matchWith(self, that, {

@@ -526,10 +525,7 @@ onMillis: (self, that) => self < that,

export const lessThanOrEqualTo: {
(self: Duration, that: Duration): boolean
(that: Duration): (self: Duration) => boolean
} = dual<
(that: Duration) => (self: Duration) => boolean,
(self: Duration, that: Duration) => boolean
>(
(that: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, that: DurationInput): boolean
} = dual(
2,
(self, that) =>
(self: DurationInput, that: DurationInput): boolean =>
matchWith(self, that, {

@@ -546,10 +542,7 @@ onMillis: (self, that) => self <= that,

export const greaterThan: {
(that: Duration): (self: Duration) => boolean
(self: Duration, that: Duration): boolean
} = dual<
(that: Duration) => (self: Duration) => boolean,
(self: Duration, that: Duration) => boolean
>(
(that: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, that: DurationInput): boolean
} = dual(
2,
(self, that) =>
(self: DurationInput, that: DurationInput): boolean =>
matchWith(self, that, {

@@ -566,10 +559,7 @@ onMillis: (self, that) => self > that,

export const greaterThanOrEqualTo: {
(self: Duration, that: Duration): boolean
(that: Duration): (self: Duration) => boolean
} = dual<
(that: Duration) => (self: Duration) => boolean,
(self: Duration, that: Duration) => boolean
>(
(that: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, that: DurationInput): boolean
} = dual(
2,
(self, that) =>
(self: DurationInput, that: DurationInput): boolean =>
matchWith(self, that, {

@@ -586,7 +576,4 @@ onMillis: (self, that) => self >= that,

export const equals: {
(that: Duration): (self: Duration) => boolean
(self: Duration, that: Duration): boolean
} = dual<
(that: Duration) => (self: Duration) => boolean,
(self: Duration, that: Duration) => boolean
>(2, Equivalence)
(that: DurationInput): (self: DurationInput) => boolean
(self: DurationInput, that: DurationInput): boolean
} = dual(2, (self: DurationInput, that: DurationInput): boolean => Equivalence(decode(self), decode(that)))

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