@adobe/helix-shared-indexer
Advanced tools
Comparing version 2.1.7 to 2.2.0
@@ -0,1 +1,8 @@ | ||
# [@adobe/helix-shared-indexer-v2.2.0](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-indexer-v2.1.7...@adobe/helix-shared-indexer-v2.2.0) (2024-11-07) | ||
### Features | ||
* support characters function ([#1022](https://github.com/adobe/helix-shared/issues/1022)) ([1f4e6f2](https://github.com/adobe/helix-shared/commit/1f4e6f255839c5494c4bb325481025d06d3ef5de)) | ||
# [@adobe/helix-shared-indexer-v2.1.7](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-indexer-v2.1.6...@adobe/helix-shared-indexer-v2.1.7) (2024-10-12) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@adobe/helix-shared-indexer", | ||
"version": "2.1.7", | ||
"version": "2.2.0", | ||
"description": "Shared modules of the Helix Project - Indexer", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -22,2 +22,33 @@ /* | ||
/** | ||
* Returns the substring from `start` to `end` of the given text. If `start` or `end` are | ||
* negative, they address the position counted from the end of the text. `end` is optional, | ||
* and defaults to the length of the text. | ||
* | ||
* Examples: | ||
* - characters('hello, world.', 0, 5) = 'hello' | ||
* - characters('hello, world.', 7) = 'world.' | ||
* - characters('hello, world.', -6, -1) = 'world' | ||
* | ||
* @param {string|Array<string>} text | ||
* @param {number} start The start position. | ||
* @param {number} [end] The end position. | ||
* @returns {Array<string>} | ||
*/ | ||
const characters = (text, start, end) => { | ||
if (Array.isArray(text)) { | ||
// eslint-disable-next-line no-param-reassign | ||
text = text.join(' '); | ||
} | ||
if (start < 0) { | ||
// eslint-disable-next-line no-param-reassign | ||
start += text.length; | ||
} | ||
if (end <= 0) { | ||
// eslint-disable-next-line no-param-reassign | ||
end += text.length; | ||
} | ||
return [text.substring(start, end)]; | ||
}; | ||
const helpers = { | ||
@@ -97,2 +128,3 @@ dateValue: (elements, format) => { | ||
}, | ||
characters, | ||
replace: (s, searchValue, replaceValue) => [s.replace(searchValue, replaceValue)], | ||
@@ -134,2 +166,10 @@ replaceAll: (s, searchValue, replaceValue) => [s.replaceAll(searchValue, replaceValue)], | ||
} | ||
case Jsep.UNARY_EXP: { | ||
const value = evalNode(node.argument); | ||
if (node.operator === '-') { | ||
return -value; | ||
} | ||
log.warn('operator not supported: ', node.operator); | ||
return undefined; | ||
} | ||
default: { | ||
@@ -136,0 +176,0 @@ log.warn('evaluate type not supported: ', node.type); |
61024
350