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.2.0 to 0.3.0

Global.d.ts

40

Chunk.js

@@ -272,20 +272,24 @@ "use strict";

/** @internal */
const copyToArray = (self, array, n) => {
switch (self.backing._tag) {
case "IArray":
{
copy(self.backing.array, 0, array, n, self.length);
break;
}
case "IConcat":
{
copyToArray(self.left, array, n);
copyToArray(self.right, array, n + self.left.length);
break;
}
case "ISingleton":
{
array[n] = self.backing.a;
break;
}
const copyToArray = (self, array, initial) => {
const toProcess = [[self, initial]];
while (toProcess.length > 0) {
const [chunk, n] = toProcess.pop();
switch (chunk.backing._tag) {
case "IArray":
{
copy(chunk.backing.array, 0, array, n, chunk.length);
break;
}
case "IConcat":
{
toProcess.push([chunk.right, n + chunk.left.length]);
toProcess.push([chunk.left, n]);
break;
}
case "ISingleton":
{
array[n] = chunk.backing.a;
break;
}
}
}

@@ -292,0 +296,0 @@ };

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

*/
export interface Tag<Service> extends Equal {
export interface Tag<Service> {
readonly _id: TagTypeId;
readonly _S: (_: Service) => Service;
readonly key: unknown;
}

@@ -48,4 +47,4 @@ /**

*
* assert.strictEqual(Context.Tag().key === Context.Tag().key, false)
* assert.strictEqual(Context.Tag("PORT").key === Context.Tag("PORT").key, true)
* assert.strictEqual(Context.Tag() === Context.Tag(), false)
* assert.strictEqual(Context.Tag("PORT") === Context.Tag("PORT"), true)
*

@@ -284,3 +283,3 @@ * @since 1.0.0

*
* const Services = pipe(someContext, Context.prune(Port))
* const Services = pipe(someContext, Context.pick(Port))
*

@@ -293,3 +292,3 @@ * assert.deepStrictEqual(Context.getOption(Services, Port), O.some({ PORT: 8080 }))

*/
export declare const prune: <Services, S extends Array<Tags<Services>>>(...tags: S) => (self: Context<Services>) => Context<{
export declare const pick: <Services, S extends Array<Tags<Services>>>(...tags: S) => (self: Context<Services>) => Context<{
[k in keyof S]: Tag.Service<S[k]>;

@@ -296,0 +295,0 @@ }[number]>;

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

});
exports.unsafeGet = exports.prune = exports.merge = exports.make = exports.isTag = exports.isContext = exports.getOption = exports.get = exports.empty = exports.add = exports.Tag = void 0;
exports.unsafeGet = exports.pick = exports.merge = exports.make = exports.isTag = exports.isContext = exports.getOption = exports.get = exports.empty = exports.add = exports.Tag = void 0;
var C = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/internal/Context"));

@@ -26,4 +26,4 @@ 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); }

*
* assert.strictEqual(Context.Tag().key === Context.Tag().key, false)
* assert.strictEqual(Context.Tag("PORT").key === Context.Tag("PORT").key, true)
* assert.strictEqual(Context.Tag() === Context.Tag(), false)
* assert.strictEqual(Context.Tag("PORT") === Context.Tag("PORT"), true)
*

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

*
* const Services = pipe(someContext, Context.prune(Port))
* const Services = pipe(someContext, Context.pick(Port))
*

@@ -248,4 +248,4 @@ * assert.deepStrictEqual(Context.getOption(Services, Port), O.some({ PORT: 8080 }))

exports.merge = merge;
const prune = C.prune;
exports.prune = prune;
const pick = C.pick;
exports.pick = pick;
//# sourceMappingURL=Context.js.map

@@ -0,1 +1,6 @@

import type * as bounded from "@effect/data/typeclass/Bounded";
import type * as equivalence from "@effect/data/typeclass/Equivalence";
import * as monoid from "@effect/data/typeclass/Monoid";
import * as order from "@effect/data/typeclass/Order";
import * as semigroup from "@effect/data/typeclass/Semigroup";
declare const TypeId: unique symbol;

@@ -61,5 +66,54 @@ /**

/**
* @category instances
* @since 1.0.0
* @category mutations
*/
export declare const Order: order.Order<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const Bounded: bounded.Bounded<Duration>;
/**
* Checks if a `Duration` is between a `minimum` and `maximum` value.
*
* @category predicates
* @since 1.0.0
*/
export declare const between: {
(minimum: Duration, maximum: Duration): (self: Duration) => boolean;
(self: Duration, minimum: Duration, maximum: Duration): boolean;
};
/**
* @category instances
* @since 1.0.0
*/
export declare const Equivalence: equivalence.Equivalence<Duration>;
/**
* @category utils
* @since 1.0.0
*/
export declare const min: {
(that: Duration): (self: Duration) => Duration;
(self: Duration, that: Duration): Duration;
};
/**
* @category utils
* @since 1.0.0
*/
export declare const max: {
(that: Duration): (self: Duration) => Duration;
(self: Duration, that: Duration): Duration;
};
/**
* @category utils
* @since 1.0.0
*/
export declare const clamp: {
(minimum: Duration, maximum: Duration): (self: Duration) => Duration;
(self: Duration, minimum: Duration, maximum: Duration): Duration;
};
/**
* @since 1.0.0
* @category math
*/
export declare const times: {

@@ -71,5 +125,5 @@ (times: number): (self: Duration) => Duration;

* @since 1.0.0
* @category mutations
* @category math
*/
export declare const add: {
export declare const sum: {
(that: Duration): (self: Duration) => Duration;

@@ -79,5 +133,40 @@ (self: Duration, that: Duration): Duration;

/**
* @category instances
* @since 1.0.0
* @category mutations
*/
export declare const SemigroupSum: semigroup.Semigroup<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const MonoidSum: monoid.Monoid<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const SemigroupMax: semigroup.Semigroup<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const MonoidMax: monoid.Monoid<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const SemigroupMin: semigroup.Semigroup<Duration>;
/**
* @category instances
* @since 1.0.0
*/
export declare const MonoidMin: monoid.Monoid<Duration>;
/**
* @category math
* @since 1.0.15
*/
export declare const sumAll: (collection: Iterable<Duration>) => Duration;
/**
* @since 1.0.0
* @category math
*/
export declare const subtract: {

@@ -89,3 +178,3 @@ (that: Duration): (self: Duration) => Duration;

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -98,3 +187,3 @@ export declare const lessThan: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -107,3 +196,3 @@ export declare const lessThanOrEqualTo: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -116,3 +205,3 @@ export declare const greaterThan: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -125,3 +214,3 @@ export declare const greaterThanOrEqualTo: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -128,0 +217,0 @@ export declare const equals: {

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

});
exports.zero = exports.weeks = exports.times = exports.subtract = exports.seconds = exports.minutes = exports.millis = exports.lessThanOrEqualTo = exports.lessThan = exports.isDuration = exports.infinity = exports.hours = exports.greaterThanOrEqualTo = exports.greaterThan = exports.equals = exports.days = exports.add = void 0;
exports.zero = exports.weeks = exports.times = exports.sumAll = exports.sum = exports.subtract = exports.seconds = exports.minutes = exports.min = exports.millis = exports.max = exports.lessThanOrEqualTo = exports.lessThan = exports.isDuration = exports.infinity = exports.hours = exports.greaterThanOrEqualTo = exports.greaterThan = exports.equals = exports.days = exports.clamp = exports.between = exports.SemigroupSum = exports.SemigroupMin = exports.SemigroupMax = exports.Order = exports.MonoidSum = exports.MonoidMin = exports.MonoidMax = exports.Equivalence = exports.Bounded = void 0;
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var Dual = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Function"));
var Hash = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Hash"));
var monoid = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Monoid"));
var order = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Order"));
var semigroup = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Semigroup"));
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); }

@@ -85,22 +88,114 @@ 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; }

/**
* @category instances
* @since 1.0.0
* @category mutations
*/
exports.weeks = weeks;
const Order = {
compare: (self, that) => self.millis < that.millis ? -1 : self.millis > that.millis ? 1 : 0
};
/**
* @category instances
* @since 1.0.0
*/
exports.Order = Order;
const Bounded = {
compare: Order.compare,
maxBound: infinity,
minBound: zero
};
/**
* Checks if a `Duration` is between a `minimum` and `maximum` value.
*
* @category predicates
* @since 1.0.0
*/
exports.Bounded = Bounded;
const between = /*#__PURE__*/order.between(Order);
/**
* @category instances
* @since 1.0.0
*/
exports.between = between;
const Equivalence = (self, that) => self.millis === that.millis;
/**
* @category utils
* @since 1.0.0
*/
exports.Equivalence = Equivalence;
const min = /*#__PURE__*/order.min(Order);
/**
* @category utils
* @since 1.0.0
*/
exports.min = min;
const max = /*#__PURE__*/order.max(Order);
/**
* @category utils
* @since 1.0.0
*/
exports.max = max;
const clamp = /*#__PURE__*/order.clamp(Order);
/**
* @since 1.0.0
* @category math
*/
exports.clamp = clamp;
const times = /*#__PURE__*/Dual.dual(2, (self, times) => new DurationImpl(self.millis * times));
/**
* @since 1.0.0
* @category mutations
* @category math
*/
exports.times = times;
const add = /*#__PURE__*/Dual.dual(2, (self, that) => new DurationImpl(self.millis + that.millis));
const sum = /*#__PURE__*/Dual.dual(2, (self, that) => new DurationImpl(self.millis + that.millis));
/**
* @category instances
* @since 1.0.0
* @category mutations
*/
exports.add = add;
exports.sum = sum;
const SemigroupSum = /*#__PURE__*/semigroup.make(sum);
/**
* @category instances
* @since 1.0.0
*/
exports.SemigroupSum = SemigroupSum;
const MonoidSum = /*#__PURE__*/monoid.fromSemigroup(SemigroupSum, zero);
/**
* @category instances
* @since 1.0.0
*/
exports.MonoidSum = MonoidSum;
const SemigroupMax = /*#__PURE__*/semigroup.make(max);
/**
* @category instances
* @since 1.0.0
*/
exports.SemigroupMax = SemigroupMax;
const MonoidMax = /*#__PURE__*/monoid.fromSemigroup(SemigroupMax, zero);
/**
* @category instances
* @since 1.0.0
*/
exports.MonoidMax = MonoidMax;
const SemigroupMin = /*#__PURE__*/semigroup.make(min);
/**
* @category instances
* @since 1.0.0
*/
exports.SemigroupMin = SemigroupMin;
const MonoidMin = /*#__PURE__*/monoid.fromSemigroup(SemigroupMin, infinity);
/**
* @category math
* @since 1.0.15
*/
exports.MonoidMin = MonoidMin;
const sumAll = MonoidSum.combineAll;
/**
* @since 1.0.0
* @category math
*/
exports.sumAll = sumAll;
const subtract = /*#__PURE__*/Dual.dual(2, (self, that) => new DurationImpl(self.millis - that.millis));
/**
* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -111,3 +206,3 @@ exports.subtract = subtract;

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -118,3 +213,3 @@ exports.lessThan = lessThan;

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -125,3 +220,3 @@ exports.lessThanOrEqualTo = lessThanOrEqualTo;

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -132,3 +227,3 @@ exports.greaterThan = greaterThan;

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -135,0 +230,0 @@ exports.greaterThanOrEqualTo = greaterThanOrEqualTo;

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

exports.zipWith = 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.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.bind = exports.bimap = exports.asUnit = exports.as = exports.appendElement = exports.ap = exports.andThenDiscard = exports.andThenBind = exports.andThen = 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;
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var _Function = /*#__PURE__*/require("@effect/data/Function");

@@ -13,3 +14,2 @@ var Gen = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Gen"));

var N = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Number"));
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var applicative = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Applicative"));

@@ -16,0 +16,0 @@ var bicovariant = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Bicovariant"));

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

});
exports.unsafeGet = exports.prune = exports.merge = exports.make = exports.isTag = exports.isContext = exports.getOption = exports.get = exports.empty = exports.add = exports.TagTypeId = exports.TagImpl = exports.ContextTypeId = exports.ContextImpl = void 0;
exports.unsafeGet = exports.pick = exports.merge = exports.make = exports.isTag = exports.isContext = exports.getOption = exports.get = exports.empty = exports.add = exports.TagTypeId = exports.TagImpl = exports.ContextTypeId = exports.ContextImpl = void 0;
var Equal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Equal"));
var Dual = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Function"));
var G = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Global"));
var Hash = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Hash"));

@@ -19,13 +20,9 @@ var option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));

class TagImpl {
constructor(key) {
constructor(id) {
this._id = TagTypeId;
this._S = _ => _;
this.key = key ?? Symbol();
if (typeof id !== "undefined") {
return G.value(id, () => this);
}
}
[Hash.symbol]() {
return Hash.hash(this.key);
}
[Equal.symbol](that) {
return isTag(that) && this.key === that.key;
}
}

@@ -71,3 +68,3 @@ /** @internal */

exports.empty = empty;
const make = (tag, service) => new ContextImpl(new Map([[tag.key, service]]));
const make = (tag, service) => new ContextImpl(new Map([[tag, service]]));
/** @internal */

@@ -77,3 +74,3 @@ exports.make = make;

const map = new Map(self.unsafeMap);
map.set(tag.key, service);
map.set(tag, service);
return new ContextImpl(map);

@@ -84,6 +81,6 @@ });

const get = /*#__PURE__*/Dual.dual(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
throw new Error("Service not found");
}
return self.unsafeMap.get(tag.key);
return self.unsafeMap.get(tag);
});

@@ -93,6 +90,6 @@ /** @internal */

const unsafeGet = /*#__PURE__*/Dual.dual(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
throw new Error("Service not found");
}
return self.unsafeMap.get(tag.key);
return self.unsafeMap.get(tag);
});

@@ -102,6 +99,6 @@ /** @internal */

const getOption = /*#__PURE__*/Dual.dual(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
return option.none();
}
return option.some(self.unsafeMap.get(tag.key));
return option.some(self.unsafeMap.get(tag));
});

@@ -119,4 +116,4 @@ /** @internal */

exports.merge = merge;
const prune = (...tags) => self => {
const tagSet = new Set(tags.map(t => t.key));
const pick = (...tags) => self => {
const tagSet = new Set(tags);
const newEnv = new Map();

@@ -130,3 +127,3 @@ for (const [tag, s] of self.unsafeMap.entries()) {

};
exports.prune = prune;
exports.pick = pick;
//# sourceMappingURL=Context.js.map

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

class AddService {
constructor(key, service) {
this.key = key;
constructor(tag, service) {
this.tag = tag;
this.service = service;

@@ -69,3 +69,3 @@ this._tag = "AddService";

[Equal.symbol](that) {
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.key, that.key) && Equal.equals(this.service, that.service);
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.tag, that.tag) && Equal.equals(this.service, that.service);
}

@@ -76,4 +76,4 @@ }

class RemoveService {
constructor(key) {
this.key = key;
constructor(tag) {
this.tag = tag;
this._tag = "RemoveService";

@@ -88,3 +88,3 @@ this._id = ContextPatchTypeId;

[Equal.symbol](that) {
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.key, that.key);
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.tag, that.tag);
}

@@ -95,4 +95,4 @@ }

class UpdateService {
constructor(key, update) {
this.key = key;
constructor(tag, update) {
this.tag = tag;
this.update = update;

@@ -108,3 +108,3 @@ this._tag = "UpdateService";

[Equal.symbol](that) {
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.key, that.key) && Equal.equals(this.update, that.update);
return typeof that === "object" && that !== null && "_id" in that && that["_id"] === this._id && "_tag" in that && that["_tag"] === this._id && Equal.equals(this.tag, that.tag) && Equal.equals(this.update, that.update);
}

@@ -157,3 +157,3 @@ }

{
updatedContext.set(head.key, head.service);
updatedContext.set(head.tag, head.service);
patches = tail;

@@ -169,3 +169,3 @@ break;

{
updatedContext.delete(head.key);
updatedContext.delete(head.tag);
patches = tail;

@@ -176,3 +176,3 @@ break;

{
updatedContext.set(head.key, head.update(updatedContext.get(head.key)));
updatedContext.set(head.tag, head.update(updatedContext.get(head.tag)));
wasServiceUpdated = true;

@@ -179,0 +179,0 @@ patches = tail;

@@ -691,2 +691,11 @@ /**

*
* @example
* import * as O from "@effect/data/Option"
*
* const getInteger = (n: number) => Number.isInteger(n) ? O.some(n) : O.none()
*
* assert.deepStrictEqual(O.tap(O.none(), getInteger), O.none())
* assert.deepStrictEqual(O.tap(O.some(1), getInteger), O.some(1))
* assert.deepStrictEqual(O.tap(O.some(1.14), getInteger), O.none())
*
* @category transforming

@@ -693,0 +702,0 @@ * @since 1.0.0

@@ -713,2 +713,11 @@ "use strict";

*
* @example
* import * as O from "@effect/data/Option"
*
* const getInteger = (n: number) => Number.isInteger(n) ? O.some(n) : O.none()
*
* assert.deepStrictEqual(O.tap(O.none(), getInteger), O.none())
* assert.deepStrictEqual(O.tap(O.some(1), getInteger), O.some(1))
* assert.deepStrictEqual(O.tap(O.some(1.14), getInteger), O.none())
*
* @category transforming

@@ -715,0 +724,0 @@ * @since 1.0.0

{
"name": "@effect/data",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",

@@ -9,3 +9,2 @@ "repository": {

},
"main": "./index.js",
"publishConfig": {

@@ -16,12 +15,2 @@ "access": "public"

"exports": {
".": {
"import": {
"types": "./index.d.ts",
"default": "./mjs/index.mjs"
},
"require": {
"types": "./index.d.ts",
"default": "./index.js"
}
},
"./*": {

@@ -28,0 +17,0 @@ "import": {

@@ -516,5 +516,65 @@ import type { TypeLambda } from "@effect/data/HKT";

/**
* @category combinators
* @since 1.0.0
*/
export declare const xor: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>;
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>;
};
/**
* @category combinators
* @since 1.0.0
*/
export declare const eqv: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>;
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>;
};
/**
* @category combinators
* @since 1.0.0
*/
export declare const implies: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>;
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>;
};
/**
* @category combinators
* @since 1.0.0
*/
export declare const nor: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>;
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>;
};
/**
* @category combinators
* @since 1.0.0
*/
export declare const nand: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>;
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>;
};
/**
* @category instances
* @since 1.0.0
*/
export declare const getSemigroupEqv: <A>() => semigroup.Semigroup<Predicate<A>>;
/**
* @category instances
* @since 1.0.0
*/
export declare const getMonoidEqv: <A>() => monoid.Monoid<Predicate<A>>;
/**
* @category instances
* @since 1.0.0
*/
export declare const getSemigroupXor: <A>() => semigroup.Semigroup<Predicate<A>>;
/**
* @category instances
* @since 1.0.0
*/
export declare const getMonoidXor: <A>() => monoid.Monoid<Predicate<A>>;
/**
* @category instances
* @since 1.0.0
*/
export declare const getSemigroupSome: <A>() => semigroup.Semigroup<Predicate<A>>;

@@ -521,0 +581,0 @@ /**

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

});
exports.tupled = exports.tuple = exports.struct = exports.some = exports.or = exports.not = exports.isUnknown = exports.isUndefined = exports.isSymbol = exports.isString = exports.isRecord = exports.isReadonlyRecord = exports.isObject = exports.isNumber = exports.isNullable = exports.isNull = exports.isNotUndefined = exports.isNotNullable = exports.isNotNull = exports.isNever = exports.isFunction = exports.isError = exports.isDate = exports.isBoolean = exports.isBigint = exports.getSemigroupSome = exports.getSemigroupEvery = exports.getMonoidSome = exports.getMonoidEvery = exports.every = exports.contramap = exports.compose = exports.bindTo = exports.appendElement = exports.andThenBind = exports.and = exports.SemiProduct = exports.Product = exports.Invariant = exports.Do = exports.Contravariant = void 0;
exports.xor = exports.tupled = exports.tuple = exports.struct = exports.some = exports.or = exports.not = exports.nor = exports.nand = exports.isUnknown = exports.isUndefined = exports.isSymbol = exports.isString = exports.isRecord = exports.isReadonlyRecord = exports.isObject = exports.isNumber = exports.isNullable = exports.isNull = exports.isNotUndefined = exports.isNotNullable = exports.isNotNull = exports.isNever = exports.isFunction = exports.isError = exports.isDate = exports.isBoolean = exports.isBigint = exports.implies = exports.getSemigroupXor = exports.getSemigroupSome = exports.getSemigroupEvery = exports.getSemigroupEqv = exports.getMonoidXor = exports.getMonoidSome = exports.getMonoidEvery = exports.getMonoidEqv = exports.every = exports.eqv = exports.contramap = exports.compose = exports.bindTo = exports.appendElement = exports.andThenBind = exports.and = exports.SemiProduct = exports.Product = exports.Invariant = exports.Do = exports.Contravariant = void 0;
var _Function = /*#__PURE__*/require("@effect/data/Function");

@@ -553,6 +553,60 @@ var readonlyArray = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/internal/ReadonlyArray"));

/**
* @category combinators
* @since 1.0.0
*/
exports.and = and;
const xor = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => a => self(a) !== that(a));
/**
* @category combinators
* @since 1.0.0
*/
exports.xor = xor;
const eqv = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => a => self(a) === that(a));
/**
* @category combinators
* @since 1.0.0
*/
exports.eqv = eqv;
const implies = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => a => self(a) ? that(a) : true);
/**
* @category combinators
* @since 1.0.0
*/
exports.implies = implies;
const nor = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => a => !(self(a) || that(a)));
/**
* @category combinators
* @since 1.0.0
*/
exports.nor = nor;
const nand = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => a => !(self(a) && that(a)));
/**
* @category instances
* @since 1.0.0
*/
exports.and = and;
exports.nand = nand;
const getSemigroupEqv = () => semigroup.make(eqv);
/**
* @category instances
* @since 1.0.0
*/
exports.getSemigroupEqv = getSemigroupEqv;
const getMonoidEqv = () => monoid.fromSemigroup(getSemigroupEqv(), _Function.constTrue);
/**
* @category instances
* @since 1.0.0
*/
exports.getMonoidEqv = getMonoidEqv;
const getSemigroupXor = () => semigroup.make(xor);
/**
* @category instances
* @since 1.0.0
*/
exports.getSemigroupXor = getSemigroupXor;
const getMonoidXor = () => monoid.fromSemigroup(getSemigroupXor(), _Function.constFalse);
/**
* @category instances
* @since 1.0.0
*/
exports.getMonoidXor = getMonoidXor;
const getSemigroupSome = () => semigroup.make(or, (self, collection) => a => {

@@ -559,0 +613,0 @@ if (self(a)) {

@@ -103,5 +103,20 @@ /**

/**
* Takes a record and returns an array of tuples containing its keys and values.
*
* @param self - The record to transform.
*
* @example
* import { fromRecord } from "@effect/data/ReadonlyArray"
*
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(fromRecord(x), [["a", 1], ["b", 2], ["c", 3]])
*
* @category conversions
* @since 1.0.0
*/
export declare const fromRecord: <K extends string, A>(self: Readonly<Record<K, A>>) => Array<[K, A]>;
/**
* @category conversions
* @since 1.0.0
*/
export declare const fromOption: <A>(self: Option<A>) => Array<A>;

@@ -580,3 +595,6 @@ /**

*/
export declare const sort: <B>(O: order.Order<B>) => <A extends B>(self: Iterable<A>) => A[];
export declare const sort: {
<B>(O: Order<B>): <A extends B>(self: Iterable<A>) => Array<A>;
<A extends B, B>(self: Iterable<A>, O: Order<B>): Array<A>;
};
/**

@@ -588,3 +606,6 @@ * Sort the elements of a `NonEmptyReadonlyArray` in increasing order, creating a new `NonEmptyArray`.

*/
export declare const sortNonEmpty: <B>(O: order.Order<B>) => <A extends B>(self: readonly [A, ...A[]]) => [A, ...A[]];
export declare const sortNonEmpty: {
<B>(O: Order<B>): <A extends B>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A>;
<A extends B, B>(self: NonEmptyReadonlyArray<A>, O: Order<B>): NonEmptyArray<A>;
};
/**

@@ -735,3 +756,6 @@ * Sort the elements of an `Iterable` in increasing order, where elements are compared

*/
export declare const uniq: <A>(isEquivalent: (self: A, that: A) => boolean) => (self: Iterable<A>) => A[];
export declare const uniq: {
<A>(isEquivalent: (self: A, that: A) => boolean): (self: Iterable<A>) => Array<A>;
<A>(self: Iterable<A>, isEquivalent: (self: A, that: A) => boolean): Array<A>;
};
/**

@@ -742,3 +766,6 @@ * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element.

*/
export declare const uniqNonEmpty: <A>(isEquivalent: (self: A, that: A) => boolean) => (self: readonly [A, ...A[]]) => [A, ...A[]];
export declare const uniqNonEmpty: {
<A>(isEquivalent: (self: A, that: A) => boolean): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A>;
<A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<A>;
};
/**

@@ -828,3 +855,6 @@ * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input

*/
export declare const group: <A>(isEquivalent: (self: A, that: A) => boolean) => (self: readonly [A, ...A[]]) => [[A, ...A[]], ...[A, ...A[]][]];
export declare const group: {
<A>(isEquivalent: (self: A, that: A) => boolean): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<NonEmptyArray<A>>;
<A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<NonEmptyArray<A>>;
};
/**

@@ -1292,7 +1322,13 @@ * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning

*/
export declare const min: <A>(O: order.Order<A>) => (self: readonly [A, ...A[]]) => A;
export declare const min: {
<A>(O: Order<A>): (self: NonEmptyReadonlyArray<A>) => A;
<A>(self: NonEmptyReadonlyArray<A>, O: Order<A>): A;
};
/**
* @since 1.0.0
*/
export declare const max: <A>(O: order.Order<A>) => (self: readonly [A, ...A[]]) => A;
export declare const max: {
<A>(O: Order<A>): (self: NonEmptyReadonlyArray<A>) => A;
<A>(self: NonEmptyReadonlyArray<A>, O: Order<A>): A;
};
/**

@@ -1299,0 +1335,0 @@ * @category constructors

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

exports.every = every;
exports.min = exports.max = exports.matchRight = exports.matchLeft = exports.match = exports.mapNonEmpty = exports.map = exports.makeBy = exports.make = exports.liftPredicate = exports.liftOption = exports.liftNullable = exports.liftMonoid = exports.liftEither = exports.lift2 = exports.let = exports.length = exports.lefts = exports.lastNonEmpty = exports.last = exports.join = exports.isNonEmptyReadonlyArray = exports.isNonEmptyArray = exports.isEmptyReadonlyArray = exports.isEmptyArray = exports.intersperseNonEmpty = exports.intersperse = exports.intersection = exports.intercalateNonEmpty = exports.intercalate = exports.insertAt = exports.initNonEmpty = exports.init = exports.headNonEmpty = exports.head = exports.groupBy = exports.group = exports.getUnionSemigroup = exports.getUnionMonoid = exports.getSemigroup = exports.getOrder = exports.getMonoid = exports.getIntersectionSemigroup = exports.get = exports.fromOption = exports.fromNullable = exports.fromIterable = exports.fromEither = exports.flattenNonEmpty = exports.flatten = exports.flatMapNullable = exports.flatMapNonEmpty = exports.flatMap = exports.flap = exports.findLastIndex = exports.findLast = exports.findFirstIndex = exports.findFirst = exports.filterMap = exports.filter = exports.extend = void 0;
exports.zipWith = exports.zipNonEmptyWith = exports.zipNonEmpty = exports.zip = exports.unzipNonEmpty = exports.unzip = exports.unsafeGet = exports.unprepend = exports.uniqNonEmpty = exports.uniq = exports.unionNonEmpty = exports.union = exports.unfold = exports.unappend = exports.tupled = exports.traverseTap = exports.traversePartitionMap = exports.traversePartition = exports.traverseNonEmpty = exports.traverseFilterMap = exports.traverseFilter = exports.traverse = exports.takeWhile = exports.takeRight = exports.take = exports.tailNonEmpty = exports.tail = exports.splitNonEmptyAt = exports.splitAt = exports.span = exports.sortNonEmpty = exports.sortByNonEmpty = exports.sortBy = exports.sort = exports.some = exports.setNonEmptyLast = exports.setNonEmptyHead = exports.sequenceNonEmpty = exports.sequence = exports.separate = exports.scanRight = exports.scan = exports.rotateNonEmpty = exports.rotate = exports.rights = exports.reverseNonEmpty = exports.reverse = exports.replicate = exports.replaceOption = exports.replace = exports.remove = exports.reduceRight = exports.reduceKind = exports.reduce = exports.range = exports.prependAllNonEmpty = exports.prependAll = exports.prepend = exports.partitionMap = exports.partition = exports.of = exports.modifyOption = exports.modifyNonEmptyLast = exports.modifyNonEmptyHead = exports.modify = void 0;
exports.max = exports.matchRight = exports.matchLeft = exports.match = exports.mapNonEmpty = exports.map = exports.makeBy = exports.make = exports.liftPredicate = exports.liftOption = exports.liftNullable = exports.liftMonoid = exports.liftEither = exports.lift2 = exports.let = exports.length = exports.lefts = exports.lastNonEmpty = exports.last = exports.join = exports.isNonEmptyReadonlyArray = exports.isNonEmptyArray = exports.isEmptyReadonlyArray = exports.isEmptyArray = exports.intersperseNonEmpty = exports.intersperse = exports.intersection = exports.intercalateNonEmpty = exports.intercalate = exports.insertAt = exports.initNonEmpty = exports.init = exports.headNonEmpty = exports.head = exports.groupBy = exports.group = exports.getUnionSemigroup = exports.getUnionMonoid = exports.getSemigroup = exports.getOrder = exports.getMonoid = exports.getIntersectionSemigroup = exports.get = exports.fromRecord = exports.fromOption = exports.fromNullable = exports.fromIterable = exports.fromEither = exports.flattenNonEmpty = exports.flatten = exports.flatMapNullable = exports.flatMapNonEmpty = exports.flatMap = exports.flap = exports.findLastIndex = exports.findLast = exports.findFirstIndex = exports.findFirst = exports.filterMap = exports.filter = exports.extend = void 0;
exports.zipWith = exports.zipNonEmptyWith = exports.zipNonEmpty = exports.zip = exports.unzipNonEmpty = exports.unzip = exports.unsafeGet = exports.unprepend = exports.uniqNonEmpty = exports.uniq = exports.unionNonEmpty = exports.union = exports.unfold = exports.unappend = exports.tupled = exports.traverseTap = exports.traversePartitionMap = exports.traversePartition = exports.traverseNonEmpty = exports.traverseFilterMap = exports.traverseFilter = exports.traverse = exports.takeWhile = exports.takeRight = exports.take = exports.tailNonEmpty = exports.tail = exports.splitNonEmptyAt = exports.splitAt = exports.span = exports.sortNonEmpty = exports.sortByNonEmpty = exports.sortBy = exports.sort = exports.some = exports.setNonEmptyLast = exports.setNonEmptyHead = exports.sequenceNonEmpty = exports.sequence = exports.separate = exports.scanRight = exports.scan = exports.rotateNonEmpty = exports.rotate = exports.rights = exports.reverseNonEmpty = exports.reverse = exports.replicate = exports.replaceOption = exports.replace = exports.remove = exports.reduceRight = exports.reduceKind = exports.reduce = exports.range = exports.prependAllNonEmpty = exports.prependAll = exports.prepend = exports.partitionMap = exports.partition = exports.of = exports.modifyOption = exports.modifyNonEmptyLast = exports.modifyNonEmptyHead = exports.modify = exports.min = void 0;
var E = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Either"));

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

var O = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));
var RR = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/ReadonlyRecord"));
var string = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/String"));

@@ -103,2 +104,12 @@ var applicative = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/typeclass/Applicative"));

/**
* Takes a record and returns an array of tuples containing its keys and values.
*
* @param self - The record to transform.
*
* @example
* import { fromRecord } from "@effect/data/ReadonlyArray"
*
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(fromRecord(x), [["a", 1], ["b", 2], ["c", 3]])
*
* @category conversions

@@ -108,2 +119,8 @@ * @since 1.0.0

exports.fromIterable = fromIterable;
const fromRecord = RR.toEntries;
/**
* @category conversions
* @since 1.0.0
*/
exports.fromRecord = fromRecord;
const fromOption = O.toArray;

@@ -651,7 +668,7 @@ /**

exports.lefts = lefts;
const sort = O => self => {
const sort = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => {
const out = Array.from(self);
out.sort(O.compare);
return out;
};
});
/**

@@ -664,3 +681,3 @@ * Sort the elements of a `NonEmptyReadonlyArray` in increasing order, creating a new `NonEmptyArray`.

exports.sort = sort;
const sortNonEmpty = O => self => sort(O)(self);
const sortNonEmpty = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => sort(O)(self));
/**

@@ -850,6 +867,6 @@ * Sort the elements of an `Iterable` in increasing order, where elements are compared

exports.contains = contains;
const uniq = isEquivalent => self => {
const uniq = /*#__PURE__*/(0, _Function.dual)(2, (self, isEquivalent) => {
const input = fromIterable(self);
return isNonEmptyReadonlyArray(input) ? uniqNonEmpty(isEquivalent)(input) : [];
};
});
/**

@@ -861,3 +878,3 @@ * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element.

exports.uniq = uniq;
const uniqNonEmpty = isEquivalent => self => {
const uniqNonEmpty = /*#__PURE__*/(0, _Function.dual)(2, (self, isEquivalent) => {
const out = [headNonEmpty(self)];

@@ -871,3 +888,3 @@ const rest = tailNonEmpty(self);

return out;
};
});
/**

@@ -966,3 +983,3 @@ * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for "chopping" up the input

exports.chunksOfNonEmpty = chunksOfNonEmpty;
const group = isEquivalent => self => chopNonEmpty(self, as => {
const group = /*#__PURE__*/(0, _Function.dual)(2, (self, isEquivalent) => chopNonEmpty(self, as => {
const h = headNonEmpty(as);

@@ -980,3 +997,3 @@ const out = [h];

return [out, as.slice(i)];
});
}));
/**

@@ -1550,6 +1567,6 @@ * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning

exports.extend = extend;
const min = O => {
const min = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => {
const S = semigroup.min(O);
return self => self.reduce(S.combine);
};
return self.reduce(S.combine);
});
/**

@@ -1559,6 +1576,6 @@ * @since 1.0.0

exports.min = min;
const max = O => {
const max = /*#__PURE__*/(0, _Function.dual)(2, (self, O) => {
const S = semigroup.max(O);
return self => self.reduce(S.combine);
};
return self.reduce(S.combine);
});
/**

@@ -1565,0 +1582,0 @@ * @category constructors

@@ -37,2 +37,32 @@ /**

/**
* Determine if a `Record` is empty.
*
* @param self - `Record` to test for emptiness.
*
* @example
* import { isEmptyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyRecord({}), true);
* assert.deepStrictEqual(isEmptyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
export declare const isEmptyRecord: <A>(self: Record<string, A>) => self is Record<string, never>;
/**
* Determine if a `ReadonlyRecord` is empty.
*
* @param self - `ReadonlyRecord` to test for emptiness.
*
* @example
* import { isEmptyReadonlyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyReadonlyRecord({}), true);
* assert.deepStrictEqual(isEmptyReadonlyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
export declare const isEmptyReadonlyRecord: <A>(self: ReadonlyRecord<A>) => self is ReadonlyRecord<never>;
/**
* Takes an iterable and a projection function and returns a record.

@@ -54,3 +84,3 @@ * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.

*
* @category constructors
* @category conversions
* @since 1.0.0

@@ -63,16 +93,20 @@ */

/**
* Determine if a `ReadonlyRecord` is empty.
* Builds a record from an iterable of key-value pairs.
*
* @param self - `ReadonlyRecord` to test for emptiness.
* If there are conflicting keys when using `fromEntries`, the last occurrence of the key/value pair will overwrite the
* previous ones. So the resulting record will only have the value of the last occurrence of each key.
*
* @param self - The iterable of key-value pairs.
*
* @example
* import { isEmpty } from "@effect/data/ReadonlyRecord"
* import { fromEntries } from '@effect/data/ReadonlyRecord'
*
* assert.deepStrictEqual(isEmpty({}), true);
* assert.deepStrictEqual(isEmpty({ a: 3 }), false);
* const input: Array<[string, number]> = [["a", 1], ["b", 2]]
*
* @category guards
* assert.deepStrictEqual(fromEntries(input), { a: 1, b: 2 })
*
* @category conversions
* @since 1.0.0
*/
export declare const isEmpty: <A>(self: ReadonlyRecord<A>) => self is Record<string, never>;
export declare const fromEntries: <A>(self: Iterable<[string, A]>) => Record<string, A>;
/**

@@ -85,3 +119,3 @@ * Transforms the values of a `ReadonlyRecord` into an `Array` with a custom mapping function.

* @example
* import { collect } from '@effect/data/ReadonlyRecord'
* import { collect } from "@effect/data/ReadonlyRecord"
*

@@ -95,15 +129,15 @@ * const x = { a: 1, b: 2, c: 3 }

export declare const collect: {
<A, B>(f: (key: string, a: A) => B): (self: ReadonlyRecord<A>) => Array<B>;
<A, B>(self: ReadonlyRecord<A>, f: (key: string, a: A) => B): Array<B>;
<K extends string, A, B>(f: (key: K, a: A) => B): (self: Readonly<Record<K, A>>) => Array<B>;
<K extends string, A, B>(self: Readonly<Record<K, A>>, f: (key: string, a: A) => B): Array<B>;
};
/**
* Converts a `ReadonlyRecord` to an `Array` of key-value pairs.
* Takes a record and returns an array of tuples containing its keys and values.
*
* @param self - A `ReadonlyRecord` to convert to an `Array`.
* @param self - The record to transform.
*
* @example
* import { toArray } from '@effect/data/ReadonlyRecord'
* import { toEntries } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2]])
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toEntries(x), [["a", 1], ["b", 2], ["c", 3]])
*

@@ -113,4 +147,21 @@ * @category conversions

*/
export declare const toArray: <A>(self: ReadonlyRecord<A>) => Array<[string, A]>;
export declare const toEntries: <K extends string, A>(self: Readonly<Record<K, A>>) => Array<[K, A]>;
/**
* Takes a record and returns an array of tuples containing its keys and values.
*
* Alias of {@link toEntries}.
*
* @param self - The record to transform.
*
* @example
* import { toArray } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2], ["c", 3]])
*
* @category conversions
* @since 1.0.0
*/
export declare const toArray: <K extends string, A>(self: Readonly<Record<K, A>>) => Array<[K, A]>;
/**
* Returns the number of key/value pairs in a `ReadonlyRecord`.

@@ -117,0 +168,0 @@ *

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

});
exports.tupled = exports.traverseTap = exports.traversePartitionMap = exports.traversePartition = exports.traverseFilterMap = exports.traverseFilter = exports.traverse = exports.toArray = exports.size = exports.sequence = exports.separate = exports.replaceOption = exports.remove = exports.pop = exports.partitionMap = exports.partition = exports.modifyOption = exports.map = exports.isEmpty = exports.has = exports.get = exports.fromIterable = exports.flap = exports.filterMap = exports.filter = exports.empty = exports.compact = exports.collect = exports.as = exports.TraversableFilterable = exports.Traversable = exports.Invariant = exports.Filterable = exports.Covariant = void 0;
exports.tupled = exports.traverseTap = exports.traversePartitionMap = exports.traversePartition = exports.traverseFilterMap = exports.traverseFilter = exports.traverse = exports.toEntries = exports.toArray = exports.size = exports.sequence = exports.separate = exports.replaceOption = exports.remove = exports.pop = exports.partitionMap = exports.partition = exports.modifyOption = exports.map = exports.isEmptyRecord = exports.isEmptyReadonlyRecord = exports.has = exports.get = exports.fromIterable = exports.fromEntries = exports.flap = exports.filterMap = exports.filter = exports.empty = exports.compact = exports.collect = exports.as = exports.TraversableFilterable = exports.Traversable = exports.Invariant = exports.Filterable = exports.Covariant = void 0;
var E = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Either"));

@@ -33,3 +33,48 @@ var _Function = /*#__PURE__*/require("@effect/data/Function");

const empty = () => ({});
// -------------------------------------------------------------------------------------
// guards
// -------------------------------------------------------------------------------------
/**
* Determine if a `Record` is empty.
*
* @param self - `Record` to test for emptiness.
*
* @example
* import { isEmptyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyRecord({}), true);
* assert.deepStrictEqual(isEmptyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
exports.empty = empty;
const isEmptyRecord = self => {
for (const k in self) {
if (has(self, k)) {
return false;
}
}
return true;
};
/**
* Determine if a `ReadonlyRecord` is empty.
*
* @param self - `ReadonlyRecord` to test for emptiness.
*
* @example
* import { isEmptyReadonlyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyReadonlyRecord({}), true);
* assert.deepStrictEqual(isEmptyReadonlyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
exports.isEmptyRecord = isEmptyRecord;
const isEmptyReadonlyRecord = isEmptyRecord;
// -------------------------------------------------------------------------------------
// conversions
// -------------------------------------------------------------------------------------
/**
* Takes an iterable and a projection function and returns a record.

@@ -51,6 +96,6 @@ * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.

*
* @category constructors
* @category conversions
* @since 1.0.0
*/
exports.empty = empty;
exports.isEmptyReadonlyRecord = isEmptyReadonlyRecord;
const fromIterable = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {

@@ -64,31 +109,22 @@ const out = {};

});
// -------------------------------------------------------------------------------------
// guards
// -------------------------------------------------------------------------------------
/**
* Determine if a `ReadonlyRecord` is empty.
* Builds a record from an iterable of key-value pairs.
*
* @param self - `ReadonlyRecord` to test for emptiness.
* If there are conflicting keys when using `fromEntries`, the last occurrence of the key/value pair will overwrite the
* previous ones. So the resulting record will only have the value of the last occurrence of each key.
*
* @param self - The iterable of key-value pairs.
*
* @example
* import { isEmpty } from "@effect/data/ReadonlyRecord"
* import { fromEntries } from '@effect/data/ReadonlyRecord'
*
* assert.deepStrictEqual(isEmpty({}), true);
* assert.deepStrictEqual(isEmpty({ a: 3 }), false);
* const input: Array<[string, number]> = [["a", 1], ["b", 2]]
*
* @category guards
* assert.deepStrictEqual(fromEntries(input), { a: 1, b: 2 })
*
* @category conversions
* @since 1.0.0
*/
exports.fromIterable = fromIterable;
const isEmpty = self => {
for (const k in self) {
if (has(self, k)) {
return false;
}
}
return true;
};
// -------------------------------------------------------------------------------------
// conversions
// -------------------------------------------------------------------------------------
const fromEntries = /*#__PURE__*/fromIterable(_Function.identity);
/**

@@ -101,3 +137,3 @@ * Transforms the values of a `ReadonlyRecord` into an `Array` with a custom mapping function.

* @example
* import { collect } from '@effect/data/ReadonlyRecord'
* import { collect } from "@effect/data/ReadonlyRecord"
*

@@ -110,3 +146,3 @@ * const x = { a: 1, b: 2, c: 3 }

*/
exports.isEmpty = isEmpty;
exports.fromEntries = fromEntries;
const collect = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {

@@ -120,11 +156,11 @@ const out = [];

/**
* Converts a `ReadonlyRecord` to an `Array` of key-value pairs.
* Takes a record and returns an array of tuples containing its keys and values.
*
* @param self - A `ReadonlyRecord` to convert to an `Array`.
* @param self - The record to transform.
*
* @example
* import { toArray } from '@effect/data/ReadonlyRecord'
* import { toEntries } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2]])
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toEntries(x), [["a", 1], ["b", 2], ["c", 3]])
*

@@ -135,3 +171,21 @@ * @category conversions

exports.collect = collect;
const toArray = /*#__PURE__*/collect((key, a) => [key, a]);
const toEntries = /*#__PURE__*/collect((key, value) => [key, value]);
/**
* Takes a record and returns an array of tuples containing its keys and values.
*
* Alias of {@link toEntries}.
*
* @param self - The record to transform.
*
* @example
* import { toArray } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2], ["c", 3]])
*
* @category conversions
* @since 1.0.0
*/
exports.toEntries = toEntries;
const toArray = toEntries;
// -------------------------------------------------------------------------------------

@@ -138,0 +192,0 @@ // utils

@@ -384,17 +384,23 @@ /**

/** @internal */
const copyToArray = <A>(self: Chunk<A>, array: Array<any>, n: number) => {
switch (self.backing._tag) {
case "IArray": {
copy(self.backing.array, 0, array, n, self.length)
break
const copyToArray = <A>(self: Chunk<A>, array: Array<any>, initial: number): void => {
const toProcess: Array<[Chunk<any>, number]> = [[self, initial]]
while (toProcess.length > 0) {
const [chunk, n] = toProcess.pop()!
switch (chunk.backing._tag) {
case "IArray": {
copy(chunk.backing.array, 0, array, n, chunk.length)
break
}
case "IConcat": {
toProcess.push([chunk.right, n + chunk.left.length])
toProcess.push([chunk.left, n])
break
}
case "ISingleton": {
array[n] = chunk.backing.a
break
}
}
case "IConcat": {
copyToArray(self.left, array, n)
copyToArray(self.right, array, n + self.left.length)
break
}
case "ISingleton": {
array[n] = self.backing.a
break
}
}

@@ -401,0 +407,0 @@ }

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

*/
export interface Tag<Service> extends Equal {
export interface Tag<Service> {
readonly _id: TagTypeId
readonly _S: (_: Service) => Service
readonly key: unknown
}

@@ -54,4 +53,4 @@

*
* assert.strictEqual(Context.Tag().key === Context.Tag().key, false)
* assert.strictEqual(Context.Tag("PORT").key === Context.Tag("PORT").key, true)
* assert.strictEqual(Context.Tag() === Context.Tag(), false)
* assert.strictEqual(Context.Tag("PORT") === Context.Tag("PORT"), true)
*

@@ -85,3 +84,3 @@ * @since 1.0.0

/** @internal */
readonly unsafeMap: Map<unknown, unknown>
readonly unsafeMap: Map<Tag<any>, any>
}

@@ -317,3 +316,3 @@

*
* const Services = pipe(someContext, Context.prune(Port))
* const Services = pipe(someContext, Context.pick(Port))
*

@@ -326,4 +325,4 @@ * assert.deepStrictEqual(Context.getOption(Services, Port), O.some({ PORT: 8080 }))

*/
export const prune: <Services, S extends Array<Tags<Services>>>(
export const pick: <Services, S extends Array<Tags<Services>>>(
...tags: S
) => (self: Context<Services>) => Context<{ [k in keyof S]: Tag.Service<S[k]> }[number]> = C.prune
) => (self: Context<Services>) => Context<{ [k in keyof S]: Tag.Service<S[k]> }[number]> = C.pick

@@ -7,2 +7,7 @@ /**

import * as Hash from "@effect/data/Hash"
import type * as bounded from "@effect/data/typeclass/Bounded"
import type * as equivalence from "@effect/data/typeclass/Equivalence"
import * as monoid from "@effect/data/typeclass/Monoid"
import * as order from "@effect/data/typeclass/Order"
import * as semigroup from "@effect/data/typeclass/Semigroup"

@@ -94,5 +99,67 @@ const TypeId: unique symbol = Symbol.for("@effect/data/Duration")

/**
* @category instances
* @since 1.0.0
* @category mutations
*/
export const Order: order.Order<Duration> = {
compare: (self, that) => (self.millis < that.millis ? -1 : self.millis > that.millis ? 1 : 0)
}
/**
* @category instances
* @since 1.0.0
*/
export const Bounded: bounded.Bounded<Duration> = {
compare: Order.compare,
maxBound: infinity,
minBound: zero
}
/**
* Checks if a `Duration` is between a `minimum` and `maximum` value.
*
* @category predicates
* @since 1.0.0
*/
export const between: {
(minimum: Duration, maximum: Duration): (self: Duration) => boolean
(self: Duration, minimum: Duration, maximum: Duration): boolean
} = order.between(Order)
/**
* @category instances
* @since 1.0.0
*/
export const Equivalence: equivalence.Equivalence<Duration> = (self, that) => self.millis === that.millis
/**
* @category utils
* @since 1.0.0
*/
export const min: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
} = order.min(Order)
/**
* @category utils
* @since 1.0.0
*/
export const max: {
(that: Duration): (self: Duration) => Duration
(self: Duration, that: Duration): Duration
} = order.max(Order)
/**
* @category utils
* @since 1.0.0
*/
export const clamp: {
(minimum: Duration, maximum: Duration): (self: Duration) => Duration
(self: Duration, minimum: Duration, maximum: Duration): Duration
} = order.clamp(Order)
/**
* @since 1.0.0
* @category math
*/
export const times: {

@@ -108,5 +175,5 @@ (times: number): (self: Duration) => Duration

* @since 1.0.0
* @category mutations
* @category math
*/
export const add: {
export const sum: {
(that: Duration): (self: Duration) => Duration

@@ -120,5 +187,47 @@ (self: Duration, that: Duration): Duration

/**
* @category instances
* @since 1.0.0
* @category mutations
*/
export const SemigroupSum: semigroup.Semigroup<Duration> = semigroup.make(sum)
/**
* @category instances
* @since 1.0.0
*/
export const MonoidSum: monoid.Monoid<Duration> = monoid.fromSemigroup(SemigroupSum, zero)
/**
* @category instances
* @since 1.0.0
*/
export const SemigroupMax: semigroup.Semigroup<Duration> = semigroup.make(max)
/**
* @category instances
* @since 1.0.0
*/
export const MonoidMax: monoid.Monoid<Duration> = monoid.fromSemigroup(SemigroupMax, zero)
/**
* @category instances
* @since 1.0.0
*/
export const SemigroupMin: semigroup.Semigroup<Duration> = semigroup.make(min)
/**
* @category instances
* @since 1.0.0
*/
export const MonoidMin: monoid.Monoid<Duration> = monoid.fromSemigroup(SemigroupMin, infinity)
/**
* @category math
* @since 1.0.15
*/
export const sumAll: (collection: Iterable<Duration>) => Duration = MonoidSum.combineAll
/**
* @since 1.0.0
* @category math
*/
export const subtract: {

@@ -134,3 +243,3 @@ (that: Duration): (self: Duration) => Duration

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -147,3 +256,3 @@ export const lessThan: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -160,3 +269,3 @@ export const lessThanOrEqualTo: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -173,3 +282,3 @@ export const greaterThan: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -186,3 +295,3 @@ export const greaterThanOrEqualTo: {

* @since 1.0.0
* @category comparisons
* @category predicates
*/

@@ -189,0 +298,0 @@ export const equals: {

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

import type * as Data from "@effect/data/Data"
import * as Equal from "@effect/data/Equal"
import type { LazyArg } from "@effect/data/Function"

@@ -14,3 +15,2 @@ import { constNull, constUndefined, dual, identity } from "@effect/data/Function"

import * as N from "@effect/data/Number"
import * as Equal from "@effect/data/Equal"
import type { Option } from "@effect/data/Option"

@@ -17,0 +17,0 @@ import type { Predicate, Refinement } from "@effect/data/Predicate"

import type * as C from "@effect/data/Context"
import * as Equal from "@effect/data/Equal"
import * as Dual from "@effect/data/Function"
import * as G from "@effect/data/Global"
import * as Hash from "@effect/data/Hash"

@@ -15,12 +16,7 @@ import type * as O from "@effect/data/Option"

readonly _S: (_: Service) => Service = (_) => _
readonly key: unknown
constructor(key?: unknown) {
this.key = key ?? Symbol()
constructor(id?: unknown) {
if (typeof id !== "undefined") {
return G.value(id, () => this)
}
}
[Hash.symbol]() {
return Hash.hash(this.key)
}
[Equal.symbol](that: unknown) {
return isTag(that) && this.key === that.key
}
}

@@ -54,3 +50,3 @@

constructor(readonly unsafeMap: Map<unknown, any>) {}
constructor(readonly unsafeMap: Map<C.Tag<unknown>, any>) {}
}

@@ -73,3 +69,3 @@

service: C.Tag.Service<T>
): C.Context<C.Tag.Service<T>> => new ContextImpl(new Map([[tag.key, service]]))
): C.Context<C.Tag.Service<T>> => new ContextImpl(new Map([[tag, service]]))

@@ -91,3 +87,3 @@ /** @internal */

const map = new Map(self.unsafeMap)
map.set(tag.key, service)
map.set(tag as C.Tag<unknown>, service)
return new ContextImpl(map)

@@ -108,6 +104,6 @@ })

>(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
throw new Error("Service not found")
}
return self.unsafeMap.get(tag.key)! as any
return self.unsafeMap.get(tag)! as any
})

@@ -120,6 +116,6 @@

>(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
throw new Error("Service not found")
}
return self.unsafeMap.get(tag.key)! as any
return self.unsafeMap.get(tag)! as any
})

@@ -132,6 +128,6 @@

>(2, (self, tag) => {
if (!self.unsafeMap.has(tag.key)) {
if (!self.unsafeMap.has(tag)) {
return option.none()
}
return option.some(self.unsafeMap.get(tag.key)! as any)
return option.some(self.unsafeMap.get(tag)! as any)
})

@@ -152,7 +148,7 @@

/** @internal */
export const prune = <Services, S extends Array<C.Tags<Services>>>(...tags: S) =>
export const pick = <Services, S extends Array<C.Tags<Services>>>(...tags: S) =>
(self: C.Context<Services>): C.Context<
{ [k in keyof S]: C.Tag.Service<S[k]> }[number]
> => {
const tagSet = new Set<unknown>(tags.map((t) => t.key))
const tagSet = new Set<unknown>(tags)
const newEnv = new Map()

@@ -159,0 +155,0 @@ for (const [tag, s] of self.unsafeMap.entries()) {

import * as Chunk from "@effect/data/Chunk"
import type { Context } from "@effect/data/Context"
import type { Context, Tag } from "@effect/data/Context"
import type * as CP from "@effect/data/Differ/ContextPatch"

@@ -64,3 +64,3 @@ import * as Equal from "@effect/data/Equal"

readonly _Output: (_: never) => Env | T = variance
constructor(readonly key: unknown, readonly service: T) {}
constructor(readonly tag: Tag<T>, readonly service: T) {}

@@ -74,3 +74,3 @@ [Hash.symbol]() {

"_tag" in that && that["_tag"] === this._id &&
Equal.equals(this.key, (that as this).key) &&
Equal.equals(this.tag, (that as this).tag) &&
Equal.equals(this.service, (that as this).service)

@@ -86,3 +86,3 @@ }

readonly _Output: (_: never) => Env = variance
constructor(readonly key: unknown) {}
constructor(readonly tag: Tag<T>) {}

@@ -96,3 +96,3 @@ [Hash.symbol]() {

"_tag" in that && that["_tag"] === this._id &&
Equal.equals(this.key, (that as this).key)
Equal.equals(this.tag, (that as this).tag)
}

@@ -108,3 +108,3 @@ }

constructor(
readonly key: unknown,
readonly tag: Tag<T>,
readonly update: (service: T) => T

@@ -121,3 +121,3 @@ ) {

"_tag" in that && that["_tag"] === this._id &&
Equal.equals(this.key, (that as this).key) &&
Equal.equals(this.tag, (that as this).tag) &&
Equal.equals(this.update, (that as this).update)

@@ -191,3 +191,3 @@ }

)
const updatedContext: Map<unknown, unknown> = new Map(context.unsafeMap)
const updatedContext: Map<Tag<any>, unknown> = new Map(context.unsafeMap)
while (Chunk.isNonEmpty(patches)) {

@@ -202,3 +202,3 @@ const head: Instruction = Chunk.headNonEmpty(patches) as Instruction

case "AddService": {
updatedContext.set(head.key, head.service)
updatedContext.set(head.tag, head.service)
patches = tail

@@ -212,3 +212,3 @@ break

case "RemoveService": {
updatedContext.delete(head.key)
updatedContext.delete(head.tag)
patches = tail

@@ -218,3 +218,3 @@ break

case "UpdateService": {
updatedContext.set(head.key, head.update(updatedContext.get(head.key)))
updatedContext.set(head.tag, head.update(updatedContext.get(head.tag)))
wasServiceUpdated = true

@@ -221,0 +221,0 @@ patches = tail

@@ -841,2 +841,11 @@ /**

*
* @example
* import * as O from "@effect/data/Option"
*
* const getInteger = (n: number) => Number.isInteger(n) ? O.some(n) : O.none()
*
* assert.deepStrictEqual(O.tap(O.none(), getInteger), O.none())
* assert.deepStrictEqual(O.tap(O.some(1), getInteger), O.some(1))
* assert.deepStrictEqual(O.tap(O.some(1.14), getInteger), O.none())
*
* @category transforming

@@ -843,0 +852,0 @@ * @since 1.0.0

@@ -616,5 +616,83 @@ /**

/**
* @category combinators
* @since 1.0.0
*/
export const xor: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(2, <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) !== that(a))
/**
* @category combinators
* @since 1.0.0
*/
export const eqv: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(2, <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) === that(a))
/**
* @category combinators
* @since 1.0.0
*/
export const implies: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(
2,
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) ? that(a) : true
)
/**
* @category combinators
* @since 1.0.0
*/
export const nor: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(
2,
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => !(self(a) || that(a))
)
/**
* @category combinators
* @since 1.0.0
*/
export const nand: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
} = dual(
2,
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => !(self(a) && that(a))
)
/**
* @category instances
* @since 1.0.0
*/
export const getSemigroupEqv = <A>(): Semigroup<Predicate<A>> => semigroup.make<Predicate<A>>(eqv)
/**
* @category instances
* @since 1.0.0
*/
export const getMonoidEqv = <A>(): monoid.Monoid<Predicate<A>> => monoid.fromSemigroup(getSemigroupEqv<A>(), constTrue)
/**
* @category instances
* @since 1.0.0
*/
export const getSemigroupXor = <A>(): Semigroup<Predicate<A>> => semigroup.make<Predicate<A>>(xor)
/**
* @category instances
* @since 1.0.0
*/
export const getMonoidXor = <A>(): monoid.Monoid<Predicate<A>> => monoid.fromSemigroup(getSemigroupXor<A>(), constFalse)
/**
* @category instances
* @since 1.0.0
*/
export const getSemigroupSome = <A>(): Semigroup<Predicate<A>> =>

@@ -621,0 +699,0 @@ semigroup.make<Predicate<A>>(

@@ -52,3 +52,50 @@ /**

// -------------------------------------------------------------------------------------
// guards
// -------------------------------------------------------------------------------------
/**
* Determine if a `Record` is empty.
*
* @param self - `Record` to test for emptiness.
*
* @example
* import { isEmptyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyRecord({}), true);
* assert.deepStrictEqual(isEmptyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
export const isEmptyRecord = <A>(self: Record<string, A>): self is Record<string, never> => {
for (const k in self) {
if (has(self, k)) {
return false
}
}
return true
}
/**
* Determine if a `ReadonlyRecord` is empty.
*
* @param self - `ReadonlyRecord` to test for emptiness.
*
* @example
* import { isEmptyReadonlyRecord } from "@effect/data/ReadonlyRecord"
*
* assert.deepStrictEqual(isEmptyReadonlyRecord({}), true);
* assert.deepStrictEqual(isEmptyReadonlyRecord({ a: 3 }), false);
*
* @category guards
* @since 1.0.0
*/
export const isEmptyReadonlyRecord: <A>(self: ReadonlyRecord<A>) => self is ReadonlyRecord<never> = isEmptyRecord
// -------------------------------------------------------------------------------------
// conversions
// -------------------------------------------------------------------------------------
/**
* Takes an iterable and a projection function and returns a record.

@@ -70,3 +117,3 @@ * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.

*
* @category constructors
* @category conversions
* @since 1.0.0

@@ -86,33 +133,22 @@ */

// -------------------------------------------------------------------------------------
// guards
// -------------------------------------------------------------------------------------
/**
* Determine if a `ReadonlyRecord` is empty.
* Builds a record from an iterable of key-value pairs.
*
* @param self - `ReadonlyRecord` to test for emptiness.
* If there are conflicting keys when using `fromEntries`, the last occurrence of the key/value pair will overwrite the
* previous ones. So the resulting record will only have the value of the last occurrence of each key.
*
* @param self - The iterable of key-value pairs.
*
* @example
* import { isEmpty } from "@effect/data/ReadonlyRecord"
* import { fromEntries } from '@effect/data/ReadonlyRecord'
*
* assert.deepStrictEqual(isEmpty({}), true);
* assert.deepStrictEqual(isEmpty({ a: 3 }), false);
* const input: Array<[string, number]> = [["a", 1], ["b", 2]]
*
* @category guards
* assert.deepStrictEqual(fromEntries(input), { a: 1, b: 2 })
*
* @category conversions
* @since 1.0.0
*/
export const isEmpty = <A>(self: ReadonlyRecord<A>): self is Record<string, never> => {
for (const k in self) {
if (has(self, k)) {
return false
}
}
return true
}
export const fromEntries: <A>(self: Iterable<[string, A]>) => Record<string, A> = fromIterable(identity)
// -------------------------------------------------------------------------------------
// conversions
// -------------------------------------------------------------------------------------
/**

@@ -125,3 +161,3 @@ * Transforms the values of a `ReadonlyRecord` into an `Array` with a custom mapping function.

* @example
* import { collect } from '@effect/data/ReadonlyRecord'
* import { collect } from "@effect/data/ReadonlyRecord"
*

@@ -135,4 +171,4 @@ * const x = { a: 1, b: 2, c: 3 }

export const collect: {
<A, B>(f: (key: string, a: A) => B): (self: ReadonlyRecord<A>) => Array<B>
<A, B>(self: ReadonlyRecord<A>, f: (key: string, a: A) => B): Array<B>
<K extends string, A, B>(f: (key: K, a: A) => B): (self: Readonly<Record<K, A>>) => Array<B>
<K extends string, A, B>(self: Readonly<Record<K, A>>, f: (key: string, a: A) => B): Array<B>
} = dual(

@@ -150,11 +186,11 @@ 2,

/**
* Converts a `ReadonlyRecord` to an `Array` of key-value pairs.
* Takes a record and returns an array of tuples containing its keys and values.
*
* @param self - A `ReadonlyRecord` to convert to an `Array`.
* @param self - The record to transform.
*
* @example
* import { toArray } from '@effect/data/ReadonlyRecord'
* import { toEntries } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2]])
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toEntries(x), [["a", 1], ["b", 2], ["c", 3]])
*

@@ -164,7 +200,25 @@ * @category conversions

*/
export const toArray: <A>(self: ReadonlyRecord<A>) => Array<[string, A]> = collect((
export const toEntries: <K extends string, A>(self: Readonly<Record<K, A>>) => Array<[K, A]> = collect((
key,
a
) => [key, a])
value
) => [key, value])
/**
* Takes a record and returns an array of tuples containing its keys and values.
*
* Alias of {@link toEntries}.
*
* @param self - The record to transform.
*
* @example
* import { toArray } from "@effect/data/ReadonlyRecord"
*
* const x = { a: 1, b: 2, c: 3 }
* assert.deepStrictEqual(toArray(x), [["a", 1], ["b", 2], ["c", 3]])
*
* @category conversions
* @since 1.0.0
*/
export const toArray: <K extends string, A>(self: Readonly<Record<K, A>>) => Array<[K, A]> = toEntries
// -------------------------------------------------------------------------------------

@@ -171,0 +225,0 @@ // utils

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

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 too big to display

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