strawpoll

Create polls on StrawPoll.

npm install strawpoll
2 downloads in the last week
2 downloads in the last month

strawpoll

Create polls on Straw Poll.

Example

Here's an example using concat-stream:

var concat = require('concat-stream');
var strawpoll = require('strawpoll');

var stream = strawpoll({
  title: 'My first poll',
  options: [
    'wow',
    'awesome',
    'amazing',
    'nice'
  ],
  multi: false,
  permissive: true
});

stream.pipe(concat(function(poll) {
  poll = JSON.parse(poll);
  // poll.id is your poll's id
  // check out your poll at strawpoll.me/id
}));

Add JSONStream and you don't even have to use JSON.parse yourself!

var concat = require('concat-stream');
var JSONStream = require('JSONStream');
var strawpoll = require('strawpoll');

var stream = strawpoll({
  title: 'My first poll',
  options: [
    'wow',
    'awesome',
    'amazing',
    'nice'
  ],
  multi: false,
  permissive: true
})
  .pipe(JSONStream.parse('id'))
  .pipe(concat(function(id) {
    // `id` is a Buffer here
    // `id.toString()` is your poll's id
  }));

Installation

$ npm install strawpoll

API

var strawpoll = require('strawpoll');

strawpoll(options)

Returns a hyperquest stream which is POSTing to Straw Poll in order to create your poll.

options:

  • title (String)
  • options (Array)
  • multi (Boolean)
  • permissive (Boolean)
npm loves you