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

@jayarjo/scheduler

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jayarjo/scheduler - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "@jayarjo/scheduler",
"version": "1.0.1",
"version": "1.0.2",
"description": "Schedule a task to execute after some period, regularly with a given interval, just given amount of times, or simply until it succeeds.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -1,1 +0,16 @@

# taskscheduler
# scheduler
```js
import { scheduler } from '@jayarjo/scheduler'
// run once in certain amount of time units (milliseconds by default)
scheduler.runIn(fn, 5000) // invoke fn in 5 secs
// run consequently with the specified interval
const taskId = scheduler.runEvery(fn, 1000) // invoke every second
// task can be removed if required after certain amount of time
setTimeout(() => {
scheduler.removeTask(taskId)
}, 5000)
```

@@ -54,2 +54,13 @@ import { TimeUnits } from './Task'

test('runEvery()', done => {
const spy = jest.fn(() => Promise.resolve('success'))
scheduler.runEvery(spy, 1000)
setTimeout(() => {
expect(spy).toHaveBeenCalledTimes(3)
done()
}, 3000)
})
test('addTask(schema)', done => {

@@ -56,0 +67,0 @@ const spy = jest.fn().mockResolvedValue('success')

@@ -66,11 +66,10 @@ import { random } from './Utils'

fn: Function,
amount: number,
interval: number,
unit?: TimeUnits,
repeatTimesBeforeFail?
): string {
const at = Date.now() + (unit ? amount * unit : amount)
return this.addTask(
new Task({
fn,
at,
interval: unit ? interval * unit : interval,
repeatTimesBeforeFail

@@ -77,0 +76,0 @@ })

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