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

pollster

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pollster - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

LICENSE

24

lib/pollster.js

@@ -1,2 +0,2 @@

exports.version = '0.0.1';
exports.version = '0.0.2';

@@ -12,3 +12,3 @@ var request = require('request');

_buildRequestUrl = function(path, params) {
_buildRequestUrl = function(path) {
var url = 'http://' + config.API_SERVER + config.API_BASE + '/' + path;

@@ -20,10 +20,6 @@

_invoke = function(path, params, callback) {
var url = _buildRequestUrl(path, params);
var url = _buildRequestUrl(path);
request(url, {qs: params}, function (error, response, body) {
if (!error && response.statusCode == 200) {
callback(JSON.parse(body));
} else {
console.log(body);
}
callback(JSON.parse(body));
});

@@ -33,4 +29,4 @@ };

pollster.charts = function(params, callback) {
_invoke('charts', params, function(result){
callback(result);
_invoke('charts', params, function(resp){
callback(resp);
});

@@ -40,4 +36,4 @@ };

pollster.chart = function(slug, callback) {
_invoke('charts/' + slug, {}, function(result){
callback(result);
_invoke('charts/' + slug, {}, function(resp){
callback(resp);
});

@@ -47,4 +43,4 @@ };

pollster.polls = function(params, callback) {
_invoke('polls/', params, function(result){
callback(result);
_invoke('polls/', params, function(resp){
callback(resp);
});

@@ -51,0 +47,0 @@ };

@@ -5,3 +5,3 @@ {

"author": "Casey Thomas <c@cpt.ph>",
"version": "0.0.1",
"version": "0.0.2",
"main": "lib/pollster",

@@ -8,0 +8,0 @@ "repository": {

@@ -7,6 +7,50 @@ # node-pollster

npm install pollster
npm install pollster
## Getting Started
var pollster = require('pollster')
var pollster = require('pollster')
See the current estimate of the president's job approval
pollster.charts({topic: 'obama-job-approval'}, function(resp){
console.log(resp[0].estimates);
});
List charts about 2012 Senate races
pollster.charts({topic: '2012-senate'}, function(resp){
console.log(resp);
});
List charts about Wisconsin
pollster.charts({state: 'WI'}, function(resp){
console.log(resp);
});
Calculate the margin between Obama and Romney from a recent general election poll
pollster.polls({chart: '2012-general-election-romney-vs-obama'}, function(resp){
var poll = resp[0],
responses = poll.questions.filter(function(q) {
return q.chart === '2012-general-election-romney-vs-obama';
})[0].subpopulations[0].responses,
obama = responses.filter(function(r) { return r.choice === 'Obama'; })[0],
romney = responses.filter(function(r) { return r.choice === 'Romney'; })[0];
console.log(obama.value - romney.value);
});
See the methodology used in recent polls about the Affordable Care Act
pollster.polls({chart:'us-health-bill'}, function(resp){
console.log(resp.map(function(p) { return [p.pollster, p.method]; }));
});
## License
See [LICENSE](https://github.com/caseypt/node-pollster/blob/master/LICENSE).
The Huffington Post Pollster API is licensed under the [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US). See [this page](http://elections.huffingtonpost.com/pollster/api) for additional license and usage information.
Not affiliated with the Huffington Post.
var pollster = require('../lib/pollster');
var assert = require('assert');
/*pollster.charts({'state': 'PA'}, function(result){
console.log(result);
pollster.chart('2012-general-election-romney-vs-obama', function(resp){
assert.equal(resp.state, 'US', 'General election chart test failed');
});
pollster.chart('2012-pennsylvania-gop-primary', function(result){
console.log(result);
});*/
pollster.polls({}, function(resp) {
assert.equal(resp.length, 10, 'Poll page size test failed');
});
pollster.polls({'state': 'PA', 'topic': '2012-house'}, function(result){
console.log(result);
pollster.chart('invalid-slug', function(resp) {
assert.ok(resp.errors, 'Invald slug test failed');
});
pollster.chart('2012-iowa-gop-primary', function(resp) {
assert.ok(Array.isArray(resp.estimates_by_date), 'Estimate by date test failed');
});

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