npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sec-block/secjs-circle

v1.0.2

Published

This libary used to sync the local time and ntp server time and caculate the working group number

Downloads

4

Readme

SECJSTimeCircle

js-standard-style

This libaray would be used to get the next working group, which shoud begin to work. This libary used dgram third-party libary to use udp protocoll, in case to send and get message from ntp server.

  • Using ntp server pool to uniform unix time
  • Every 30s switch to next group, which should to work

API

new secjsCircle(config)

Instance a circle object and selected the nearest ntp server based on the timezone

  • config: config json for instance

secjsCircle.initialCircle()

Initialize the timestamp, when the first group begin to work. Save the time stamp to attribute this.timeStampOfLastGroup

secjsCircle.getWorkingGroupNumber(callback)

This API is a aync method to get the next group number after a while

  • callback: a callback function to get the caculated working group number

secjsCircle.getNextGroupBeginTimeDiff(currentUnixTime, callback)

This function used to get the time of next group begin to work

secjsCircle.getNextPeriodeBeginTimeDiff(currentUnixTime, callback)

This function used to get the time of the next periode

Usage

To use the libary to get the next working group, you need to do following steps.

  1. Select the nearest ntp server
const SECjsCircle = require('<path of src>')
const config = {
  circleTimeOut: 30,
  ntpTryOut: 0,
  timeServer: 'DE',
  sumOfGroups: 10,
  isMiningHost: true
}
let secjsCircle = new SECjsCircle(config)
  1. Initialize the time stamp of the circle if the group at the first time begin to work
secjsCircle.initial(() => {
    // do something
})
  1. Get the next group number, which should begin to work
secjsCircle.getWorkingGroupNumber((nextWorkingGroupNumber) => {
    let workingGroupNumber = nextWorkingGroupNumber
    console.log(`The next working group should be ${workingGroupNumber}`)
})

License

MIT