Skip to content

Commit

Permalink
Merge branch 'master' of github.com:manuelstofer/json-pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelstofer committed Sep 8, 2013
2 parents 29497f3 + dc7d434 commit ee105db
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Convenience wrapper around the api.

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


```Javascript
Expand All @@ -48,17 +48,18 @@ objPointer('/existing') // gets '/existing' from `obj`
objPointer('/new-value/bla') // gets '/new-value/bla' from `obj`
```

The wrapper supports chainable object oriented style
The wrapper supports chainable object oriented style.

```

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

### .get(object, pointer)

Looks up a JSON pointer in an object
Looks up a JSON pointer in an object.

```Javascript
var obj = {
Expand All @@ -73,7 +74,7 @@ pointer.get(obj, '/example/bla');

### .set(object, pointer, value)

Sets a new value on object at the location described by pointer
Sets a new value on object at the location described by pointer.

```Javascript
var obj = {};
Expand All @@ -83,7 +84,7 @@ pointer.set(obj, '/example/bla', 'hello');

### .dict(object)

Creates a dictionary object (pointer -> value)
Creates a dictionary object (pointer -> value).

```Javascript
var obj = {
Expand All @@ -109,7 +110,7 @@ each(pointer.dict(obj), iterator);

### .has(object, pointer)

Tests if an object has a value for a JSON pointer
Tests if an object has a value for a JSON pointer.

```Javascript
var obj = {
Expand All @@ -124,7 +125,7 @@ pointer.has(obj, '/non/existing'); // -> false

### .escape(str)

Escapes a reference token
Escapes a reference token.

```Javascript
pointer.escape('hello~bla'); // -> 'hello~0bla'
Expand All @@ -135,7 +136,7 @@ pointer.escape('hello/bla'); // -> 'hello~1bla'

### .unescape(str)

Unescape a reference token
Unescape a reference token.

```Javascript
pointer.unescape('hello~0bla'); // -> 'hello~bla'
Expand All @@ -145,7 +146,7 @@ pointer.unescape('hello~1bla'); // -> 'hello/bla'

### .parse(str)

Converts a JSON pointer into an array of reference tokens
Converts a JSON pointer into an array of reference tokens.

```Javascript
pointer.parse('/hello/bla'); // -> ['hello', 'bla']
Expand All @@ -154,7 +155,7 @@ pointer.parse('/hello/bla'); // -> ['hello', 'bla']

### .compile(str)

Builds a json pointer from an array of reference tokens
Builds a json pointer from an array of reference tokens.

```Javascript
pointer.compile(['hello', 'bla']); // -> '/hello/bla'
Expand Down

0 comments on commit ee105db

Please sign in to comment.