New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shared-tick

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shared-tick

Run function in same setInterval

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

SharedTick.js

Run function in same setInterval

Installation

use npm

npm install shared-tick --save

use yarn

yarn add shared-tick

use pnpm

pnpm install shared-tick

Usage

run function per second

import { runTick } from 'shared-tick'

const onTick = () => {
  // do something per second
}

runTick({onTick})

run function per 3 second

import { runTick } from 'shared-tick'

const onTick = () => {
  // do something per second
}

runTick({onTick, tick: 3000})

stop runner

import { stopTickRunner, runTick } from "shared-tick"

const id = runTick({...})
stopTickRunner(id)

restart runner

import { stopTickRunner, , startTickRunner, runTick } from "shared-tick"

const id = runTick({...})
stopTickRunner(id)

// restart runner after 5sec
setTimeout(() => startTickRunner(id), 5000)

API

runTick

runTick(config)

Parameter

FieldTypeDefaultRequirementDescription
ticknumber1000NoRunning interval time
idsymbolSymbol()NoIdentifying objects
onTick(t: number) => voidNoYesRunner function, The first parameter is the current timestamp

stopTickRunner

stopTickRunner(id: symbol)

stopTickRunner

startTickRunner(id: symbol)

License

The files included in this repository are licensed under the MIT license.

FAQs

Package last updated on 07 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts