Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-select

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-select - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

test/timeline.js

33

index.js

@@ -5,3 +5,3 @@ var traverse = require("traverse"),

module.exports = function(obj, string) {
sels = parseSelectors(string);
var sels = parseSelectors(string);

@@ -28,3 +28,32 @@ return {

},
condense: function() {
traverse(obj).forEach(function(node) {
if (!this.parent) return;
if (this.parent.keep) {
this.keep = true;
} else {
var match = matchesAny(sels, this);
this.keep = match;
if (!match) {
if (this.isLeaf) {
this.remove();
} else {
this.after(function() {
if (this.keep_child) {
this.parent.keep_child = true;
}
if (!this.keep && !this.keep_child) {
this.remove();
}
});
}
} else {
this.parent.keep_child = true;
}
}
});
},
forEach: function(cb) {

@@ -31,0 +60,0 @@ traverse(obj).forEach(function(node) {

2

package.json
{
"name": "js-select",
"description": "Traverse and modify objects with JSONSelect selectors",
"version": "0.5.0",
"version": "0.5.1",
"author": "Heather Arthur <fayearthur@gmail.com>",

@@ -6,0 +6,0 @@ "repository": {

# js-select
js-select uses [js-traverse](https://github.com/substack/js-traverse) to traverse and modify JavaScript object nodes that match [JSONSelect](http://jsonselect.org/) selectors:
js-select uses [js-traverse](https://github.com/substack/js-traverse) to traverse and modify JavaScript object nodes that match [JSONSelect](http://jsonselect.org/) selectors.

@@ -15,24 +15,59 @@ ```javascript

}
}
};
```
select(people, ".age").nodes(); // [35, 15]
### .forEach(fn)
select(people, ".age").update(function(age) {
return age - 5;
Iterates over all matching nodes in the object. The callback gets a special `this` context. See [js-traverse](https://github.com/substack/js-traverse) for all the things you can do to modify and inspect the node with this context. In addition, js-select adds a `this.matches()` which will test if the node matches a selector:
```javascript
select(people).forEach(function(node) {
if (this.matches(".mary > .movie")) {
this.remove();
}
});
```
### .nodes()
Returns all matching nodes from the object.
```javascript
select(people, ".age").nodes(); // [35, 15]
```
### .remove()
Removes matching elements from the original object.
```javascript
select(people, ".age").remove();
```
There's also a `forEach()` which gets a special `this` context. See [js-traverse](https://github.com/substack/js-traverse) for all the things you can do to modify and inspect the node with the context. In addition, js-select adds a `this.matches()` which will test if the node matches a selector:
### .update(fn)
Updates all matching nodes using the given callback.
```javascript
select(people).forEach(function(node) {
if (this.matches(".mary > .movie")) {
this.remove();
}
select(people, ".age").update(function(age) {
return age - 5;
});
```
### .condense()
Reduces the original object down to only the matching elements (the hierarchy is maintained).
```javascript
select(people, ".age").condense();
```
```javascript
{
george: { age: 35 },
mary: { age: 15 }
}
```
# selectors
## Selectors

@@ -64,3 +99,3 @@ js-select supports the following [JSONSelect](http://jsonselect.org/) selectors:

# install
## Install

@@ -83,4 +118,4 @@ For [node](http://nodejs.org), install with [npm](http://npmjs.org):

# propers
## Propers
Huge thanks to [@substack](http://github.com/substack) for the ingenious [js-traverse](https://github.com/substack/js-traverse) and [@lloyd](https://github.com/lloyd) for the ingenious [JSONSelect spec](http://http://jsonselect.org/) and [selector parser](http://search.npmjs.org/#/JSONSelect).
Huge thanks to [@substack](http://github.com/substack) for the ingenious [js-traverse](https://github.com/substack/js-traverse) and [@lloyd](https://github.com/lloyd) for the ingenious [JSONSelect spec](http://http://jsonselect.org/) and [selector parser](http://search.npmjs.org/#/JSONSelect).

@@ -1,1 +0,37 @@

var select=function(){var a=function(b,c){var d=a.resolve(b,c||"/"),e=a.modules[d];if(!e)throw new Error("Failed to resolve module "+b+", tried "+d);var f=e._cached?e._cached:e();return f},b=a;a.paths=[],a.modules={},a.extensions=[".js",".coffee"],a.resolve=function(){var b={assert:!0,events:!0,fs:!0,path:!0,vm:!0};return function(c,d){function l(a){var b;a==="/"?b=[""]:b=e.normalize(a).split("/");var c=[];for(var d=b.length-1;d>=0;d--){if(b[d]==="node_modules")continue;var f=b.slice(0,d+1).join("/")+"/node_modules";c.push(f)}return c}function k(a,b){var c=l(b);for(var d=0;d<c.length;d++){var e=c[d],f=i(e+"/"+a);if(f)return f;var g=j(e+"/"+a);if(g)return g}var f=i(a);if(f)return f}function j(b){b=b.replace(/\/+$/,"");var c=b+"/package.json";if(a.modules[c]){var d=a.modules[c](),f=d.browserify;if(typeof f=="object"&&f.main){var g=i(e.resolve(b,f.main));if(g)return g}else if(typeof f=="string"){var g=i(e.resolve(b,f));if(g)return g}else if(d.main){var g=i(e.resolve(b,d.main));if(g)return g}}return i(b+"/index")}function i(b){if(a.modules[b])return b;for(var c=0;c<a.extensions.length;c++){var d=a.extensions[c];if(a.modules[b+d])return b+d}}d||(d="/");if(b[c])return c;var e=a.modules.path(),f=d||".";if(c.match(/^(?:\.\.?\/|\/)/)){var g=i(e.resolve(f,c))||j(e.resolve(f,c));if(g)return g}var h=k(c,f);if(h)return h;throw new Error("Cannot find module '"+c+"'")}}(),a.alias=function(b,c){var d=a.modules.path(),e=null;try{e=a.resolve(b+"/package.json","/")}catch(f){e=a.resolve(b,"/")}var g=d.dirname(e);Object.keys(a.modules).forEach(function(b){if(b.slice(0,g.length+1)===g+"/"){var d=b.slice(g.length);a.modules[c+d]=a.modules[g+d]}else b===g&&(a.modules[c]=a.modules[g])})},typeof process=="undefined"&&(process={}),process.nextTick||(process.nextTick=function(a){setTimeout(a,0)}),process.title||(process.title="browser"),process.binding||(process.binding=function(b){if(b==="evals")return a("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),a.modules.path=function(){var a={exports:{}},c=a.exports,d=".",e="path",f=function(a){return b(a,".")};f.resolve=function(a){return b.resolve(name,".")},f.modules=b.modules,b.modules.path._cached=a.exports,function(){function a(a,b){var c=0;for(var d=a.length;d>=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var b=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;c.resolve=function(){var b="",c=!1;for(var d=arguments.length;d>=-1&&!c;d--){var e=d>=0?arguments[d]:process.cwd();if(typeof e!="string"||!e)continue;b=e+"/"+b,c=e.charAt(0)==="/"}b=a(b.split("/").filter(function(a){return!!a}),!c).join("/");return(c?"/":"")+b||"."},c.normalize=function(b){var c=b.charAt(0)==="/",d=b.slice(-1)==="/";b=a(b.split("/").filter(function(a){return!!a}),!c).join("/"),!b&&!c&&(b="."),b&&d&&(b+="/");return(c?"/":"")+b},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(a.filter(function(a,b){return a&&typeof a=="string"}).join("/"))},c.dirname=function(a){var c=b.exec(a)[1]||"",d=!1;return c?c.length===1||d&&c.length<=3&&c.charAt(1)===":"?c:c.substring(0,c.length-1):"."},c.basename=function(a,c){var d=b.exec(a)[2]||"";c&&d.substr(-1*c.length)===c&&(d=d.substr(0,d.length-c.length));return d},c.extname=function(a){return b.exec(a)[3]||""}}.call(a.exports),b.modules.path._cached=a.exports;return a.exports},a.modules["/node_modules/js-select/package.json"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/js-select",e="/node_modules/js-select/package.json",f=function(a){return b(a,"/node_modules/js-select")};f.resolve=function(a){return b.resolve(name,"/node_modules/js-select")},f.modules=b.modules,b.modules["/node_modules/js-select/package.json"]._cached=a.exports,function(){a.exports={name:"js-select",description:"Traverse and modify objects with JSONSelect selectors",version:"0.4.0",author:"Heather Arthur <fayearthur@gmail.com>",repository:{type:"git",url:"http://github.com/harthur/js-select.git"},main:"./index",dependencies:{traverse:"0.4.x",JSONSelect:"0.2.x"},devDependencies:{nomnom:"0.6.x",color:"0.3.x"},keywords:["json"]}}.call(a.exports),b.modules["/node_modules/js-select/package.json"]._cached=a.exports;return a.exports},a.modules["/node_modules/js-select/index.js"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/js-select",e="/node_modules/js-select/index.js",f=function(a){return b(a,"/node_modules/js-select")};f.resolve=function(a){return b.resolve(name,"/node_modules/js-select")},f.modules=b.modules,b.modules["/node_modules/js-select/index.js"]._cached=a.exports,function(){function i(a,c){var d=c.key,f=c.node,h=c.parent;if(a.id&&d!=a.id)return!1;if(a.type)if(a.type=="null"){if(c.node!==null)return!1}else if(a.type=="array"){if(!j(c.node))return!1}else if(a.type=="object"){if(typeof c.node!="object"||c.node===null||j(c.node))return!1}else if(a.type!=typeof c.node)return!1;if(a.pf==":nth-child"){var i=parseInt(d)+1;if(a.a==0&&i!==a.b||a.a==1&&!(i>=-a.b)||a.a==-1&&!(i<=a.b)||a.a==2&&i%2!=a.b)return!1}if(a.pf==":nth-last-child"){var k=c.parent&&c.parent.node.length;if(!k||d!=k-a.b)return!1}if(a.pc==":only-child"){var k=c.parent&&c.parent.node.length;if(!k||k!=1)return!1}if(a.pc==":root"&&d!==undefined)return!1;if(a.has){var l=e(a.has[0]),m=!1;b(f).forEach(function(a){g(l,this)&&(m=!0)});if(!m)return!1}if(a.expr){var n=a.expr,o=n[0],p=n[1],q=n[2];if(typeof f!="string"||!o&&p=="="&&f!=q||!o&&p=="*="&&f.indexOf(q)==-1)return!1}return!0}function h(a,b){var c=b.parents.concat([b]),d=c.length-1,e=a.length-1,f=!0;while(e>=0&&d>=0){var g=a[e],b=c[d];if(g==">"){e--,f=!0;continue}if(i(g,b))e--;else if(f)return!1;d--,f=!1}return e==-1}function g(a,b){for(var c=0;c<a.length;c++)if(h(a[c],b))return!0;return!1}function e(a){return a[0]==","?a.slice(1):[a]}function d(a){var b=c._parse(a||"*")[1];return e(b)}var b=f("traverse"),c=f("JSONSelect");a.exports=function(a,c){sels=d(c);return{nodes:function(){var a=[];this.forEach(function(b){a.push(b)});return a},forEach:function(c){b(a).forEach(function(a){g(sels,this)&&(this.matches=function(a){return g(d(a),this)},c.call(this,a))})}}};var j=Array.isArray||function(a){return toString.call(a)==="[object Array]"}}.call(a.exports),b.modules["/node_modules/js-select/index.js"]._cached=a.exports;return a.exports},a.modules["/node_modules/traverse/package.json"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/traverse",e="/node_modules/traverse/package.json",f=function(a){return b(a,"/node_modules/traverse")};f.resolve=function(a){return b.resolve(name,"/node_modules/traverse")},f.modules=b.modules,b.modules["/node_modules/traverse/package.json"]._cached=a.exports,function(){a.exports={name:"traverse",version:"0.4.4",description:"Traverse and transform objects by visiting every node on a recursive walk",author:"James Halliday",license:"MIT/X11",main:"./index",repository:{type:"git",url:"http://github.com/substack/js-traverse.git"},devDependencies:{expresso:"0.7.x"},scripts:{test:"expresso"}}}.call(a.exports),b.modules["/node_modules/traverse/package.json"]._cached=a.exports;return a.exports},a.modules["/node_modules/traverse/index.js"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/traverse",e="/node_modules/traverse/index.js",f=function(a){return b(a,"/node_modules/traverse")};f.resolve=function(a){return b.resolve(name,"/node_modules/traverse")},f.modules=b.modules,b.modules["/node_modules/traverse/index.js"]._cached=a.exports,function(){function d(a){if(typeof a=="object"&&a!==null){var b;Array.isArray(a)?b=[]:a instanceof Date?b=new Date(a):a instanceof Boolean?b=new Boolean(a):a instanceof Number?b=new Number(a):a instanceof String?b=new String(a):b=Object.create(Object.getPrototypeOf(a)),Object.keys(a).forEach(function(c){b[c]=a[c]});return b}return a}function c(a,b,c){var e=[],f=[],g=!0;return function h(a){var i=c?d(a):a,j={},k=!0,l={node:i,node_:a,path:[].concat(e),parent:f[f.length-1],parents:f,key:e.slice(-1)[0],isRoot:e.length===0,level:e.length,circular:null,update:function(a,b){l.isRoot||(l.parent.node[l.key]=a),l.node=a,b&&(k=!1)},"delete":function(){delete l.parent.node[l.key]},remove:function(){Array.isArray(l.parent.node)?l.parent.node.splice(l.key,1):delete l.parent.node[l.key]},before:function(a){j.before=a},after:function(a){j.after=a},pre:function(a){j.pre=a},post:function(a){j.post=a},stop:function(){g=!1},block:function(){k=!1}};if(!g)return l;if(typeof i=="object"&&i!==null){l.isLeaf=Object.keys(i).length==0;for(var m=0;m<f.length;m++)if(f[m].node_===a){l.circular=f[m];break}}else l.isLeaf=!0;l.notLeaf=!l.isLeaf,l.notRoot=!l.isRoot;var n=b.call(l,l.node);n!==undefined&&l.update&&l.update(n),l.keys=null,j.before&&j.before.call(l,l.node);if(!k)return l;if(typeof l.node=="object"&&l.node!==null&&!l.circular){f.push(l);var o=l.keys||Object.keys(l.node);o.forEach(function(a,b){e.push(a),j.pre&&j.pre.call(l,l.node[a],a);var d=h(l.node[a]);c&&Object.hasOwnProperty.call(l.node,a)&&(l.node[a]=d.node),d.isLast=b==o.length-1,d.isFirst=b==0,j.post&&j.post.call(l,d),e.pop()}),f.pop()}j.after&&j.after.call(l,l.node);return l}(a).node}function b(a){if(this instanceof b)this.value=a;else return new b(a)}a.exports=b,b.prototype.get=function(a){var b=this.value;for(var c=0;c<a.length;c++){var d=a[c];if(!Object.hasOwnProperty.call(b,d)){b=undefined;break}b=b[d]}return b},b.prototype.set=function(a,b){var c=this.value;for(var d=0;d<a.length-1;d++){var e=a[d];Object.hasOwnProperty.call(c,e)||(c[e]={}),c=c[e]}c[a[d]]=b;return b},b.prototype.map=function(a){return c(this.value,a,!0)},b.prototype.forEach=function(a){this.value=c(this.value,a,!1);return this.value},b.prototype.reduce=function(a,b){var c=arguments.length===1,d=c?this.value:b;this.forEach(function(b){if(!this.isRoot||!c)d=a.call(this,d,b)});return d},b.prototype.deepEqual=function(a){if(arguments.length!==1)throw new Error("deepEqual requires exactly one object to compare against");var c=!0,d=a;this.forEach(function(e){var f=function(){c=!1;return undefined}.bind(this);if(!this.isRoot){if(typeof d!="object")return f();d=d[this.key]}var g=d;this.post(function(){d=g});var h=function(a){return Object.prototype.toString.call(a)};if(this.circular)b(a).get(this.circular.path)!==g&&f();else if(typeof g!=typeof e)f();else if(g===null||e===null||g===undefined||e===undefined)g!==e&&f();else if(g.__proto__!==e.__proto__)f();else if(g!==e)if(typeof g=="function")g instanceof RegExp?g.toString()!=e.toString()&&f():g!==e&&f();else if(typeof g=="object")if(h(e)==="[object Arguments]"||h(g)==="[object Arguments]")h(g)!==h(e)&&f();else if(g instanceof Date||e instanceof Date)(!(g instanceof Date)||!(e instanceof Date)||g.getTime()!==e.getTime())&&f();else{var i=Object.keys(g),j=Object.keys(e);if(i.length!==j.length)return f();for(var k=0;k<i.length;k++){var l=i[k];Object.hasOwnProperty.call(e,l)||f()}}});return c},b.prototype.paths=function(){var a=[];this.forEach(function(b){a.push(this.path)});return a},b.prototype.nodes=function(){var a=[];this.forEach(function(b){a.push(this.node)});return a},b.prototype.clone=function(){var a=[],b=[];return function c(e){for(var f=0;f<a.length;f++)if(a[f]===e)return b[f];if(typeof e=="object"&&e!==null){var g=d(e);a.push(e),b.push(g),Object.keys(e).forEach(function(a){g[a]=c(e[a])}),a.pop(),b.pop();return g}return e}(this.value)},Object.keys(b.prototype).forEach(function(a){b[a]=function(c){var d=[].slice.call(arguments,1),e=b(c);return e[a].apply(e,d)}})}.call(a.exports),b.modules["/node_modules/traverse/index.js"]._cached=a.exports;return a.exports},a.modules["/node_modules/JSONSelect/package.json"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/JSONSelect",e="/node_modules/JSONSelect/package.json",f=function(a){return b(a,"/node_modules/JSONSelect")};f.resolve=function(a){return b.resolve(name,"/node_modules/JSONSelect")},f.modules=b.modules,b.modules["/node_modules/JSONSelect/package.json"]._cached=a.exports,function(){a.exports={author:"Lloyd Hilaiel <lloyd@hilaiel.com> (http://trickyco.de)",name:"JSONSelect",description:"CSS-like selectors for JSON",version:"0.2.1",homepage:"http://jsonselect.org",repository:{type:"git",url:"https://github.com/lloyd/JSONSelect.git"},main:"src/jsonselect",engines:{node:">=0.4.7"},dependencies:{},devDependencies:{},files:["src/jsonselect.js","src/test/run.js","src/test/tests","tests","README.md","JSONSelect.md","package.json","LICENSE"]}}.call(a.exports),b.modules["/node_modules/JSONSelect/package.json"]._cached=a.exports;return a.exports},a.modules["/node_modules/JSONSelect/src/jsonselect.js"]=function(){var a={exports:{}},c=a.exports,d="/node_modules/JSONSelect/src",e="/node_modules/JSONSelect/src/jsonselect.js",f=function(a){return b(a,"/node_modules/JSONSelect/src")};f.resolve=function(a){return b.resolve(name,"/node_modules/JSONSelect/src")},f.modules=b.modules,b.modules["/node_modules/JSONSelect/src/jsonselect.js"]._cached=a.exports,function(){(function(a){function z(a){return{sel:q(a)[1],match:function(a){return y(this.sel,a)},forEach:function(a,b){return x(this.sel,a,b)}}}function y(a,b){var c=[];x(a,b,function(a){c.push(a)});return c}function x(a,b,c,d,e,f){var g=a[0]===","?a.slice(1):[a],h=[],i=!1,j=0,k=0,l,m;for(j=0;j<g.length;j++){m=w(b,g[j],d,e,f),m[0]&&(i=!0);for(k=0;k<m[1].length;k++)h.push(m[1][k])}if(h.length&&typeof b=="object"){h.length>=1&&h.unshift(",");if(u(b))for(j=0;j<b.length;j++)x(h,b[j],c,undefined,j,b.length);else for(l in b)b.hasOwnProperty(l)&&x(h,b[l],c,l)}i&&c&&c(b)}function w(a,b,c,d,e){var f=[],g=b[0]===">"?b[1]:b[0],h=!0,i;g.type&&(h=h&&g.type===v(a)),g.id&&(h=h&&g.id===c),h&&g.pf&&(g.pf===":nth-last-child"?d=e-d:d++,g.a===0?h=g.b===d:(i=(d-g.b)%g.a,h=!i&&d*g.a+g.b>=0));if(h&&g.has){var j=function(){throw 42};for(var k=0;k<g.has.length;k++){try{x(g.has[k],a,j)}catch(l){if(l===42)continue}h=!1;break}}h&&g.expr&&(h=p(g.expr,a)),b[0]!==">"&&b[0].pc!==":root"&&f.push(b),h&&(b[0]===">"?b.length>2&&(h=!1,f.push(b.slice(2))):b.length>1&&(h=!1,f.push(b.slice(1))));return[h,f]}function v(a){if(a===null)return"null";var b=typeof a;b==="object"&&u(a)&&(b="array");return b}function u(a){return Array.isArray?Array.isArray(a):b.call(a)==="[object Array]"}function t(a,b,c){var d=b,g={},j=i(a,b);j&&j[1]===" "&&(d=b=j[0],j=i(a,b)),j&&j[1]===f.typ?(g.type=j[2],j=i(a,b=j[0])):j&&j[1]==="*"&&(j=i(a,b=j[0]));for(;;){if(j===undefined)break;if(j[1]===f.ide)g.id&&e("nmi",j[1]),g.id=j[2];else if(j[1]===f.psc)(g.pc||g.pf)&&e("mpc",j[1]),j[2]===":first-child"?(g.pf=":nth-child",g.a=0,g.b=1):j[2]===":last-child"?(g.pf=":nth-last-child",g.a=0,g.b=1):g.pc=j[2];else{if(j[1]!==f.psf)break;if(j[2]===":val"||j[2]===":contains")g.expr=[undefined,j[2]===":val"?"=":"*=",undefined],j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!=="(")&&e("pex",a),j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!==f.str)&&e("sex",a),g.expr[2]=j[2],j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!==")")&&e("epex",a);else if(j[2]===":has"){j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0])),(!j||j[1]!=="(")&&e("pex",a);var k=q(a,j[0],!0);j[0]=k[0],g.has||(g.has=[]),g.has.push(k[1])}else if(j[2]===":expr"){g.expr&&e("mexp",a);var l=o(a,j[0]);j[0]=l[0],g.expr=l[1]}else{(g.pc||g.pf)&&e("mpc",a),g.pf=j[2];var m=h.exec(a.substr(j[0]));m||e("mepf",a),m[5]?(g.a=2,g.b=m[5]==="odd"?1:0):m[6]?(g.a=0,g.b=parseInt(m[6],10)):(g.a=parseInt((m[1]?m[1]:"+")+(m[2]?m[2]:"1"),10),g.b=m[3]?parseInt(m[3]+m[4],10):0),j[0]+=m[0].length}}j=i(a,b=j[0])}d===b&&e("se",a);return[b,g]}function s(a){if(a[0]===","){var b=[","];for(var c=c;c<a.length;c++){var d=r(d[c]);b=b.concat(d[0]===","?d.slice(1):d)}return b}return r(a)}function r(a){var b=[],c;for(var d=0;d<a.length;d++)if(a[d]==="~"){if(d<2||a[d-2]!=">")c=a.slice(0,d-1),c=c.concat([{has:[[{pc:":root"},">",a[d-1]]]},">"]),c=c.concat(a.slice(d+1)),b.push(c);if(d>1){var e=a[d-2]===">"?d-3:d-2;c=a.slice(0,e);var f={};for(var g in a[e])a[e].hasOwnProperty(g)&&(f[g]=a[e][g]);f.has||(f.has=[]),f.has.push([{pc:":root"},">",a[d-1]]),c=c.concat(f,">",a.slice(d+1)),b.push(c)}break}return d==a.length?a:b.length>1?[","].concat(b):b[0]}function q(a,b,c,d){c||(d={});var f=[],g,h;b||(b=0);for(;;){var j=t(a,b,d);f.push(j[1]),j=i(a,b=j[0]),j&&j[1]===" "&&(j=i(a,b=j[0]));if(!j)break;if(j[1]===">"||j[1]==="~")j[1]==="~"&&(d.usesSiblingOp=!0),f.push(j[1]),b=j[0];else if(j[1]===",")g===undefined?g=[",",f]:g.push(f),f=[],b=j[0];else if(j[1]===")"){c||e("ucp",j[1]),h=1,b=j[0];break}}c&&!h&&e("mcp",a),g&&g.push(f);var k;!c&&d.usesSiblingOp?k=s(g?g:f):k=g?g:f;return[b,k]}function p(a,b){if(a===undefined)return b;if(a===null||typeof a!="object")return a;var c=p(a[0],b),d=p(a[2],b);return l[a[1]][1](c,d)}function o(a,b){function c(a){return typeof a!="object"||a===null?a:a[0]==="("?c(a[1]):[c(a[0]),a[1],c(a[2])]}var d=n(a,b?b:0);return[d[0],c(d[1])]}function n(a,b){b||(b=0);var c=m(a,b),d;if(c&&c[1]==="("){d=n(a,c[0]);var f=m(a,d[0]);(!f||f[1]!==")")&&e("epex",a),b=f[0],d=["(",d[1]]}else!c||c[1]&&c[1]!="x"?e("ee",a+" - "+(c[1]&&c[1])):(d=c[1]==="x"?undefined:c[2],b=c[0]);var g=m(a,b);if(!g||g[1]==")")return[b,d];(g[1]=="x"||!g[1])&&e("bop",a+" - "+(g[1]&&g[1]));var h=n(a,g[0]);b=h[0],h=h[1];var i;if(typeof h!="object"||h[0]==="("||l[g[1]][0]<l[h[1]][0])i=[d,g[1],h];else{i=h;while(typeof h[0]=="object"&&h[0][0]!="("&&l[g[1]][0]>=l[h[0][1]][0])h=h[0];h[0]=[d,g[1],h[0]]}return[b,i]}function m(a,b){var d,e=j.exec(a.substr(b));if(e){b+=e[0].length,d=e[1]||e[2]||e[3]||e[5]||e[6];if(e[1]||e[2]||e[3])return[b,0,c(d)];if(e[4])return[b,0,undefined];return[b,d]}}function k(a,b){return typeof a===b}function i(a,b){b||(b=0);var d=g.exec(a.substr(b));if(!d)return undefined;b+=d[0].length;var h;d[1]?h=[b," "]:d[2]?h=[b,d[0]]:d[3]?h=[b,f.typ,d[0]]:d[4]?h=[b,f.psc,d[0]]:d[5]?h=[b,f.psf,d[0]]:d[6]?e("upc",a):d[8]?h=[b,d[7]?f.ide:f.str,c(d[8])]:d[9]?e("ujs",a):d[10]&&(h=[b,f.ide,d[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")]);return h}function e(a,b){throw new Error(d[a]+(b&&" in '"+b+"'"))}function c(a){try{return JSON&&JSON.parse?JSON.parse(a):(new Function("return "+a))()}catch(b){e("ijs",b.message)}}var b=Object.prototype.toString,d={bop:"binary operator expected",ee:"expression expected",epex:"closing paren expected ')'",ijs:"invalid json string",mcp:"missing closing paren",mepf:"malformed expression in pseudo-function",mexp:"multiple expressions not allowed",mpc:"multiple pseudo classes (:xxx) not allowed",nmi:"multiple ids not allowed",pex:"opening paren expected '('",se:"selector expected",sex:"string expected",sra:"string required after '.'",uc:"unrecognized char",ucp:"unexpected closing paren",ujs:"unclosed json string",upc:"unrecognized pseudo class"},f={psc:1,psf:2,typ:3,str:4,ide:5},g=new RegExp('^(?:([\\r\\n\\t\\ ]+)|([~*,>\\)\\(])|(string|boolean|null|array|object|number)|(:(?:root|first-child|last-child|only-child))|(:(?:nth-child|nth-last-child|has|expr|val|contains))|(:\\w+)|(?:(\\.)?(\\"(?:[^\\\\\\"]|\\\\[^\\"])*\\"))|(\\")|\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*))'),h=/^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/,j=new RegExp('^\\s*(?:(true|false|null)|(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|("(?:[^\\]|\\[^"])*")|(x)|(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|([\\(\\)]))'),l={"*":[9,function(a,b){return a*b}],"/":[9,function(a,b){return a/b}],"%":[9,function(a,b){return a%b}],"+":[7,function(a,b){return a+b}],"-":[7,function(a,b){return a-b}],"<=":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a<=b}],">=":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a>=b}],"$=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.lastIndexOf(b)===a.length-b.length}],"^=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.indexOf(b)===0}],"*=":[5,function(a,b){return k(a,"string")&&k(b,"string")&&a.indexOf(b)!==-1}],">":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a>b}],"<":[5,function(a,b){return k(a,"number")&&k(b,"number")&&a<b}],"=":[3,function(a,b){return a===b}],"!=":[3,function(a,b){return a!==b}],"&&":[2,function(a,b){return a&&b}],"||":[1,function(a,b){return a||b}]};a._lex=i,a._parse=q,a.match=function(a,b){return z(a).match(b)},a.forEach=function(a,b,c){return z(a).forEach(b,c)},a.compile=z})(typeof c=="undefined"?window.JSONSelect={}:c)}.call(a.exports),b.modules["/node_modules/JSONSelect/src/jsonselect.js"]._cached=a.exports;return a.exports};return a("js-select")}()
var select=function(){var c=function(j,f){var d=c.resolve(j,f||"/"),l=c.modules[d];if(!l)throw Error("Failed to resolve module "+j+", tried "+d);return(d=c.cache[d])?d.exports:l()};c.paths=[];c.modules={};c.cache={};c.extensions=[".js",".coffee"];c._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0};c.resolve=function(j,f){function d(b){b=h.normalize(b);if(c.modules[b])return b;for(var a=0;a<c.extensions.length;a++){var e=c.extensions[a];if(c.modules[b+e])return b+e}}function l(b){var b=b.replace(/\/+$/,
""),a=h.normalize(b+"/package.json");if(c.modules[a]){var a=c.modules[a](),e=a.browserify;if("object"===typeof e&&e.main){if(a=d(h.resolve(b,e.main)))return a}else if("string"===typeof e){if(a=d(h.resolve(b,e)))return a}else if(a.main&&(a=d(h.resolve(b,a.main))))return a}return d(b+"/index")}f||(f="/");if(c._core[j])return j;var h=c.modules.path(),a=(f=h.resolve("/",f))||"/";if(j.match(/^(?:\.\.?\/|\/)/)){var e=d(h.resolve(a,j))||l(h.resolve(a,j));if(e)return e}a:{for(var e="/"===a?[""]:h.normalize(a).split("/"),
a=[],g=e.length-1;0<=g;g--)if("node_modules"!==e[g]){var b=e.slice(0,g+1).join("/")+"/node_modules";a.push(b)}for(e=0;e<a.length;e++){g=a[e];if(b=d(g+"/"+j)){a=b;break a}if(g=l(g+"/"+j)){a=g;break a}}a=(b=d(j))?b:void 0}if(a)return a;throw Error("Cannot find module '"+j+"'");};c.alias=function(j,f){var d=c.modules.path(),l=null;try{l=c.resolve(j+"/package.json","/")}catch(h){l=c.resolve(j,"/")}for(var d=d.dirname(l),l=(Object.keys||function(a){var b=[],e;for(e in a)b.push(e);return b})(c.modules),
a=0;a<l.length;a++){var e=l[a];e.slice(0,d.length+1)===d+"/"?(e=e.slice(d.length),c.modules[f+e]=c.modules[d+e]):e===d&&(c.modules[f]=c.modules[d])}};var u={};c.define=function(j,f){c.modules.__browserify_process&&(u=c.modules.__browserify_process());var d=c._core[j]?"":c.modules.path().dirname(j),l=function(a){var e=c(a,d);if((a=c.cache[c.resolve(a,d)])&&null===a.parent)a.parent=h;return e};l.resolve=function(a){return c.resolve(a,d)};l.modules=c.modules;l.define=c.define;l.cache=c.cache;var h={id:j,
filename:j,exports:{},loaded:!1,parent:null};c.modules[j]=function(){c.cache[j]=h;f.call(h.exports,l,h,h.exports,d,j,u);h.loaded=!0;return h.exports}};c.define("path",function(c,f,d,l,h,a){function e(a,b){for(var e=[],g=0;g<a.length;g++)b(a[g],g,a)&&e.push(a[g]);return e}function g(a,b){for(var e=0,g=a.length;0<=g;g--){var d=a[g];"."==d?a.splice(g,1):".."===d?(a.splice(g,1),e++):e&&(a.splice(g,1),e--)}if(b)for(;e--;e)a.unshift("..");return a}var b=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;d.resolve=
function(){for(var b="",o=!1,d=arguments.length;-1<=d&&!o;d--){var c=0<=d?arguments[d]:a.cwd();"string"===typeof c&&c&&(b=c+"/"+b,o="/"===c.charAt(0))}b=g(e(b.split("/"),function(a){return!!a}),!o).join("/");return(o?"/":"")+b||"."};d.normalize=function(a){var b="/"===a.charAt(0),d="/"===a.slice(-1),a=g(e(a.split("/"),function(a){return!!a}),!b).join("/");!a&&!b&&(a=".");a&&d&&(a+="/");return(b?"/":"")+a};d.join=function(){var a=Array.prototype.slice.call(arguments,0);return d.normalize(e(a,function(a){return a&&
"string"===typeof a}).join("/"))};d.dirname=function(a){return(a=b.exec(a)[1]||"")?1===a.length?a:a.substring(0,a.length-1):"."};d.basename=function(a,e){var g=b.exec(a)[2]||"";e&&g.substr(-1*e.length)===e&&(g=g.substr(0,g.length-e.length));return g};d.extname=function(a){return b.exec(a)[3]||""}});c.define("__browserify_process",function(c,f,d,l,h,a){var f=a=f.exports={},e=[],g="undefined"!==typeof window&&window.postMessage&&window.addEventListener;g&&window.addEventListener("message",function(a){a.source===
window&&"browserify-tick"===a.data&&(a.stopPropagation(),0<e.length&&e.shift()())},!0);f.nextTick=function(a){g?(e.push(a),window.postMessage("browserify-tick","*")):setTimeout(a,0)};a.title="browser";a.browser=!0;a.env={};a.argv=[];a.binding=function(a){if("evals"===a)return c("vm");throw Error("No such module. (Possibly not yet loaded)");};var b="/",t;a.cwd=function(){return b};a.chdir=function(a){t||(t=c("path"));b=t.resolve(a,b)}});c.define("vm",function(c,f){f.exports=c("vm-browserify")});c.define("/node_modules/vm-browserify/package.json",
function(c,f){f.exports={main:"index.js"}});c.define("/node_modules/vm-browserify/index.js",function(c,f,d){var l=function(a){if(Object.keys)return Object.keys(a);var g=[],b;for(b in a)g.push(b);return g},h=function(a,g){if(a.forEach)return a.forEach(g);for(var b=0;b<a.length;b++)g(a[b],b,a)},a=d.Script=function(e){if(!(this instanceof a))return new a(e);this.code=e};a.prototype.runInNewContext=function(a){a||(a={});var g=document.createElement("iframe");g.style||(g.style={});g.style.display="none";
document.body.appendChild(g);var b=g.contentWindow;h(l(a),function(g){b[g]=a[g]});!b.eval&&b.execScript&&b.execScript("null");var d=b.eval(this.code);h(l(b),function(g){a[g]=b[g]});document.body.removeChild(g);return d};a.prototype.runInThisContext=function(){return eval(this.code)};a.prototype.runInContext=function(a){return this.runInNewContext(a)};h(l(a.prototype),function(e){d[e]=a[e]=function(g){var b=a(g);return b[e].apply(b,[].slice.call(arguments,1))}});d.createScript=function(a){return d.Script(a)};
d.createContext=a.createContext=function(a){var g={};"object"===typeof a&&h(l(a),function(b){g[b]=a[b]});return g}});c.define("/package.json",function(c,f){f.exports={main:"./index"}});c.define("js-select",function(c,f){function d(a){a=e._parse(a||"*")[1];return","==a[0]?a.slice(1):[a]}function l(a,e){for(var g=0;g<a.length;g++){var d;a:{d=a[g];for(var c=e,l=c.parents.concat([c]),j=l.length-1,f=d.length-1,r=!0;0<=f&&0<=j;){var q=d[f],c=l[j];if(">"==q)f--,r=!0;else{if(h(q,c))f--;else if(r){d=!1;break a}j--;
r=!1}}d=-1==f}if(d)return!0}return!1}function h(b,e){var d=e.key,c=e.node,h=e.parent;if(b.id&&d!=b.id)return!1;if(b.type){var f=b.type;if("null"==f&&null!==c||"array"==f&&!g(c)||"object"==f&&("object"!=typeof c||null===c||g(c))||("boolean"==f||"string"==f||"number"==f)&&f!=typeof c)return!1}if(":nth-child"==b.pf&&(f=parseInt(d)+1,0==b.a&&f!==b.b||1==b.a&&!(f>=-b.b)||-1==b.a&&!(f<=b.b)||2==b.a&&f%2!=b.b)||":nth-last-child"==b.pf&&(!h||d!=h.node.length-b.b)||":only-child"==b.pc&&(!h||1!=h.node.length)||
":root"==b.pc&&void 0!==d)return!1;if(b.has){var j=","==b.has[0][0]?b.has[0].slice(1):[b.has[0]],p=!1;a(c).forEach(function(){l(j,this)&&(p=!0)});if(!p)return!1}return b.expr&&(f=b.expr,d=f[0],h=f[1],f=f[2],"string"!=typeof c||!d&&"="==h&&c!=f||!d&&"*="==h&&-1==c.indexOf(f))?!1:!0}var a=c("traverse"),e=c("JSONSelect");f.exports=function(b,e){var g=d(e);return{nodes:function(){var a=[];this.forEach(function(b){a.push(b)});return a},update:function(a){this.forEach(function(b){this.update("function"==
typeof a?a(b):a)})},remove:function(){this.forEach(function(){this.remove()})},condense:function(){a(b).forEach(function(){if(this.parent)if(this.parent.keep)this.keep=!0;else{var a=l(g,this);(this.keep=a)?this.parent.keep_child=!0:this.isLeaf?this.remove():this.after(function(){this.keep_child&&(this.parent.keep_child=!0);!this.keep&&!this.keep_child&&this.remove()})}})},forEach:function(e){a(b).forEach(function(a){l(g,this)&&(this.matches=function(a){return l(d(a),this)},e.call(this,a))})}}};var g=
Array.isArray||function(a){return"[object Array]"===toString.call(a)}});c.define("/node_modules/traverse/package.json",function(c,f){f.exports={main:"./index"}});c.define("/node_modules/traverse/index.js",function(c,f){function d(a){if(!(this instanceof d))return new d(a);this.value=a}function l(a,e,g){var b=[],d=[],c=!0;return function x(a){var f=g?h(a):a,l,j,q,v,n=!0,i={node:f,node_:a,path:[].concat(b),parent:d[d.length-1],parents:d,key:b.slice(-1)[0],isRoot:0===b.length,level:b.length,circular:null,
update:function(a,b){i.isRoot||(i.parent.node[i.key]=a);i.node=a;b&&(n=!1)},"delete":function(){delete i.parent.node[i.key]},remove:function(){Array.isArray(i.parent.node)?i.parent.node.splice(i.key,1):delete i.parent.node[i.key]},keys:null,before:function(a){l=a},after:function(a){j=a},pre:function(a){q=a},post:function(a){v=a},stop:function(){c=!1},block:function(){n=!1}};if(!c)return i;if("object"===typeof f&&null!==f){i.keys=Object.keys(f);i.isLeaf=0==i.keys.length;for(f=0;f<d.length;f++)if(d[f].node_===
a){i.circular=d[f];break}}else i.isLeaf=!0;i.notLeaf=!i.isLeaf;i.notRoot=!i.isRoot;a=e.call(i,i.node);void 0!==a&&i.update&&i.update(a);l&&l.call(i,i.node);if(!n)return i;"object"==typeof i.node&&(null!==i.node&&!i.circular)&&(d.push(i),i.keys.forEach(function(a,e){b.push(a);q&&q.call(i,i.node[a],a);var d=x(i.node[a]);g&&Object.hasOwnProperty.call(i.node,a)&&(i.node[a]=d.node);d.isLast=e==i.keys.length-1;d.isFirst=0==e;v&&v.call(i,d);b.pop()}),d.pop());j&&j.call(i,i.node);return i}(a).node}function h(a){if("object"===
typeof a&&null!==a){var e;e=Array.isArray(a)?[]:a instanceof Date?new Date(a):a instanceof Boolean?new Boolean(a):a instanceof Number?new Number(a):a instanceof String?new String(a):Object.create(Object.getPrototypeOf(a));Object.keys(a).forEach(function(d){e[d]=a[d]});return e}return a}f.exports=d;d.prototype.get=function(a){for(var e=this.value,d=0;d<a.length;d++){var b=a[d];if(!Object.hasOwnProperty.call(e,b)){e=void 0;break}e=e[b]}return e};d.prototype.set=function(a,e){for(var d=this.value,b=
0;b<a.length-1;b++){var c=a[b];Object.hasOwnProperty.call(d,c)||(d[c]={});d=d[c]}return d[a[b]]=e};d.prototype.map=function(a){return l(this.value,a,!0)};d.prototype.forEach=function(a){return this.value=l(this.value,a,!1)};d.prototype.reduce=function(a,d){var c=1===arguments.length,b=c?this.value:d;this.forEach(function(d){if(!this.isRoot||!c)b=a.call(this,b,d)});return b};d.prototype.deepEqual=function(a){if(1!==arguments.length)throw Error("deepEqual requires exactly one object to compare against");
var e=!0,c=a;this.forEach(function(b){var f=function(){e=!1}.bind(this);if(!this.isRoot){if("object"!==typeof c)return f();c=c[this.key]}var h=c;this.post(function(){c=h});if(this.circular)d(a).get(this.circular.path)!==h&&f();else if(typeof h!==typeof b)f();else if(null===h||null===b||void 0===h||void 0===b)h!==b&&f();else if(h.__proto__!==b.__proto__)f();else if(h!==b)if("function"===typeof h)h instanceof RegExp?h.toString()!=b.toString()&&f():h!==b&&f();else if("object"===typeof h)if("[object Arguments]"===
Object.prototype.toString.call(b)||"[object Arguments]"===Object.prototype.toString.call(h))Object.prototype.toString.call(h)!==Object.prototype.toString.call(b)&&f();else if(h instanceof Date||b instanceof Date)(!(h instanceof Date)||!(b instanceof Date)||h.getTime()!==b.getTime())&&f();else{var l=Object.keys(h),j=Object.keys(b);if(l.length!==j.length)return f();for(j=0;j<l.length;j++)Object.hasOwnProperty.call(b,l[j])||f()}});return e};d.prototype.paths=function(){var a=[];this.forEach(function(){a.push(this.path)});
return a};d.prototype.nodes=function(){var a=[];this.forEach(function(){a.push(this.node)});return a};d.prototype.clone=function(){var a=[],d=[];return function b(c){for(var f=0;f<a.length;f++)if(a[f]===c)return d[f];if("object"===typeof c&&null!==c){var j=h(c);a.push(c);d.push(j);Object.keys(c).forEach(function(a){j[a]=b(c[a])});a.pop();d.pop();return j}return c}(this.value)};Object.keys(d.prototype).forEach(function(a){d[a]=function(c){var f=[].slice.call(arguments,1),b=d(c);return b[a].apply(b,
f)}})});c.define("/node_modules/JSONSelect/package.json",function(c,f){f.exports={main:"src/jsonselect"}});c.define("/node_modules/JSONSelect/src/jsonselect.js",function(c,f,d){var c="undefined"===typeof d?window.JSONSelect={}:d,l=function(a){try{return JSON&&JSON.parse?JSON.parse(a):(new Function("return "+a))()}catch(b){h("ijs",b.message)}},h=function(a,b){throw Error(v[a]+(b&&" in '"+b+"'"));},a=function(a,b){b||(b=0);var d=i.exec(a.substr(b));if(d){var b=b+d[0].length,c;d[1]?c=[b," "]:d[2]?c=
[b,d[0]]:d[3]?c=[b,n.typ,d[0]]:d[4]?c=[b,n.psc,d[0]]:d[5]?c=[b,n.psf,d[0]]:d[6]?h("upc",a):d[8]?c=[b,d[7]?n.ide:n.str,l(d[8])]:d[9]?h("ujs",a):d[10]&&(c=[b,n.ide,d[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")]);return c}},e=function(a,b){return typeof a===b},g=function(a,b){var d,c=B.exec(a.substr(b));if(c)return b+=c[0].length,d=c[1]||c[2]||c[3]||c[5]||c[6],c[1]||c[2]||c[3]?[b,0,l(d)]:c[4]?[b,0,void 0]:[b,d]},b=function(a,d){d||(d=0);var c=g(a,d),e;c&&"("===c[1]?(e=b(a,c[0]),c=g(a,e[0]),(!c||")"!==
c[1])&&h("epex",a),d=c[0],e=["(",e[1]]):!c||c[1]&&"x"!=c[1]?h("ee",a+" - "+(c[1]&&c[1])):(e="x"===c[1]?void 0:c[2],d=c[0]);c=g(a,d);if(!c||")"==c[1])return[d,e];("x"==c[1]||!c[1])&&h("bop",a+" - "+(c[1]&&c[1]));var f=b(a,c[0]),d=f[0],f=f[1],l;if("object"!==typeof f||"("===f[0]||w[c[1]][0]<w[f[1]][0])l=[e,c[1],f];else{for(l=f;"object"===typeof f[0]&&"("!=f[0][0]&&w[c[1]][0]>=w[f[0][1]][0];)f=f[0];f[0]=[e,c[1],f[0]]}return[d,l]},t=function(a,c){function d(a){return"object"!==typeof a||null===a?a:"("===
a[0]?d(a[1]):[d(a[0]),a[1],d(a[2])]}var e=b(a,c?c:0);return[e[0],d(e[1])]},o=function(a,c){if(void 0===a)return c;if(null===a||"object"!==typeof a)return a;var b=o(a[0],c),d=o(a[2],c);return w[a[1]][1](b,d)},y=function(c,b,d,e){d||(e={});var f=[],g,l;for(b||(b=0);;){var m;m=c;var i=b,b=i,j={},k=a(m,i);k&&" "===k[1]&&(b=i=k[0],k=a(m,i));k&&k[1]===n.typ?(j.type=k[2],k=a(m,i=k[0])):k&&"*"===k[1]&&(k=a(m,i=k[0]));for(;void 0!==k;){if(k[1]===n.ide)j.id&&h("nmi",k[1]),j.id=k[2];else if(k[1]===n.psc)(j.pc||
j.pf)&&h("mpc",k[1]),":first-child"===k[2]?(j.pf=":nth-child",j.a=0,j.b=1):":last-child"===k[2]?(j.pf=":nth-last-child",j.a=0,j.b=1):j.pc=k[2];else if(k[1]===n.psf)":val"===k[2]||":contains"===k[2]?(j.expr=[void 0,":val"===k[2]?"=":"*=",void 0],(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||"("!==k[1])&&h("pex",m),(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||k[1]!==n.str)&&h("sex",m),j.expr[2]=k[2],(k=a(m,k[0]))&&" "===k[1]&&(k=a(m,k[0])),(!k||")"!==k[1])&&h("epex",m)):":has"===k[2]?((k=a(m,k[0]))&&
" "===k[1]&&(k=a(m,k[0])),(!k||"("!==k[1])&&h("pex",m),i=y(m,k[0],!0),k[0]=i[0],j.has||(j.has=[]),j.has.push(i[1])):":expr"===k[2]?(j.expr&&h("mexp",m),i=t(m,k[0]),k[0]=i[0],j.expr=i[1]):((j.pc||j.pf)&&h("mpc",m),j.pf=k[2],(i=A.exec(m.substr(k[0])))||h("mepf",m),i[5]?(j.a=2,j.b="odd"===i[5]?1:0):i[6]?(j.a=0,j.b=parseInt(i[6],10)):(j.a=parseInt((i[1]?i[1]:"+")+(i[2]?i[2]:"1"),10),j.b=i[3]?parseInt(i[3]+i[4],10):0),k[0]+=i[0].length);else break;k=a(m,i=k[0])}b===i&&h("se",m);m=[i,j];f.push(m[1]);(m=
a(c,b=m[0]))&&" "===m[1]&&(m=a(c,b=m[0]));if(!m)break;if(">"===m[1]||"~"===m[1])"~"===m[1]&&(e.usesSiblingOp=!0),f.push(m[1]),b=m[0];else if(","===m[1])void 0===g?g=[",",f]:g.push(f),f=[],b=m[0];else if(")"===m[1]){d||h("ucp",m[1]);l=1;b=m[0];break}}d&&!l&&h("mcp",c);g&&g.push(f);var s;if(!d&&e.usesSiblingOp)if(c=g?g:f,","===c[0]){for(d=[","];s<c.length;s++)var o=x(o[s]),d=d.concat(","===o[0]?o.slice(1):o);s=d}else s=x(c);else s=g?g:f;return[b,s]},x=function(a){for(var c=[],b,d=0;d<a.length;d++)if("~"===
a[d]){if(2>d||">"!=a[d-2])b=a.slice(0,d-1),b=b.concat([{has:[[{pc:":root"},">",a[d-1]]]},">"]),b=b.concat(a.slice(d+1)),c.push(b);if(1<d){var e=">"===a[d-2]?d-3:d-2;b=a.slice(0,e);var f={},g;for(g in a[e])a[e].hasOwnProperty(g)&&(f[g]=a[e][g]);f.has||(f.has=[]);f.has.push([{pc:":root"},">",a[d-1]]);b=b.concat(f,">",a.slice(d+1));c.push(b)}break}return d==a.length?a:1<c.length?[","].concat(c):c[0]},u=function(a){return Array.isArray?Array.isArray(a):"[object Array]"===q.call(a)},z=function(a,b,c,d,
e){var f=[],g=">"===b[0]?b[1]:b[0],h=!0;if(g.type&&h){var h=g.type,i;null===a?i="null":(i=typeof a,"object"===i&&u(a)&&(i="array"));h=h===i}g.id&&(h=h&&g.id===c);h&&g.pf&&(":nth-last-child"===g.pf?d=e-d:d++,0===g.a?h=g.b===d:(c=(d-g.b)%g.a,h=!c&&0<=d*g.a+g.b));if(h&&g.has){d=function(){throw 42;};for(c=0;c<g.has.length;c++){try{p(g.has[c],a,d)}catch(j){if(42===j)continue}h=!1;break}}h&&g.expr&&(h=o(g.expr,a));">"!==b[0]&&":root"!==b[0].pc&&f.push(b);h&&(">"===b[0]?2<b.length&&(h=!1,f.push(b.slice(2))):
1<b.length&&(h=!1,f.push(b.slice(1))));return[h,f]},p=function(a,b,c,d,e,f){for(var a=","===a[0]?a.slice(1):[a],g=[],h=!1,i=0,j=0,k,l,i=0;i<a.length;i++){l=z(b,a[i],d,e,f);l[0]&&(h=!0);for(j=0;j<l[1].length;j++)g.push(l[1][j])}if(g.length&&"object"===typeof b)if(1<=g.length&&g.unshift(","),u(b))for(i=0;i<b.length;i++)p(g,b[i],c,void 0,i,b.length);else for(k in b)b.hasOwnProperty(k)&&p(g,b[k],c,k);h&&c&&c(b)},r=function(a){return{sel:y(a)[1],match:function(a){var b=[];p(this.sel,a,function(a){b.push(a)});
return b},forEach:function(a,b){return p(this.sel,a,b)}}},q=Object.prototype.toString,v={bop:"binary operator expected",ee:"expression expected",epex:"closing paren expected ')'",ijs:"invalid json string",mcp:"missing closing paren",mepf:"malformed expression in pseudo-function",mexp:"multiple expressions not allowed",mpc:"multiple pseudo classes (:xxx) not allowed",nmi:"multiple ids not allowed",pex:"opening paren expected '('",se:"selector expected",sex:"string expected",sra:"string required after '.'",
uc:"unrecognized char",ucp:"unexpected closing paren",ujs:"unclosed json string",upc:"unrecognized pseudo class"},n={psc:1,psf:2,typ:3,str:4,ide:5},i=RegExp('^(?:([\\r\\n\\t\\ ]+)|([~*,>\\)\\(])|(string|boolean|null|array|object|number)|(:(?:root|first-child|last-child|only-child))|(:(?:nth-child|nth-last-child|has|expr|val|contains))|(:\\w+)|(?:(\\.)?(\\"(?:[^\\\\\\"]|\\\\[^\\"])*\\"))|(\\")|\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*))'),
A=/^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/,B=RegExp('^\\s*(?:(true|false|null)|(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|("(?:[^\\]|\\[^"])*")|(x)|(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|([\\(\\)]))'),w={"*":[9,function(a,b){return a*b}],"/":[9,function(a,b){return a/b}],"%":[9,function(a,b){return a%b}],"+":[7,function(a,b){return a+b}],"-":[7,function(a,b){return a-b}],"<=":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a<=b}],">=":[5,function(a,
b){return e(a,"number")&&e(b,"number")&&a>=b}],"$=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&a.lastIndexOf(b)===a.length-b.length}],"^=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&0===a.indexOf(b)}],"*=":[5,function(a,b){return e(a,"string")&&e(b,"string")&&-1!==a.indexOf(b)}],">":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a>b}],"<":[5,function(a,b){return e(a,"number")&&e(b,"number")&&a<b}],"=":[3,function(a,b){return a===b}],"!=":[3,function(a,b){return a!==b}],
"&&":[2,function(a,b){return a&&b}],"||":[1,function(a,b){return a||b}]};c._lex=a;c._parse=y;c.match=function(a,b){return r(a).match(b)};c.forEach=function(a,b,c){return r(a).forEach(b,c)};c.compile=r});return c("js-select")}();

@@ -1,1458 +0,1533 @@

var select = (function() { var require = function (file, cwd) {
var resolved = require.resolve(file, cwd || '/');
var mod = require.modules[resolved];
if (!mod) throw new Error(
'Failed to resolve module ' + file + ', tried ' + resolved
);
var res = mod._cached ? mod._cached : mod();
return res;
}
var __require = require;
var select = (function() {
var require = function (file, cwd) {
var resolved = require.resolve(file, cwd || '/');
var mod = require.modules[resolved];
if (!mod) throw new Error(
'Failed to resolve module ' + file + ', tried ' + resolved
);
var cached = require.cache[resolved];
var res = cached? cached.exports : mod();
return res;
};
require.paths = [];
require.modules = {};
require.extensions = [".js",".coffee"];
require.paths = [];
require.modules = {};
require.cache = {};
require.extensions = [".js",".coffee"];
require.resolve = (function () {
var core = {
'assert': true,
'events': true,
'fs': true,
'path': true,
'vm': true
};
return function (x, cwd) {
if (!cwd) cwd = '/';
require._core = {
'assert': true,
'events': true,
'fs': true,
'path': true,
'vm': true
};
require.resolve = (function () {
return function (x, cwd) {
if (!cwd) cwd = '/';
if (core[x]) return x;
var path = require.modules.path();
var y = cwd || '.';
if (require._core[x]) return x;
var path = require.modules.path();
cwd = path.resolve('/', cwd);
var y = cwd || '/';
if (x.match(/^(?:\.\.?\/|\/)/)) {
var m = loadAsFileSync(path.resolve(y, x))
|| loadAsDirectorySync(path.resolve(y, x));
if (m) return m;
}
if (x.match(/^(?:\.\.?\/|\/)/)) {
var m = loadAsFileSync(path.resolve(y, x))
|| loadAsDirectorySync(path.resolve(y, x));
if (m) return m;
}
var n = loadNodeModulesSync(x, y);
if (n) return n;
var n = loadNodeModulesSync(x, y);
if (n) return n;
throw new Error("Cannot find module '" + x + "'");
throw new Error("Cannot find module '" + x + "'");
function loadAsFileSync (x) {
if (require.modules[x]) {
return x;
}
function loadAsFileSync (x) {
x = path.normalize(x);
if (require.modules[x]) {
return x;
}
for (var i = 0; i < require.extensions.length; i++) {
var ext = require.extensions[i];
if (require.modules[x + ext]) return x + ext;
}
}
for (var i = 0; i < require.extensions.length; i++) {
var ext = require.extensions[i];
if (require.modules[x + ext]) return x + ext;
}
}
function loadAsDirectorySync (x) {
x = x.replace(/\/+$/, '');
var pkgfile = x + '/package.json';
if (require.modules[pkgfile]) {
var pkg = require.modules[pkgfile]();
var b = pkg.browserify;
if (typeof b === 'object' && b.main) {
var m = loadAsFileSync(path.resolve(x, b.main));
if (m) return m;
}
else if (typeof b === 'string') {
var m = loadAsFileSync(path.resolve(x, b));
if (m) return m;
}
else if (pkg.main) {
var m = loadAsFileSync(path.resolve(x, pkg.main));
if (m) return m;
}
}
function loadAsDirectorySync (x) {
x = x.replace(/\/+$/, '');
var pkgfile = path.normalize(x + '/package.json');
if (require.modules[pkgfile]) {
var pkg = require.modules[pkgfile]();
var b = pkg.browserify;
if (typeof b === 'object' && b.main) {
var m = loadAsFileSync(path.resolve(x, b.main));
if (m) return m;
}
else if (typeof b === 'string') {
var m = loadAsFileSync(path.resolve(x, b));
if (m) return m;
}
else if (pkg.main) {
var m = loadAsFileSync(path.resolve(x, pkg.main));
if (m) return m;
}
}
return loadAsFileSync(x + '/index');
}
return loadAsFileSync(x + '/index');
}
function loadNodeModulesSync (x, start) {
var dirs = nodeModulesPathsSync(start);
for (var i = 0; i < dirs.length; i++) {
var dir = dirs[i];
var m = loadAsFileSync(dir + '/' + x);
if (m) return m;
var n = loadAsDirectorySync(dir + '/' + x);
if (n) return n;
}
function loadNodeModulesSync (x, start) {
var dirs = nodeModulesPathsSync(start);
for (var i = 0; i < dirs.length; i++) {
var dir = dirs[i];
var m = loadAsFileSync(dir + '/' + x);
if (m) return m;
var n = loadAsDirectorySync(dir + '/' + x);
if (n) return n;
}
var m = loadAsFileSync(x);
if (m) return m;
}
var m = loadAsFileSync(x);
if (m) return m;
}
function nodeModulesPathsSync (start) {
var parts;
if (start === '/') parts = [ '' ];
else parts = path.normalize(start).split('/');
function nodeModulesPathsSync (start) {
var parts;
if (start === '/') parts = [ '' ];
else parts = path.normalize(start).split('/');
var dirs = [];
for (var i = parts.length - 1; i >= 0; i--) {
if (parts[i] === 'node_modules') continue;
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
dirs.push(dir);
}
var dirs = [];
for (var i = parts.length - 1; i >= 0; i--) {
if (parts[i] === 'node_modules') continue;
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
dirs.push(dir);
}
return dirs;
}
};
})();
return dirs;
}
};
})();
require.alias = function (from, to) {
var path = require.modules.path();
var res = null;
try {
res = require.resolve(from + '/package.json', '/');
}
catch (err) {
res = require.resolve(from, '/');
}
var basedir = path.dirname(res);
require.alias = function (from, to) {
var path = require.modules.path();
var res = null;
try {
res = require.resolve(from + '/package.json', '/');
}
catch (err) {
res = require.resolve(from, '/');
}
var basedir = path.dirname(res);
Object.keys(require.modules)
.forEach(function (x) {
if (x.slice(0, basedir.length + 1) === basedir + '/') {
var f = x.slice(basedir.length);
require.modules[to + f] = require.modules[basedir + f];
}
else if (x === basedir) {
require.modules[to] = require.modules[basedir];
}
})
;
};
var keys = (Object.keys || function (obj) {
var res = [];
for (var key in obj) res.push(key);
return res;
})(require.modules);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key.slice(0, basedir.length + 1) === basedir + '/') {
var f = key.slice(basedir.length);
require.modules[to + f] = require.modules[basedir + f];
}
else if (key === basedir) {
require.modules[to] = require.modules[basedir];
}
}
};
if (typeof process === 'undefined') process = {};
(function () {
var process = {};
require.define = function (filename, fn) {
if (require.modules.__browserify_process) {
process = require.modules.__browserify_process();
}
var dirname = require._core[filename]
? ''
: require.modules.path().dirname(filename)
;
var require_ = function (file) {
var requiredModule = require(file, dirname);
var cached = require.cache[require.resolve(file, dirname)];
if (!process.nextTick) process.nextTick = function (fn) {
setTimeout(fn, 0);
};
if (cached && cached.parent === null) {
cached.parent = module_;
}
if (!process.title) process.title = 'browser';
return requiredModule;
};
require_.resolve = function (name) {
return require.resolve(name, dirname);
};
require_.modules = require.modules;
require_.define = require.define;
require_.cache = require.cache;
var module_ = {
id : filename,
filename: filename,
exports : {},
loaded : false,
parent: null
};
require.modules[filename] = function () {
require.cache[filename] = module_;
fn.call(
module_.exports,
require_,
module_,
module_.exports,
dirname,
filename,
process
);
module_.loaded = true;
return module_.exports;
};
};
})();
if (!process.binding) process.binding = function (name) {
if (name === 'evals') return require('vm')
else throw new Error('No such module')
};
if (!process.cwd) process.cwd = function () { return '.' };
require.define("path",function(require,module,exports,__dirname,__filename,process){function filter (xs, fn) {
var res = [];
for (var i = 0; i < xs.length; i++) {
if (fn(xs[i], i, xs)) res.push(xs[i]);
}
return res;
}
require.modules["path"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = ".";
var __filename = "path";
var require = function (file) {
return __require(file, ".");
};
require.resolve = function (file) {
return __require.resolve(name, ".");
};
require.modules = __require.modules;
__require.modules["path"]._cached = module.exports;
(function () {
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for (var i = parts.length; i >= 0; i--) {
var last = parts[i];
if (last == '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for (var i = parts.length; i >= 0; i--) {
var last = parts[i];
if (last == '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
// if the path is allowed to go above the root, restore leading ..s
if (allowAboveRoot) {
for (; up--; up) {
parts.unshift('..');
}
}
// if the path is allowed to go above the root, restore leading ..s
if (allowAboveRoot) {
for (; up--; up) {
parts.unshift('..');
}
}
return parts;
}
return parts;
}
// Regex to split a filename into [*, dir, basename, ext]
// posix version
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
// Regex to split a filename into [*, dir, basename, ext]
// posix version
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0)
? arguments[i]
: process.cwd();
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0)
? arguments[i]
: process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
continue;
}
// Skip empty and invalid entries
if (typeof path !== 'string' || !path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
// Normalize the path
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
// path.normalize(path)
// posix version
exports.normalize = function(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.slice(-1) === '/';
// path.normalize(path)
// posix version
exports.normalize = function(path) {
var isAbsolute = path.charAt(0) === '/',
trailingSlash = path.slice(-1) === '/';
// Normalize the path
path = normalizeArray(path.split('/').filter(function(p) {
return !!p;
}), !isAbsolute).join('/');
// Normalize the path
path = normalizeArray(filter(path.split('/'), function(p) {
return !!p;
}), !isAbsolute).join('/');
if (!path && !isAbsolute) {
path = '.';
}
if (path && trailingSlash) {
path += '/';
}
if (!path && !isAbsolute) {
path = '.';
}
if (path && trailingSlash) {
path += '/';
}
return (isAbsolute ? '/' : '') + path;
};
return (isAbsolute ? '/' : '') + path;
};
// posix version
exports.join = function() {
var paths = Array.prototype.slice.call(arguments, 0);
return exports.normalize(paths.filter(function(p, index) {
return p && typeof p === 'string';
}).join('/'));
};
// posix version
exports.join = function() {
var paths = Array.prototype.slice.call(arguments, 0);
return exports.normalize(filter(paths, function(p, index) {
return p && typeof p === 'string';
}).join('/'));
};
exports.dirname = function(path) {
var dir = splitPathRe.exec(path)[1] || '';
var isWindows = false;
if (!dir) {
// No dirname
return '.';
} else if (dir.length === 1 ||
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
// It is just a slash or a drive letter with a slash
return dir;
} else {
// It is a full dirname, strip trailing slash
return dir.substring(0, dir.length - 1);
}
};
exports.dirname = function(path) {
var dir = splitPathRe.exec(path)[1] || '';
var isWindows = false;
if (!dir) {
// No dirname
return '.';
} else if (dir.length === 1 ||
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
// It is just a slash or a drive letter with a slash
return dir;
} else {
// It is a full dirname, strip trailing slash
return dir.substring(0, dir.length - 1);
}
};
exports.basename = function(path, ext) {
var f = splitPathRe.exec(path)[2] || '';
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
exports.basename = function(path, ext) {
var f = splitPathRe.exec(path)[2] || '';
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
exports.extname = function(path) {
return splitPathRe.exec(path)[3] || '';
};
;
}).call(module.exports);
exports.extname = function(path) {
return splitPathRe.exec(path)[3] || '';
};
});
require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process){var process = module.exports = {};
process.nextTick = (function () {
var queue = [];
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;
__require.modules["path"]._cached = module.exports;
return module.exports;
};
if (canPost) {
window.addEventListener('message', function (ev) {
if (ev.source === window && ev.data === 'browserify-tick') {
ev.stopPropagation();
if (queue.length > 0) {
var fn = queue.shift();
fn();
}
}
}, true);
}
return function (fn) {
if (canPost) {
queue.push(fn);
window.postMessage('browserify-tick', '*');
}
else setTimeout(fn, 0);
};
})();
require.modules["/node_modules/js-select/package.json"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/js-select";
var __filename = "/node_modules/js-select/package.json";
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.binding = function (name) {
if (name === 'evals') return (require)('vm')
else throw new Error('No such module. (Possibly not yet loaded)')
};
(function () {
var cwd = '/';
var path;
process.cwd = function () { return cwd };
process.chdir = function (dir) {
if (!path) path = require('path');
cwd = path.resolve(dir, cwd);
};
})();
});
require.define("vm",function(require,module,exports,__dirname,__filename,process){module.exports = require("vm-browserify")});
require.define("/node_modules/vm-browserify/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"index.js"}});
require.define("/node_modules/vm-browserify/index.js",function(require,module,exports,__dirname,__filename,process){var Object_keys = function (obj) {
if (Object.keys) return Object.keys(obj)
else {
var res = [];
for (var key in obj) res.push(key)
return res;
}
};
var forEach = function (xs, fn) {
if (xs.forEach) return xs.forEach(fn)
else for (var i = 0; i < xs.length; i++) {
fn(xs[i], i, xs);
}
};
var Script = exports.Script = function NodeScript (code) {
if (!(this instanceof Script)) return new Script(code);
this.code = code;
};
Script.prototype.runInNewContext = function (context) {
if (!context) context = {};
var require = function (file) {
return __require(file, "/node_modules/js-select");
};
var iframe = document.createElement('iframe');
if (!iframe.style) iframe.style = {};
iframe.style.display = 'none';
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/js-select");
};
document.body.appendChild(iframe);
require.modules = __require.modules;
__require.modules["/node_modules/js-select/package.json"]._cached = module.exports;
var win = iframe.contentWindow;
(function () {
module.exports = {"name":"js-select","description":"Traverse and modify objects with JSONSelect selectors","version":"0.4.0","author":"Heather Arthur <fayearthur@gmail.com>","repository":{"type":"git","url":"http://github.com/harthur/js-select.git"},"main":"./index","dependencies":{"traverse":"0.4.x","JSONSelect":"0.2.x"},"devDependencies":{"nomnom":"0.6.x","color":"0.3.x"},"keywords":["json"]};
}).call(module.exports);
forEach(Object_keys(context), function (key) {
win[key] = context[key];
});
if (!win.eval && win.execScript) {
// win.eval() magically appears when this is called in IE:
win.execScript('null');
}
__require.modules["/node_modules/js-select/package.json"]._cached = module.exports;
return module.exports;
};
require.modules["/node_modules/js-select/index.js"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/js-select";
var __filename = "/node_modules/js-select/index.js";
var res = win.eval(this.code);
var require = function (file) {
return __require(file, "/node_modules/js-select");
};
forEach(Object_keys(win), function (key) {
context[key] = win[key];
});
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/js-select");
};
document.body.removeChild(iframe);
require.modules = __require.modules;
__require.modules["/node_modules/js-select/index.js"]._cached = module.exports;
(function () {
var traverse = require("traverse"),
JSONSelect = require("JSONSelect");
return res;
};
module.exports = function(obj, string) {
sels = parseSelectors(string);
Script.prototype.runInThisContext = function () {
return eval(this.code); // maybe...
};
return {
nodes: function() {
var nodes = [];
this.forEach(function(node) {
nodes.push(node);
});
return nodes;
},
Script.prototype.runInContext = function (context) {
// seems to be just runInNewContext on magical context objects which are
// otherwise indistinguishable from objects except plain old objects
// for the parameter segfaults node
return this.runInNewContext(context);
};
forEach: function(cb) {
traverse(obj).forEach(function(node) {
if (matchesAny(sels, this)) {
this.matches = function(string) {
return matchesAny(parseSelectors(string), this);
};
// inherit context from js-traverse
cb.call(this, node);
}
});
}
};
}
forEach(Object_keys(Script.prototype), function (name) {
exports[name] = Script[name] = function (code) {
var s = Script(code);
return s[name].apply(s, [].slice.call(arguments, 1));
};
});
function parseSelectors(string) {
var parsed = JSONSelect._parse(string || "*")[1];
return getSelectors(parsed);
}
exports.createScript = function (code) {
return exports.Script(code);
};
function getSelectors(parsed) {
if (parsed[0] == ",") {
return parsed.slice(1);
}
return [parsed];
}
exports.createContext = Script.createContext = function (context) {
// not really sure what this one does
// seems to just make a shallow copy
var copy = {};
if(typeof context === 'object') {
forEach(Object_keys(context), function (key) {
copy[key] = context[key];
});
}
return copy;
};
});
function matchesAny(sels, context) {
for (var i = 0; i < sels.length; i++) {
if (matches(sels[i], context)) {
return true;
}
}
return false;
}
require.define("/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"./index"}});
function matches(sel, context) {
var path = context.parents.concat([context]),
i = path.length - 1,
j = sel.length - 1;
require.define("js-select",function(require,module,exports,__dirname,__filename,process){var traverse = require("traverse"),
JSONSelect = require("JSONSelect");
// walk up the ancestors
var must = true;
while(j >= 0 && i >= 0) {
var part = sel[j],
context = path[i];
module.exports = function(obj, string) {
var sels = parseSelectors(string);
if (part == ">") {
j--;
must = true;
continue;
}
return {
nodes: function() {
var nodes = [];
this.forEach(function(node) {
nodes.push(node);
});
return nodes;
},
update: function(cb) {
this.forEach(function(node) {
this.update(typeof cb == "function" ? cb(node) : cb);
});
},
remove: function() {
this.forEach(function(node) {
this.remove();
})
},
condense: function() {
traverse(obj).forEach(function(node) {
if (!this.parent) return;
if (this.parent.keep) {
this.keep = true;
} else {
var match = matchesAny(sels, this);
this.keep = match;
if (!match) {
if (this.isLeaf) {
this.remove();
} else {
this.after(function() {
if (this.keep_child) {
this.parent.keep_child = true;
}
if (!this.keep && !this.keep_child) {
this.remove();
}
});
}
} else {
this.parent.keep_child = true;
}
}
});
},
forEach: function(cb) {
traverse(obj).forEach(function(node) {
if (matchesAny(sels, this)) {
this.matches = function(string) {
return matchesAny(parseSelectors(string), this);
};
// inherit context from js-traverse
cb.call(this, node);
}
});
}
};
}
if (matchesKey(part, context)) {
j--;
}
else if(must) {
return false;
}
function parseSelectors(string) {
var parsed = JSONSelect._parse(string || "*")[1];
return getSelectors(parsed);
}
i--;
must = false;
}
return j == -1;
}
function getSelectors(parsed) {
if (parsed[0] == ",") { // "selector1, selector2"
return parsed.slice(1);
}
return [parsed];
}
function matchesKey(part, context) {
var key = context.key,
node = context.node,
parent = context.parent;
function matchesAny(sels, context) {
for (var i = 0; i < sels.length; i++) {
if (matches(sels[i], context)) {
return true;
}
}
return false;
}
if (part.id && key != part.id) {
return false;
}
if (part.type) {
if (part.type == "null") {
if (context.node !== null) {
return false;
}
}
else if (part.type == "array") {
if (!isArray(context.node)) {
return false;
}
}
else if (part.type == "object") {
if (typeof context.node != "object"
|| context.node === null || isArray(context.node)) {
return false;
}
}
else if (part.type != typeof context.node) {
return false;
}
}
if (part.pf == ":nth-child") {
var index = parseInt(key) + 1;
if ((part.a == 0 && index !== part.b) // :nth-child(i)
|| (part.a == 1 && !(index >= -part.b)) // :nth-child(n)
|| (part.a == -1 && !(index <= part.b)) // :nth-child(-n + 1)
|| (part.a == 2 && index % 2 != part.b)) { // :nth-child(even)
return false;
}
}
if (part.pf == ":nth-last-child") {
var n = context.parent && context.parent.node.length;
if (!n || key != n - part.b) {
return false;
}
}
if (part.pc == ":only-child") {
var n = context.parent && context.parent.node.length;
if (!n || n != 1) {
return false;
}
}
if (part.pc == ":root" && key !== undefined) {
return false;
}
if (part.has) {
var sels = getSelectors(part.has[0]),
match = false;
traverse(node).forEach(function(child) {
if (matchesAny(sels, this)) {
match = true;
}
});
if (!match) {
return false;
}
}
if (part.expr) {
var expr = part.expr, lhs = expr[0], op = expr[1], rhs = expr[2];
if (typeof node != "string"
|| (!lhs && op == "=" && node != rhs) // :val("str")
|| (!lhs && op == "*=" && node.indexOf(rhs) == -1)) { // :contains("substr")
return false;
}
}
return true;
}
function matches(sel, context) {
var path = context.parents.concat([context]),
i = path.length - 1,
j = sel.length - 1;
var isArray = Array.isArray || function(obj) {
return toString.call(obj) === '[object Array]';
}
;
}).call(module.exports);
__require.modules["/node_modules/js-select/index.js"]._cached = module.exports;
return module.exports;
};
// walk up the ancestors
var must = true;
while(j >= 0 && i >= 0) {
var part = sel[j],
context = path[i];
require.modules["/node_modules/traverse/package.json"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/traverse";
var __filename = "/node_modules/traverse/package.json";
var require = function (file) {
return __require(file, "/node_modules/traverse");
};
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/traverse");
};
require.modules = __require.modules;
__require.modules["/node_modules/traverse/package.json"]._cached = module.exports;
(function () {
module.exports = {"name":"traverse","version":"0.4.4","description":"Traverse and transform objects by visiting every node on a recursive walk","author":"James Halliday","license":"MIT/X11","main":"./index","repository":{"type":"git","url":"http://github.com/substack/js-traverse.git"},"devDependencies":{"expresso":"0.7.x"},"scripts":{"test":"expresso"}};
}).call(module.exports);
__require.modules["/node_modules/traverse/package.json"]._cached = module.exports;
return module.exports;
};
if (part == ">") {
j--;
must = true;
continue;
}
require.modules["/node_modules/traverse/index.js"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/traverse";
var __filename = "/node_modules/traverse/index.js";
var require = function (file) {
return __require(file, "/node_modules/traverse");
};
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/traverse");
};
require.modules = __require.modules;
__require.modules["/node_modules/traverse/index.js"]._cached = module.exports;
(function () {
module.exports = Traverse;
function Traverse (obj) {
if (!(this instanceof Traverse)) return new Traverse(obj);
this.value = obj;
}
if (matchesKey(part, context)) {
j--;
}
else if (must) {
return false;
}
Traverse.prototype.get = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) {
node = undefined;
break;
}
node = node[key];
}
return node;
};
i--;
must = false;
}
return j == -1;
}
Traverse.prototype.set = function (ps, value) {
var node = this.value;
for (var i = 0; i < ps.length - 1; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) node[key] = {};
node = node[key];
}
node[ps[i]] = value;
return value;
};
function matchesKey(part, context) {
var key = context.key,
node = context.node,
parent = context.parent;
Traverse.prototype.map = function (cb) {
return walk(this.value, cb, true);
};
if (part.id && key != part.id) {
return false;
}
if (part.type) {
var type = part.type;
Traverse.prototype.forEach = function (cb) {
this.value = walk(this.value, cb, false);
return this.value;
};
if (type == "null" && node !== null) {
return false;
}
else if (type == "array" && !isArray(node)) {
return false;
}
else if (type == "object" && (typeof node != "object"
|| node === null || isArray(node))) {
return false;
}
else if ((type == "boolean" || type == "string" || type == "number")
&& type != typeof node) {
return false;
}
}
if (part.pf == ":nth-child") {
var index = parseInt(key) + 1;
if ((part.a == 0 && index !== part.b) // :nth-child(i)
|| (part.a == 1 && !(index >= -part.b)) // :nth-child(n)
|| (part.a == -1 && !(index <= part.b)) // :nth-child(-n + 1)
|| (part.a == 2 && index % 2 != part.b)) { // :nth-child(even)
return false;
}
}
if (part.pf == ":nth-last-child"
&& (!parent || key != parent.node.length - part.b)) {
return false;
}
if (part.pc == ":only-child"
&& (!parent || parent.node.length != 1)) {
return false;
}
if (part.pc == ":root" && key !== undefined) {
return false;
}
if (part.has) {
var sels = getSelectors(part.has[0]),
match = false;
traverse(node).forEach(function(child) {
if (matchesAny(sels, this)) {
match = true;
}
});
if (!match) {
return false;
}
}
if (part.expr) {
var expr = part.expr, lhs = expr[0], op = expr[1], rhs = expr[2];
if (typeof node != "string"
|| (!lhs && op == "=" && node != rhs) // :val("str")
|| (!lhs && op == "*=" && node.indexOf(rhs) == -1)) { // :contains("substr")
return false;
}
}
return true;
}
Traverse.prototype.reduce = function (cb, init) {
var skip = arguments.length === 1;
var acc = skip ? this.value : init;
this.forEach(function (x) {
if (!this.isRoot || !skip) {
acc = cb.call(this, acc, x);
}
});
return acc;
};
var isArray = Array.isArray || function(obj) {
return toString.call(obj) === '[object Array]';
}
});
Traverse.prototype.deepEqual = function (obj) {
if (arguments.length !== 1) {
throw new Error(
'deepEqual requires exactly one object to compare against'
);
}
require.define("/node_modules/traverse/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"./index"}});
require.define("/node_modules/traverse/index.js",function(require,module,exports,__dirname,__filename,process){module.exports = Traverse;
function Traverse (obj) {
if (!(this instanceof Traverse)) return new Traverse(obj);
this.value = obj;
}
Traverse.prototype.get = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) {
node = undefined;
break;
}
node = node[key];
}
return node;
};
Traverse.prototype.set = function (ps, value) {
var node = this.value;
for (var i = 0; i < ps.length - 1; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) node[key] = {};
node = node[key];
}
node[ps[i]] = value;
return value;
};
Traverse.prototype.map = function (cb) {
return walk(this.value, cb, true);
};
Traverse.prototype.forEach = function (cb) {
this.value = walk(this.value, cb, false);
return this.value;
};
Traverse.prototype.reduce = function (cb, init) {
var skip = arguments.length === 1;
var acc = skip ? this.value : init;
this.forEach(function (x) {
if (!this.isRoot || !skip) {
acc = cb.call(this, acc, x);
}
});
return acc;
};
Traverse.prototype.deepEqual = function (obj) {
if (arguments.length !== 1) {
throw new Error(
'deepEqual requires exactly one object to compare against'
);
}
var equal = true;
var node = obj;
var equal = true;
var node = obj;
this.forEach(function (y) {
var notEqual = (function () {
equal = false;
//this.stop();
return undefined;
}).bind(this);
this.forEach(function (y) {
var notEqual = (function () {
equal = false;
//this.stop();
return undefined;
}).bind(this);
//if (node === undefined || node === null) return notEqual();
//if (node === undefined || node === null) return notEqual();
if (!this.isRoot) {
/*
if (!Object.hasOwnProperty.call(node, this.key)) {
return notEqual();
}
*/
if (typeof node !== 'object') return notEqual();
node = node[this.key];
}
if (!this.isRoot) {
/*
if (!Object.hasOwnProperty.call(node, this.key)) {
return notEqual();
}
*/
if (typeof node !== 'object') return notEqual();
node = node[this.key];
}
var x = node;
var x = node;
this.post(function () {
node = x;
});
this.post(function () {
node = x;
});
var toS = function (o) {
return Object.prototype.toString.call(o);
};
var toS = function (o) {
return Object.prototype.toString.call(o);
};
if (this.circular) {
if (Traverse(obj).get(this.circular.path) !== x) notEqual();
}
else if (typeof x !== typeof y) {
notEqual();
}
else if (x === null || y === null || x === undefined || y === undefined) {
if (x !== y) notEqual();
}
else if (x.__proto__ !== y.__proto__) {
notEqual();
}
else if (x === y) {
// nop
}
else if (typeof x === 'function') {
if (x instanceof RegExp) {
// both regexps on account of the __proto__ check
if (x.toString() != y.toString()) notEqual();
}
else if (x !== y) notEqual();
}
else if (typeof x === 'object') {
if (toS(y) === '[object Arguments]'
|| toS(x) === '[object Arguments]') {
if (toS(x) !== toS(y)) {
notEqual();
}
}
else if (x instanceof Date || y instanceof Date) {
if (!(x instanceof Date) || !(y instanceof Date)
|| x.getTime() !== y.getTime()) {
notEqual();
}
}
else {
var kx = Object.keys(x);
var ky = Object.keys(y);
if (kx.length !== ky.length) return notEqual();
for (var i = 0; i < kx.length; i++) {
var k = kx[i];
if (!Object.hasOwnProperty.call(y, k)) {
notEqual();
}
}
}
}
});
if (this.circular) {
if (Traverse(obj).get(this.circular.path) !== x) notEqual();
}
else if (typeof x !== typeof y) {
notEqual();
}
else if (x === null || y === null || x === undefined || y === undefined) {
if (x !== y) notEqual();
}
else if (x.__proto__ !== y.__proto__) {
notEqual();
}
else if (x === y) {
// nop
}
else if (typeof x === 'function') {
if (x instanceof RegExp) {
// both regexps on account of the __proto__ check
if (x.toString() != y.toString()) notEqual();
}
else if (x !== y) notEqual();
}
else if (typeof x === 'object') {
if (toS(y) === '[object Arguments]'
|| toS(x) === '[object Arguments]') {
if (toS(x) !== toS(y)) {
notEqual();
}
}
else if (x instanceof Date || y instanceof Date) {
if (!(x instanceof Date) || !(y instanceof Date)
|| x.getTime() !== y.getTime()) {
notEqual();
}
}
else {
var kx = Object.keys(x);
var ky = Object.keys(y);
if (kx.length !== ky.length) return notEqual();
for (var i = 0; i < kx.length; i++) {
var k = kx[i];
if (!Object.hasOwnProperty.call(y, k)) {
notEqual();
}
}
}
}
});
return equal;
};
return equal;
};
Traverse.prototype.paths = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.path);
});
return acc;
};
Traverse.prototype.paths = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.path);
});
return acc;
};
Traverse.prototype.nodes = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.node);
});
return acc;
};
Traverse.prototype.nodes = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.node);
});
return acc;
};
Traverse.prototype.clone = function () {
var parents = [], nodes = [];
Traverse.prototype.clone = function () {
var parents = [], nodes = [];
return (function clone (src) {
for (var i = 0; i < parents.length; i++) {
if (parents[i] === src) {
return nodes[i];
}
}
return (function clone (src) {
for (var i = 0; i < parents.length; i++) {
if (parents[i] === src) {
return nodes[i];
}
}
if (typeof src === 'object' && src !== null) {
var dst = copy(src);
if (typeof src === 'object' && src !== null) {
var dst = copy(src);
parents.push(src);
nodes.push(dst);
parents.push(src);
nodes.push(dst);
Object.keys(src).forEach(function (key) {
dst[key] = clone(src[key]);
});
Object.keys(src).forEach(function (key) {
dst[key] = clone(src[key]);
});
parents.pop();
nodes.pop();
return dst;
}
else {
return src;
}
})(this.value);
};
parents.pop();
nodes.pop();
return dst;
}
else {
return src;
}
})(this.value);
};
function walk (root, cb, immutable) {
var path = [];
var parents = [];
var alive = true;
function walk (root, cb, immutable) {
var path = [];
var parents = [];
var alive = true;
return (function walker (node_) {
var node = immutable ? copy(node_) : node_;
var modifiers = {};
return (function walker (node_) {
var node = immutable ? copy(node_) : node_;
var modifiers = {};
var keepGoing = true;
var keepGoing = true;
var state = {
node : node,
node_ : node_,
path : [].concat(path),
parent : parents[parents.length - 1],
parents : parents,
key : path.slice(-1)[0],
isRoot : path.length === 0,
level : path.length,
circular : null,
update : function (x, stopHere) {
if (!state.isRoot) {
state.parent.node[state.key] = x;
}
state.node = x;
if (stopHere) keepGoing = false;
},
'delete' : function () {
delete state.parent.node[state.key];
},
remove : function () {
if (Array.isArray(state.parent.node)) {
state.parent.node.splice(state.key, 1);
}
else {
delete state.parent.node[state.key];
}
},
before : function (f) { modifiers.before = f },
after : function (f) { modifiers.after = f },
pre : function (f) { modifiers.pre = f },
post : function (f) { modifiers.post = f },
stop : function () { alive = false },
block : function () { keepGoing = false }
};
var state = {
node : node,
node_ : node_,
path : [].concat(path),
parent : parents[parents.length - 1],
parents : parents,
key : path.slice(-1)[0],
isRoot : path.length === 0,
level : path.length,
circular : null,
update : function (x, stopHere) {
if (!state.isRoot) {
state.parent.node[state.key] = x;
}
state.node = x;
if (stopHere) keepGoing = false;
},
'delete' : function () {
delete state.parent.node[state.key];
},
remove : function () {
if (Array.isArray(state.parent.node)) {
state.parent.node.splice(state.key, 1);
}
else {
delete state.parent.node[state.key];
}
},
keys : null,
before : function (f) { modifiers.before = f },
after : function (f) { modifiers.after = f },
pre : function (f) { modifiers.pre = f },
post : function (f) { modifiers.post = f },
stop : function () { alive = false },
block : function () { keepGoing = false }
};
if (!alive) return state;
if (!alive) return state;
if (typeof node === 'object' && node !== null) {
state.isLeaf = Object.keys(node).length == 0;
if (typeof node === 'object' && node !== null) {
state.keys = Object.keys(node);
for (var i = 0; i < parents.length; i++) {
if (parents[i].node_ === node_) {
state.circular = parents[i];
break;
}
}
}
else {
state.isLeaf = true;
}
state.isLeaf = state.keys.length == 0;
for (var i = 0; i < parents.length; i++) {
if (parents[i].node_ === node_) {
state.circular = parents[i];
break;
}
}
}
else {
state.isLeaf = true;
}
state.notLeaf = !state.isLeaf;
state.notRoot = !state.isRoot;
state.notLeaf = !state.isLeaf;
state.notRoot = !state.isRoot;
// use return values to update if defined
var ret = cb.call(state, state.node);
if (ret !== undefined && state.update) state.update(ret);
state.keys = null;
if (modifiers.before) modifiers.before.call(state, state.node);
// use return values to update if defined
var ret = cb.call(state, state.node);
if (ret !== undefined && state.update) state.update(ret);
if (!keepGoing) return state;
if (modifiers.before) modifiers.before.call(state, state.node);
if (typeof state.node == 'object'
&& state.node !== null && !state.circular) {
parents.push(state);
if (!keepGoing) return state;
if (typeof state.node == 'object'
&& state.node !== null && !state.circular) {
parents.push(state);
var keys = state.keys || Object.keys(state.node);
keys.forEach(function (key, i) {
path.push(key);
state.keys.forEach(function (key, i) {
path.push(key);
if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
var child = walker(state.node[key]);
if (immutable && Object.hasOwnProperty.call(state.node, key)) {
state.node[key] = child.node;
}
var child = walker(state.node[key]);
if (immutable && Object.hasOwnProperty.call(state.node, key)) {
state.node[key] = child.node;
}
child.isLast = i == keys.length - 1;
child.isFirst = i == 0;
child.isLast = i == state.keys.length - 1;
child.isFirst = i == 0;
if (modifiers.post) modifiers.post.call(state, child);
if (modifiers.post) modifiers.post.call(state, child);
path.pop();
});
parents.pop();
}
path.pop();
});
parents.pop();
}
if (modifiers.after) modifiers.after.call(state, state.node);
if (modifiers.after) modifiers.after.call(state, state.node);
return state;
})(root).node;
}
return state;
})(root).node;
}
Object.keys(Traverse.prototype).forEach(function (key) {
Traverse[key] = function (obj) {
var args = [].slice.call(arguments, 1);
var t = Traverse(obj);
return t[key].apply(t, args);
};
});
Object.keys(Traverse.prototype).forEach(function (key) {
Traverse[key] = function (obj) {
var args = [].slice.call(arguments, 1);
var t = Traverse(obj);
return t[key].apply(t, args);
};
});
function copy (src) {
if (typeof src === 'object' && src !== null) {
var dst;
function copy (src) {
if (typeof src === 'object' && src !== null) {
var dst;
if (Array.isArray(src)) {
dst = [];
}
else if (src instanceof Date) {
dst = new Date(src);
}
else if (src instanceof Boolean) {
dst = new Boolean(src);
}
else if (src instanceof Number) {
dst = new Number(src);
}
else if (src instanceof String) {
dst = new String(src);
}
else {
dst = Object.create(Object.getPrototypeOf(src));
}
if (Array.isArray(src)) {
dst = [];
}
else if (src instanceof Date) {
dst = new Date(src);
}
else if (src instanceof Boolean) {
dst = new Boolean(src);
}
else if (src instanceof Number) {
dst = new Number(src);
}
else if (src instanceof String) {
dst = new String(src);
}
else {
dst = Object.create(Object.getPrototypeOf(src));
}
Object.keys(src).forEach(function (key) {
dst[key] = src[key];
});
return dst;
}
else return src;
}
;
}).call(module.exports);
__require.modules["/node_modules/traverse/index.js"]._cached = module.exports;
return module.exports;
};
Object.keys(src).forEach(function (key) {
dst[key] = src[key];
});
return dst;
}
else return src;
}
});
require.modules["/node_modules/JSONSelect/package.json"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/JSONSelect";
var __filename = "/node_modules/JSONSelect/package.json";
var require = function (file) {
return __require(file, "/node_modules/JSONSelect");
};
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/JSONSelect");
};
require.modules = __require.modules;
__require.modules["/node_modules/JSONSelect/package.json"]._cached = module.exports;
(function () {
module.exports = {"author":"Lloyd Hilaiel <lloyd@hilaiel.com> (http://trickyco.de)","name":"JSONSelect","description":"CSS-like selectors for JSON","version":"0.2.1","homepage":"http://jsonselect.org","repository":{"type":"git","url":"https://github.com/lloyd/JSONSelect.git"},"main":"src/jsonselect","engines":{"node":">=0.4.7"},"dependencies":{},"devDependencies":{},"files":["src/jsonselect.js","src/test/run.js","src/test/tests","tests","README.md","JSONSelect.md","package.json","LICENSE"]};
}).call(module.exports);
__require.modules["/node_modules/JSONSelect/package.json"]._cached = module.exports;
return module.exports;
};
require.define("/node_modules/JSONSelect/package.json",function(require,module,exports,__dirname,__filename,process){module.exports = {"main":"src/jsonselect"}});
require.modules["/node_modules/JSONSelect/src/jsonselect.js"] = function () {
var module = { exports : {} };
var exports = module.exports;
var __dirname = "/node_modules/JSONSelect/src";
var __filename = "/node_modules/JSONSelect/src/jsonselect.js";
var require = function (file) {
return __require(file, "/node_modules/JSONSelect/src");
};
require.resolve = function (file) {
return __require.resolve(name, "/node_modules/JSONSelect/src");
};
require.modules = __require.modules;
__require.modules["/node_modules/JSONSelect/src/jsonselect.js"]._cached = module.exports;
(function () {
/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
/*
* This is the JSONSelect reference implementation, in javascript.
*/
(function(exports) {
require.define("/node_modules/JSONSelect/src/jsonselect.js",function(require,module,exports,__dirname,__filename,process){/*! Copyright (c) 2011, Lloyd Hilaiel, ISC License */
/*
* This is the JSONSelect reference implementation, in javascript.
*/
(function(exports) {
var // localize references
toString = Object.prototype.toString;
var // localize references
toString = Object.prototype.toString;
function jsonParse(str) {
try {
if(JSON && JSON.parse){
return JSON.parse(str);
}
return (new Function("return " + str))();
} catch(e) {
te("ijs", e.message);
}
}
function jsonParse(str) {
try {
if(JSON && JSON.parse){
return JSON.parse(str);
}
return (new Function("return " + str))();
} catch(e) {
te("ijs", e.message);
}
}
// emitted error codes.
var errorCodes = {
"bop": "binary operator expected",
"ee": "expression expected",
"epex": "closing paren expected ')'",
"ijs": "invalid json string",
"mcp": "missing closing paren",
"mepf": "malformed expression in pseudo-function",
"mexp": "multiple expressions not allowed",
"mpc": "multiple pseudo classes (:xxx) not allowed",
"nmi": "multiple ids not allowed",
"pex": "opening paren expected '('",
"se": "selector expected",
"sex": "string expected",
"sra": "string required after '.'",
"uc": "unrecognized char",
"ucp": "unexpected closing paren",
"ujs": "unclosed json string",
"upc": "unrecognized pseudo class"
};
// emitted error codes.
var errorCodes = {
"bop": "binary operator expected",
"ee": "expression expected",
"epex": "closing paren expected ')'",
"ijs": "invalid json string",
"mcp": "missing closing paren",
"mepf": "malformed expression in pseudo-function",
"mexp": "multiple expressions not allowed",
"mpc": "multiple pseudo classes (:xxx) not allowed",
"nmi": "multiple ids not allowed",
"pex": "opening paren expected '('",
"se": "selector expected",
"sex": "string expected",
"sra": "string required after '.'",
"uc": "unrecognized char",
"ucp": "unexpected closing paren",
"ujs": "unclosed json string",
"upc": "unrecognized pseudo class"
};
// throw an error message
function te(ec, context) {
throw new Error(errorCodes[ec] + ( context && " in '" + context + "'"));
}
// throw an error message
function te(ec, context) {
throw new Error(errorCodes[ec] + ( context && " in '" + context + "'"));
}
// THE LEXER
var toks = {
psc: 1, // pseudo class
psf: 2, // pseudo class function
typ: 3, // type
str: 4, // string
ide: 5 // identifiers (or "classes", stuff after a dot)
};
// THE LEXER
var toks = {
psc: 1, // pseudo class
psf: 2, // pseudo class function
typ: 3, // type
str: 4, // string
ide: 5 // identifiers (or "classes", stuff after a dot)
};
// The primary lexing regular expression in jsonselect
var pat = new RegExp(
"^(?:" +
// (1) whitespace
"([\\r\\n\\t\\ ]+)|" +
// (2) one-char ops
"([~*,>\\)\\(])|" +
// (3) types names
"(string|boolean|null|array|object|number)|" +
// (4) pseudo classes
"(:(?:root|first-child|last-child|only-child))|" +
// (5) pseudo functions
"(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
// (6) bogusly named pseudo something or others
"(:\\w+)|" +
// (7 & 8) identifiers and JSON strings
"(?:(\\.)?(\\\"(?:[^\\\\\\\"]|\\\\[^\\\"])*\\\"))|" +
// (8) bogus JSON strings missing a trailing quote
"(\\\")|" +
// (9) identifiers (unquoted)
"\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
")"
);
// The primary lexing regular expression in jsonselect
var pat = new RegExp(
"^(?:" +
// (1) whitespace
"([\\r\\n\\t\\ ]+)|" +
// (2) one-char ops
"([~*,>\\)\\(])|" +
// (3) types names
"(string|boolean|null|array|object|number)|" +
// (4) pseudo classes
"(:(?:root|first-child|last-child|only-child))|" +
// (5) pseudo functions
"(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
// (6) bogusly named pseudo something or others
"(:\\w+)|" +
// (7 & 8) identifiers and JSON strings
"(?:(\\.)?(\\\"(?:[^\\\\\\\"]|\\\\[^\\\"])*\\\"))|" +
// (8) bogus JSON strings missing a trailing quote
"(\\\")|" +
// (9) identifiers (unquoted)
"\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
")"
);
// A regular expression for matching "nth expressions" (see grammar, what :nth-child() eats)
var nthPat = /^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/;
function lex(str, off) {
if (!off) off = 0;
var m = pat.exec(str.substr(off));
if (!m) return undefined;
off+=m[0].length;
var a;
if (m[1]) a = [off, " "];
else if (m[2]) a = [off, m[0]];
else if (m[3]) a = [off, toks.typ, m[0]];
else if (m[4]) a = [off, toks.psc, m[0]];
else if (m[5]) a = [off, toks.psf, m[0]];
else if (m[6]) te("upc", str);
else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
else if (m[9]) te("ujs", str);
else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
return a;
}
// A regular expression for matching "nth expressions" (see grammar, what :nth-child() eats)
var nthPat = /^\s*\(\s*(?:([+\-]?)([0-9]*)n\s*(?:([+\-])\s*([0-9]))?|(odd|even)|([+\-]?[0-9]+))\s*\)/;
function lex(str, off) {
if (!off) off = 0;
var m = pat.exec(str.substr(off));
if (!m) return undefined;
off+=m[0].length;
var a;
if (m[1]) a = [off, " "];
else if (m[2]) a = [off, m[0]];
else if (m[3]) a = [off, toks.typ, m[0]];
else if (m[4]) a = [off, toks.psc, m[0]];
else if (m[5]) a = [off, toks.psf, m[0]];
else if (m[6]) te("upc", str);
else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
else if (m[9]) te("ujs", str);
else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
return a;
}
// THE EXPRESSION SUBSYSTEM
// THE EXPRESSION SUBSYSTEM
var exprPat = new RegExp(
// skip and don't capture leading whitespace
"^\\s*(?:" +
// (1) simple vals
"(true|false|null)|" +
// (2) numbers
"(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" +
// (3) strings
"(\"(?:[^\\]|\\[^\"])*\")|" +
// (4) the 'x' value placeholder
"(x)|" +
// (5) binops
"(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|" +
// (6) parens
"([\\(\\)])" +
")"
);
var exprPat = new RegExp(
// skip and don't capture leading whitespace
"^\\s*(?:" +
// (1) simple vals
"(true|false|null)|" +
// (2) numbers
"(-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)|" +
// (3) strings
"(\"(?:[^\\]|\\[^\"])*\")|" +
// (4) the 'x' value placeholder
"(x)|" +
// (5) binops
"(&&|\\|\\||[\\$\\^<>!\\*]=|[=+\\-*/%<>])|" +
// (6) parens
"([\\(\\)])" +
")"
);
function is(o, t) { return typeof o === t; }
var operators = {
'*': [ 9, function(lhs, rhs) { return lhs * rhs; } ],
'/': [ 9, function(lhs, rhs) { return lhs / rhs; } ],
'%': [ 9, function(lhs, rhs) { return lhs % rhs; } ],
'+': [ 7, function(lhs, rhs) { return lhs + rhs; } ],
'-': [ 7, function(lhs, rhs) { return lhs - rhs; } ],
'<=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs <= rhs; } ],
'>=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs >= rhs; } ],
'$=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.lastIndexOf(rhs) === lhs.length - rhs.length; } ],
'^=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) === 0; } ],
'*=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) !== -1; } ],
'>': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs > rhs; } ],
'<': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs < rhs; } ],
'=': [ 3, function(lhs, rhs) { return lhs === rhs; } ],
'!=': [ 3, function(lhs, rhs) { return lhs !== rhs; } ],
'&&': [ 2, function(lhs, rhs) { return lhs && rhs; } ],
'||': [ 1, function(lhs, rhs) { return lhs || rhs; } ]
};
function is(o, t) { return typeof o === t; }
var operators = {
'*': [ 9, function(lhs, rhs) { return lhs * rhs; } ],
'/': [ 9, function(lhs, rhs) { return lhs / rhs; } ],
'%': [ 9, function(lhs, rhs) { return lhs % rhs; } ],
'+': [ 7, function(lhs, rhs) { return lhs + rhs; } ],
'-': [ 7, function(lhs, rhs) { return lhs - rhs; } ],
'<=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs <= rhs; } ],
'>=': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs >= rhs; } ],
'$=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.lastIndexOf(rhs) === lhs.length - rhs.length; } ],
'^=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) === 0; } ],
'*=': [ 5, function(lhs, rhs) { return is(lhs, 'string') && is(rhs, 'string') && lhs.indexOf(rhs) !== -1; } ],
'>': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs > rhs; } ],
'<': [ 5, function(lhs, rhs) { return is(lhs, 'number') && is(rhs, 'number') && lhs < rhs; } ],
'=': [ 3, function(lhs, rhs) { return lhs === rhs; } ],
'!=': [ 3, function(lhs, rhs) { return lhs !== rhs; } ],
'&&': [ 2, function(lhs, rhs) { return lhs && rhs; } ],
'||': [ 1, function(lhs, rhs) { return lhs || rhs; } ]
};
function exprLex(str, off) {
var v, m = exprPat.exec(str.substr(off));
if (m) {
off += m[0].length;
v = m[1] || m[2] || m[3] || m[5] || m[6];
if (m[1] || m[2] || m[3]) return [off, 0, jsonParse(v)];
else if (m[4]) return [off, 0, undefined];
return [off, v];
}
}
function exprLex(str, off) {
var v, m = exprPat.exec(str.substr(off));
if (m) {
off += m[0].length;
v = m[1] || m[2] || m[3] || m[5] || m[6];
if (m[1] || m[2] || m[3]) return [off, 0, jsonParse(v)];
else if (m[4]) return [off, 0, undefined];
return [off, v];
}
}
function exprParse2(str, off) {
if (!off) off = 0;
// first we expect a value or a '('
var l = exprLex(str, off),
lhs;
if (l && l[1] === '(') {
lhs = exprParse2(str, l[0]);
var p = exprLex(str, lhs[0]);
if (!p || p[1] !== ')') te('epex', str);
off = p[0];
lhs = [ '(', lhs[1] ];
} else if (!l || (l[1] && l[1] != 'x')) {
te("ee", str + " - " + ( l[1] && l[1] ));
} else {
lhs = ((l[1] === 'x') ? undefined : l[2]);
off = l[0];
}
function exprParse2(str, off) {
if (!off) off = 0;
// first we expect a value or a '('
var l = exprLex(str, off),
lhs;
if (l && l[1] === '(') {
lhs = exprParse2(str, l[0]);
var p = exprLex(str, lhs[0]);
if (!p || p[1] !== ')') te('epex', str);
off = p[0];
lhs = [ '(', lhs[1] ];
} else if (!l || (l[1] && l[1] != 'x')) {
te("ee", str + " - " + ( l[1] && l[1] ));
} else {
lhs = ((l[1] === 'x') ? undefined : l[2]);
off = l[0];
}
// now we expect a binary operator or a ')'
var op = exprLex(str, off);
if (!op || op[1] == ')') return [off, lhs];
else if (op[1] == 'x' || !op[1]) {
te('bop', str + " - " + ( op[1] && op[1] ));
}
// now we expect a binary operator or a ')'
var op = exprLex(str, off);
if (!op || op[1] == ')') return [off, lhs];
else if (op[1] == 'x' || !op[1]) {
te('bop', str + " - " + ( op[1] && op[1] ));
}
// tail recursion to fetch the rhs expression
var rhs = exprParse2(str, op[0]);
off = rhs[0];
rhs = rhs[1];
// tail recursion to fetch the rhs expression
var rhs = exprParse2(str, op[0]);
off = rhs[0];
rhs = rhs[1];
// and now precedence! how shall we put everything together?
var v;
if (typeof rhs !== 'object' || rhs[0] === '(' || operators[op[1]][0] < operators[rhs[1]][0] ) {
v = [lhs, op[1], rhs];
}
else {
v = rhs;
while (typeof rhs[0] === 'object' && rhs[0][0] != '(' && operators[op[1]][0] >= operators[rhs[0][1]][0]) {
rhs = rhs[0];
}
rhs[0] = [lhs, op[1], rhs[0]];
}
return [off, v];
}
// and now precedence! how shall we put everything together?
var v;
if (typeof rhs !== 'object' || rhs[0] === '(' || operators[op[1]][0] < operators[rhs[1]][0] ) {
v = [lhs, op[1], rhs];
}
else {
v = rhs;
while (typeof rhs[0] === 'object' && rhs[0][0] != '(' && operators[op[1]][0] >= operators[rhs[0][1]][0]) {
rhs = rhs[0];
}
rhs[0] = [lhs, op[1], rhs[0]];
}
return [off, v];
}
function exprParse(str, off) {
function deparen(v) {
if (typeof v !== 'object' || v === null) return v;
else if (v[0] === '(') return deparen(v[1]);
else return [deparen(v[0]), v[1], deparen(v[2])];
}
var e = exprParse2(str, off ? off : 0);
return [e[0], deparen(e[1])];
}
function exprParse(str, off) {
function deparen(v) {
if (typeof v !== 'object' || v === null) return v;
else if (v[0] === '(') return deparen(v[1]);
else return [deparen(v[0]), v[1], deparen(v[2])];
}
var e = exprParse2(str, off ? off : 0);
return [e[0], deparen(e[1])];
}
function exprEval(expr, x) {
if (expr === undefined) return x;
else if (expr === null || typeof expr !== 'object') {
return expr;
}
var lhs = exprEval(expr[0], x),
rhs = exprEval(expr[2], x);
return operators[expr[1]][1](lhs, rhs);
}
function exprEval(expr, x) {
if (expr === undefined) return x;
else if (expr === null || typeof expr !== 'object') {
return expr;
}
var lhs = exprEval(expr[0], x),
rhs = exprEval(expr[2], x);
return operators[expr[1]][1](lhs, rhs);
}
// THE PARSER
// THE PARSER
function parse(str, off, nested, hints) {
if (!nested) hints = {};
function parse(str, off, nested, hints) {
if (!nested) hints = {};
var a = [], am, readParen;
if (!off) off = 0;
var a = [], am, readParen;
if (!off) off = 0;
while (true) {
var s = parse_selector(str, off, hints);
a.push(s[1]);
s = lex(str, off = s[0]);
if (s && s[1] === " ") s = lex(str, off = s[0]);
if (!s) break;
// now we've parsed a selector, and have something else...
if (s[1] === ">" || s[1] === "~") {
if (s[1] === "~") hints.usesSiblingOp = true;
a.push(s[1]);
off = s[0];
} else if (s[1] === ",") {
if (am === undefined) am = [ ",", a ];
else am.push(a);
a = [];
off = s[0];
} else if (s[1] === ")") {
if (!nested) te("ucp", s[1]);
readParen = 1;
off = s[0];
break;
}
}
if (nested && !readParen) te("mcp", str);
if (am) am.push(a);
var rv;
if (!nested && hints.usesSiblingOp) {
rv = normalize(am ? am : a);
} else {
rv = am ? am : a;
}
return [off, rv];
}
while (true) {
var s = parse_selector(str, off, hints);
a.push(s[1]);
s = lex(str, off = s[0]);
if (s && s[1] === " ") s = lex(str, off = s[0]);
if (!s) break;
// now we've parsed a selector, and have something else...
if (s[1] === ">" || s[1] === "~") {
if (s[1] === "~") hints.usesSiblingOp = true;
a.push(s[1]);
off = s[0];
} else if (s[1] === ",") {
if (am === undefined) am = [ ",", a ];
else am.push(a);
a = [];
off = s[0];
} else if (s[1] === ")") {
if (!nested) te("ucp", s[1]);
readParen = 1;
off = s[0];
break;
}
}
if (nested && !readParen) te("mcp", str);
if (am) am.push(a);
var rv;
if (!nested && hints.usesSiblingOp) {
rv = normalize(am ? am : a);
} else {
rv = am ? am : a;
}
return [off, rv];
}
function normalizeOne(sel) {
var sels = [], s;
for (var i = 0; i < sel.length; i++) {
if (sel[i] === '~') {
// `A ~ B` maps to `:has(:root > A) > B`
// `Z A ~ B` maps to `Z :has(:root > A) > B, Z:has(:root > A) > B`
// This first clause, takes care of the first case, and the first half of the latter case.
if (i < 2 || sel[i-2] != '>') {
s = sel.slice(0,i-1);
s = s.concat([{has:[[{pc: ":root"}, ">", sel[i-1]]]}, ">"]);
s = s.concat(sel.slice(i+1));
sels.push(s);
}
// here we take care of the second half of above:
// (`Z A ~ B` maps to `Z :has(:root > A) > B, Z :has(:root > A) > B`)
// and a new case:
// Z > A ~ B maps to Z:has(:root > A) > B
if (i > 1) {
var at = sel[i-2] === '>' ? i-3 : i-2;
s = sel.slice(0,at);
var z = {};
for (var k in sel[at]) if (sel[at].hasOwnProperty(k)) z[k] = sel[at][k];
if (!z.has) z.has = [];
z.has.push([{pc: ":root"}, ">", sel[i-1]]);
s = s.concat(z, '>', sel.slice(i+1));
sels.push(s);
}
break;
}
}
if (i == sel.length) return sel;
return sels.length > 1 ? [','].concat(sels) : sels[0];
}
function normalizeOne(sel) {
var sels = [], s;
for (var i = 0; i < sel.length; i++) {
if (sel[i] === '~') {
// `A ~ B` maps to `:has(:root > A) > B`
// `Z A ~ B` maps to `Z :has(:root > A) > B, Z:has(:root > A) > B`
// This first clause, takes care of the first case, and the first half of the latter case.
if (i < 2 || sel[i-2] != '>') {
s = sel.slice(0,i-1);
s = s.concat([{has:[[{pc: ":root"}, ">", sel[i-1]]]}, ">"]);
s = s.concat(sel.slice(i+1));
sels.push(s);
}
// here we take care of the second half of above:
// (`Z A ~ B` maps to `Z :has(:root > A) > B, Z :has(:root > A) > B`)
// and a new case:
// Z > A ~ B maps to Z:has(:root > A) > B
if (i > 1) {
var at = sel[i-2] === '>' ? i-3 : i-2;
s = sel.slice(0,at);
var z = {};
for (var k in sel[at]) if (sel[at].hasOwnProperty(k)) z[k] = sel[at][k];
if (!z.has) z.has = [];
z.has.push([{pc: ":root"}, ">", sel[i-1]]);
s = s.concat(z, '>', sel.slice(i+1));
sels.push(s);
}
break;
}
}
if (i == sel.length) return sel;
return sels.length > 1 ? [','].concat(sels) : sels[0];
}
function normalize(sels) {
if (sels[0] === ',') {
var r = [","];
for (var i = i; i < sels.length; i++) {
var s = normalizeOne(s[i]);
r = r.concat(s[0] === "," ? s.slice(1) : s);
}
return r;
} else {
return normalizeOne(sels);
}
}
function normalize(sels) {
if (sels[0] === ',') {
var r = [","];
for (var i = i; i < sels.length; i++) {
var s = normalizeOne(s[i]);
r = r.concat(s[0] === "," ? s.slice(1) : s);
}
return r;
} else {
return normalizeOne(sels);
}
}
function parse_selector(str, off, hints) {
var soff = off;
var s = { };
var l = lex(str, off);
// skip space
if (l && l[1] === " ") { soff = off = l[0]; l = lex(str, off); }
if (l && l[1] === toks.typ) {
s.type = l[2];
l = lex(str, (off = l[0]));
} else if (l && l[1] === "*") {
// don't bother representing the universal sel, '*' in the
// parse tree, cause it's the default
l = lex(str, (off = l[0]));
}
function parse_selector(str, off, hints) {
var soff = off;
var s = { };
var l = lex(str, off);
// skip space
if (l && l[1] === " ") { soff = off = l[0]; l = lex(str, off); }
if (l && l[1] === toks.typ) {
s.type = l[2];
l = lex(str, (off = l[0]));
} else if (l && l[1] === "*") {
// don't bother representing the universal sel, '*' in the
// parse tree, cause it's the default
l = lex(str, (off = l[0]));
}
// now support either an id or a pc
while (true) {
if (l === undefined) {
break;
} else if (l[1] === toks.ide) {
if (s.id) te("nmi", l[1]);
s.id = l[2];
} else if (l[1] === toks.psc) {
if (s.pc || s.pf) te("mpc", l[1]);
// collapse first-child and last-child into nth-child expressions
if (l[2] === ":first-child") {
s.pf = ":nth-child";
s.a = 0;
s.b = 1;
} else if (l[2] === ":last-child") {
s.pf = ":nth-last-child";
s.a = 0;
s.b = 1;
} else {
s.pc = l[2];
}
} else if (l[1] === toks.psf) {
if (l[2] === ":val" || l[2] === ":contains") {
s.expr = [ undefined, l[2] === ":val" ? "=" : "*=", undefined];
// any amount of whitespace, followed by paren, string, paren
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== "(") te("pex", str);
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== toks.str) te("sex", str);
s.expr[2] = l[2];
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== ")") te("epex", str);
} else if (l[2] === ":has") {
// any amount of whitespace, followed by paren
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== "(") te("pex", str);
var h = parse(str, l[0], true);
l[0] = h[0];
if (!s.has) s.has = [];
s.has.push(h[1]);
} else if (l[2] === ":expr") {
if (s.expr) te("mexp", str);
var e = exprParse(str, l[0]);
l[0] = e[0];
s.expr = e[1];
} else {
if (s.pc || s.pf ) te("mpc", str);
s.pf = l[2];
var m = nthPat.exec(str.substr(l[0]));
if (!m) te("mepf", str);
if (m[5]) {
s.a = 2;
s.b = (m[5] === "odd") ? 1 : 0;
} else if (m[6]) {
s.a = 0;
s.b = parseInt(m[6], 10);
} else {
s.a = parseInt((m[1] ? m[1] : "+") + (m[2] ? m[2] : "1"),10);
s.b = m[3] ? parseInt(m[3] + m[4],10) : 0;
}
l[0] += m[0].length;
}
} else {
break;
}
l = lex(str, (off = l[0]));
}
// now support either an id or a pc
while (true) {
if (l === undefined) {
break;
} else if (l[1] === toks.ide) {
if (s.id) te("nmi", l[1]);
s.id = l[2];
} else if (l[1] === toks.psc) {
if (s.pc || s.pf) te("mpc", l[1]);
// collapse first-child and last-child into nth-child expressions
if (l[2] === ":first-child") {
s.pf = ":nth-child";
s.a = 0;
s.b = 1;
} else if (l[2] === ":last-child") {
s.pf = ":nth-last-child";
s.a = 0;
s.b = 1;
} else {
s.pc = l[2];
}
} else if (l[1] === toks.psf) {
if (l[2] === ":val" || l[2] === ":contains") {
s.expr = [ undefined, l[2] === ":val" ? "=" : "*=", undefined];
// any amount of whitespace, followed by paren, string, paren
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== "(") te("pex", str);
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== toks.str) te("sex", str);
s.expr[2] = l[2];
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== ")") te("epex", str);
} else if (l[2] === ":has") {
// any amount of whitespace, followed by paren
l = lex(str, (off = l[0]));
if (l && l[1] === " ") l = lex(str, off = l[0]);
if (!l || l[1] !== "(") te("pex", str);
var h = parse(str, l[0], true);
l[0] = h[0];
if (!s.has) s.has = [];
s.has.push(h[1]);
} else if (l[2] === ":expr") {
if (s.expr) te("mexp", str);
var e = exprParse(str, l[0]);
l[0] = e[0];
s.expr = e[1];
} else {
if (s.pc || s.pf ) te("mpc", str);
s.pf = l[2];
var m = nthPat.exec(str.substr(l[0]));
if (!m) te("mepf", str);
if (m[5]) {
s.a = 2;
s.b = (m[5] === "odd") ? 1 : 0;
} else if (m[6]) {
s.a = 0;
s.b = parseInt(m[6], 10);
} else {
s.a = parseInt((m[1] ? m[1] : "+") + (m[2] ? m[2] : "1"),10);
s.b = m[3] ? parseInt(m[3] + m[4],10) : 0;
}
l[0] += m[0].length;
}
} else {
break;
}
l = lex(str, (off = l[0]));
}
// now if we didn't actually parse anything it's an error
if (soff === off) te("se", str);
// now if we didn't actually parse anything it's an error
if (soff === off) te("se", str);
return [off, s];
}
return [off, s];
}
// THE EVALUATOR
// THE EVALUATOR
function isArray(o) {
return Array.isArray ? Array.isArray(o) :
toString.call(o) === "[object Array]";
}
function isArray(o) {
return Array.isArray ? Array.isArray(o) :
toString.call(o) === "[object Array]";
}
function mytypeof(o) {
if (o === null) return "null";
var to = typeof o;
if (to === "object" && isArray(o)) to = "array";
return to;
}
function mytypeof(o) {
if (o === null) return "null";
var to = typeof o;
if (to === "object" && isArray(o)) to = "array";
return to;
}
function mn(node, sel, id, num, tot) {
var sels = [];
var cs = (sel[0] === ">") ? sel[1] : sel[0];
var m = true, mod;
if (cs.type) m = m && (cs.type === mytypeof(node));
if (cs.id) m = m && (cs.id === id);
if (m && cs.pf) {
if (cs.pf === ":nth-last-child") num = tot - num;
else num++;
if (cs.a === 0) {
m = cs.b === num;
} else {
mod = ((num - cs.b) % cs.a);
function mn(node, sel, id, num, tot) {
var sels = [];
var cs = (sel[0] === ">") ? sel[1] : sel[0];
var m = true, mod;
if (cs.type) m = m && (cs.type === mytypeof(node));
if (cs.id) m = m && (cs.id === id);
if (m && cs.pf) {
if (cs.pf === ":nth-last-child") num = tot - num;
else num++;
if (cs.a === 0) {
m = cs.b === num;
} else {
mod = ((num - cs.b) % cs.a);
m = (!mod && ((num*cs.a + cs.b) >= 0));
}
}
if (m && cs.has) {
// perhaps we should augment forEach to handle a return value
// that indicates "client cancels traversal"?
var bail = function() { throw 42; };
for (var i = 0; i < cs.has.length; i++) {
try {
forEach(cs.has[i], node, bail);
} catch (e) {
if (e === 42) continue;
}
m = false;
break;
}
}
if (m && cs.expr) {
m = exprEval(cs.expr, node);
}
// should we repeat this selector for descendants?
if (sel[0] !== ">" && sel[0].pc !== ":root") sels.push(sel);
m = (!mod && ((num*cs.a + cs.b) >= 0));
}
}
if (m && cs.has) {
// perhaps we should augment forEach to handle a return value
// that indicates "client cancels traversal"?
var bail = function() { throw 42; };
for (var i = 0; i < cs.has.length; i++) {
try {
forEach(cs.has[i], node, bail);
} catch (e) {
if (e === 42) continue;
}
m = false;
break;
}
}
if (m && cs.expr) {
m = exprEval(cs.expr, node);
}
// should we repeat this selector for descendants?
if (sel[0] !== ">" && sel[0].pc !== ":root") sels.push(sel);
if (m) {
// is there a fragment that we should pass down?
if (sel[0] === ">") { if (sel.length > 2) { m = false; sels.push(sel.slice(2)); } }
else if (sel.length > 1) { m = false; sels.push(sel.slice(1)); }
}
if (m) {
// is there a fragment that we should pass down?
if (sel[0] === ">") { if (sel.length > 2) { m = false; sels.push(sel.slice(2)); } }
else if (sel.length > 1) { m = false; sels.push(sel.slice(1)); }
}
return [m, sels];
}
return [m, sels];
}
function forEach(sel, obj, fun, id, num, tot) {
var a = (sel[0] === ",") ? sel.slice(1) : [sel],
a0 = [],
call = false,
i = 0, j = 0, k, x;
for (i = 0; i < a.length; i++) {
x = mn(obj, a[i], id, num, tot);
if (x[0]) {
call = true;
}
for (j = 0; j < x[1].length; j++) {
a0.push(x[1][j]);
}
}
if (a0.length && typeof obj === "object") {
if (a0.length >= 1) {
a0.unshift(",");
}
if (isArray(obj)) {
for (i = 0; i < obj.length; i++) {
forEach(a0, obj[i], fun, undefined, i, obj.length);
}
} else {
for (k in obj) {
if (obj.hasOwnProperty(k)) {
forEach(a0, obj[k], fun, k);
}
}
}
}
if (call && fun) {
fun(obj);
}
}
function forEach(sel, obj, fun, id, num, tot) {
var a = (sel[0] === ",") ? sel.slice(1) : [sel],
a0 = [],
call = false,
i = 0, j = 0, k, x;
for (i = 0; i < a.length; i++) {
x = mn(obj, a[i], id, num, tot);
if (x[0]) {
call = true;
}
for (j = 0; j < x[1].length; j++) {
a0.push(x[1][j]);
}
}
if (a0.length && typeof obj === "object") {
if (a0.length >= 1) {
a0.unshift(",");
}
if (isArray(obj)) {
for (i = 0; i < obj.length; i++) {
forEach(a0, obj[i], fun, undefined, i, obj.length);
}
} else {
for (k in obj) {
if (obj.hasOwnProperty(k)) {
forEach(a0, obj[k], fun, k);
}
}
}
}
if (call && fun) {
fun(obj);
}
}
function match(sel, obj) {
var a = [];
forEach(sel, obj, function(x) {
a.push(x);
});
return a;
}
function match(sel, obj) {
var a = [];
forEach(sel, obj, function(x) {
a.push(x);
});
return a;
}
function compile(sel) {
return {
sel: parse(sel)[1],
match: function(obj){
return match(this.sel, obj);
},
forEach: function(obj, fun) {
return forEach(this.sel, obj, fun);
}
};
}
function compile(sel) {
return {
sel: parse(sel)[1],
match: function(obj){
return match(this.sel, obj);
},
forEach: function(obj, fun) {
return forEach(this.sel, obj, fun);
}
};
}
exports._lex = lex;
exports._parse = parse;
exports.match = function (sel, obj) {
return compile(sel).match(obj);
};
exports.forEach = function(sel, obj, fun) {
return compile(sel).forEach(obj, fun);
};
exports.compile = compile;
})(typeof exports === "undefined" ? (window.JSONSelect = {}) : exports);
;
}).call(module.exports);
__require.modules["/node_modules/JSONSelect/src/jsonselect.js"]._cached = module.exports;
return module.exports;
};
return require('js-select')})();
exports._lex = lex;
exports._parse = parse;
exports.match = function (sel, obj) {
return compile(sel).match(obj);
};
exports.forEach = function(sel, obj, fun) {
return compile(sel).forEach(obj, fun);
};
exports.compile = compile;
})(typeof exports === "undefined" ? (window.JSONSelect = {}) : exports);
});
return require('js-select');
})();

@@ -19,7 +19,24 @@ var select = require("./index"),

stars: 6
},
"changeset": {
changes: [{
field_name: "status"
}, {
field_name: "resolution"
}
]
}
};
select(people, ".changes > *").forEach(function(node) {
console.log(this.parent.keys)
//console.log(this.prev && this.prev.key);
//var parent = this.key;
})
console.log(select(people, ".changes > *").nodes())
/*
var selector = ':contains("Clueless")';
console.log(select(people, selector).nodes())
console.log(JSONSelect.match(selector, people))
*/

@@ -33,4 +33,6 @@ var assert = require("assert"),

}
}
};
var people2;
assert.deepEqual(select(people, "*").nodes(), [{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}},{"age":35,"movies":[{"name":"Repo Man","stars":5}]},35,[{"name":"Repo Man","stars":5}],{"name":"Repo Man","stars":5},"Repo Man",5,{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},15,[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}],{"name":"Twilight","stars":3},"Twilight",3,{"name":"Trudy","stars":2},"Trudy",2,{"name":"The Fighter","stars":4},"The Fighter",4,{"car":null,"male":true},null,true]);

@@ -87,3 +89,3 @@ assert.deepEqual(select(people, ".george").nodes(), [{"age":35,"movies":[{"name":"Repo Man","stars":5}]}]);

// update()
var people2 = traverse.clone(people);
people2 = traverse.clone(people);

@@ -104,3 +106,15 @@ select(people2, ".age").update(function(age) {

// condense()
people2 = traverse.clone(people);
select(people2, ".george").condense();
assert.deepEqual(people2, {"george": {age: 35, movies: [{name: "Repo Man", stars: 5}]}});
people2 = traverse.clone(people);
select(people2, ".hmmm").condense();
assert.deepEqual(people2, {});
people2 = traverse.clone(people);
select(people2, ".stars").condense();
assert.deepEqual(people2, {"george": {movies: [{stars: 5}]}, "mary": {movies: [{stars: 3},{stars: 2},{stars: 4}]}});
// forEach()

@@ -116,3 +130,3 @@ people2 = traverse.clone(people);

// this.matches()
var people2 = traverse.clone(people);
people2 = traverse.clone(people);
select(people2).forEach(function(node) {

@@ -127,3 +141,3 @@ if (this.matches(".age")) {

// bigger stuff
var timeline = require("./timeline.json")
var timeline = require("./timeline.js");

@@ -130,0 +144,0 @@ console.time("select time");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc