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

openrosa-xpath-evaluator

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openrosa-xpath-evaluator - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

10

CHANGELOG.md

@@ -6,2 +6,12 @@ Change Log

[2.0.6] - 2021-04-20
---------------------
##### Removed
- `decimal-date()` function (as it was an accident and is not in the spec).
##### Fixed
- Using `decimal-time()` with a node-set parameter fails.
- The not-equals operator fails when preceded by a node-set without a trailing space.
- Using `uuid()` with a node-set parameter fails.
[2.0.5] - 2021-04-12

@@ -8,0 +18,0 @@ ---------------------

2

package.json
{
"name": "openrosa-xpath-evaluator",
"version": "2.0.5",
"version": "2.0.6",
"description": "Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.",

@@ -5,0 +5,0 @@ "homepage": "https://enketo.org",

Openrosa XForms Evaluator
=========================
<a href="https://travis-ci.org/enketo/openrosa-xpath-evaluator"><img src="https://travis-ci.org/enketo/openrosa-xpath-evaluator.svg?branch=master"/></a>
<a href="https://travis-ci.com/enketo/openrosa-xpath-evaluator"><img src="https://travis-ci.com/enketo/openrosa-xpath-evaluator.svg?branch=master"/></a>

@@ -6,0 +6,0 @@ Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.

@@ -429,2 +429,6 @@ const { handleOperation } = require('./utils/operation');

break;
case '!':
if(cur.v) handleXpathExpr();
cur.v = c;
break;
case '>':

@@ -431,0 +435,0 @@ case '<':

@@ -155,3 +155,3 @@ require('./date-extensions');

},
'decimal-date': function(date) {
'decimal-date-time': function(date) {
if(arguments.length > 1) throw TOO_MANY_ARGS;

@@ -164,3 +164,3 @@ const res = Date.parse(asString(date)) / MILLIS_PER_DAY;

if(r.t === 'num') return XPR.number(NaN);
const time = r.v;
const time = asString(r);
// There is no Time type, and so far we don't need it so we do all validation

@@ -402,3 +402,3 @@ // and conversion here, manually.

uuid: function(r) {
if(r && r.v) return XPR.string(randomToken(asNumber(r)));
if(r) return XPR.string(randomToken(asNumber(r)));
return XPR.string(uuid());

@@ -430,3 +430,2 @@ },

func['date-time'] = func.date;
func['decimal-date-time'] = func['decimal-date'];
func['format-date-time'] = func['format-date'];

@@ -433,0 +432,0 @@

@@ -148,2 +148,41 @@ const _ = require('lodash');

});
describe('with nodes', () =>{
const doc = initDoc(`
<data>
<a>1</a>
<b>2</b>
</data>`);
_.forEach({
'/data/a!= /data/b': true,
'/data/a!=/data/b': true,
'/data/a!= "1"': false,
'/data/a!="1"': false,
'"1" != /data/a': false,
'"1"!= /data/a': false,
'"1"!=/data/a': false,
'/data/a<= /data/b': true,
'/data/a<=/data/b': true,
'/data/a<= "1"': true,
'/data/a<="1"': true,
'"1" <= /data/a': true,
'"1"<= /data/a': true,
'"1"<=/data/a': true,
'/data/a>= /data/b': false,
'/data/a>=/data/b': false,
'/data/a>= "1"': true,
'/data/a>="1"': true,
'"1" >= /data/a': true,
'"1">= /data/a': true,
'"1">=/data/a': true,
}, (expectedBoolean, expr) => {
it('should evaluate "' + expr + '" as ' + expectedBoolean.toString().toUpperCase(), () => {
assertBoolean(doc, null, expr, expectedBoolean);
});
});
});
describe('number operations', () => {

@@ -150,0 +189,0 @@ it( '*,+,-,mod,div precedence rules are applied correctly', () => {

const { assertThrow, assertNumberValue } = require('../helpers');
describe('#decimal-date-time()', () => {
[
['decimal-date-time("1970-01-01T00:00:00Z")', 0],
['decimal-date-time("1970-01-02T00:00:00Z")', 1],
['decimal-date-time("1969-12-31T00:00:00Z")', -1],
].forEach(([expr, expectedDaysSinceEpoch]) => {
it('should convert ' + expr + ' into ' + expectedDaysSinceEpoch, () => {
assertNumberValue(expr, expectedDaysSinceEpoch);
describe('with full date + timestamp', () => {
[
['decimal-date-time("1970-01-01T00:00:00Z")', 0],
['decimal-date-time("1970-01-02T00:00:00Z")', 1],
['decimal-date-time("1969-12-31T00:00:00Z")', -1],
].forEach(([expr, expectedDaysSinceEpoch]) => {
it('should convert ' + expr + ' into ' + expectedDaysSinceEpoch, () => {
assertNumberValue(expr, expectedDaysSinceEpoch);
});
});
});
describe('with date only', () => {
[
['decimal-date-time("1970-01-01")', 0],
['decimal-date-time("1970-01-02")', 1],
['decimal-date-time("1969-12-31")', -1]
].forEach( ([expr, expectedDaysSinceEpoch]) => {
it('should convert ' + expr + ' into ' + expectedDaysSinceEpoch, () => {
assertNumberValue(expr, expectedDaysSinceEpoch);
});
});
});
it('with invalid args, throws an error', () => {

@@ -15,0 +29,0 @@ assertThrow('decimal-date-time("1970-01-01T00:00:00.000Z", 2)');

@@ -1,2 +0,2 @@

const {assertThrow, assertNumberValue } = require('../helpers');
const {assertThrow, assertNumberValue, initDoc} = require('../helpers');

@@ -19,2 +19,10 @@ describe('decimal-time()', () => {

it('should convert times provided with a node parameter', () => {
const doc = initDoc(`
<data>
<a>06:00:00.000-07:00</a>
</data>`);
assertNumberValue(doc, null, 'decimal-time( /data/a )', 0.250);
});
it('facilitates time calculations and evaluates', () => {

@@ -21,0 +29,0 @@ assertNumberValue('decimal-time("12:00:00.000-07:00") - decimal-time("06:00:00.000-07:00")', 0.250);

const { initDoc, assert, assertThrow, assertTrue, nsResolver } = require('../helpers');
describe.only('randomize()', () => {
describe('randomize()', () => {
describe('called on a non-nodeset', () => {

@@ -5,0 +5,0 @@ [

@@ -20,2 +20,3 @@ const { assert } = require('chai');

['uuid(20)', 20],
['uuid(0)', 0],
].forEach(([expr, expectedLength]) => {

@@ -22,0 +23,0 @@ assertStringLength(expr, expectedLength);

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