Skip to content

Commit

Permalink
[UPDATE] README.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Mar 3, 2015
1 parent f5c5241 commit 79737cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,20 @@ arr = indexspace( '[:-2]', 5 );
// returns [ 0, 1, 2 ]
```

The function also recognizes the `end` keyword, which refers to the last index; i.e., `len-1`. If specified as the `stop` index, `end` is inclusive.
The function also recognizes the `end` keyword, which refers to the last index; i.e., `len-1`. If specified as the `stop` index, `end` is __inclusive__.

``` javascript
var arr = indexspace( '[end::-1]', 5 );
// returns [ 4, 3, 2, 1, 0 ]

arr = indexspace( '[:end]', 5 );
// returns [ 0, 1, 2, 3, 4 ]

arr = indexspace( '[:end/2]', 5 );
// returns [ 0, 1 ]

arr = indexspace( '[end/2:]', 5 );
// returns [ 2, 3, 4 ]
```

Basic arithmetic (subtraction and division) may be performed on the `end` keyword. The result from division is rounded up to the next integer.
Expand Down

0 comments on commit 79737cd

Please sign in to comment.