0.1.0 • Published 6 years ago

set-variable-interval v0.1.0

Weekly downloads
7
License
-
Repository
github
Last release
6 years ago

set-variable-interval

Install

npm i set-variable-interval

Usage

const clearFn = setVariableInterval(fn, intervalFn, ...params)
  • fn [function] Code to execute
  • intervalFn [function] Function to provide the next interval to be used

    (last) => { return (/*next*/) }
    • last Last return value of this function

      Must return a value to be used as next interval

  • params Params passed to fn

  • (returns) clearFn [function] To clear the interval

Example

const setVariableInterval = require('set-variable-interval');

const clear = setVariableInterval(() => {
  console.log(new Date().split('T')[1]);
}, (i = 0) => i + 200);
00:00:00.000Z
00:00:00.200Z
00:00:00.600Z
00:00:01.200Z
00:00:02.000Z
00:00:03.000Z
00:00:04.200Z
00:00:05.600Z
...