> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackerjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# stacker

> Provides classes and utilities for creating digests and handling events.

## `Digest`

The `Digest` class is used to create a digest object which can group events together and send them at a specified time with a specified schedule.

### Constructor

```TypeScript theme={null}
new Digest(name: string, options: { cron: string; email: string; })
```

* **name**: The name of the digest.
* **options**:
  * **cron**: A cron string specifying the schedule.
  * **email**: The email address where the digest will be sent.

### Methods

```typescript theme={null}
push(data: GitHubEvent): void
```

* Pushes a GitHub event to the digest.

### Examples

```TypeScript theme={null}
import { Digest } from "stacker";

// At 9am every weekday this digest will be sent
const daily = new Digest("daily", {
  cron: "0 9 * * 1-5",
  email: "work@work.com",
});
 
// Every hour between 9am and 5pm every weekday this digest will be sent
const important = new Digest("important", {
  cron: "0 9-17 * * 1-5",
  email: "work@work.com",
});
```

## `events`

Provides a whay to handle events from various sources. Events can be pushed to a Digest or, if they are not important, you can just ignore them.

### Methods

```typescript theme={null}
on(source: string, callback: (event: GitHubEvent) => void): void
```

* Registers an event listener for a specified source.
* **source**: The source of the event.
  * The only supported source right now is `github`.
* **callback**: The callback function to handle the event.

### Examples

```typescript theme={null}
import { events } from "stacker";
import { type GitHubEvent, GitHubReasons } from "stacker/github";

events.on("github", (event: GitHubEvent) => {
  if (event.reason === GitHubReasons.Subscribed) {
    daily.push(event);
  } 
  // else ignore the event
});
```

## `settings`

### Methods

```typescript theme={null}
setTimezone(timezone: string): void
```

* Sets the timezone for the module.
* **timezone**: The timezone string.

### Examples

```typescript theme={null}
import { settings } from "stacker";

settings.setTimezone("America/New_York");
```
