Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@weedzcokie/scheduler

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@weedzcokie/scheduler - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

12

dist/main.d.ts
/// <reference types="node" resolution-mode="require"/>
export interface Task {
export interface Task<T = unknown> {
name: string;
fn: () => unknown | Promise<unknown>;
fn: () => T | Promise<T>;
timeout: undefined | NodeJS.Timeout;
getNextExecutionTime: () => number;
errorHandler?: (err: unknown) => unknown;
successHandler?: (result: T) => unknown;
}

@@ -14,4 +15,9 @@ export declare const msInHour = 3600000;

export declare function msUntilNextDay(): number;
export declare function schedule(name: string, fn: () => number, period?: () => number, errorHandler?: Task["errorHandler"]): void;
interface ScheduleOpts {
errorHandler?: Task["errorHandler"];
successHandler?: Task["successHandler"];
}
export declare function schedule(name: string, fn: () => number, period?: Task["getNextExecutionTime"], opts?: ScheduleOpts): void;
export declare function stopTask(name: string): boolean;
export declare function rescheduleTask(name: string, period?: Task["getNextExecutionTime"]): boolean;
export {};

@@ -20,3 +20,4 @@ export const msInHour = 3600000;

try {
await task.fn();
const result = await task.fn();
task.successHandler?.(result);
}

@@ -32,3 +33,3 @@ catch (err) {

const tasks = new Map();
export function schedule(name, fn, period = () => 1000, errorHandler) {
export function schedule(name, fn, period = () => 1000, opts = {}) {
const task = {

@@ -39,3 +40,4 @@ name,

getNextExecutionTime: period,
errorHandler,
errorHandler: opts.errorHandler,
successHandler: opts.successHandler,
};

@@ -42,0 +44,0 @@ task.timeout = setTimeout(runTask, task.getNextExecutionTime(), task);

{
"name": "@weedzcokie/scheduler",
"version": "1.0.6",
"version": "1.0.7",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,1 +0,3 @@

# nodejs-scheduler
# nodejs-scheduler
[![npm](https://img.shields.io/npm/v/@weedzcokie/scheduler?style=flat-square)](https://www.npmjs.com/package/@weedzcokie/scheduler)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc