Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
eventproxy
Advanced tools
这个世界上不存在所谓回调函数深度嵌套的问题。 —— Jackson Tian(http://weibo.com/shyvo)
npm install eventproxy
EventProxy.js仅仅是一个很轻量的工具,但是能够带来一种事件式编程的思维变化。有几个特点:
现在的,无深度嵌套的,并行的
var proxy = new EventProxy();
var render = function (template, data, l10n){
_.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
// something
proxy.trigger("template", template);
});
$.get("data", function (data) {
// something
proxy.trigger("data", data);
});
$.get("l10n", function (l10n) {
// something
proxy.trigger("l10n", l10n);
});
过去的,深度嵌套的,串行的。
var render = function (template, data){
_.template(template, data);
};
$.get("template", function (template) {
// something
$.get("data", function (data) {
// something
$.get("l10n", function (l10n) {
// something
render(template, data);
});
});
});
For Frontend user:
Assign once. The callback will be executed once when all event were fired.
<script src="eventproxy.js"></script>
<script>
var proxy = new EventProxy();
var render = function (template, data, l10n){
_.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
// something
proxy.trigger("template", template);
});
$.get("data", function (data) {
// something
proxy.trigger("data", data);
});
$.get("l10n", function (l10n) {
// something
proxy.trigger("l10n", l10n);
});
</script>
Assign always. The callback will be executed first time when all event were fired. And after that, any event was fired will trigger callback. It's useful when you need refresh UI with newest data, e.g. stock app.
<script src="eventproxy.js"></script>
<script>
var proxy = new EventProxy();
var render = function (template, data, l10n){
_.template(template, data);
};
proxy.assignAll("template", "dataUpdate", "l10n", render);
$.get("template", function (template) {
// something
proxy.trigger("template", template);
});
$.get("l10n", function (l10n) {
// something
proxy.trigger("l10n", l10n);
});
// Need refresh data and UI for some realtime application.
setInterval(function () {
$.get("data", function (data) {
// something
proxy.trigger("dataUpdate", data);
});
}, 1000);
</script>
For Node.js:
var EventProxy = require("eventproxy.js").EventProxy;
var proxy = new EventProxy();
var render = function (template, data, l10n){
return _.template(template, data);
};
proxy.assign("template", "data", "l10n", render);
$.get("template", function (template) {
// something
proxy.trigger("template", template);
});
$.get("data", function (data) {
// something
proxy.trigger("data", data);
});
$.get("l10n", function (l10n) {
// something
proxy.trigger("l10n", l10n);
});
FAQs
An implementation of task/event based asynchronous pattern.
The npm package eventproxy receives a total of 5,461 weekly downloads. As such, eventproxy popularity was classified as popular.
We found that eventproxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.