npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@perdieminc/time-slots

v0.0.6

Published

Generate time slots for scheduling

Readme

@perdieminc/time-slots

Generate time slots for scheduling—pickup, delivery, and curbside—with timezone-aware business hours, prep time, and optional pre-sale / catering rules.

Requirements

  • Node.js ≥ 20
  • TypeScript (consumers can use the package from source or your built output)

Install

npm install @perdieminc/time-slots

Overview

This library helps you:

  • Build fulfillment schedules (days and time slots) for a given location and fulfillment type (pickup, delivery, curbside).
  • Respect business hours and overrides (e.g. holidays, special hours).
  • Apply prep time (per shift or per day) and slot gaps to compute the first available slot and generate slots.
  • Support pre-sale windows (date range and optional custom hours) and weekly pre-sale (fixed pickup/ordering days).
  • Support catering flows with cart-derived prep time (by minute, hour, or day).
  • Filter slots by busy times and optional menu/category rules.

All date/time logic is timezone-aware (e.g. America/New_York). The package supports multiple platforms for timezone handling: web (default, uses @date-fns/tz) and ios/android (uses timezone-support).

Main API

getSchedules(params): GetSchedulesResult

Builds the schedule for the current location and fulfillment preference.

Parameters (GetSchedulesParams):

| Field | Description | |-------|-------------| | store | Store config: ASAP/same-day flags, max future days, business hour overrides, pre-sale and weekly pre-sale config. | | locations | List of locations (with location_id, timezone, and business hours). | | cartItems | Cart items (used for pre-sale, weekly pre-sale, catering prep time, and category-based filtering). | | fulfillmentPreference | "PICKUP" | "DELIVERY" | "CURBSIDE". | | prepTimeSettings | Prep time in minutes, per-weekday overrides, gap, busy times, fulfillAtBusinessDayStart (when true, prep is by day; when false, by minutes), and optional delivery buffer. | | currentLocation | The location to generate the schedule for. | | isCateringFlow | If true, prep time is derived from cart catering config. | | platform | "web" | "ios" | "android" for timezone handling (default "web"). |

Returns: { schedule: FulfillmentSchedule, isWeeklyPreSaleAvailable: boolean }.

  • schedule is an array of day schedules, each with date, openingTime, closingTime, firstAvailableSlot, and slots (array of Date).

Types and constants

  • Fulfillment: FULFILLMENT_TYPES, FulfillmentType, FulfillmentSchedule, DaySchedule.
  • Prep time: PrepTimeBehaviour (first shift / every shift / roll), DEFAULT_PREP_TIME_IN_MINUTES, DEFAULT_GAP_IN_MINUTES, MINUTES_PER_DAY, PrepTimeSettings, PrepTimeCadence (minute / hour / day).
  • Store / cart: StoreConfig, PreSaleConfig, WeeklyPreSaleConfig, CartItem, PrepTimeSettings, CateringPrepTimeResult.
  • Location / hours: LocationLike, BusinessHour, BusinessHoursOverrideInput / Output, getLocationsBusinessHoursOverrides, getOpeningClosingTime.
  • Platform: PLATFORM (web, ios, android).

Utilities (exported)

  • getCateringPrepTimeConfig(params) – Derives prep time cadence and frequency from cart items for catering.
  • getPreSalePickupDates(pickupDays, orderingDays) – Dates when weekly pre-sale pickup is allowed.
  • isTodayInTimeZone(date, timezone) / isTomorrowInTimeZone(date, timezone) – Date checks in a given timezone.
  • overrideTimeZoneOnUTC(utcDate, timezone) – Interpret a UTC date in a store timezone.
  • filterBusyTimesFromSchedule({ schedule, busyTimes, cartCategoryIds }) – Remove busy blocks from a schedule.
  • filterMenusFromSchedule – Filter schedule by menu type.
  • getOpeningClosingTime(params) – Opening/closing time for a given date and business hours.

Internal schedule generation uses getNextAvailableDates-style logic (timezone-aware “next N open days”) and slot generation with configurable prep time behaviour and gap.

Prep time (high level)

Prep time is either by minutes or by day (e.g. in dashboard, when prep is set to “day”, it is treated as day-based).

  • By day: First slot is at business start (opening) on the next open day(s). Number of days is derived from prepTimeInMinutes (e.g. 1440 min = 1 day).
  • By minutes: First slot = order time + prep minutes, within store hours.
  • Per weekday: different prep minutes per day via weekDayPrepTimes (when not using day-based prep).
  • Catering: when isCateringFlow is true, cadence and frequency are derived from cart items via getCateringPrepTimeConfig.
  • Delivery: optional estimatedDeliveryMinutes added to weekday prep times for delivery.

QA-friendly test cases (Given / When / Expected) are in docs/TEST-CASES.md.

Scripts

npm run build        # Compile TypeScript
npm run test         # Run tests
npm run test:coverage
npm run lint         # Lint with Biome
npm run format       # Format with Biome

License

MIT © Per Diem Subscriptions Inc.

Repository