1.0.5 • Published 5 years ago

snoostorm-es6 v1.0.5

Weekly downloads
363
License
-
Repository
github
Last release
5 years ago

snoostorm-es6

event-based wrapper around snoowrap
fork of SnooStorm

usage

setup:

'use strict';

const snoowrap = require('snoowrap');
const snoostorm = require('snoostorm-es6');

const options = {
    userAgent: "<user agent>",
    clientSecret: "<client secret>",
    clientId: "<client id>",
    username: "<username>",
    password: "<password>"
};

const r = new snoowrap(options);
const s = new snoostorm(r);

comment streaming

const comments = s.Stream("comment", {
  subreddit: "all",
  results: 100, // defaults to 25, max is 100
  pollTime: 5000
});

comments.on("item", item => {
  console.log(item);
});

submission streaming

const submissions = s.Stream("submission", {
  subreddit: "asoiaf",
  pollTime: 10000
});

submissions.on("item", item => {
  console.log(item.title);
});

inbox streaming

// filter one of "inbox" (default), "unread", "messages", "comments", "selfreply", or "mentions"
const mentions = s.Stream("inbox", {
  filter: "mentions"
});

mentions.on("item", item => {
  console.log(item.author.name);
});

error handling

comments.on("error", e => {
  console.log(e); // stop breaking the rate-limit
});

ending a stream

comments.on("end", () => {
  console.log("your one hour comment stream has ended.");
});

setTimeout(() => {
  comments.emit("end");
}, 3600000);
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago