Socket
Socket
Sign inDemoInstall

action-chain

Package Overview
Dependencies
Maintainers
2
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

action-chain - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0-1537638985639

22

es/index.test.js

@@ -43,2 +43,3 @@ import * as tslib_1 from "tslib";

},
Constr: TestProvider,
},

@@ -150,2 +151,23 @@ test: new TestProvider(),

});
test('should track execution of constructor instantiation', function () {
expect.assertions(3);
var fn = action().test(function (_a) {
var foo = _a.foo;
var instance = new foo.Constr();
expect(instance.foo()).toBe('bar');
expect(instance).toBeInstanceOf(TestProvider);
});
actionChain.once('effect', function (task) {
expect(task).toEqual({
operatorId: 0,
actionId: 0,
executionId: 0,
method: 'Constr',
args: [],
name: 'foo',
result: '[Constr]',
});
});
fn();
});
});

@@ -152,0 +174,0 @@ describe('ACTION CHAIN', function () {

20

es/utils.js

@@ -5,6 +5,7 @@ export var doNotProxy = Symbol('doNotProxy');

}
var hasWarnedConstructor = false;
function createProxyGetHandler(path, cb) {
return function (target, prop) {
if (typeof target[prop] === 'function') {
return function () {
var func = function () {
var args = [];

@@ -37,2 +38,19 @@ for (var _i = 0; _i < arguments.length; _i++) {

};
return new Proxy(func, {
construct: function (_, args) {
var _a;
// eslint-disable-next-line
cb({
name: path,
method: prop,
args: args,
result: "[" + prop.toString() + "]",
});
if (!hasWarnedConstructor) {
console.warn("EFFECTS - It is highly recommended to create a custom effect, exposing a method that deals with the instantiation of \"" + path + "." + prop.toString() + "\". It improves readability and debugability of your app");
hasWarnedConstructor = true;
}
return new ((_a = target[prop]).bind.apply(_a, [void 0].concat(args)))();
},
});
}

@@ -39,0 +57,0 @@ if (isObject(target[prop])) {

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

},
Constr: TestProvider,
},

@@ -152,2 +153,23 @@ test: new TestProvider(),

});
test('should track execution of constructor instantiation', function () {
expect.assertions(3);
var fn = action().test(function (_a) {
var foo = _a.foo;
var instance = new foo.Constr();
expect(instance.foo()).toBe('bar');
expect(instance).toBeInstanceOf(TestProvider);
});
actionChain.once('effect', function (task) {
expect(task).toEqual({
operatorId: 0,
actionId: 0,
executionId: 0,
method: 'Constr',
args: [],
name: 'foo',
result: '[Constr]',
});
});
fn();
});
});

@@ -154,0 +176,0 @@ describe('ACTION CHAIN', function () {

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

}
var hasWarnedConstructor = false;
function createProxyGetHandler(path, cb) {
return function (target, prop) {
if (typeof target[prop] === 'function') {
return function () {
var func = function () {
var args = [];

@@ -39,2 +40,19 @@ for (var _i = 0; _i < arguments.length; _i++) {

};
return new Proxy(func, {
construct: function (_, args) {
var _a;
// eslint-disable-next-line
cb({
name: path,
method: prop,
args: args,
result: "[" + prop.toString() + "]",
});
if (!hasWarnedConstructor) {
console.warn("EFFECTS - It is highly recommended to create a custom effect, exposing a method that deals with the instantiation of \"" + path + "." + prop.toString() + "\". It improves readability and debugability of your app");
hasWarnedConstructor = true;
}
return new ((_a = target[prop]).bind.apply(_a, [void 0].concat(args)))();
},
});
}

@@ -41,0 +59,0 @@ if (isObject(target[prop])) {

4

package.json
{
"name": "action-chain",
"version": "1.0.3",
"version": "1.1.0-1537638985639",
"description": "Functional actions",

@@ -34,5 +34,5 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>",

"tslib": "^1.9.3",
"betsy": "1.0.1"
"betsy": "1.0.1-1537638985639"
},
"devDependencies": {}
}

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