Yet another cron clone – but this one is better :o) - new improved syntax – milliseconds resolution – both for node JS and browser
npm install timexe``javascript`
timexe(” * 12”, function(){console.log(“hello - it is noon again”)});
The time expression syntax is like cron, but in reverse order: starting with year, month... (where as cron start with minutes, hours...) plus some enhancements.
or a time stamp.
Each field contain wild-cards, ranges, sets, not flags and every flags. Plus some special flags for year days and week days.
The epoch timestamp is seconds since 1970-01-01 UTC with fractions of second as decimal part:
@
##### Field syntax: [!][-]`
space : field separator
* : all values. Flags will be ignored.
! : not
/ : every (can not be combined with ! and range)
- : Negative values are counted back from the maximum value
a-b : range. both a and b included.
a,b : set of values
Day field can have the one of the following flags as well
y: day of year
w: day of week 1-7 (1 is Monday)
`
Unspecified minor fields are assumed to have the lowest possible value
Returns a result object:
``
{
result: “ok” or null
error: A failure explanation or null
id: integer used to identify the timer
}
##### timexe.remove(id)
where id is the value returned from timexe
Returns a result object:
``
{
result: “ok” or null
error: A failure explanation or null
}
##### timexe.get([id])
where the optional id is the value returned from timexe
Returnes either a timexe timer object if id is given, or an array of all active timer objects.
##### timexe.maxTimerDelay (integer)
Maximum run time of a setTimeout call. Some javascripts engines cant handle more then 32 bit = 0x7FFFFFF. thats about 28 days. default is 86400000 = 1 day.
When this time have elapsed, the time expression are reevaluated.
bash
$ npm install timexe
`
#### Use
`js
var timexe = require('timexe');// Add
var res1=timexe(” * 12”, function(){console.log(“hello wolrd”)});
// Remove
var res2=timexe.remove(res1.id);
`
With HTML & javascript
---
#### Install
Copy files to folder.#### Use
`html
``1.0.3 Bugfix: mismatched ID
1.0.2 Temp bugfix of mismatched ID.
1.0.1 Documentation
1.0.0 Fixed test cases:
"Cascading carry" failed
"Only Wildcards = every hour" failed
Documentation
0.9.19 Bug fix. failed when "processs" undefined
0.9.18 Documentation update.
0.9.14 A quick code review. No bugs repported for 2 years.
0.9.13 Minor changes to timex.js
0.9.12 Minor changes to comments and reamne.md
0.9.11 Minor changes to comments and reamne.md
0.9.10 Adapted example to runkit
0.9.9 Minor bugfix. timexe.list made into a regular array.
#### Help
Please don't hesitate to submit an issue on github! It's the only way to make it better.
But please be prepared to present a test case.
Contributions of almost any kind are welcome.