No description
Find a file
2016-04-30 15:23:56 -04:00
.editorconfig create project 2016-04-27 15:06:24 -04:00
.gitattributes create project 2016-04-27 15:06:24 -04:00
.gitignore create project 2016-04-27 15:06:24 -04:00
.travis.yml speed up travis 2016-04-27 15:13:55 -04:00
index.js add all as an event emitter 2016-04-28 22:23:21 -04:00
license create project 2016-04-27 15:06:24 -04:00
package.json add all as an event emitter 2016-04-28 22:23:21 -04:00
readme.md fix file extension in result 2016-04-30 15:23:56 -04:00
test.js add all as an event emitter 2016-04-28 22:23:21 -04:00

random-puppy Build Status

Get a random puppy image url.

Install

$ npm install --save random-puppy

Usage

const randomPuppy = require('random-puppy');

randomPuppy()
    .then(url => {
        console.log(url);
    })

//=> 'http://imgur.com/IoI8uS5.jpg'

API

randomPuppy()

Returns a promise for a random puppy image url from http://imgur.com/ from https://www.reddit.com/r/puppy

randomPuppy(subreddit)

Returns a promise for a random image url from the selected subreddit. Warning: We cannot promise it will be a image of a puppy!

randomPuppy.all(subreddit)

Returns an eventemitter for getting all random images for a subreddit.

const event = randomPuppy.all(subreddit);
event.on('data', url => console.log(url));

Or:

const event = randomPuppy.all('puppies');

Observable.fromEvent(event, 'data')
    .subscribe(data => {
      console.log(data);
    });

Notes

  • Node 4 or newer.
  • Caches results from imgur in memory.
  • Created for the purpose of using in a training exercise on different ways to do async in JavaScript at Opower.

License

MIT © Dylan Greene