JSPM

@nexim/task-scheduler

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 83
  • Score
    100M100P100Q84135F
  • License AGPL-3.0-only

A TypeScript task scheduler with persistence and conditional execution.

Package Exports

  • @nexim/task-scheduler

Readme

@nexim/task-scheduler

NPM Version npm bundle size Build & Lint & Test NPM Downloads NPM License

Overview

@nexim/task-scheduler provides a TypeScript task scheduler with persistence and conditional execution. It allows you to schedule recurring tasks with localStorage persistence, conditional execution, and duration-based intervals.

Installation

Install the package using npm or yarn:

npm install @nexim/task-scheduler

# Or using yarn
yarn add @nexim/task-scheduler

Usage

import { taskScheduler } from '@nexim/task-scheduler';

// Add a task that runs every 5 minutes
taskScheduler.addTask(
  'data-sync',
  async () => {
    console.log('Syncing data...');
    // Your task logic here
  },
  '5m',
  {
    shouldRun: () => navigator.onLine, // Only run when online
  },
);

// Update last run timestamp
taskScheduler.updateLastRun('data-sync');

// Remove a task
taskScheduler.removeTask('data-sync');

Features

  • Duration-based intervals: Use human-readable durations like '5m', '1h', '2d'
  • Persistence: Task states are persisted in localStorage
  • Conditional execution: Optional conditions to check before running tasks
  • Error handling: Graceful error handling with logging
  • TypeScript support: Full TypeScript support with type safety

Documentation

Read full documentation here.