Permalink
Browse files

bump to version 0.2.5

  • Loading branch information...
dchester committed Jun 17, 2016
1 parent 785b6ef commit 51eae99646a55f20602a2d8c23dd48df9e98e79b
Showing with 133 additions and 130 deletions.
  1. +129 −126 jsonpath.js
  2. +3 −3 jsonpath.min.js
  3. +1 −1 package.json
View
@@ -1,4 +1,4 @@
/*! jsonpath 0.2.3 */
/*! jsonpath 0.2.5 */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsonpath = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"./aesprim":[function(require,module,exports){
/*
@@ -4483,7 +4483,7 @@ if (typeof module !== 'undefined' && require.main === module) {
}
}).call(this,require('_process'))
},{"_process":12,"fs":8,"path":11}],2:[function(require,module,exports){
},{"_process":12,"fs":9,"path":11}],2:[function(require,module,exports){
module.exports = {
identifier: "[a-zA-Z_]+[a-zA-Z0-9_]*",
integer: "-?(?:0|[1-9][0-9]*)",
@@ -4601,7 +4601,7 @@ var grammar = {
module.exports = grammar;
},{"./dict":2,"fs":8}],4:[function(require,module,exports){
},{"./dict":2,"fs":9}],4:[function(require,module,exports){
var aesprim = require('./aesprim');
var slice = require('./slice');
var _evaluate = require('static-eval');
@@ -4855,7 +4855,7 @@ function unique(results) {
module.exports = Handlers;
},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,"underscore":8}],5:[function(require,module,exports){
},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":13,"underscore":9}],5:[function(require,module,exports){
/* global toString */
var assert = require('assert');
@@ -4893,7 +4893,10 @@ JSONPath.prototype.apply = function(obj, string, fn) {
assert.ok(string, "we need a path");
assert.equal(typeof fn, "function", "fn needs to be function")
var nodes = this.nodes(obj, string);
var nodes = this.nodes(obj, string).sort(function(a, b) {
// sort nodes so we apply from the bottom up
return b.path.length - a.path.length;
});
nodes.forEach(function(node) {
var key = node.path.pop();
@@ -5105,7 +5108,7 @@ instance.JSONPath = JSONPath;
module.exports = instance;
},{"./dict":2,"./handlers":4,"./parser":6,"assert":9}],6:[function(require,module,exports){
},{"./dict":2,"./handlers":4,"./parser":6,"assert":8}],6:[function(require,module,exports){
var grammar = require('./grammar');
var gparser = require('../generated/parser');
@@ -5168,8 +5171,6 @@ function integer(val) {
}
},{}],8:[function(require,module,exports){
},{}],9:[function(require,module,exports){
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
@@ -5530,7 +5531,9 @@ var objectKeys = Object.keys || function (obj) {
return keys;
};
},{"util/":14}],10:[function(require,module,exports){
},{"util/":15}],9:[function(require,module,exports){
},{}],10:[function(require,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
@@ -5880,13 +5883,128 @@ process.chdir = function (dir) {
process.umask = function() { return 0; };
},{}],13:[function(require,module,exports){
var unparse = require('escodegen').generate;
module.exports = function (ast, vars) {
if (!vars) vars = {};
var FAIL = {};
var result = (function walk (node) {
if (node.type === 'Literal') {
return node.value;
}
else if (node.type === 'UnaryExpression'){
var val = walk(node.argument)
if (node.operator === '+') return +val
if (node.operator === '-') return -val
if (node.operator === '~') return ~val
if (node.operator === '!') return !val
return FAIL
}
else if (node.type === 'ArrayExpression') {
var xs = [];
for (var i = 0, l = node.elements.length; i < l; i++) {
var x = walk(node.elements[i]);
if (x === FAIL) return FAIL;
xs.push(x);
}
return xs;
}
else if (node.type === 'ObjectExpression') {
var obj = {};
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
var value = prop.value === null
? prop.value
: walk(prop.value)
;
if (value === FAIL) return FAIL;
obj[prop.key.value || prop.key.name] = value;
}
return obj;
}
else if (node.type === 'BinaryExpression' ||
node.type === 'LogicalExpression') {
var l = walk(node.left);
if (l === FAIL) return FAIL;
var r = walk(node.right);
if (r === FAIL) return FAIL;
var op = node.operator;
if (op === '==') return l == r;
if (op === '===') return l === r;
if (op === '!=') return l != r;
if (op === '!==') return l !== r;
if (op === '+') return l + r;
if (op === '-') return l - r;
if (op === '*') return l * r;
if (op === '/') return l / r;
if (op === '%') return l % r;
if (op === '<') return l < r;
if (op === '<=') return l <= r;
if (op === '>') return l > r;
if (op === '>=') return l >= r;
if (op === '|') return l | r;
if (op === '&') return l & r;
if (op === '^') return l ^ r;
if (op === '&&') return l && r;
if (op === '||') return l || r;
return FAIL;
}
else if (node.type === 'Identifier') {
if ({}.hasOwnProperty.call(vars, node.name)) {
return vars[node.name];
}
else return FAIL;
}
else if (node.type === 'CallExpression') {
var callee = walk(node.callee);
if (callee === FAIL) return FAIL;
var ctx = node.callee.object ? walk(node.callee.object) : FAIL;
if (ctx === FAIL) ctx = null;
var args = [];
for (var i = 0, l = node.arguments.length; i < l; i++) {
var x = walk(node.arguments[i]);
if (x === FAIL) return FAIL;
args.push(x);
}
return callee.apply(ctx, args);
}
else if (node.type === 'MemberExpression') {
var obj = walk(node.object);
if (obj === FAIL) return FAIL;
if (node.property.type === 'Identifier') {
return obj[node.property.name];
}
var prop = walk(node.property);
if (prop === FAIL) return FAIL;
return obj[prop];
}
else if (node.type === 'ConditionalExpression') {
var val = walk(node.test)
if (val === FAIL) return FAIL;
return val ? walk(node.consequent) : walk(node.alternate)
}
else if (node.type === 'FunctionExpression') {
return Function('return ' + unparse(node))();
}
else return FAIL;
})(ast);
return result === FAIL ? undefined : result;
};
},{"escodegen":9}],14:[function(require,module,exports){
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
},{}],14:[function(require,module,exports){
},{}],15:[function(require,module,exports){
(function (process,global){
// Copyright Joyent, Inc. and other Node contributors.
//
@@ -6476,122 +6594,7 @@ function hasOwnProperty(obj, prop) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./support/isBuffer":13,"_process":12,"inherits":10}],15:[function(require,module,exports){
var unparse = require('escodegen').generate;
module.exports = function (ast, vars) {
if (!vars) vars = {};
var FAIL = {};
var result = (function walk (node) {
if (node.type === 'Literal') {
return node.value;
}
else if (node.type === 'UnaryExpression'){
var val = walk(node.argument)
if (node.operator === '+') return +val
if (node.operator === '-') return -val
if (node.operator === '~') return ~val
if (node.operator === '!') return !val
return FAIL
}
else if (node.type === 'ArrayExpression') {
var xs = [];
for (var i = 0, l = node.elements.length; i < l; i++) {
var x = walk(node.elements[i]);
if (x === FAIL) return FAIL;
xs.push(x);
}
return xs;
}
else if (node.type === 'ObjectExpression') {
var obj = {};
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
var value = prop.value === null
? prop.value
: walk(prop.value)
;
if (value === FAIL) return FAIL;
obj[prop.key.value || prop.key.name] = value;
}
return obj;
}
else if (node.type === 'BinaryExpression' ||
node.type === 'LogicalExpression') {
var l = walk(node.left);
if (l === FAIL) return FAIL;
var r = walk(node.right);
if (r === FAIL) return FAIL;
var op = node.operator;
if (op === '==') return l == r;
if (op === '===') return l === r;
if (op === '!=') return l != r;
if (op === '!==') return l !== r;
if (op === '+') return l + r;
if (op === '-') return l - r;
if (op === '*') return l * r;
if (op === '/') return l / r;
if (op === '%') return l % r;
if (op === '<') return l < r;
if (op === '<=') return l <= r;
if (op === '>') return l > r;
if (op === '>=') return l >= r;
if (op === '|') return l | r;
if (op === '&') return l & r;
if (op === '^') return l ^ r;
if (op === '&&') return l && r;
if (op === '||') return l || r;
return FAIL;
}
else if (node.type === 'Identifier') {
if ({}.hasOwnProperty.call(vars, node.name)) {
return vars[node.name];
}
else return FAIL;
}
else if (node.type === 'CallExpression') {
var callee = walk(node.callee);
if (callee === FAIL) return FAIL;
var ctx = node.callee.object ? walk(node.callee.object) : FAIL;
if (ctx === FAIL) ctx = null;
var args = [];
for (var i = 0, l = node.arguments.length; i < l; i++) {
var x = walk(node.arguments[i]);
if (x === FAIL) return FAIL;
args.push(x);
}
return callee.apply(ctx, args);
}
else if (node.type === 'MemberExpression') {
var obj = walk(node.object);
if (obj === FAIL) return FAIL;
if (node.property.type === 'Identifier') {
return obj[node.property.name];
}
var prop = walk(node.property);
if (prop === FAIL) return FAIL;
return obj[prop];
}
else if (node.type === 'ConditionalExpression') {
var val = walk(node.test)
if (val === FAIL) return FAIL;
return val ? walk(node.consequent) : walk(node.alternate)
}
else if (node.type === 'FunctionExpression') {
return Function('return ' + unparse(node))();
}
else return FAIL;
})(ast);
return result === FAIL ? undefined : result;
};
},{"escodegen":8}],"jsonpath":[function(require,module,exports){
},{"./support/isBuffer":14,"_process":12,"inherits":10}],"jsonpath":[function(require,module,exports){
module.exports = require('./lib/index');
},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")
Oops, something went wrong.

0 comments on commit 51eae99

Please sign in to comment.