# events-series

> Uses logic from [rrule](https://github.com/jakubroztocil/rrule) to handle logic for updating recurring events.

Latest version **0.0.3** (published 2019-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install events-series
pnpm add events-series
yarn add events-series
bun add events-series
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-06-10 |
| First published | 2019-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 5 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eventive |
| Maintainers | epicfaace |

## Links

- npm: https://www.npmjs.com/package/events-series
- npm.io page: https://npm.io/package/events-series

## Dependencies (5)

- [luxon](https://npm.io/package/luxon.md) ^1.16.0
- [rrule](https://npm.io/package/rrule.md) ^2.6.2
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [mockdate](https://npm.io/package/mockdate.md) ^2.0.2
- [@types/luxon](https://npm.io/package/@types/luxon.md) ^1.15.1

## Recent versions

- 0.0.3 (latest) — 2019-06-10
- 0.0.2 — 2019-06-10

## README

# events-series

Uses logic from [rrule](https://github.com/jakubroztocil/rrule) to handle logic for updating recurring events.

You have a bunch of events generated from a particular recurrence. But then you change the recurrence -- what do you do? events-series handles this logic for you.

## Sample usage

```js
import Series from "events-series";
import moment from "moment";
import { RRule } from "rrule";

// Initialization with a list of events. Times are in UTC.
const events = [
    {
        start: moment("2019-05-01T03:00:00.000Z").toDate(),
        end: moment("2019-05-01T03:00:00.000Z").toDate()
    },
    {
        start: moment("2019-05-01T03:00:00.000Z").toDate(),
        end: moment("2019-05-01T03:00:00.000Z").toDate()
    }
];
const series = new Series(events, options);

// Set recurrence for event (as an RRule string). If using timezones, tzid should be specified, and dtstart and until should be in the local timezone (in this case, America/Los_Angeles).
const rrule = new RRule({
    freq: RRule.DAILY,
    interval: 1,
    dtstart: moment("2019-05-01T03:00:00.000Z").toDate(),
    until: moment("2019-05-03T03:00:00.000Z").toDate(),
    tzid: "America/Los_Angeles"
});
series.setRecurrence(rrule.toString());
// Get all current events in the series:
series.getEvents()
// Get all events created by the previous operation:
series.getCreated()
// Get all events deleted by the previous operation:
series.getDeleted()

// Set length of all events to a particular duration, keeping the start times constant (and only varying the end time).
series.setLength(moment.duration(2, 'hours').asMilliseconds());
// Get all events updated by the previous operation:
series.getUpdated()


// Split the series into two (includes events that start at the current time).
const {past, future} = series.split(moment("2019-05-02T03:00:00.000Z").toDate());
// Set all future events' length to 1 hour.
future.setLength(moment.duration(2, 'hours').asMilliseconds());

```

## Options config
```
const options = {
    maxRepeats: 100, // Maximum number of repeats generated when applying an rrule to a series.
    length: 10000, // Length in milliseconds of new dates to be added. If not specified, defaults to the length of the first event, or 0.
}
```

---
_Source: https://npm.io/package/events-series · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
