Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

document the short-form api, bump to 0.3

  • Loading branch information...
commit de709edd6ae055137a78b6b3acd876753a353b74 1 parent 8a81e30
@substack authored
Showing with 25 additions and 2 deletions.
  1. +22 −0 README.markdown
  2. +2 −1  lib/select.js
  3. +1 −1  package.json
View
22 README.markdown
@@ -154,6 +154,28 @@ Fire `fn(node)` for every element in the html stream that matches the css
The nodes are described in the nodes section of this document.
+tr.update(selector, fn)
+-----------------------
+
+Calls `node.update(fn)` on the nodes that match the `selector`
+except that `fn` gets the `node` as a second argument.
+
+To update attributes you'll need to use the long-form of calling `tr.select()`
+then `node.update(fn, attrs)` inside the callback.
+
+tr.replace(selector, fn)
+------------------------
+
+Calls `node.replace(fn)` on the nodes that match the `selector`
+except that `fn` gets the `node` as a second argument.
+
+tr.remove(selector, fn)
+-----------------------
+
+Calls `node.remove()` on nodes that match the `selector`.
+
+If `fn` is provided, it will be called after an element is removed.
+
nodes
=====
View
3  lib/select.js
@@ -23,9 +23,10 @@ module.exports = function (parser, opts) {
});
};
- stream.remove = function (s) {
+ stream.remove = function (s, fn) {
return stream.select(s, function (node) {
node.remove();
+ if (typeof fn === 'function') fn(node);
});
};
View
2  package.json
@@ -1,6 +1,6 @@
{
"name" : "trumpet",
- "version" : "0.2.7",
+ "version" : "0.3.0",
"description" : "parse and transform streaming html using css selectors",
"main" : "index.js",
"directories" : {
Please sign in to comment.
Something went wrong with that request. Please try again.