New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fig-tree-evaluator

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fig-tree-evaluator - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

13

build/operators/equal.js

@@ -15,2 +15,3 @@ "use strict";

const _operatorUtils_1 = require("./_operatorUtils");
const lite_1 = require("dequal/lite");
const requiredProperties = ['values'];

@@ -20,5 +21,13 @@ const operatorAliases = ['=', 'eq', 'equal', 'equals'];

const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
var _a;
const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
return values.every((value) => value == values[0]);
const nullEqualsUndefined = nullMatch !== undefined
? nullMatch
: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
? config.options.nullEqualsUndefined
: false;
if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
return values.every((value) => value === null || value === undefined);
return values.every((value) => (0, lite_1.dequal)(value, values[0]));
});

@@ -25,0 +34,0 @@ exports.EQUAL = {

@@ -15,2 +15,3 @@ "use strict";

const _operatorUtils_1 = require("./_operatorUtils");
const lite_1 = require("dequal/lite");
const requiredProperties = ['values'];

@@ -20,5 +21,13 @@ const operatorAliases = ['!=', '!', 'ne', 'notEqual'];

const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
var _a;
const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
return values.some((val) => val !== values[0]);
const nullEqualsUndefined = nullMatch !== undefined
? nullMatch
: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
? config.options.nullEqualsUndefined
: false;
if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
return values.some((value) => value === null && value === undefined);
return values.some((val) => !(0, lite_1.dequal)(val, values[0]));
});

@@ -25,0 +34,0 @@ exports.NOT_EQUAL = {

@@ -20,2 +20,3 @@ import { BasicExtendedNode, SubtractionNode, DivisionNode, ComparatorNode, ConditionalNode, RegexNode, StringSubNode, SplitNode, ObjPropNode, APINode, PGNode, GraphQLNode, BuildObjectNode, FunctionNode, PassThruNode, PGConnection, GraphQLConnection } from './operators';

returnErrorAsString?: boolean;
nullEqualsUndefined?: boolean;
allowJSONStringInput?: boolean;

@@ -22,0 +23,0 @@ skipRuntimeTypeCheck?: boolean;

3

package.json
{
"name": "fig-tree-evaluator",
"version": "2.0.0",
"version": "2.0.1",
"description": "Module to evaluate JSON-structured expression trees",

@@ -38,2 +38,3 @@ "main": "build/index.js",

"change-case": "^4.1.2",
"dequal": "^2.0.3",
"object-property-extractor": "^1.0.3"

@@ -40,0 +41,0 @@ },

@@ -143,2 +143,3 @@ # fig-tree-evaluator

- `skipRuntimeTypeCheck` -- we perform comprehensive type checking at runtime to ensure that each operator only performs its operation on valid inputs. If type checking fails, we throw an error detailing the explicit problem. However, if `skipRuntimeTypeCheck` is set to `true`, then all inputs are passed to the operator regardless, and any errors will come from whatever standard javascript errors might be encoutered (e.g. trying to pass a primitive value when an array is expected => `.map is not a function`)
- `nullEqualsUndefined` -- this only affects the [`equal`/`notEqual` operators](#equal) (see there for more detail).

@@ -301,3 +302,4 @@ As mentioned above, `options` can be provided as part of the constructor as part of each seperate evaluation. You can also change the options permanently for a given evaluator instance with:

- `values`<sup>*</sup>: (array) -- any number of elements; will be compared using Javascript `==` operator
- `values`<sup>*</sup>: (array) -- any number of elements; will be compared for strict equality. This includes simple types as well as deep equality of objects and arrays.
- `nullEqualsUndefined`: (boolean, default `false`) -- there are times when it is convenient for `null` to be considered equal to `undefined`. If this is desiered, set this property to `true`, otherwise all equality checks will be "strict" equality. If you find that you want this setting enabled globally, then you can set it in the overall [evaluator options](#available-options) instead of having to add this additional property to every equality expression.

@@ -324,3 +326,4 @@ e.g.

- `values`<sup>*</sup>: (array) -- any number of elements; will be compared using Javascript `!=` operator
- `values`<sup>*</sup>: (array) -- any number of elements; will be compared for inequality. This includes simple types as well as deep comparison of objects and arrays.
- `nullEqualsUndefined`: (boolean, default `false`) -- as [above](#equal)

@@ -1253,2 +1256,4 @@ e.g.

- **v2.0.1**: Add deep equality comparison for objects/arrayr in =/!= operators
- **v2.0.0**: Re-write as stand-alone package. Major improvements include:

@@ -1255,0 +1260,0 @@ - more [operators](#operator-reference)

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