timeslot-availability

1.0.2 • Public • Published

timeslot-availability

Find availability around events

npm install timeslot-availability

or

yarn add timeslot-availability

Given events, which it will merge, it will find availability in a timeframe.

const availability = require('.');

const start = new Date('2019-08-08T08:00:00.000Z');
const end = new Date('2019-08-08T16:00:00.000Z');
const timespan = 30 * 60; // 30 minutes

const siestas = [
  {
    start: '2019-08-08T09:00:00.000Z',
    end: '2019-08-08T12:00:00.000Z',
  },
  {
    start: '2019-08-08T10:00:00.000Z',
    end: '2019-08-08T12:00:00.000Z',
  },
  {
    start: '2019-08-08T13:00:00.000Z',
    end: '2019-08-08T14:00:00.000Z',
  },
];

const bookable = availability(start, end, timespan, siestas);

console.log(bookable);

[ 
  { start: 2019-08-08T08:00:00.000Z,
    end: 2019-08-08T08:30:00.000Z },
  { start: 2019-08-08T08:30:00.000Z,
    end: 2019-08-08T09:00:00.000Z },
  { start: 2019-08-08T12:00:00.000Z,
    end: 2019-08-08T12:30:00.000Z },
  { start: 2019-08-08T12:30:00.000Z,
    end: 2019-08-08T13:00:00.000Z },
  { start: 2019-08-08T14:00:00.000Z,
    end: 2019-08-08T14:30:00.000Z },
  { start: 2019-08-08T14:30:00.000Z,
    end: 2019-08-08T15:00:00.000Z },
  { start: 2019-08-08T15:00:00.000Z,
    end: 2019-08-08T15:30:00.000Z },
  { start: 2019-08-08T15:30:00.000Z,
    end: 2019-08-08T16:00:00.000Z } 
]

Package Sidebar

Install

npm i timeslot-availability

Weekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

10 kB

Total Files

12

Last publish

Collaborators

  • webjay