Skip to content

Commit

Permalink
Updates wrapper documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelstofer committed Apr 26, 2014
1 parent fa8a1fc commit f0ba9a4
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,6 @@ $ component install manuelstofer/json-pointer
var pointer = require('json-pointer');
```

### pointer(object, [pointer, [value]])

Convenience wrapper around the api.

Calls `.get` when called with an `object` and a `pointer`.
Calls `.set` when also called with `value`.
If only `object` is supplied, it returns a partially applied function, mapped to the object.


```Javascript
var obj = {
existing: 'bla'
};

pointer(obj, '/new-value/bla', 'expected'); // .set a property
var objPointer = pointer(obj); // all api calls are now scoped to `obj`
objPointer('/existing') // gets '/existing' from `obj`
objPointer('/new-value/bla') // gets '/new-value/bla' from `obj`
```

The wrapper supports chainable object oriented style.

```Javascript
var obj = {anything: 'bla'};
var objPointer = pointer(obj);
objPointer.set('/example', 'bla').dict();
```


### .get(object, pointer)

Expand Down Expand Up @@ -170,3 +142,22 @@ Builds a json pointer from an array of reference tokens.
```Javascript
pointer.compile(['hello', 'bla']); // -> '/hello/bla'
```


### pointer(object, [pointer, [value]])

Convenience wrapper around the api.

```Javascript
pointer(object) // bind object
pointer(object, pointer) // get
pointer(object, pointer, value) // set
```

The wrapper supports chainable object oriented style.

```Javascript
var obj = {anything: 'bla'};
var objPointer = pointer(obj);
objPointer.set('/example', 'bla').dict();
```

0 comments on commit f0ba9a4

Please sign in to comment.