Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from justbill2020/main
Browse files Browse the repository at this point in the history
update moment.js version and create nodejs example
  • Loading branch information
justbill2020 committed Feb 26, 2021
2 parents 0ad5f84 + 214b742 commit 79bfe3b
Show file tree
Hide file tree
Showing 7 changed files with 36,136 additions and 496 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ Feel free to [open a new issue](https://github.com/SeverinDK/moment-timer/issues
---
## Changelog
#### v1.3.1
Added nodejs example and increased minimum version of moment. See https://github.com/SeverinDK/moment-timer/issues/26
#### v1.3.0
Fixed issue where .stop() would not stop the timer. See https://github.com/SeverinDK/moment-timer/issues/20
#### v1.2.3
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moment-timer",
"version": "1.3.0",
"version": "1.3.1",
"description": "A moment.js plugin for timers setInterval & setTimeout.",
"main": "lib/moment-timer.js",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions example/index.html → example/browser/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>

<head>
<script src="vendor/moment.js"></script>
<script src="../lib/moment-timer.js"></script>
<script src="../vendor/moment.js"></script>
<script src="../../lib/moment-timer.js"></script>
</head>

<body>
Expand Down
33 changes: 33 additions & 0 deletions example/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const requirejs = require("../vendor/r.js")

requirejs.config({
packages: [{
name: 'moment',
location: '../vendor',
main: 'moment'
}]
})

let moment = requirejs('moment')
let timer = requirejs("../../lib/moment-timer.js")

let timeoutStartTick = new Date().getTime();
let timeout = moment.duration(1000).timer({
loop: false
},
function() {
console.log(`Timeout Callback fired ${(new Date().getTime() - timeoutStartTick)} ms after script was started.`);
});

let limit = 10
let intervalStartTick = new Date().getTime();
let interval = moment.duration(1, "seconds").timer({
loop: true,
wait: 2500,
executeAfterWait: true
},
function() {
limit --;
if (limit == 0) { interval.stop() }
console.log(`Interval Callback fired ${(new Date().getTime() - intervalStartTick)} ms after script was started.`);
});
6,157 changes: 5,666 additions & 491 deletions example/vendor/moment.js

Large diffs are not rendered by default.

0 comments on commit 79bfe3b

Please sign in to comment.