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

horpyna

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

horpyna - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

46

dist/index.js

@@ -118,3 +118,3 @@ require("source-map-support").install();

this.channelManager.createChannel(DEFAULT_CHANNEL);
this.status = STATUS.INIT;
this.finalComponentFlag = false;

@@ -150,3 +150,3 @@ this.rootComponent = new _root2.default();

if (typeof this.componentFunction === "function") {
this.channelManager.setStatusProcess();
this.status = STATUS.PROCESS;
this.componentFunction(request, this._getResponseObject());

@@ -214,2 +214,3 @@ } else {

if (_this2.rootComponent.status === STATUS.PROCESS) {
_this2.status = STATUS.DONE;
_this2.channelManager.setStatusDone(channel);

@@ -225,7 +226,2 @@ channel.output = output;

}
},
finish: function finish(output) {
if (_this2.rootComponent.status === STATUS.PROCESS) {
_this2.rootComponent.finish(output);
}
}

@@ -239,2 +235,7 @@ };

}
}, {
key: "createChannel",
value: function createChannel(channelName) {
this.channelManager.createChannel(channelName);
}

@@ -409,24 +410,5 @@ /**

}, {
key: "setStatusProcess",
value: function setStatusProcess() {
var _this = this;
Object.keys(this.channels).forEach(function (key) {
var channel = _this.channels[key];
channel.setStatusProcess();
});
}
}, {
key: "setStatusDone",
value: function setStatusDone(doneChannel) {
var _this2 = this;
Object.keys(this.channels).forEach(function (key) {
var channel = _this2.channels[key];
if (channel === doneChannel) {
channel.setStatusDone();
} else {
channel.setStatusInit();
}
});
doneChannel.setStatusDone();
}

@@ -490,12 +472,2 @@ }, {

}, {
key: "setStatusInit",
value: function setStatusInit() {
this._status = STATUS.INIT;
}
}, {
key: "setStatusProcess",
value: function setStatusProcess() {
this._status = STATUS.PROCESS;
}
}, {
key: "setStatusDone",

@@ -502,0 +474,0 @@ value: function setStatusDone() {

2

package.json
{
"name": "horpyna",
"version": "0.2.1",
"version": "0.2.2",
"description": "promised modules flow control core library",

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

@@ -22,10 +22,2 @@ import * as STATUS from "../constants/statuses";

setStatusInit() {
this._status = STATUS.INIT;
}
setStatusProcess() {
this._status = STATUS.PROCESS;
}
setStatusDone() {

@@ -32,0 +24,0 @@ this._status = STATUS.DONE;

@@ -14,18 +14,4 @@ import Channel from "./channel";

setStatusProcess() {
Object.keys(this.channels).forEach(key => {
let channel = this.channels[key];
channel.setStatusProcess();
});
}
setStatusDone(doneChannel) {
Object.keys(this.channels).forEach(key => {
let channel = this.channels[key];
if(channel === doneChannel) {
channel.setStatusDone();
} else {
channel.setStatusInit();
}
});
doneChannel.setStatusDone();
}

@@ -32,0 +18,0 @@

@@ -38,3 +38,2 @@ import Root from "./root";

this.status = STATUS.PROCESS;
this.channelManager.setStatusProcess();
this.componentFunction(request, this._getResponseObject());

@@ -98,7 +97,2 @@ } else {

}
},
finish: output => {
if(this.rootComponent.status === STATUS.PROCESS) {
this.rootComponent.finish(output);
}
}

@@ -105,0 +99,0 @@ };

@@ -12,4 +12,4 @@ import sinon from "sinon";

const TEST_MESSAGE_A = "messageA";
describe("Basic functionality", () => {

@@ -24,6 +24,7 @@

spyCustomFunc();
response.finish();
response.send(TEST_MESSAGE_A);
});
component.final();
let promise = component.run();
promise.then(() => {
promise.then(output => {
spyComponent();

@@ -33,2 +34,3 @@ expect(spyComponent.calledOnce).to.be.true;

expect(spyCustomFunc.calledBefore(spyComponent)).to.be.true;
expect(output).to.be.equal(TEST_MESSAGE_A);
done();

@@ -42,5 +44,9 @@ });

let ExtendComponent = class extends Horpyna.Component {
constructor() {
super();
this.final();
}
componentFunction(request, response) {
spyCustomFunc();
response.finish();
response.send(TEST_MESSAGE_A);
}

@@ -50,3 +56,3 @@ };

let promise = component.run();
promise.then(() => {
promise.then(output => {
spyComponent();

@@ -56,2 +62,3 @@ expect(spyComponent.calledOnce).to.be.true;

expect(spyCustomFunc.calledBefore(spyComponent)).to.be.true;
expect(output).to.be.equal(TEST_MESSAGE_A);
done();

@@ -72,3 +79,2 @@ });

it("should return value to child component", done => {
const RESPONSE = "1234456564";
let componentA = new Horpyna.Component((request, response) => {

@@ -78,26 +84,10 @@ response.send(request.input);

let componentB = new Horpyna.Component((request, response) => {
expect(request.input).to.be.equal(RESPONSE);
response.finish();
expect(request.input).to.be.equal(TEST_MESSAGE_A);
response.send();
done();
});
componentB.final();
componentB.bind(componentA);
componentA.run(RESPONSE);
componentA.run(TEST_MESSAGE_A);
})
it("should resolve promise when component is mark as final", done => {
let spyComponent = sinon.spy();
let spyCustomFunc = sinon.spy();
let component = new Horpyna.Component((request, response) => {
spyCustomFunc();
response.send();
});
component.final();
let promise = component.run();
promise.then(() => {
spyComponent();
expect(spyComponent.calledOnce).to.be.true;
expect(spyCustomFunc.calledOnce).to.be.true;
expect(spyCustomFunc.calledBefore(spyComponent)).to.be.true;
done();
});
})
});

@@ -126,5 +116,6 @@

spyC();
response.finish();
response.send();
}, 10);
});
componentC.final();
componentB.bind(componentA);

@@ -177,5 +168,6 @@ componentC.bind(componentB);

spyD();
response.finish();
response.send();
}, 20);
});
componentD.final();
componentB.bind(componentA);

@@ -205,6 +197,33 @@ componentC.bind(componentA);

describe("Check channels", () => {
let componentA = new Horpyna.Component((request, response) => {
it("should return message to final component connected by custom channel", (done) => {
let spyA = sinon.spy();
let spyB = sinon.spy();
const CHANNEL_AA = "channelAA";
let componentA = new Horpyna.Component((request, response) => {
spyA();
response.send(TEST_MESSAGE_A, CHANNEL_AA);
});
componentA.createChannel(CHANNEL_AA);
let componentB = new Horpyna.Component((request, response) => {
spyB();
expect(request.input).to.be.equal(TEST_MESSAGE_A);
response.send();
});
componentB.bind(componentA, CHANNEL_AA);
componentB.final();
let promise = componentA.run();
promise.then((response) => {
expect(spyA.calledOnce).to.be.true;
expect(spyB.calledOnce).to.be.true;
expect(spyA.calledBefore(spyB)).to.be.true;
done();
});
});
});
});

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