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

slt

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slt - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

lib/__tests__/rulesWithDependencies.js

11

lib/__tests__/data/deps.js

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

params = params || { id: 1 };
return this.set(name, _service2["default"][name](params.id));
var route = {};
if (url == "Help") {
route.params = { id: 1 };
route.name = "page";
return this.set("route", route);
}
},

@@ -29,3 +33,4 @@

params = params || { id: 1 };
return this.set(name, _service2["default"][name](params.id));
this.set("url", url);
this.set(name, _service2["default"][name](params.id));
},

@@ -32,0 +37,0 @@ deps: ["request"]

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

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -87,5 +89,12 @@

(function () {
var deps = _this.getDeps(path).map(function (dep) {
var dependency = _this.state.getIn(_slots2["default"].makePath(dep));
if (!dependency) {
throw new Error("Rule on `" + path.toArray().join(".") + "` requires `" + dep + "` state dependency which not provided");
}
return dependency;
});
log("RULE on path %s matched with value %s", (0, _utils.insp)(path), (0, _utils.insp)(value));
var branch = _this.newBranch(state);
rule.call(branch, value);
rule.apply(branch, [value].concat(_toConsumableArray(deps)));
state = branch.state;

@@ -96,2 +105,3 @@ if (!(0, _utils.isPromise)(branch)) {

d("RESULT is %s", (0, _utils.insp)(state));
_this.state = state;
} else {

@@ -113,2 +123,4 @@ log("PROMISE RETURNED");

});
} else {
_this.state = state; // No rule found. Set as is.
}

@@ -118,3 +130,2 @@ }

applyRules(new _immutable.List(path), value);
this.state = state;
return this;

@@ -121,0 +132,0 @@ }

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

}
return (0, _utils.isArray)(path) && path || (0, _utils.isString)(path) && path.split(".") || (function () {
return (0, _utils.isArray)(path) && path || ((0, _utils.isString)(path) || (0, _utils.isNumber)(path)) && path.toString().split(".") || (function () {
throw new Error("path should be an array or dot-separated string or null,\n " + Object.prototype.toString.call(path) + " given");

@@ -220,0 +220,0 @@ })();

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

exports.isString = isString;
exports.isNumber = isNumber;
exports.toJS = toJS;

@@ -46,2 +47,6 @@ exports.insp = insp;

function isNumber(v) {
return Object.prototype.toString.call(v) === "[object Number]";
}
function toJS(v) {

@@ -48,0 +53,0 @@ return v && isImmutable(v) && v.toJS() || v;

{
"name": "slt",
"version": "1.3.0",
"version": "1.3.1",
"description": "Take care of your state",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,4 +5,8 @@ import service from "./service"

"request": function ({ url }) {
params = params || {id: 1};
return this.set(name, service[name](params.id));
let route = {};
if (url == "Help") {
route.params = {id: 1};
route.name = "page";
return this.set("route", route);
}
},

@@ -13,3 +17,4 @@

params = params || {id: 1};
return this.set(name, service[name](params.id));
this.set("url", url);
this.set(name, service[name](params.id));
},

@@ -16,0 +21,0 @@ deps: ["request"]

@@ -44,5 +44,13 @@ import { fromJS, is, Map, List} from "immutable";

if (rule) {
let deps = this.getDeps(path).map(dep => {
let dependency = this.state.getIn(Slots.makePath(dep));
if (!dependency) {
throw new Error("Rule on `" + path.toArray().join(".") +
"` requires `" + dep + "` state dependency which not provided");
}
return dependency;
});
log("RULE on path %s matched with value %s", insp(path), insp(value));
let branch = this.newBranch(state);
rule.call(branch, value);
rule.apply(branch, [value, ...deps]);
state = branch.state;

@@ -53,2 +61,3 @@ if (!isPromise(branch)) {

d("RESULT is %s", insp(state));
this.state = state
} else {

@@ -68,2 +77,4 @@ log("PROMISE RETURNED");

Object.keys(value).forEach(k => applyRules(path.push(k), value[k]));
} else {
this.state = state; // No rule found. Set as is.
}

@@ -73,3 +84,2 @@ }

applyRules(new List(path), value);
this.state = state;
return this;

@@ -76,0 +86,0 @@ }

import { fromJS, is, Map, List} from "immutable";
import debug from "debug";
import { toJS, isArray, isString, isFunction, isPromise, insp } from "./utils";
import { toJS, isArray, isString, isNumber, isFunction, isPromise, insp } from "./utils";
import Context from "./context";

@@ -153,3 +153,3 @@ const d = debug("slt");

}
return isArray(path) && path || isString(path) && path.split('.') ||
return isArray(path) && path || (isString(path) || isNumber(path)) && path.toString().split('.') ||
(() => { throw new Error (

@@ -156,0 +156,0 @@ `path should be an array or dot-separated string or null,

@@ -27,2 +27,6 @@ import util from "util";

export function isNumber(v) {
return Object.prototype.toString.call(v) === "[object Number]";
}
export function toJS(v) {

@@ -29,0 +33,0 @@ return v && isImmutable(v) && v.toJS() || v;

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