New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fp-ts-contrib

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fp-ts-contrib - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

5

CHANGELOG.md

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

# 0.0.4
- **Polish**
- improve `Do` performance (@gcanti)
# 0.0.3

@@ -18,0 +23,0 @@

118

lib/Do.js
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
Object.defineProperty(exports, "__esModule", { value: true });
var nil = { type: 'Nil', length: 0 };
var cons = function (head, tail) { return ({
type: 'Cons',
head: head,
tail: tail,
length: tail.length + 1
}); };
var toArray = function (list) {
var len = list.length;
var r = new Array(len);
var l = list;
var i = 1;
while (l.type !== 'Nil') {
r[len - i] = l.head;
i++;
l = l.tail;
}
return r;
};
var DoClass = /** @class */ (function () {
function DoClass(M, actions) {
this.M = M;
this.actions = actions;
}
DoClass.prototype.do = function (action) {
return new DoClass(this.M, cons({ type: 'do', action: action }, this.actions));
};
DoClass.prototype.doL = function (f) {
return new DoClass(this.M, cons({ type: 'doL', f: f }, this.actions));
};
DoClass.prototype.bind = function (name, action) {
return new DoClass(this.M, cons({ type: 'bind', name: name, action: action }, this.actions));
};
DoClass.prototype.bindL = function (name, f) {
return new DoClass(this.M, cons({ type: 'bindL', name: name, f: f }, this.actions));
};
DoClass.prototype.return = function (f) {
return this.M.map(this.done(), f);
};
DoClass.prototype.done = function () {
var actions = this.actions;
var len = actions.length;
var as = toArray(actions);
var result = this.M.of({});
var M = this.M;
var _loop_1 = function (i) {
var a = as[i];
switch (a.type) {
case 'do':
result = M.chain(result, function (s) { return M.map(a.action, function () { return s; }); });
break;
case 'doL':
result = M.chain(result, function (s) { return M.map(a.f(s), function () { return s; }); });
break;
case 'bind':
result = M.chain(result, function (s) {
return M.map(a.action, function (b) {
s[a.name] = b;
return s;
});
});
break;
case 'bindL':
result = M.chain(result, function (s) {
return M.map(a.f(s), function (b) {
s[a.name] = b;
return s;
});
});
break;
}
};
for (var i = 0; i < len; i++) {
_loop_1(i);
}
return t;
return result;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
return DoClass;
}());
function Do(M) {
function toDo(ms) {
return {
do: function (mv) {
return toDo(M.chain(ms, function (a) { return M.map(mv, function () { return a; }); }));
},
doL: function (fmv) {
return toDo(M.chain(ms, function (a) { return M.map(fmv(a), function () { return a; }); }));
},
bind: function (name, mb) {
return toDo(M.chain(ms, function (a) { return M.map(mb, function (b) {
var _a;
return (__assign({}, a, (_a = {}, _a[name] = b, _a)));
}); }));
},
bindL: function (name, fmb) {
return toDo(M.chain(ms, function (a) { return M.map(fmb(a), function (b) {
var _a;
return (__assign({}, a, (_a = {}, _a[name] = b, _a)));
}); }));
},
return: function (f) {
return M.map(ms, f);
},
done: function () {
return ms;
}
};
}
return toDo(M.of({}));
return new DoClass(M, nil);
}
exports.Do = Do;
{
"name": "fp-ts-contrib",
"version": "0.0.3",
"version": "0.0.4",
"description": "A community driven utility package for fp-ts",

@@ -37,4 +37,6 @@ "files": [

"devDependencies": {
"@types/benchmark": "^1.0.31",
"@types/jest": "^23.3.13",
"@types/node": "^10.12.18",
"benchmark": "^2.1.4",
"docs-ts": "0.0.1",

@@ -41,0 +43,0 @@ "doctoc": "^1.4.0",

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