UNPKG

key-interval

Version:

You can set or clear time interval with key. It's like setInterval and clearInterval. You must use a keyword 'new' because it is class object.

19 lines (13 loc) 428 B
const KeyInterval = require('./index.js'); const runTest = () => { const SETTIME = 1000; const ENDTIME = 3500; const KEY = 'test'; const RUNNING = '✅ Running three times.\nSetting time is 1s.\nIt will be stoped after 3.5s from first output.\n'; const test = new KeyInterval(); const cb = (str) => console.log(str); test.setTimeInterval(cb, [RUNNING], KEY, SETTIME); test.setEndTime(KEY, ENDTIME); }; runTest();