countingup 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/lib/Counter.js +0 -36
package/package.json
CHANGED
package/lib/Counter.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
function Counter(base) {
|
|
2
|
-
if (base == null || !Number.isFinite(base)) base = 0
|
|
3
|
-
var counter = base
|
|
4
|
-
this.reset = function(base) {
|
|
5
|
-
if (base == null || !Number.isFinite(base)) base = 0
|
|
6
|
-
counter = base
|
|
7
|
-
return this
|
|
8
|
-
}
|
|
9
|
-
this.getCurrentNumber = function() {
|
|
10
|
-
return counter
|
|
11
|
-
}
|
|
12
|
-
this.count = function(increment, direction) {
|
|
13
|
-
if (increment == null) increment = 1
|
|
14
|
-
if (direction == null) direction = 'forwards'
|
|
15
|
-
if (!Number.isFinite(increment) || !Number.isInteger(increment)) {
|
|
16
|
-
return console.error('Invalid increment')
|
|
17
|
-
}
|
|
18
|
-
switch (direction) {
|
|
19
|
-
case 'forwards': {
|
|
20
|
-
counter += increment
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
case 'backwards' || 'reverse': {
|
|
25
|
-
counter -= increment
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
default: {
|
|
30
|
-
return console.error('Invalid direction')
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = Counter
|