From 2cadf82cb01604bb36922d73505662161434bd22 Mon Sep 17 00:00:00 2001 From: Manuel Stofer Date: Sat, 9 Nov 2013 15:32:58 +0900 Subject: [PATCH] Adds documentation for remove --- Readme.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 9795e23..098895d 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,6 @@ [![Build Status](https://travis-ci.org/manuelstofer/json-pointer.png)](https://travis-ci.org/manuelstofer/json-pointer) - Some utilities for JSON pointers described by RFC 6901 Provides some additional stuff i needed but is not included in [node-jsonpointer](https://github.com/janl/node-jsonpointer) @@ -22,6 +21,7 @@ $ npm install json-pointer $ component install manuelstofer/json-pointer ``` + ## API ```Javascript @@ -50,13 +50,13 @@ 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) Looks up a JSON pointer in an object. @@ -71,7 +71,6 @@ pointer.get(obj, '/example/bla'); ``` - ### .set(object, pointer, value) Sets a new value on object at the location described by pointer. @@ -82,6 +81,19 @@ pointer.set(obj, '/example/bla', 'hello'); ``` +### .remove(object, pointer) + +Removes an attribute of object referenced by pointer + +```Javascript +var obj = { + example: 'hello' +}; +pointer.remove(obj, '/example'); +// obj -> {} +``` + + ### .dict(object) Creates a dictionary object (pointer -> value). @@ -122,7 +134,6 @@ pointer.has(obj, '/non/existing'); // -> false ``` - ### .escape(str) Escapes a reference token. @@ -133,7 +144,6 @@ pointer.escape('hello/bla'); // -> 'hello~1bla' ``` - ### .unescape(str) Unescape a reference token.