Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Latest commit

 

History

History
58 lines (37 loc) · 1.35 KB

README.md

File metadata and controls

58 lines (37 loc) · 1.35 KB

Availability lib

Introduction

This package is use for:

  • Cheking the given time is available or not with configured availability slots.
  • Find the next available time with the given time

APIs

Initiate a availability service

import { AvailabilityService } from "availability-lib";

const service = new AvailabilityService(from, to);

// from, to is moment instance

Add an unavailable event

import { AvailabilityService, Interval } from "availability-lib";

const service = new AvailabilityService(from, to);
service.setUnAvailability(from, to, Interval.ONCE);

// from, to: moment instance
// Interval: Enum {"ONCE", "DAILY", "WEEKLY", "MONTHLY", "YEARLY" }

NOTE: Currently, from and to should be in the same date. Will make improvement to set in difference day

Check if the given time is available or not

import { AvailabilityService, Interval } from "availability-lib";

const service = new AvailabilityService(from, to);
const result = service.isAvailable(from, to);

// from, to: moment instance
// result: boolean

Check if when is the next available with the given time

import { AvailabilityService, Interval } from "availability-lib";

const service = new AvailabilityService(from, to);
const result = service.getNextAvailability(time);

// time: moment instance
// result: Moment instance