Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fp-ts/optic

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fp-ts/optic - npm Package Compare versions

Comparing version 0.22.0 to 0.23.0

8

data/Either.d.ts

@@ -12,4 +12,4 @@ /**

export declare const right: {
<E, A>(): Prism<Either.Either<E, A>, A>;
<E, A, B>(): PolyPrism<Either.Either<E, A>, Either.Either<E, B>, A, B>;
<A, E>(): Prism<Either.Either<A, E>, A>;
<A, E, B>(): PolyPrism<Either.Either<A, E>, Either.Either<B, E>, A, B>;
};

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

export declare const left: {
<E, A>(): Prism<Either.Either<E, A>, E>;
<E, A, B>(): PolyPrism<Either.Either<E, A>, Either.Either<B, A>, E, B>;
<A, E>(): Prism<Either.Either<A, E>, E>;
<A, E, B>(): PolyPrism<Either.Either<A, E>, Either.Either<A, B>, E, B>;
};
//# sourceMappingURL=Either.d.ts.map

@@ -13,4 +13,4 @@ /**

export interface Optic<in GetWhole, in SetWholeBefore, in SetPiece, out GetError, out SetError, out GetPiece, out SetWholeAfter> {
readonly getOptic: (GetWhole: GetWhole) => Either.Either<readonly [GetError, SetWholeAfter], GetPiece>;
readonly setOptic: (SetPiece: SetPiece) => (SetWholeBefore: SetWholeBefore) => Either.Either<readonly [SetError, SetWholeAfter], SetWholeAfter>;
readonly getOptic: (GetWhole: GetWhole) => Either.Either<GetPiece, readonly [GetError, SetWholeAfter]>;
readonly setOptic: (SetPiece: SetPiece) => (SetWholeBefore: SetWholeBefore) => Either.Either<SetWholeAfter, readonly [SetError, SetWholeAfter]>;
/**

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

*/
key<S, A>(this: Optional<S, ReadonlyRecord.ReadonlyRecord<A>>, key: string): Optional<S, A>;
key<S, A>(this: Optional<S, ReadonlyRecord.ReadonlyRecord<string, A>>, key: string): Optional<S, A>;
}

@@ -152,3 +152,3 @@ /**

*/
export declare const polyPrism: <S, T, A, B>(polyDecode: (s: S) => Either.Either<readonly [Error, T], A>, encode: (b: B) => T) => PolyPrism<S, T, A, B>;
export declare const polyPrism: <S, T, A, B>(polyDecode: (s: S) => Either.Either<A, readonly [Error, T]>, encode: (b: B) => T) => PolyPrism<S, T, A, B>;
/**

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

*/
export declare const prism: <S, A>(decode: (s: S) => Either.Either<Error, A>, encode: (a: A) => S) => Prism<S, A>;
export declare const prism: <S, A>(decode: (s: S) => Either.Either<A, Error>, encode: (a: A) => S) => Prism<S, A>;
/**

@@ -183,3 +183,3 @@ * An optic that accesses the `Cons` case of a `ReadonlyArray`.

*/
export declare const polyReversedPrism: <S, T, A, B>(get: (s: S) => A, polyReplaceEither: (b: B) => (s: S) => Either.Either<readonly [Error, T], T>) => PolyReversedPrism<S, T, A, B>;
export declare const polyReversedPrism: <S, T, A, B>(get: (s: S) => A, polyReplaceEither: (b: B) => (s: S) => Either.Either<T, readonly [Error, T]>) => PolyReversedPrism<S, T, A, B>;
/**

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

*/
export declare const reversedPrism: <S, A>(get: (s: S) => A, replaceEither: (a: A) => Either.Either<Error, S>) => ReversedPrism<S, A>;
export declare const reversedPrism: <S, A>(get: (s: S) => A, replaceEither: (a: A) => Either.Either<S, Error>) => ReversedPrism<S, A>;
/**

@@ -214,3 +214,3 @@ * An optic that accesses the input case specified by a predicate.

*/
export declare const polyOptional: <S, T, A, B>(polyDecode: (s: S) => Either.Either<readonly [Error, T], A>, polyReplaceEither: (b: B) => (s: S) => Either.Either<readonly [Error, T], T>) => PolyOptional<S, T, A, B>;
export declare const polyOptional: <S, T, A, B>(polyDecode: (s: S) => Either.Either<A, readonly [Error, T]>, polyReplaceEither: (b: B) => (s: S) => Either.Either<T, readonly [Error, T]>) => PolyOptional<S, T, A, B>;
/**

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

*/
export declare const optional: <S, A>(decode: (s: S) => Either.Either<Error, A>, replaceEither: (a: A) => (s: S) => Either.Either<Error, S>) => Optional<S, A>;
export declare const optional: <S, A>(decode: (s: S) => Either.Either<A, Error>, replaceEither: (a: A) => (s: S) => Either.Either<S, Error>) => Optional<S, A>;
/**

@@ -278,3 +278,3 @@ * An optic that accesses all of the elements in a `ReadonlyArray`.

*/
export declare const polyTraversal: <S, T, A, B>(decode: (s: S) => Either.Either<readonly [Error, T], readonly A[]>, replace: (bs: readonly B[]) => (s: S) => Either.Either<readonly [Error, T], T>) => PolyTraversal<S, T, A, B>;
export declare const polyTraversal: <S, T, A, B>(decode: (s: S) => Either.Either<readonly A[], readonly [Error, T]>, replace: (bs: readonly B[]) => (s: S) => Either.Either<T, readonly [Error, T]>) => PolyTraversal<S, T, A, B>;
/**

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

*/
export declare const traversal: <S, A>(decode: (s: S) => Either.Either<Error, readonly A[]>, replace: (as: readonly A[]) => (s: S) => Either.Either<Error, S>) => Traversal<S, A>;
export declare const traversal: <S, A>(decode: (s: S) => Either.Either<readonly A[], Error>, replace: (as: readonly A[]) => (s: S) => Either.Either<S, Error>) => Traversal<S, A>;
/**

@@ -307,7 +307,7 @@ * @since 1.0.0

*/
export declare const getOrModify: <S, T, A, B>(optic: PolyOptional<S, T, A, B>) => (s: S) => Either.Either<T, A>;
export declare const getOrModify: <S, T, A, B>(optic: PolyOptional<S, T, A, B>) => (s: S) => Either.Either<A, T>;
/**
* @since 1.0.0
*/
export declare const decode: <S, T, A, B>(optic: PolyPrism<S, T, A, B>) => (GetWhole: S) => Either.Either<Error, A>;
export declare const decode: <S, T, A, B>(optic: PolyPrism<S, T, A, B>) => (GetWhole: S) => Either.Either<A, Error>;
/**

@@ -314,0 +314,0 @@ * @since 1.0.0

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

var ReadonlyRecord = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/ReadonlyRecord"));
var S = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Struct"));
var Struct = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Struct"));
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); }

@@ -20,3 +20,2 @@ 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; }

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

@@ -27,3 +26,3 @@ * Compose two optics when the piece of the whole returned by the get

*/
const prismComposition = that => self => new Builder("prism", getWhole => (0, _Function.pipe)(self.getOptic(getWhole), Either.flatMap(getPiece => (0, _Function.pipe)(that.getOptic(getPiece), orElse(([GetError1, SetPiece]) => (0, _Function.pipe)(self.setOptic(SetPiece)(getWhole), Either.match({
const prismComposition = that => self => new Builder("prism", getWhole => (0, _Function.pipe)(self.getOptic(getWhole), Either.flatMap(getPiece => (0, _Function.pipe)(that.getOptic(getPiece), Either.orElse(([GetError1, SetPiece]) => (0, _Function.pipe)(self.setOptic(SetPiece)(getWhole), Either.match({
onLeft: ([_, SetWholeAfter]) => Either.left([GetError1, SetWholeAfter]),

@@ -42,3 +41,3 @@ onRight: SetWholeAfter => Either.left([GetError1, SetWholeAfter])

*/
const lensComposition = that => self => new Builder("lens", s => (0, _Function.pipe)(self.getOptic(s), Either.flatMap(a => (0, _Function.pipe)(that.getOptic(a), orElse(([de, b]) => (0, _Function.pipe)(self.setOptic(b)(s), Either.match({
const lensComposition = that => self => new Builder("lens", s => (0, _Function.pipe)(self.getOptic(s), Either.flatMap(a => (0, _Function.pipe)(that.getOptic(a), Either.orElse(([de, b]) => (0, _Function.pipe)(self.setOptic(b)(s), Either.match({
onLeft: ([_ee, t]) => Either.left([de, t]),

@@ -64,10 +63,2 @@ onRight: t => Either.left([de, t])

});
const pick = (...keys) => lens(S.pick(...keys), a => s => ({
...s,
...a
}));
const omit = (...keys) => lens(S.omit(...keys), a => s => ({
...s,
...a
}));
const filter = (predicate, message) => prism(s => predicate(s) ? Either.right(s) : Either.left(new Error(message ?? "Expected a value satisfying the specified predicate")), _Function.identity);

@@ -91,6 +82,12 @@ const nonNullable = () => filter(s => s != null, "Expected a non nullable value");

pick(...keys) {
return this.compose(pick(...keys));
return this.compose(lens(Struct.pick(...keys), a => s => ({
...s,
...a
})));
}
omit(...keys) {
return this.compose(omit(...keys));
return this.compose(lens(Struct.omit(...keys), a => s => ({
...s,
...a
})));
}

@@ -97,0 +94,0 @@ filter(predicate, message) {

{
"name": "@fp-ts/optic",
"version": "0.22.0",
"version": "0.23.0",
"license": "MIT",

@@ -10,4 +10,4 @@ "repository": {

"peerDependencies": {
"@effect/typeclass": "^0.22.0",
"effect": "^2.0.0"
"@effect/typeclass": "^0.23.0",
"effect": "^2.4.0"
},

@@ -14,0 +14,0 @@ "main": "./index.js",

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