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

yog-bigpipe

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yog-bigpipe - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

.travis.yml

2

index.js

@@ -24,3 +24,3 @@ var BigPipe = require('./lib/bigpipe.js');

res.locals = res.locals || {};
// res.locals 肯定是一个对象,不信可以去查看 express/middleware/init
res.locals.isQuickingMode = bigpipe.isQuickingMode();

@@ -27,0 +27,0 @@

var Pagelet = require('./pagelet.js');
var status = Pagelet.status;
var mode = Pagelet.mode;
var mixin = require('./util.js').mixin;
var _ = require('./util.js');
var Readable = require('stream').Readable;

@@ -9,3 +9,3 @@ var util = require('util');

var BigPipe = module.exports = function BigPipe(options) {
this.options = mixin(mixin({}, BigPipe.options), options);
this.options = _.mixin(_.mixin({}, BigPipe.options), options);
this.pagelets = [];

@@ -25,5 +25,18 @@ this.pipelines = [];

// configure output template.
// you can use the following varible.
//
// - this.id pagelet id
// - this.js pagelet js
// - this.css pagelet css
// - this.scripts pagelet inline scripts
// - this.styles pagelet inline css
// - this.html pagelet html content
// - this.container pagelet container if specified
// - this.json stringfied json data.
tpl: {
_default: '<script type="text/javascript">BigPipe.onPageletArrive(${data});</script>',
quickling: 'BigPipe.onPageletArrive(${data});'
_default: '<script type="text/javascript">' +
'BigPipe.onPageletArrive(<%= this.json %>);' +
'</script>',
quickling: 'BigPipe.onPageletArrive(<%= this.json %>);'
}

@@ -88,2 +101,6 @@ };

pagelet.on('error', function(reason) {
self.emit('error', reason);
});
pagelet.on('before-render', function() {

@@ -144,2 +161,4 @@ var args = [].slice.call(arguments);

this.emit('pagelet-done', pagelet);
if (pagelet.mode === mode.pipeline) {

@@ -184,8 +203,11 @@ // 必须按顺序

var type = pagelet.mode;
var obj = pagelet.toJson();
var json = pagelet.toJson();
var obj = {};
tpl = tpl[type] || tpl['_default'];
return tpl.replace(/\${data}/g, JSON.stringify(obj));
_.mixin(obj, json);
obj.json = JSON.stringify(json);
return _.tpl(tpl, obj);
};

@@ -192,0 +214,0 @@

@@ -78,3 +78,3 @@ var util = require("util");

if (!provider && (eventname = 'onPagelet' + _.ucfirst(this.id)) &&
if (!provider && this.locals && (eventname = 'onPagelet' + _.ucfirst(this.id)) &&
typeof this.locals[eventname] === 'function') {

@@ -85,3 +85,3 @@

if (!provider && typeof this.locals['onPagelet'] === 'function') {
if (!provider && this.locals && typeof this.locals['onPagelet'] === 'function') {
provider = this.locals['onPagelet'].bind(null, this.id);

@@ -154,2 +154,3 @@ }

css.push(m[2]);
return '';
}

@@ -156,0 +157,0 @@

@@ -14,2 +14,24 @@ var _ = module.exports = {};

return str.substring(0, 1).toUpperCase() + str.substring(1);
};
_.tpl = function(str, locals) {
var code = "var p=[];" +
"p.push('" +
// Convert the template into pure JavaScript
str
.replace(/[\r\t\n]/g, " ")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
.replace(/\t=(.*?)%>/g, "',$1,'")
.split("\t").join("');")
.split("%>").join("p.push('")
.split("\r").join("\\'") +
"');return p.join('');";
var fn = new Function(code);
return locals ? fn.call(locals) : fn;
};
{
"name": "yog-bigpipe",
"version": "0.0.9",
"version": "0.0.10",
"description": "An express.js middleware for fis widget pipline output.",

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

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