Dolce is a collection library used primarily for routing.
Use Cases:
Basic Example:
var dolce = col1 = dolcecol2 = dolcecol3 = dolcecol4 = dolcecol5 = dolce; //explicit chaincol1;col1; console; //[{ value: 'HELLO' }, { value: 'WORLD' }] //parameterscol5;col5;console; //[{ value: 'HELLO' }, { value: 'WORLD' }] //implicit chaincol2col2; console; //[{ value: 'HELLO' }, { value: 'WORLD' } ] //greedy chaincol3col3;col3; console; //[{ value: 'HELLO' }, { value: 'AWESOME' }, { value: 'WORLD' } ] //filtering chainscol4;col4;col4; console; //[{ tags: { method: 'GET' }, value: 'get user' }];
API
.add(type, value);
Adds data to the collection
.addObject(value);
Adds an object to the collection
collection
.get(channel[, ops])
Returns a collection based on the params given
channel
- the path to the value, e.g., 'add/user', 'validate/some/stuff'ops
- the options for fetching datatags
- the tags to filter against
A returned value may look something like this:
"paths": "value": "users" "param": false "value": "14732843" "param": false "tags": "method": "GET" "chains": "paths": "value": "users" "param": false "value": "userid" "param": true "params": "userid": "14732843" "tags": "method": "GET" "value": "get user"
.contains(channel[, ops])
TRUE if the given channel exists in the collection. API is the same as .get
Caveats
collection;collection;collection; //goes through -method=POST validate/** before getting to login, NOT -anotherTag validate/** collection; collection;collection; //does NOT go through validate/** because the method is not POSTcollection; //this doesn't workcollection; //with this.collection; //but with this this:collection;