@truto/truto-jsonata 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1811,6 +1811,58 @@ expression.evaluate({ data }).then(result => { console.log(result); });
1811
1811
 
1812
1812
  </details>
1813
1813
 
1814
+ <details>
1815
+ <summary>flatten(array)</summary>
1816
+
1817
+ Flattens an array a single level deep.
1818
+
1819
+ **Example:**
1820
+
1821
+ ```javascript
1822
+ import trutoJsonata from '@truto/truto-jsonata';
1823
+
1824
+ const expression = trutoJsonata("$flatten([1, [2, [3]]])");
1825
+ expression.evaluate({}).then(result => { console.log(result); });
1826
+ // Output: [1, 2, [3]]
1827
+ ```
1828
+
1829
+ </details>
1830
+
1831
+ <details>
1832
+ <summary>flattenDeep(array)</summary>
1833
+
1834
+ Recursively flattens an array, flattening all nested arrays into a single array.
1835
+
1836
+ **Example:**
1837
+
1838
+ ```javascript
1839
+ import trutoJsonata from '@truto/truto-jsonata';
1840
+
1841
+ const expression = trutoJsonata("$flattenDeep([1, [2, [3, [4, [5]]]])");
1842
+ expression.evaluate({}).then(result => { console.log(result); });
1843
+ // Output: [1, 2, 3, 4, 5]
1844
+ ```
1845
+
1846
+ </details>
1847
+
1848
+ <details>
1849
+ <summary>flattenDepth(array, depth)</summary>
1850
+
1851
+ Flattens an array up to the specified depth.
1852
+
1853
+ **Example:**
1854
+
1855
+ ```javascript
1856
+ import trutoJsonata from '@truto/truto-jsonata';
1857
+
1858
+ const expression = trutoJsonata("$flattenDepth([1, [2, [3, [4, [5]]]]], 2)");
1859
+ expression.evaluate({}).then(result => { console.log(result); });
1860
+ // Output: [1, 2, 3, [4, [5]]]
1861
+ ```
1862
+
1863
+ </details>
1864
+
1865
+
1814
1866
  ---
1815
1867
 
1816
1868
  ### Parsing and URL Functions
package/dist/main.cjs CHANGED
@@ -1618,6 +1618,15 @@ function $af351c41b7fd6f79$export$2e2bcd8739ae039(expression) {
1618
1618
  expression.registerFunction("bufferToString", (0, $0f748d6318103cdf$export$2e2bcd8739ae039));
1619
1619
  expression.registerFunction("parseQuery", (0, $7161d3cc11fbd965$export$2e2bcd8739ae039));
1620
1620
  expression.registerFunction("stringifyQuery", (0, $d3ad656830753df3$export$2e2bcd8739ae039));
1621
+ expression.registerFunction("flatten", function(arr) {
1622
+ return (0, $dxT2C$lodashes.flatten)((0, $dxT2C$lodashes.castArray)(arr));
1623
+ });
1624
+ expression.registerFunction("flattenDeep", function(arr) {
1625
+ return (0, $dxT2C$lodashes.flattenDeep)((0, $dxT2C$lodashes.castArray)(arr));
1626
+ });
1627
+ expression.registerFunction("flattenDepth", function(arr, depth) {
1628
+ return (0, $dxT2C$lodashes.flattenDepth)((0, $dxT2C$lodashes.castArray)(arr), depth);
1629
+ });
1621
1630
  return expression;
1622
1631
  }
1623
1632