countingup 0.0.1 → 0.1.1
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/README.md +60 -0
- package/package.json +9 -2
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Countingup
|
|
2
|
+
Countingup is a simple but useful math library for JavaScript.
|
|
3
|
+
## Installation
|
|
4
|
+
Using npm:
|
|
5
|
+
```
|
|
6
|
+
$ npm install countingup
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
In Node.js
|
|
10
|
+
```javascript
|
|
11
|
+
const countingup = require('countingup')
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
# Counter class
|
|
15
|
+
The ``Counter`` class provides a tool to count numbers.
|
|
16
|
+
|
|
17
|
+
Initializing
|
|
18
|
+
```javascript
|
|
19
|
+
const Counter = countingup.Counter
|
|
20
|
+
const myCounter = new Counter()
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Counting
|
|
24
|
+
```javascript
|
|
25
|
+
myCounter.count()
|
|
26
|
+
console.log(myCounter.getCurrentNumber()) // 1
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Resetting
|
|
30
|
+
```javascript
|
|
31
|
+
myCounter.reset()
|
|
32
|
+
console.log(myCounter.getCurrentNumber()) // 0
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
# Bonus Features
|
|
36
|
+
Customizing the Increment
|
|
37
|
+
```javascript
|
|
38
|
+
myCounter.count()
|
|
39
|
+
console.log(myCounter.getCurrentNumber()) // 1
|
|
40
|
+
myCounter.count(3)
|
|
41
|
+
console.log(myCounter.getCurrentNumber()) // 4
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Customizing the Direction
|
|
45
|
+
This allows you to change the direction so it counts down and subtracts
|
|
46
|
+
```javascript
|
|
47
|
+
myCounter.reset()
|
|
48
|
+
myCounter.count(5)
|
|
49
|
+
console.log(myCounter.getCurrentNumber()) // 5
|
|
50
|
+
myCounter.count(5, 'reverse') // 0
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Customizing the Starting Number
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
const myCounter2 = new Counter(4)
|
|
57
|
+
console.log(myCounter2.getCurrentNumber()) // 4
|
|
58
|
+
myCounter2.reset(3)
|
|
59
|
+
console.log(myCounter2.getCurrentNumber()) // 3
|
|
60
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "countingup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Math Utils for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -8,5 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {},
|
|
10
10
|
"author": "Samuel Fox J.",
|
|
11
|
-
"license": "UNLICENSED"
|
|
11
|
+
"license": "UNLICENSED",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"math",
|
|
14
|
+
"js",
|
|
15
|
+
"utils",
|
|
16
|
+
"problems",
|
|
17
|
+
"calculations"
|
|
18
|
+
]
|
|
12
19
|
}
|