JavaScript library for WebPipes. Use with Node.js, in the browser, or the command-line.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
docs
examples
lib
src
test
.gitignore
.npmignore
.travis.yml
AUTHORS
Cakefile
LICENSE
README.md
index.js
package.json
webpipe.min.js

README.md

webpipe.js

Javascript library for working with WebPipes. Use with Node.js or in the browser.

Build Status

Installation

Just include the script. The webpipe object is automagically added to your environment. No need for new or any other sort of initialization.

Browser

<script src="webpipe.js"></script>

As a courtesy, webpipejs.org offers a compressed and CDN-hosted version:

<script src="http://cdn.webpipejs.org/latest.min.js"></script>

Or, use a specific version by replacing x.x.x:

<script src="http://cdn.webpipejs.org/x.x.x/webpipe.min.js"></script>

Node

Or, if you're using webpipe.js with node.js

$ npm [-g] install webpipe

Then require the "webpipe" module:

var webpipe = require("webpipe");

Usage

webpipe.js exposes two methods: webpipe.execute() and webpipe.options(). Use webpipe.options() to load a WebPipe's Block Definition. It can be handy while debugging and/or learning about new WebPipes. See examples/ for usage examples.

webpipe.execute(url, inputs, callback)

The real workhorse is webpipe.execute(). Use it to make a request to your WebPipe of choice.

var url = "http://block-parse-markdown.herokuapp.com/";
var inputs = { markdown: "*hello world*" };
webpipe.execute(url, inputs, function (err, data) {
  if (err) return console.warn("Error: ", err);

  // Prints the response of the Parse Markdown webpipe.
  console.log(data);
});

Command-line Usage

You can also use webpipe.js from the command-line. To use this feature make sure you install webpipe.js globally.

$ webpipe http://block-parse-markdown.herokuapp.com/ --markdown "*hello world*"

Store an alias (in ~/.webpipe) so you don't have to type the URL every time:

$ webpipe alias markdown http://block-parse-markdown.herokuapp.com/

Prefix a value with @ to read from a file, or - for STDIN:

$ webpipe markdown --markdown @README.md
$ cat README.md | ./webpipe markdown --markdown @-

Suggestions

All comments in how to improve this library are very welcome. Feel free post suggestions to the Issue tracker, or even better, fork the repository to implement your own ideas and submit a pull request.

License

Unless attributed otherwise, everything is under the MIT License (see LICENSE for more info).