Code Monkey home page Code Monkey logo

interval-next's Introduction

Interval-next

Interval-next is a package that extends Javascript's built-in setInterval() capabilities. You have a plain and promisified interval method, which you can also use as a sleep code. It allows you to use human parseable time, such as 15 second or 20 minute, and also more complex times such as 1 day, 12 hour and 30 second, which you can take a look at more detailed examples down below. Functions returns the interval object itself, which you can use later to kill the interval with built-in clearInterval() method.

Example usage

IntervalNext .set(<callbackFn>, <human readable time>,<immediate: boolean>?)

const  IntervalNext  =  require("interval-next")

const  Interval  =  IntervalNext.set(()  =>  {

// do something

}), "1 day, 12 hour and 30 minute")

IntervalNext.setAsync(<callbackFn>, <human readable time>,<immediate: boolean>?)

const  IntervalNext  =  require("interval-next")

const  Interval  =  IntervalNext.setAsync(()  =>  {

// do something

}), "20 minute and 30 second", true)

Complex time parsing

Interval-next can understand and parse all of the following examples.

const  Interval  =  IntervalNext.set(()  =>  {}), "20 minute and 30 second")
const  Interval  =  IntervalNext.set(()  =>  {}), "1 hour, 45 minute and 30 second")
const  Interval  =  IntervalNext.set(()  =>  {}), "1 month, 15 day, 12 hour and 30 minute")
const  Interval  =  IntervalNext.set(()  =>  {}), "1 year, 6 month, 15 day hour, 12 hour and 15 second")

Accepted units

  • second

  • minute

  • hour

  • day

  • month (assumed 30 days)

  • year (assumed 365 days)

Plans

  • Adding an override support for human readable time, allowing to use numbers

  • Revamping readable time to make it more useful, by adding complex time parsing

  • Adding stopping and resuming to intervals

  • Adding killInterval() function, to enhance the capabilities of default clearInterval() method

interval-next's People

Contributors

kaanrkaraman avatar kuzeeeyk avatar

Stargazers

 avatar Aziz avatar Eren Demir avatar  avatar Bae avatar

Watchers

 avatar

Forkers

kuzeeeyk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.