+5
-7
lines changedFilter options
+5
-7
lines changed Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ export const functions: FunctionBuildersMap = {
130
130
}
131
131
},
132
132
133
-
filter: <T>(predicate: JSONQuery[]) => {
133
+
filter: <T>(predicate: JSONQuery) => {
134
134
const _predicate = compile(predicate)
135
135
136
136
return (data: T[]) => data.filter((item) => truthy(_predicate(item)))
@@ -171,7 +171,7 @@ export const functions: FunctionBuildersMap = {
171
171
172
172
pick: (...properties: JSONQueryProperty[]) => {
173
173
const getters = properties.map(
174
-
([_get, ...path]) => [path[path.length - 1], functions.get(...path)] as Getter
174
+
([_get, ...path]) => [path[path.length - 1], functions.get(...(path as JSONPath))] as Getter
175
175
)
176
176
177
177
const _pick = (object: Record<string, unknown>, getters: Getter[]): unknown => {
@@ -294,7 +294,7 @@ export const functions: FunctionBuildersMap = {
294
294
not: buildFunction((a: unknown) => !a),
295
295
296
296
exists: (queryGet: JSONQueryFunction) => {
297
-
const parentPath = queryGet.slice(1)
297
+
const parentPath = queryGet.slice(1) as JSONPath
298
298
const key = parentPath.pop()
299
299
const getter = functions.get(...parentPath)
300
300
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ export type {
29
29
JSONQueryObject,
30
30
JSONQueryOptions,
31
31
JSONQueryParseOptions,
32
-
JSONQueryPipe,
33
32
JSONQueryPrimitive,
34
33
JSONQueryProperty,
35
34
JSONQueryStringifyOptions
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
1
-
export type JSONQueryPipe = JSONQuery[]
2
-
export type JSONQueryFunction = [name: string, ...args: JSONQuery[]]
1
+
export type JSONQueryFunction = [name: string, ...args: unknown[]]
3
2
export type JSONQueryObject = { [key: string]: JSONQuery }
4
3
export type JSONQueryPrimitive = string | number | boolean | null
5
-
export type JSONQuery = JSONQueryFunction | JSONQueryPipe | JSONQueryObject | JSONQueryPrimitive
4
+
export type JSONQuery = JSONQueryFunction | JSONQueryObject | JSONQueryPrimitive
6
5
7
6
export type JSONProperty = string
8
7
export type JSONPath = JSONProperty[]
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