Skip to content

Commit d7222de

Browse files
committed
document the public api for the jsonselect javascript library
1 parent f169259 commit d7222de

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/jsonselect.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
22
/*
3-
* This is the JSONSelect reference implementation, in javascript.
3+
* This is the JSONSelect reference implementation, in javascript. This
4+
* code is designed to run under node.js or in a browser. In the former
5+
* case, the "public API" is exposed as properties on the `export` object,
6+
* in the latter, as properties on `window.JSONSelect`. That API is thus:
7+
*
8+
* .match(selector, object)
9+
*
10+
* Parses and "compiles" the selector, then matches it against the object
11+
* argument. Matches are returned in an array. Throws an error when
12+
* there's a problem parsing the selector.
13+
*
14+
* .forEach(selector, object, callback)
15+
*
16+
* Like match, but rather than returning an array, invokes the provided
17+
* callback once per match as the matches are discovered.
18+
*
19+
* .compile(selector)
20+
*
21+
* Parses the selector and compiles it to an internal form, and returns
22+
* an object which contains the compiled selector and has two properties:
23+
* `match` and `forEach`. These two functions work identically to the
24+
* above, except they do not take a selector as an argument and instead
25+
* use the compiled selector.
26+
*
27+
* For cases where a complex selector is repeatedly used, this method
28+
* should be faster as it will avoid recompiling the selector each time.
429
*/
530
(function(exports) {
631

0 commit comments

Comments
 (0)