Socket
Socket
Sign inDemoInstall

monocle-ts

Package Overview
Dependencies
1
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

5

CHANGELOG.md

@@ -15,2 +15,7 @@ # Changelog

# 0.3.0
- **Breaking Change**
- upgrade to latest fp-ts (@gcanti)
# 0.2.0

@@ -17,0 +22,0 @@

41

lib/index.d.ts

@@ -1,2 +0,2 @@

import { HKT, HKTS } from 'fp-ts/lib/HKT';
import { HKT } from 'fp-ts/lib/HKT';
import { Monoid } from 'fp-ts/lib/Monoid';

@@ -33,6 +33,6 @@ import { Applicative } from 'fp-ts/lib/Applicative';

set: (a: A, s: S) => S;
static fromPath: typeof lensFromPath;
constructor(get: (s: S) => A, set: (a: A, s: S) => S);
/** generate a lens from a type and a prop */
static fromProp<T, P extends keyof T>(prop: P): Lens<T, T[P]>;
static fromPath: typeof lensFromPath;
modify(f: (a: A) => A, s: S): S;

@@ -43,4 +43,4 @@ /** compose a Lens with a Lens */

asOptional(): Optional<S, A>;
composePrism<B>(prism: Prism<A, B>): Optional<S, B>;
composeOptional<B>(optional: Optional<A, B>): Optional<S, B>;
composePrism<B>(ab: Prism<A, B>): Optional<S, B>;
composeOptional<B>(ab: Optional<A, B>): Optional<S, B>;
}

@@ -59,4 +59,4 @@ export declare class Prism<S, A> {

asOptional(): Optional<S, A>;
composeLens<B>(lens: Lens<A, B>): Optional<S, B>;
composeOptional<B>(optional: Optional<A, B>): Optional<S, B>;
composeLens<B>(ab: Lens<A, B>): Optional<S, B>;
composeOptional<B>(ab: Optional<A, B>): Optional<S, B>;
}

@@ -73,8 +73,8 @@ export declare class Optional<S, A> {

asTraversal(): Traversal<S, A>;
composeLens<B>(lens: Lens<A, B>): Optional<S, B>;
composePrism<B>(prism: Prism<A, B>): Optional<S, B>;
composeLens<B>(ab: Lens<A, B>): Optional<S, B>;
composePrism<B>(ab: Prism<A, B>): Optional<S, B>;
}
export declare class Traversal<S, A> {
modifyF: <F extends HKTS>(applicative: Applicative<F>, f: (a: A) => HKT<A>[F], s: S) => HKT<S>[F];
constructor(modifyF: <F extends HKTS>(applicative: Applicative<F>, f: (a: A) => HKT<A>[F], s: S) => HKT<S>[F]);
modifyF: <F>(F: Applicative<F>, f: (a: A) => HKT<F, A>, s: S) => HKT<F, S>;
constructor(modifyF: <F>(F: Applicative<F>, f: (a: A) => HKT<F, A>, s: S) => HKT<F, S>);
modify(f: (a: A) => A, s: S): S;

@@ -87,7 +87,5 @@ set(a: A, s: S): S;

}
/** create a Traversal from a Traversable */
export declare function fromTraversable<T extends HKTS, A>(traversable: Traversable<T>): Traversal<HKT<A>[T], A>;
export declare class Fold<S, A> {
foldMap: <M>(monoid: Monoid<M>, f: (a: A) => M, s: S) => M;
constructor(foldMap: <M>(monoid: Monoid<M>, f: (a: A) => M, s: S) => M);
foldMap: <M>(M: Monoid<M>, f: (a: A) => M, s: S) => M;
constructor(foldMap: <M>(M: Monoid<M>, f: (a: A) => M, s: S) => M);
/** compose a Fold with a Fold */

@@ -106,3 +104,14 @@ compose<B>(ab: Fold<A, B>): Fold<S, B>;

}
/** create a Fold from a Foldable */
export declare function fromFoldable<F extends HKTS, A>(fold: Foldable<F>): Fold<HKT<A>[F], A>;
export declare class Ops {
/** create a Traversal from a Traversable */
fromTraversable<T, A>(T: Traversable<T>): Traversal<HKT<T, A>, A>;
/** create a Fold from a Foldable */
fromFoldable<F, A>(F: Foldable<F>): Fold<HKT<F, A>, A>;
}
export declare const fromTraversable: Ops['fromTraversable'];
export declare const fromFoldable: Ops['fromFoldable'];
import { ArrayURI } from 'fp-ts/lib/overloadings';
export interface Ops {
fromTraversable<A>(T: Traversable<ArrayURI>): Traversal<Array<A>, A>;
fromFoldable<A>(F: Foldable<ArrayURI>): Fold<Array<A>, A>;
}

@@ -76,11 +76,11 @@ "use strict";

};
Lens.prototype.composePrism = function (prism) {
return this.asOptional().compose(prism.asOptional());
Lens.prototype.composePrism = function (ab) {
return this.asOptional().compose(ab.asOptional());
};
Lens.prototype.composeOptional = function (optional) {
return this.asOptional().compose(optional);
Lens.prototype.composeOptional = function (ab) {
return this.asOptional().compose(ab);
};
Lens.fromPath = lensFromPath;
return Lens;
}());
Lens.fromPath = lensFromPath;
exports.Lens = Lens;

@@ -98,3 +98,3 @@ /*

Prism.fromPredicate = function (predicate) {
return new Prism(function (s) { return predicate(s) ? Option_1.some(s) : Option_1.none; }, function (a) { return a; });
return new Prism(function (s) { return (predicate(s) ? Option_1.some(s) : Option_1.none); }, function (a) { return a; });
};

@@ -105,9 +105,7 @@ Prism.some = function () {

Prism.prototype.modify = function (f, s) {
return this.modifyOption(f, s)
.fold(function_1.constant(s), function_1.identity);
return this.modifyOption(f, s).fold(function_1.constant(s), function_1.identity);
};
Prism.prototype.modifyOption = function (f, s) {
var _this = this;
return this.getOption(s)
.map(function (a) { return _this.reverseGet(f(a)); });
return this.getOption(s).map(function (a) { return _this.reverseGet(f(a)); });
};

@@ -123,7 +121,7 @@ /** compose a Prism with a Prism */

};
Prism.prototype.composeLens = function (lens) {
return this.asOptional().compose(lens.asOptional());
Prism.prototype.composeLens = function (ab) {
return this.asOptional().compose(ab.asOptional());
};
Prism.prototype.composeOptional = function (optional) {
return this.asOptional().compose(optional);
Prism.prototype.composeOptional = function (ab) {
return this.asOptional().compose(ab);
};

@@ -136,3 +134,3 @@ return Prism;

Laws:
1. getOption(s).fold(identity, set(_, s)) = s
1. getOption(s).fold(identity, a => set(a, s)) = s
2. getOption(set(a, s)) = getOption(s).map(_ => a)

@@ -147,9 +145,7 @@ 3. set(a, set(a, s)) = set(a, s)

Optional.prototype.modify = function (f, s) {
return this.modifyOption(f, s)
.fold(function_1.constant(s), function_1.identity);
return this.modifyOption(f, s).fold(function_1.constant(s), function_1.identity);
};
Optional.prototype.modifyOption = function (f, s) {
var _this = this;
return this.getOption(s)
.map(function (a) { return _this.set(f(a), s); });
return this.getOption(s).map(function (a) { return _this.set(f(a), s); });
};

@@ -164,11 +160,11 @@ /** compose a Optional with a Optional */

var _this = this;
return new Traversal(function (applicative, f, s) {
return _this.getOption(s).fold(function () { return applicative.of(s); }, function (a) { return applicative.map(function (a) { return _this.set(a, s); }, f(a)); });
return new Traversal(function (F, f, s) {
return _this.getOption(s).fold(function () { return F.of(s); }, function (a) { return F.map(function (a) { return _this.set(a, s); }, f(a)); });
});
};
Optional.prototype.composeLens = function (lens) {
return this.compose(lens.asOptional());
Optional.prototype.composeLens = function (ab) {
return this.compose(ab.asOptional());
};
Optional.prototype.composePrism = function (prism) {
return this.compose(prism.asOptional());
Optional.prototype.composePrism = function (ab) {
return this.compose(ab.asOptional());
};

@@ -193,4 +189,4 @@ return Optional;

var _this = this;
return new Traversal(function (applicative, f, s) {
return _this.modifyF(applicative, function (a) { return ab.modifyF(applicative, f, a); }, s);
return new Traversal(function (F, f, s) {
return _this.modifyF(F, function (a) { return ab.modifyF(F, f, a); }, s);
});

@@ -201,4 +197,4 @@ };

var _this = this;
return new Fold(function (monoid, f, s) {
return _this.modifyF(con.getApplicative(monoid), function (a) { return new con.Const(f(a)); }, s).fold(function_1.identity);
return new Fold(function (M, f, s) {
return _this.modifyF(con.getApplicative(M), function (a) { return new con.Const(f(a)); }, s).fold(function_1.identity);
});

@@ -209,9 +205,2 @@ };

exports.Traversal = Traversal;
/** create a Traversal from a Traversable */
function fromTraversable(traversable) {
return new Traversal(function (applicative, f, s) {
return traversable.traverse(applicative)(f, s);
});
}
exports.fromTraversable = fromTraversable;
var Fold = (function () {

@@ -224,5 +213,3 @@ function Fold(foldMap) {

var _this = this;
return new Fold(function (monoid, f, s) {
return _this.foldMap(monoid, function (a) { return ab.foldMap(monoid, f, a); }, s);
});
return new Fold(function (M, f, s) { return _this.foldMap(M, function (a) { return ab.foldMap(M, f, a); }, s); });
};

@@ -235,3 +222,3 @@ /** get all the targets of a Fold */

Fold.prototype.find = function (p, s) {
return this.foldMap(option.getFirstMonoid(), function (a) { return p(a) ? option.of(a) : option.none; }, s);
return this.foldMap(option.getFirstMonoid(), function (a) { return (p(a) ? option.of(a) : option.none); }, s);
};

@@ -253,9 +240,19 @@ /** get the first target of a Fold */

exports.Fold = Fold;
/** create a Fold from a Foldable */
function fromFoldable(fold) {
return new Fold(function (monoid, f, s) {
return Foldable_1.foldMap(fold, monoid)(f, s);
});
}
exports.fromFoldable = fromFoldable;
var Ops = (function () {
function Ops() {
}
Ops.prototype.fromTraversable = function (T) {
return new Traversal(function (F, f, s) {
return T.traverse(F)(f, s);
});
};
Ops.prototype.fromFoldable = function (F) {
return new Fold(function (M, f, s) { return Foldable_1.foldMap(F, M)(f, s); });
};
return Ops;
}());
exports.Ops = Ops;
var ops = new Ops();
exports.fromTraversable = ops.fromTraversable;
exports.fromFoldable = ops.fromFoldable;
//# sourceMappingURL=index.js.map
{
"name": "monocle-ts",
"version": "0.2.0",
"version": "0.3.0",
"description": "A porting of scala monocle library to TypeScript",
"files": [
"lib"
],
"files": ["lib"],
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"lint": "tslint src/**/*.ts test/**/*.ts",
"typings-checker": "typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts",
"mocha": "mocha -r ts-node/register test/*.ts",
"test": "npm run mocha",
"prettier": "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test,examples}/**/*.ts\"",
"test": "npm run prettier && npm run lint && npm run typings-checker && npm run mocha",
"clean": "rm -rf lib/*",

@@ -27,3 +28,3 @@ "build": "npm run clean && tsc"

"dependencies": {
"fp-ts": "^0.3.0"
"fp-ts": "^0.4.0"
},

@@ -34,19 +35,11 @@ "devDependencies": {

"mocha": "^3.2.0",
"ts-node": "^2.0.0",
"typescript": "^2.2.0"
"prettier": "1.5.2",
"ts-node": "3.1.0",
"tslint": "4.4.2",
"tslint-config-standard": "4.0.0",
"typescript": "2.4.1",
"typings-checker": "1.1.2"
},
"tags": [
"typescript",
"functional-programming",
"optics",
"lens",
"fp-ts"
],
"keywords": [
"typescript",
"functional-programming",
"optics",
"lens",
"fp-ts"
]
"tags": ["typescript", "functional-programming", "optics", "lens", "fp-ts"],
"keywords": ["typescript", "functional-programming", "optics", "lens", "fp-ts"]
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc