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

lib-task-scheduler

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lib-task-scheduler - npm Package Compare versions

Comparing version 1.0.13 to 1.0.15

7

dist/src/index.d.ts

@@ -25,4 +25,7 @@ /// <reference types="node" />

*/
name: string;
name?: string;
}
export interface MomentDuration {
asMilliseconds(): number;
}
export interface Guard {

@@ -53,3 +56,3 @@ getExclusive(name: string, ttlSeconds: number): Promise<boolean>;

*/
schedule(task: Task, config: TaskConfig): void;
schedule(task: Task, configArg: MomentDuration | number | TaskConfig): void;
/**

@@ -56,0 +59,0 @@ * Begin a graceful shutdown of the scheduler. This will wait for all *actively* running

@@ -39,6 +39,35 @@ "use strict";

*/
schedule(task, config) {
schedule(task, configArg) {
if (this.isShutdown) {
throw new Error('Scheduler has been shutdown.');
}
let config;
if (!configArg) {
throw new Error('Schedule config (second argument) is required.');
}
else if (_.isFunction(configArg.asMilliseconds)) {
config = {
intervalMs: configArg.asMilliseconds(),
};
}
else if (_.isInteger(configArg)) {
config = {
intervalMs: configArg,
};
}
else if (_.isInteger(_.get(configArg, 'intervalMs'))) {
config = configArg;
}
else {
throw new Error('Schedule config (second argument) must be an duration, number, or object with intervalMs.');
}
if (!config.name && _.has(task, 'name')) {
config.name = task.name;
}
else if (!config.name && _.has(task, 'constructor.name')) {
config.name = task.constructor.name;
}
else if (!config.name) {
throw new Error('Task must be configured with a name (either through its TaskConfig, a name property, or having a named constructor)');
}
if (config.intervalMs <= 0) {

@@ -45,0 +74,0 @@ throw new Error('Task interval must be greater than zero.');

{
"name": "lib-task-scheduler",
"version": "1.0.13",
"version": "1.0.15",
"description": "A lightweight, modular task scheduler.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/convoyinc/lib-task-scheduler",

Sorry, the diff of this file is not supported yet

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