Skip to content

Commit a52dd41

Browse files
committed
- Fix: Handle React-Native environment's lack of support for
Node vm (@simon-scherzinger); closes #87 - Testing: Avoid favicon check - npm: Bump to 0.18.0
1 parent f58d9f7 commit a52dd41

11 files changed

Lines changed: 20 additions & 10 deletions

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# jsonpath-plus changes
22

3-
## ?
3+
## 0.18.0 (October 20, 2018)
44

55
- Security enhancement: Use global eval instead of regular eval
6+
- Fix: Handle React-Native environment's lack of support for
7+
Node vm (@simon-scherzinger); closes #87
68
- Refactoring: Use arrow functions, for-of, declare block scope vars
79
closer to block
810
- Docs: Clarify current `wrap` behavior

dist/index-es.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ function _possibleConstructorReturn(self, call) {
135135

136136
/* eslint-disable no-eval */
137137
var globalEval = eval;
138+
var supportsNodeVM = typeof module !== 'undefined' && !!module.exports && !(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
138139
var allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
139140
var hasOwnProperty = Object.prototype.hasOwnProperty;
140141
/**
@@ -158,7 +159,7 @@ var moveToAnotherArray = function moveToAnotherArray(source, target, conditionCb
158159
}
159160
};
160161

161-
var vm = typeof module !== 'undefined' ? require('vm') : {
162+
var vm = supportsNodeVM ? require('vm') : {
162163
/**
163164
* @param {string} expr Expression to evaluate
164165
* @param {object} context Object whose items will be added to evaluation

dist/index-es.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-es.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141

142142
/* eslint-disable no-eval */
143143
var globalEval = eval;
144+
var supportsNodeVM = typeof module !== 'undefined' && !!module.exports && !(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
144145
var allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
145146
var hasOwnProperty = Object.prototype.hasOwnProperty;
146147
/**
@@ -164,7 +165,7 @@
164165
}
165166
};
166167

167-
var vm = typeof module !== 'undefined' ? require('vm') : {
168+
var vm = supportsNodeVM ? require('vm') : {
168169
/**
169170
* @param {string} expr Expression to evaluate
170171
* @param {object} context Object whose items will be added to evaluation

dist/index-umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Stefan Goessner",
33
"name": "jsonpath-plus",
4-
"version": "0.17.0",
4+
"version": "0.18.0",
55
"main": "dist/index-umd.js",
66
"module": "dist/index-es.js",
77
"description": "A JS implementation of JSONPath with some additional operators",
@@ -41,6 +41,9 @@
4141
"engines": {
4242
"node": ">=6.0"
4343
},
44+
"react-native": {
45+
"vm": false
46+
},
4447
"dependencies": {},
4548
"devDependencies": {
4649
"@babel/core": "^7.1.2",

src/jsonpath.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-disable no-eval */
22

33
const globalEval = eval;
4+
const supportsNodeVM = typeof module !== 'undefined' && !!module.exports &&
5+
!(typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
46
const allowedResultTypes = ['value', 'path', 'pointer', 'parent', 'parentProperty', 'all'];
57
const {hasOwnProperty} = Object.prototype;
68

@@ -22,7 +24,7 @@ const moveToAnotherArray = function (source, target, conditionCb) {
2224
}
2325
};
2426

25-
const vm = typeof module !== 'undefined'
27+
const vm = supportsNodeVM
2628
? require('vm') : {
2729
/**
2830
* @param {string} expr Expression to evaluate

0 commit comments

Comments
 (0)