GitXplorerGitXplorer
k

strawpoll

public
7 stars
0 forks
2 issues

Commits

List of commits on branch master.
Verified
9a587606247df698176b5de5e45cb5e39e00b6b4

Release 1.1.0

kkenany committed 9 years ago
Verified
0f98cc02cffcec6b6349510f1d877729acc0ae32

set Content-Type to json

kkenany committed 9 years ago
Unverified
b96711d0e09ea9e61871f9961ba31aaa63f0dc5c

Add `strawpoll.get` for getting existing polls

PProbablePrime committed 9 years ago
Verified
e1a5ee75ac5a24e2a443a39f0c3382a4e9f0f1b6

Release 1.0.5

kkenany committed 9 years ago
Verified
db5e0e3a171da4bea37f3ec187973afb5b128a43

tape@^4.0.2

kkenany committed 9 years ago
Verified
5d732ea28648f291a23657ee7eb9382bd2b4ad51

lodash.isfunction@^3.0.6

kkenany committed 9 years ago

README

The README file for this repository.

strawpoll

Build Status Dependency Status

Create and get 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
  }));

An example of getting a poll with concat-stream:

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

var stream = strawpoll.get(1)
  .pipe(concat(function(poll) {
    poll = JSON.parse(poll);
    // poll.id is the id you requested
    // poll.title is the title of the poll
  }));

The JSON parsed response will match examples from the Straw Poll API.

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)

strawpoll.create(options)

Alias of just strawpoll(options).

strawpoll.get(id)

Returns a hyperquest stream which is GETing poll information from Straw Poll based on Number id.