Socket
Socket
Sign inDemoInstall

snoostorm

Package Overview
Dependencies
58
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    snoostorm

A streaming client for reddit, based off of snoowrap


Version published
Weekly downloads
42
decreased by-41.67%
Maintainers
1
Install size
6.71 MB
Created
Weekly downloads
 

Readme

Source

SnooStorm

Event-based wrapper around snoowrap

Usage

Basic Usage:

import { InboxStream, CommentStream, SubmissionStream } from "snoostorm";
import Snoowrap from "snoowrap";

const creds = require("./credentials.json");

const client = new Snoowrap(creds);

// Options object is a Snoowrap Listing object, but with subreddit and pollTime options
const comments = new CommentStream(client, {
  subreddit: "AskReddit",
  limit: 10,
  pollTime: 2000,
});
comments.on("item", console.log);

const submissions = new SubmissionStream(client, {
  subreddit: "AskReddit",
  limit: 10,
  pollTime: 2000,
});
submissions.on("item", console.log);

const inbox = new InboxStream(client);
inbox.on("item", console.log);

inbox.end();
inbox.on("end", () => console.log("And now my watch has ended"));

Custom Polls

Out of the box, snoostorm supports the following objects:

  • Comments
  • Submissions
  • Inbox
  • Modmail

If you would like to poll another object in snoowrap, you can implement your own Poll easily. For example, here is an implementation that will poll for new friends:


import { Poll } from "snoostorm"

export interface FriendStreamOptions {
  pollTime?: number;
}

export class FriendStream extends Poll<Snoowrap.RedditUser> {
  constructor(
    client: Snoowrap,
    options: FriendStreamOptions = { pollTime: 2000 }
  ) {
    super({
      frequency: options.pollTime,
      get: () => client.getFriends(),
      identifier: "name",
    });
  }
}

const friends = new FriendStream(client);

friends.on("item", (item) => {
  console.log("New Friend!", item.name);
});


Keywords

FAQs

Last updated on 26 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc