fontoxpath
Advanced tools
Comparing version 3.25.1 to 3.26.0
@@ -210,2 +210,6 @@ /// <reference lib="dom" /> | ||
/** | ||
* Resolve to all results, adapted to JavaScript values | ||
*/ | ||
ALL_RESULTS_TYPE: ReturnType_2.ALL_RESULTS; | ||
/** | ||
* Returns the result of the query, can be anything depending on the | ||
@@ -215,2 +219,6 @@ * query. Note that the return type is determined dynamically, not | ||
* arrays and not null, like one might expect. | ||
* | ||
* @deprecated | ||
* | ||
* For predictable results, use the ALL_RESULTS return type | ||
*/ | ||
@@ -647,2 +655,5 @@ ANY_TYPE: ReturnType_2.ANY; | ||
[ReturnType_2.NUMBERS]: number[]; | ||
[ReturnType_2.ALL_RESULTS]: (T | string | Date | boolean | number | any[] | { | ||
[s: string]: any; | ||
})[]; | ||
[ReturnType_2.ASYNC_ITERATOR]: AsyncIterableIterator<any>; | ||
@@ -998,12 +1009,63 @@ } | ||
declare enum ReturnType_2 { | ||
/** | ||
* ANY Will result in ANY result. This closesly resembles what XPathResult.ANY_TYPE returns. | ||
* | ||
* If the result is a single item (ie. one node, one string, one number, etcetera), only that value is returned. | ||
* | ||
* If the result is the empty sequence, an empty array is returned | ||
* | ||
* If the result is multiple items, an array with those items is returned. Nodes are returned as-is, but attribute nodes are atomized. | ||
* | ||
* Note that this is usually _not_ what you'd expect, and may cause bugs to show up when you | ||
* don't expect. Use ALL_RESULTS to get all results, always as an array, without special | ||
* handling for attribute nodes. | ||
* | ||
* @deprecated use ALL_RESULTS instead | ||
*/ | ||
'ANY' = 0, | ||
/** | ||
* Always returns a number. NaN if the result of the query is not a valid number | ||
*/ | ||
'NUMBER' = 1, | ||
/** | ||
* Always returns a string. | ||
*/ | ||
'STRING' = 2, | ||
/** | ||
* Always returns a boolean. Uses the `effective boolean value` algorithm to determine the result if the query did not return a boolean by itself | ||
*/ | ||
'BOOLEAN' = 3, | ||
/** | ||
* Returns all nodes, as an array. Throws an error if the result contains anything but nodes | ||
*/ | ||
'NODES' = 7, | ||
/** | ||
* Returns only the first node in the result | ||
*/ | ||
'FIRST_NODE' = 9, | ||
/** | ||
* Returns all strings the query returns, as an array | ||
*/ | ||
'STRINGS' = 10, | ||
/** | ||
* Returns the map the query returns. Error when the query does not result in exactly one map | ||
*/ | ||
'MAP' = 11, | ||
/** | ||
* Returns the array the query returns. Error when the query does not result in exactly one array | ||
*/ | ||
'ARRAY' = 12, | ||
/** | ||
* Returns all numbers the query resulted in. Invalid numbers are replaced with NaN | ||
*/ | ||
'NUMBERS' = 13, | ||
/** | ||
* Returns all results of the query, as completely as possible: nodes are nodes, attributes are attribute nodes, dateTimes are turned into DateTime objects. | ||
*/ | ||
'ALL_RESULTS' = 14, | ||
/** | ||
* Returns an async iterator of the results. Since FontoXPath can no longer return results asychronously, the ALL_RESULTS option is better to use. | ||
* | ||
* @deprecated Use ALL_RESULTS instead | ||
*/ | ||
'ASYNC_ITERATOR' = 99 | ||
@@ -1010,0 +1072,0 @@ } |
{ | ||
"name": "fontoxpath", | ||
"version": "3.25.1", | ||
"version": "3.26.0", | ||
"description": "A minimalistic XPath 3.1 engine in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/fontoxpath.js", |
@@ -39,8 +39,9 @@ # fontoxpath  [](http://badge.fury.io/js/fontoxpath) [](https://bundlephobia.com/result?p=fontoxpath) [](https://coveralls.io/github/FontoXML/fontoxpath?branch=master) [](https://snyk.io/test/github/FontoXML/fontoxpath?targetFile=package.json) [](https://www.codefactor.io/repository/github/fontoxml/fontoxpath) | ||
- `variables` `<Object>` The properties of `variables` are available variables within the | ||
`xpathExpression`. Defaults to an empty `Object`. Can only be used to set variables in the global namespace. | ||
`xpathExpression`. Defaults to an empty `Object`. Can only be used to set variables in the | ||
global namespace. | ||
- `returnType` `<number>` Determines the type of the result. Defaults to | ||
`evaluateXPath.ANY_TYPE`. Possible values: | ||
- `evaluateXPath.ANY_TYPE` Returns the result of the query, can be anything depending on the | ||
query. Note that the return type is determined dynamically, not statically: XPaths returning | ||
empty sequences will return empty arrays and not null, like one might expect. | ||
- `evaluateXPath.ALL_RESULTS_TYPE` Returns the result of the query, can be anything depending | ||
on the query. This will always be an array, and the result can be mixed: contain both nodes | ||
and strings for example. | ||
- `evaluateXPath.NUMBER_TYPE` Resolve to a `number`, like count((1,2,3)) resolves to 3. | ||
@@ -61,2 +62,6 @@ - `evaluateXPath.STRING_TYPE` Resolve to a `string`, like //someElement[1] resolves to the text | ||
- `evaluateXPath.NUMBERS_TYPE` Resolve to an array of numbers `number[]`. | ||
- `evaluateXPath.ANY_TYPE` Returns the result of the query, can be anything depending on the | ||
query. Note that the return type is determined dynamically, not statically: XPaths returning | ||
empty sequences will return empty arrays and not null, like one might expect. | ||
This is deprecated, use `evaluateXPath.ALL_RESULTS_TYPE` instead, since that is more predictable. | ||
- `options` `<Object>` Options used to modify the behavior. The following options are available: | ||
@@ -63,0 +68,0 @@ - `namespaceResolver` `<function(string):string?>` By default, the namespaces in scope of the |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
698436
3949
483