while2 2.0.1 → 2.0.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/README.md +4 -4
- package/index.js +1 -1
- package/package.json +29 -29
- package/t.js +8 -0
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ To use while2, first import the module. It is recommended to call it `w2`.
|
|
|
14
14
|
const w2 = require('while2')
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
For every while2 statement, you will create a new instance of `w2`, as it is a class, and pass a condition. For everything that you want to run while the condition is true, put `.do(...)` and then pass in a function in the parentheses. Always type `.end()`at the end to run the while loop or it won't work
|
|
17
|
+
For every while2 statement, you will create a new instance of `w2`, as it is a class, and pass a condition. The condition must be a function that returns something. For everything that you want to run while the condition is true, put `.do(...)` and then pass in a function in the parentheses. Always type `.end()`at the end to run the while loop or it won't work
|
|
18
18
|
|
|
19
19
|
```javascript
|
|
20
20
|
const w2 = require('while2')
|
|
21
21
|
|
|
22
|
-
new w2(true) // equivalent to while (true)
|
|
22
|
+
new w2(() => true) // equivalent to while (true)
|
|
23
23
|
.do(() => {
|
|
24
24
|
// anything here will run again and again forever
|
|
25
25
|
})
|
|
@@ -33,7 +33,7 @@ While2 includes an i parameter that will automatically increment every time the
|
|
|
33
33
|
```javascript
|
|
34
34
|
const w2 = require('while2')
|
|
35
35
|
|
|
36
|
-
new w2(true)
|
|
36
|
+
new w2(() => true)
|
|
37
37
|
.do(i => {
|
|
38
38
|
console.log(i) /* will print 1 2 3 4 5 6 7... */
|
|
39
39
|
})
|
|
@@ -47,7 +47,7 @@ While2 includes a `breakLoop` parameter function so that you can break your whil
|
|
|
47
47
|
```javascript
|
|
48
48
|
const w2 = require('while2')
|
|
49
49
|
|
|
50
|
-
new w2(true)
|
|
50
|
+
new w2(() => true)
|
|
51
51
|
.do((i, breakLoop) => {
|
|
52
52
|
if (i > 3) breakLoop() // prints 0, 1, 2, 3 then stops
|
|
53
53
|
console.log(i)
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "while2",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "while in fp",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"while",
|
|
7
|
-
"while2",
|
|
8
|
-
"declaration",
|
|
9
|
-
"statement"
|
|
10
|
-
],
|
|
11
|
-
"homepage": "https://github.com/in-fp/while2#readme",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/in-fp/while2/issues"
|
|
14
|
-
},
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/in-fp/while2.git"
|
|
18
|
-
},
|
|
19
|
-
"license": "UNLICENSED",
|
|
20
|
-
"author": "me",
|
|
21
|
-
"type": "commonjs",
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"directories": {
|
|
24
|
-
"lib": "lib"
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "while2",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "while in fp",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"while",
|
|
7
|
+
"while2",
|
|
8
|
+
"declaration",
|
|
9
|
+
"statement"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/in-fp/while2#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/in-fp/while2/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/in-fp/while2.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"author": "me",
|
|
21
|
+
"type": "commonjs",
|
|
22
|
+
"main": "index.js",
|
|
23
|
+
"directories": {
|
|
24
|
+
"lib": "lib"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
|
+
}
|
|
29
|
+
}
|