Skip to content

Commit

Permalink
add documentation for reach using negative index
Browse files Browse the repository at this point in the history
  • Loading branch information
danielb2 committed Dec 31, 2014
1 parent b128e06 commit 297d049
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,20 @@ Converts an object key chain string to reference
- `strict` - if `true`, will throw an error on missing member, default is `false`
- `functions` - if `true` allow traversing functions for properties. `false` will throw an error if a function is part of the chain.

A chain including negative numbers will work like negative indices on an
array.

```javascript

var chain = 'a.b.c';
var obj = {a : {b : { c : 1}}};

Hoek.reach(obj, chain); // returns 1

var chain = 'a.b.-1';
var obj = {a : {b : [2,3,6]}};

Hoek.reach(obj, chain); // returns 6
```

### transform(obj, transform, [options])
Expand Down

0 comments on commit 297d049

Please sign in to comment.