@putout/plugin-for-of 12.5.1 → 12.5.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 +16 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ npm i @putout/plugin-for-of
|
|
|
34
34
|
- ✅ [remove-useless-variables](#remove-useless-variables);
|
|
35
35
|
- ✅ [to-for-n](#to-for-n);
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Config
|
|
38
38
|
|
|
39
39
|
```json
|
|
40
40
|
{
|
|
@@ -269,15 +269,13 @@ for (const x of Array.from(y)) {}
|
|
|
269
269
|
for (const x of y) {}
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
## for
|
|
272
|
+
## for-n
|
|
273
273
|
|
|
274
274
|
> The `for` statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement to be executed in the loop.
|
|
275
275
|
>
|
|
276
276
|
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for)
|
|
277
277
|
|
|
278
|
-
###
|
|
279
|
-
|
|
280
|
-
#### ❌ Example of incorrect code
|
|
278
|
+
### ❌ Example of incorrect code
|
|
281
279
|
|
|
282
280
|
```js
|
|
283
281
|
const n = items.length;
|
|
@@ -288,7 +286,7 @@ for (let i = 0; i < n; i++) {
|
|
|
288
286
|
}
|
|
289
287
|
```
|
|
290
288
|
|
|
291
|
-
|
|
289
|
+
### ✅ Example of correct code
|
|
292
290
|
|
|
293
291
|
```js
|
|
294
292
|
for (const item of items) {
|
|
@@ -296,9 +294,9 @@ for (const item of items) {
|
|
|
296
294
|
}
|
|
297
295
|
```
|
|
298
296
|
|
|
299
|
-
|
|
297
|
+
## for-length
|
|
300
298
|
|
|
301
|
-
|
|
299
|
+
### ❌ Example of incorrect code
|
|
302
300
|
|
|
303
301
|
```js
|
|
304
302
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -307,7 +305,7 @@ for (let i = 0; i < array.length; i++) {
|
|
|
307
305
|
}
|
|
308
306
|
```
|
|
309
307
|
|
|
310
|
-
|
|
308
|
+
### ✅ Example of correct code
|
|
311
309
|
|
|
312
310
|
```js
|
|
313
311
|
for (const item of items) {
|
|
@@ -315,9 +313,9 @@ for (const item of items) {
|
|
|
315
313
|
}
|
|
316
314
|
```
|
|
317
315
|
|
|
318
|
-
|
|
316
|
+
## for-entries
|
|
319
317
|
|
|
320
|
-
|
|
318
|
+
### ❌ Example of incorrect code
|
|
321
319
|
|
|
322
320
|
```js
|
|
323
321
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -326,7 +324,7 @@ for (let i = 0; i < array.length; i++) {
|
|
|
326
324
|
}
|
|
327
325
|
```
|
|
328
326
|
|
|
329
|
-
|
|
327
|
+
### ✅ Example of correct code
|
|
330
328
|
|
|
331
329
|
```js
|
|
332
330
|
for (const [i, item] of array.entries()) {
|
|
@@ -334,9 +332,9 @@ for (const [i, item] of array.entries()) {
|
|
|
334
332
|
}
|
|
335
333
|
```
|
|
336
334
|
|
|
337
|
-
|
|
335
|
+
## for-entries-n
|
|
338
336
|
|
|
339
|
-
|
|
337
|
+
### ❌ Example of incorrect code
|
|
340
338
|
|
|
341
339
|
```js
|
|
342
340
|
const n = array.length;
|
|
@@ -347,7 +345,7 @@ for (let i = 0; i < n; i++) {
|
|
|
347
345
|
}
|
|
348
346
|
```
|
|
349
347
|
|
|
350
|
-
|
|
348
|
+
### ✅ Example of correct code
|
|
351
349
|
|
|
352
350
|
```js
|
|
353
351
|
for (const [i, item] of array.entries()) {
|
|
@@ -381,7 +379,7 @@ for (let i = 0; i < n; i++) {
|
|
|
381
379
|
}
|
|
382
380
|
```
|
|
383
381
|
|
|
384
|
-
|
|
382
|
+
## from-while
|
|
385
383
|
|
|
386
384
|
> The `while` statement creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
|
|
387
385
|
>
|
|
@@ -389,7 +387,7 @@ for (let i = 0; i < n; i++) {
|
|
|
389
387
|
|
|
390
388
|
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e4faebbc52bc2410425facc557b9acc7/9db52e3880190fe4f898ee6ac2722598073edf01).
|
|
391
389
|
|
|
392
|
-
|
|
390
|
+
### ❌ Example of incorrect code
|
|
393
391
|
|
|
394
392
|
```js
|
|
395
393
|
let i = 0;
|
|
@@ -403,7 +401,7 @@ while (i < node.signature.params.length) {
|
|
|
403
401
|
}
|
|
404
402
|
```
|
|
405
403
|
|
|
406
|
-
|
|
404
|
+
### ✅ Example of correct code
|
|
407
405
|
|
|
408
406
|
```js
|
|
409
407
|
for (const {name} of node.signature.params) {
|
package/package.json
CHANGED