Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
changed: version 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Apr 26, 2017
1 parent cdaa251 commit 1d3ed5c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

[Unreleased]
[1.5.0] - 2017-04-25
--------------------
##### Added
- Ends-with() support.
Expand Down
54 changes: 48 additions & 6 deletions dist/enketo-xpathjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4537,9 +4537,7 @@ var XPathJS = (function(){
{
// Using ParseInt, creates a problem for very small or large numbers that are displayed in scientific
// notation. E.g. parseInt(1/47999799999, 10) is 2 instead of 0 (2.08e-11)
// Therefore this function is essentially an alias for floor(). It's argument is a string though,
// but I don't think it behaves different from floor in any way.
return new NumberType( Math.floor( str.toNumber() ) );
return new NumberType( ( str.toNumber() >= 0 ) ? Math.floor( str.toNumber() ) : -Math.floor( Math.abs( str.toNumber() ) ) );
},
args: [
{t: 'string'}
Expand Down Expand Up @@ -5345,11 +5343,55 @@ var XPathJS = (function(){
],

ret: 'number'
}
},

'ends-with': {
/**
* The ends-with function returns true if the first argument string
* ends with the second argument string, and otherwise returns false.
*
* An alternative (faster?) would be to reverse the first argument and use starts-with (in Enketo Core)?
*
* @see https://www.w3.org/TR/xpath-functions-30/#func-ends-with
* @param {StringType} haystack
* @param {StringType} needle
* @return {StringType}
*/
fn: function(haystack, needle)
{
return new BooleanType(haystack.toString().substr(haystack.toString().length - needle.toString().length) === needle.toString());
},

args: [
{t: 'string'},
{t: 'string'}
],

ret: 'string'
},

abs: {
/**
* Returns the absolute value of the argument.
*
* @see https://www.w3.org/TR/xpath-functions-30/#func-abs
* @param {NumberType}
* @return {NumberType}
*/
fn: function(number)
{
return new NumberType(Math.abs(number));
},

args: [
{t: 'number'}
],

ret: 'number'
},

/**
* The indexed-repeat function... should be used as little as possible
* THIS FUNCTION DOESN'T WORK NICELY WITH POSITION-INJECTION INSIDE REPEATS
* MOVED TO ENKETO-CORE WHERE IT TRANSFORMED INTO REGULAR XPATH
*
* @param { NodeSetType} nodeset Collection of nodes of which to select one
* @param { NodeSetType} r1,r2,r3,r4,r5 The repeat nodes
Expand Down
6 changes: 3 additions & 3 deletions dist/enketo-xpathjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "enketo-xpathjs",
"description": "JS implementation of XPath extended with OpenRosa functions and the date datatype",
"homepage": "https://enketo.org",
"version": "1.4.0",
"version": "1.5.0",
"repository": {
"type": "git",
"url": "https://github.com/enketo/enketo-xpathjs"
Expand Down

0 comments on commit 1d3ed5c

Please sign in to comment.