countingup 0.2.2 → 0.2.4

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.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/lib/index.js +11 -7
  3. package/package.json +10 -2
package/README.md CHANGED
@@ -48,8 +48,9 @@ This allows you to change the direction so it counts down and subtracts
48
48
  myCounter.reset()
49
49
  myCounter.count(5)
50
50
  console.log(myCounter.getCurrentNumber()) // 5
51
- myCounter.count(5, 'backwards') // 0
51
+ myCounter.count(5, countingup.DIRECTION.REVERSE) // 0
52
52
  ```
53
+ By default it will be forwards (countingup.DIRECTION.FORWARDS)
53
54
 
54
55
  Customizing the Starting Number
55
56
 
@@ -58,4 +59,4 @@ const myCounter2 = new Counter(4)
58
59
  console.log(myCounter2.getCurrentNumber()) // 4
59
60
  myCounter2.reset(3)
60
61
  console.log(myCounter2.getCurrentNumber()) // 3
61
- ```
62
+ ```
package/lib/index.js CHANGED
@@ -1,4 +1,8 @@
1
- module.exports = mathUtils = {
1
+ module.exports = countingup = {
2
+ DIRECTION: {
3
+ FORWARDS: 'forwards',
4
+ REVERSE: 'reverse'
5
+ },
2
6
  Counter: function Counter(base) {
3
7
  if (base == null || !Number.isFinite(base)) base = 0
4
8
  var counter = base
@@ -12,25 +16,25 @@ module.exports = mathUtils = {
12
16
  }
13
17
  this.count = function(increment, direction) {
14
18
  if (increment == null) increment = 1
15
- if (direction == null) direction = 'forwards'
19
+ if (direction == null) direction = countingup.DIRECTION.FORWARDS
16
20
  if (!Number.isFinite(increment) || !Number.isInteger(increment)) {
17
21
  return console.error('Invalid increment')
18
22
  }
19
23
  switch (direction) {
20
- case 'forwards': {
24
+ case countingup.DIRECTION.FORWARDS: {
21
25
  counter += increment
22
26
  return
23
27
  }
24
-
25
- case 'backwards' || 'reverse': {
28
+
29
+ case countingup.DIRECTION.REVERSE: {
26
30
  counter -= increment
27
31
  return
28
32
  }
29
-
33
+
30
34
  default: {
31
35
  return console.error('Invalid direction')
32
36
  }
33
37
  }
34
38
  }
35
39
  }
36
- }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "countingup",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Counter Class for JavaScrippt",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -15,5 +15,13 @@
15
15
  "utils",
16
16
  "problems",
17
17
  "calculations"
18
- ]
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/tj-commits/countingup.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/tj-commits/countingup/issues"
25
+ },
26
+ "homepage": "https://github.com/tj-commits/countingup#readme"
19
27
  }