Skip to content

Commit 4b771ec

Browse files
committed
fix typo
1 parent a7d5841 commit 4b771ec

File tree

5 files changed

+85
-71
lines changed

5 files changed

+85
-71
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ var filter = sift(
439439
[1, 2, 3, 4, 5].filter(filter); // 1, 3, 5
440440
```
441441

442-
#### Omitting builtin operations
442+
#### Omitting built-in operations
443443

444-
You can create a filter function that omits the builtin operations like so:
444+
You can create a filter function that omits the built-in operations like so:
445445

446446
```javascript
447447
import { createQueryTester } from "sift";
@@ -456,4 +456,4 @@ const test = createQueryTester(
456456
[1, 2, 3, 4, 10].filter(test);
457457
```
458458

459-
For bundlers like Webpack and Rollup, operations that aren't used are omitted from application bundles via tree-shaking.
459+
For bundlers like `Webpack` and `Rollup`, operations that aren't used are omitted from application bundles via tree-shaking.

index.d.ts

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,80 @@
1-
export type SupportedType =
2-
| string
3-
| { [index: string]: RegExp | any }
4-
| number
5-
| null
6-
| any;
7-
export type KeyOrValue<T extends SupportedType> = T;
1+
// export type SupportedType =
2+
// | string
3+
// | { [index: string]: RegExp | any }
4+
// | number
5+
// | null
6+
// | any;
7+
// export type KeyOrValue<T extends SupportedType> = T;
88

9-
export type ElemMatch<T> = { [P in keyof T]?: SiftQuery<T[P]> };
9+
// export type ElemMatch<T> = { [P in keyof T]?: SiftQuery<T[P]> };
1010

11-
export type Query<T extends SupportedType> = {
12-
$eq?: T;
13-
$ne?: T;
14-
$or?: T[];
15-
$gt?: T;
16-
$gte?: T;
17-
$lt?: T;
18-
$lte?: T;
19-
$mod?: number[];
20-
$in?: T[];
21-
$nin?: T[];
22-
$not?: SiftQuery<T>;
23-
$type?: any;
24-
$all?: T[];
25-
$size?: number;
26-
$nor?: T[];
27-
$and?: T[];
28-
$regex?: RegExp | string;
29-
$elemMatch?: ExternalQuery<T>;
30-
$exists?: boolean;
31-
$where?: string | WhereFn<T>;
32-
};
11+
// export type Query<T extends SupportedType> = {
12+
// $eq?: T;
13+
// $ne?: T;
14+
// $or?: T[];
15+
// $gt?: T;
16+
// $gte?: T;
17+
// $lt?: T;
18+
// $lte?: T;
19+
// $mod?: number[];
20+
// $in?: T[];
21+
// $nin?: T[];
22+
// $not?: SiftQuery<T>;
23+
// $type?: any;
24+
// $all?: T[];
25+
// $size?: number;
26+
// $nor?: T[];
27+
// $and?: T[];
28+
// $regex?: RegExp | string;
29+
// $elemMatch?: ExternalQuery<T>;
30+
// $exists?: boolean;
31+
// $where?: string | WhereFn<T>;
32+
// };
3333

34-
export interface InternalQuery<T extends SupportedType> extends Query<T> {}
34+
// export interface InternalQuery<T extends SupportedType> extends Query<T> {}
3535

36-
export type ExternalQuery<T extends SupportedType> = ElemMatch<T>;
36+
// export type ExternalQuery<T extends SupportedType> = ElemMatch<T>;
3737

38-
export type WhereFn<T extends SupportedType> = (
39-
this: T,
40-
value: T,
41-
index: number,
42-
array: T
43-
) => boolean;
38+
// export type WhereFn<T extends SupportedType> = (
39+
// this: T,
40+
// value: T,
41+
// index: number,
42+
// array: T
43+
// ) => boolean;
4444

45-
export type FilterFn = <T>(value: T, index?: number, array?: T[]) => boolean;
45+
// export type FilterFn = <T>(value: T, index?: number, array?: T[]) => boolean;
4646

47-
export type SiftQuery<T extends SupportedType> =
48-
| ExternalQuery<T>
49-
| InternalQuery<T>;
47+
// export type SiftQuery<T extends SupportedType> =
48+
// | ExternalQuery<T>
49+
// | InternalQuery<T>;
5050

51-
export type PluginDefinition<T> = {
52-
[index: string]: (a: T, b: T) => boolean | number;
53-
};
51+
// export type PluginDefinition<T> = {
52+
// [index: string]: (a: T, b: T) => boolean | number;
53+
// };
5454

55-
export type PluginFunction<T> = (sift: Sift) => PluginDefinition<T>;
55+
// export type PluginFunction<T> = (sift: Sift) => PluginDefinition<T>;
5656

57-
export type Exec = <T extends SupportedType>(array: T) => T;
57+
// export type Exec = <T extends SupportedType>(array: T) => T;
5858

59-
type Options<T> = {
60-
expressions?: {
61-
[identifier: string]: (
62-
item: T,
63-
query: SiftQuery<T>,
64-
options: Options<T>
65-
) => boolean;
66-
};
67-
};
59+
// type Options<T> = {
60+
// expressions?: {
61+
// [identifier: string]: (
62+
// item: T,
63+
// query: SiftQuery<T>,
64+
// options: Options<T>
65+
// ) => boolean;
66+
// };
67+
// };
6868

69-
export interface Sift {
70-
<T extends SupportedType>(
71-
query: SiftQuery<T>,
72-
options?: Options<T>
73-
): FilterFn;
74-
compare<T, K>(a: T, b: K): 0 | -1 | 1;
75-
}
69+
// export interface Sift {
70+
// <T extends SupportedType>(
71+
// query: SiftQuery<T>,
72+
// options?: Options<T>
73+
// ): FilterFn;
74+
// compare<T, K>(a: T, b: K): 0 | -1 | 1;
75+
// }
7676

77-
declare const Sift: Sift;
78-
export default Sift;
77+
// declare const Sift: Sift;
78+
// export default Sift;
79+
80+
export * from "./core";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sift",
33
"description": "mongodb query style array filtering",
4-
"version": "11.0.7",
4+
"version": "11.0.8",
55
"repository": "crcn/sift.js",
66
"sideEffects": false,
77
"author": {

src/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ export class EqualsOperation<TParam> extends BaseOperation<TParam> {
216216
}
217217
}
218218

219+
export const createEqualsOperation = (
220+
params: any,
221+
owneryQuery: any,
222+
options: Options
223+
) => new EqualsOperation(params, owneryQuery, options);
224+
219225
export class NopeOperation<TParam> extends BaseOperation<TParam> {
220226
next() {
221227
this.done = true;

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import * as defaultOperations from "./operations";
2-
import { Query, Options, createQueryTester, EqualsOperation } from "./core";
2+
import {
3+
Query,
4+
Options,
5+
createQueryTester,
6+
EqualsOperation,
7+
createEqualsOperation
8+
} from "./core";
39

410
const createDefaultQueryTester = (
511
query: Query,
@@ -11,6 +17,6 @@ const createDefaultQueryTester = (
1117
});
1218
};
1319

14-
export { Query, EqualsOperation, createQueryTester };
20+
export { Query, EqualsOperation, createQueryTester, createEqualsOperation };
1521

1622
export default createDefaultQueryTester;

0 commit comments

Comments
 (0)