JSPM

tinychrono

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q14599F
  • License MIT

Create short operation hour range

Package Exports

  • tinychrono

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tinychrono) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Tiny Chrono

Create short operation hour range

Tests

Installation

npm install tinychrono

Basic Usage

Single day

const { formatTimeRange } = require('tinychrono');

const content = formatTimeRange({
  day: 1,
  type: 'RANGE',
  hours: [
    [830, 1200],
    [1300, 1740],
  ],
});

console.log(content);
// Monday - 08:30 AM-12:00 PM, 01:00 PM-05:40 PM

Multiple Days

const { formatDays } = require('tinychrono');

const content = formatDays([
  {
    day: 1,
    type: 'RANGE',
    hours: [
      [830, 1200],
      [1300, 1740],
    ],
  },
  {
    day: 5,
    type: 'FULL_DAY',
  },
  {
    day: 6,
    type: 'CLOSED',
  },
  {
    day: 0,
    type: 'RANGE',
    hours: [[700, 1100]],
  },
]);

console.log(content);

// Monday - 08:30 AM-12:00 PM, 01:00 PM-05:40 PM
// Friday - Open 24/7
// Saturday - Closed
// Sunday - 07:00 AM-11:00 AM

Milestone

  • Format Days
  • Parse string to day objects
  • Use Rollup to build ESM and UMD
  • types.d.ts
  • Expose utility functions