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

trumpet

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trumpet - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

6

example/special.js

@@ -7,2 +7,3 @@ var trumpet = require('../');

/*
tr.select('.a .b', function (node) {

@@ -19,1 +20,6 @@ node.html(function (html) {

});
*/
tr.select('input', function (node) {
console.log('input ' + node.attributes.type);
});

17

lib/select.js

@@ -55,3 +55,6 @@ var Stream = require('stream').Stream;

sel.pending.forEach(function (p) {
p.buffered = '';
if (p.writes === 0) {
p.buffered = '';
}
if (typeof p.writes === 'number') p.writes ++;
});

@@ -125,10 +128,6 @@ });

var sel = function (tag, parser) {
var tags = parser.tags.filter(function (t) {
return special.indexOf(t.name) < 0;
});
var tags = parser.tags;
if (special.indexOf(tag.name) < 0) {
if (!siblings[tags.length]) siblings[tags.length] = [];
siblings[tags.length].push(tag);
}
if (!siblings[tags.length]) siblings[tags.length] = [];
siblings[tags.length].push(tag);

@@ -186,2 +185,3 @@ if (depth > tags.length) return;

p.callback = cb;
p.writes = 0;
sel.pending.push(p);

@@ -199,2 +199,3 @@ },

};
p.writes = 0;
sel.updating = true;

@@ -201,0 +202,0 @@ sel.pending.push(p);

{
"name" : "trumpet",
"version" : "0.2.3",
"version" : "0.2.4",
"description" : "parse and transform streaming html using css selectors",

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

@@ -6,3 +6,3 @@ var test = require('tap').test;

test('select', function (t) {
t.plan(6 + 4);
t.plan(11);

@@ -28,2 +28,8 @@ var tr = trumpet();

});
tr.select('.c', function (node) {
node.html(function (html) {
t.equal(html, '<b>beep</b><i>boop</i>');
});
});
});

@@ -6,3 +6,3 @@ var test = require('tap').test;

test('special tags', function (t) {
t.plan(2);
t.plan(10);

@@ -23,2 +23,27 @@ var tr = trumpet();

});
var types = [ 'text', 'text', 'password', 'submit' ];
tr.select('input', function (node) {
t.equal(node.attributes.type, types.shift());
});
tr.select('hr + input', function (node) {
t.equal(node.attributes.type, 'submit');
});
tr.select('br + .d', function (node) {
node.html(function (html) {
t.equal(html, 'wooo');
});
});
tr.select('img + .b', function (node) {
node.html(function (html) {
t.equal(html, 'boop');
});
});
tr.select('.d + hr', function (node) {
t.equal(node.name, 'hr');
});
});

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