@tictuk/item-availability
v1.2.0
Published
Provides functions to check availability
Downloads
3,093
Readme
Item Availability Package
It's a simple package that implements availability checking.
Usage
import { isAvailableNow, isAvailable } from '@tictuk/item-availability';
const availability = {
weekly: [],
exceptions: [],
};
console.log(isAvailableNow(availability)); // true
console.log(isAvailable(availability, new Date(2022, 4, 1))); // true
You can also pass Item objects directly
import {
isItemAvailable,
isItemAvailableNow,
Item,
} from '@tictuk/item-availability';
const item: Item = {
condition: {
conditions: [
{},
{},
{},
{
weekly: [],
exceptions: [],
},
],
},
};
console.log(isItemAvailableNow(item)); // true
console.log(isItemAvailable(item, new Date(Date.now()))); // The date has to be UTC timezone