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

action-chain

Package Overview
Dependencies
Maintainers
1
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.0-1532015160372 to 1.0.0-1532018253864

44

es/ActionChain.js

@@ -12,26 +12,28 @@ import * as tslib_1 from "tslib";

getContext: function (executionContext) {
var _this = this;
var instance = this;
var providers = Object.keys(context).reduce(function (currentContext, key) {
if (IS_DEVELOPMENT && options.providerExceptions.indexOf(key) === -1) {
currentContext[key] = Object.keys(context[key]).reduce(function (currentProvider, method) {
currentProvider[method] = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
currentContext[key] = new Proxy(context[key], {
get: function (target, prop) {
if (typeof target[prop] === 'function') {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var result = target[prop].apply(target, args);
if (result instanceof Promise) {
result.then(function (promisedResult) {
instance.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: prop, result: promisedResult }));
});
}
else {
instance.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: prop, result: result }));
}
return result;
};
}
var _a;
var result = (_a = context[key])[method].apply(_a, args);
if (result instanceof Promise) {
result.then(function (promisedResult) {
_this.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: method, result: promisedResult }));
});
}
else {
_this.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: method,
result: result }));
}
return result;
};
return currentProvider;
}, {});
return target[prop];
},
});
}

@@ -38,0 +40,0 @@ else {

@@ -20,2 +20,10 @@ import { actionChainFactory, actionBaseFactory, } from './';

}
var TestProvider = /** @class */ (function () {
function TestProvider() {
}
TestProvider.prototype.foo = function () {
return 'bar';
};
return TestProvider;
}());
var context = {

@@ -27,2 +35,3 @@ foo: {

},
test: new TestProvider(),
};

@@ -81,2 +90,20 @@ var actionChain = actionChainFactory(context);

});
test('should track execution of clas instance providers', function () {
expect.assertions(2);
var foo = action().test(function (_, _a) {
var test = _a.test;
expect(test.foo()).toBe('bar');
});
actionChain.once('provider', function (task) {
expect(task).toEqual({
operatorId: 0,
actionId: 0,
executionId: 0,
method: 'foo',
name: 'test',
result: 'bar',
});
});
foo();
});
});

@@ -83,0 +110,0 @@ describe('ACTION CHAIN', function () {

@@ -14,26 +14,28 @@ "use strict";

getContext: function (executionContext) {
var _this = this;
var instance = this;
var providers = Object.keys(context).reduce(function (currentContext, key) {
if (IS_DEVELOPMENT && options.providerExceptions.indexOf(key) === -1) {
currentContext[key] = Object.keys(context[key]).reduce(function (currentProvider, method) {
currentProvider[method] = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
currentContext[key] = new Proxy(context[key], {
get: function (target, prop) {
if (typeof target[prop] === 'function') {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var result = target[prop].apply(target, args);
if (result instanceof Promise) {
result.then(function (promisedResult) {
instance.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: prop, result: promisedResult }));
});
}
else {
instance.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: prop, result: result }));
}
return result;
};
}
var _a;
var result = (_a = context[key])[method].apply(_a, args);
if (result instanceof Promise) {
result.then(function (promisedResult) {
_this.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: method, result: promisedResult }));
});
}
else {
_this.emit('provider', tslib_1.__assign({}, executionContext.__execution, { name: key, method: method,
result: result }));
}
return result;
};
return currentProvider;
}, {});
return target[prop];
},
});
}

@@ -40,0 +42,0 @@ else {

@@ -22,2 +22,10 @@ "use strict";

}
var TestProvider = /** @class */ (function () {
function TestProvider() {
}
TestProvider.prototype.foo = function () {
return 'bar';
};
return TestProvider;
}());
var context = {

@@ -29,2 +37,3 @@ foo: {

},
test: new TestProvider(),
};

@@ -83,2 +92,20 @@ var actionChain = _1.actionChainFactory(context);

});
test('should track execution of clas instance providers', function () {
expect.assertions(2);
var foo = action().test(function (_, _a) {
var test = _a.test;
expect(test.foo()).toBe('bar');
});
actionChain.once('provider', function (task) {
expect(task).toEqual({
operatorId: 0,
actionId: 0,
executionId: 0,
method: 'foo',
name: 'test',
result: 'bar',
});
});
foo();
});
});

@@ -85,0 +112,0 @@ describe('ACTION CHAIN', function () {

{
"name": "action-chain",
"version": "1.0.0-1532015160372",
"version": "1.0.0-1532018253864",
"description": "Functional actions",

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

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