Commit f577fb5
authored
fix(slice): explicit zero end no longer returns the whole array (#265)
A slice with an explicit `0` end (e.g. `$[:0]`, `$[2:0]`) returned the
entire array instead of an empty result. `end` was computed with
`(parts[1] && Number.parseInt(parts[1])) || len`, so a parsed end of `0`
is falsy and got replaced by the array length. Treat an omitted end
(empty string) as the length and parse any explicit value, including 0.1 parent 3a471a0 commit f577fb5
2 files changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
611 | | - | |
| 611 | + | |
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
45 | 66 | | |
0 commit comments