+24
-10
lines changedFilter options
+24
-10
lines changed Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ Try it out on the online playground: <https://jsonquerylang.org>
10
10
11
11
## Features
12
12
13
-
- Small: just `3.2 kB` when minified and gzipped! The JSON query engine without parse/stringify is only `1.7 kB`.
13
+
- Small: just `3.3 kB` when minified and gzipped! The JSON query engine without parse/stringify is only `1.7 kB`.
14
14
- Feature rich (50+ powerful functions and operators)
15
15
- Easy to interoperate with thanks to the intermediate JSON format.
16
16
- Expressive
Original file line number Diff line number Diff line change
@@ -206,10 +206,10 @@ export const functions: FunctionBuildersMap = {
206
206
(data: T[]) =>
207
207
data.join(separator),
208
208
209
-
split:
210
-
(separator = '') =>
211
-
(data: string) =>
212
-
data.split(separator as string),
209
+
split: (separator?: string) =>
210
+
separator !== undefined
211
+
? (data: string) => data.split(separator)
212
+
: (data: string) => data.trim().split(/\s+/),
213
213
214
214
substring: (start: number, end: number) => (data: string) => data.slice(Math.max(start, 0), end),
215
215
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"source": "https://github.com/jsonquerylang/jsonquery/tree/main/test-suite/compile.test.json",
3
-
"updated": "2024-11-29T11:00:00Z",
3
+
"updated": "2024-12-02T11:00:00Z",
4
4
"tests": [
5
5
{
6
6
"category": "value",
@@ -506,16 +506,30 @@
506
506
{
507
507
"category": "split",
508
508
"description": "should split a string",
509
-
"input": "abc",
509
+
"input": "start with a b c",
510
+
"query": ["split"],
511
+
"output": ["start", "with", "a", "b", "c"]
512
+
},
513
+
{
514
+
"category": "split",
515
+
"description": "should split a string with multiple whitespaces between the words",
516
+
"input": " \n\n\t start with a b \n\r\t c \n\n\t ",
510
517
"query": ["split"],
518
+
"output": ["start", "with", "a", "b", "c"]
519
+
},
520
+
{
521
+
"category": "split",
522
+
"description": "should split a string by individual characters",
523
+
"input": "abc",
524
+
"query": ["split", ""],
511
525
"output": ["a", "b", "c"]
512
526
},
513
527
{
514
528
"category": "split",
515
529
"description": "should split a string with a separator",
516
-
"input": "hi there how are you doing?",
517
-
"query": ["split", " "],
518
-
"output": ["hi", "there", "how", "are", "you", "doing?"]
530
+
"input": "a,b,c",
531
+
"query": ["split", ","],
532
+
"output": ["a", "b", "c"]
519
533
},
520
534
521
535
{
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4