Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
righ committed Aug 28, 2024
1 parent 1151c43 commit 9bdb036
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ make(factors, { // optional
length: 2,
// SuggestRowType<typeof factors> is { machine: string, os: string, browser: string }
preFilter: (row: SuggestRowType<typeof factors>) => !(row.os === 'Android' && row.machine !== 'Pixel'), // default: null
// Or DictType that is { [key: string]: string }
// Or DictType that is { [key: string]: any }
postFilter: (row: DictType) => !(row.os === 'iOS' && row.browser !== 'Safari'), // default: null
});
```
Expand Down Expand Up @@ -109,8 +109,8 @@ Obviously the more it increases, the more number of combinations increases.
### sorter
Determines the order of combinations.

- sorters.random: It makes different combinations everytime. (fastest)
- sorters.hash: It makes combinations depending on hash of the pair and seed. (default)
- sorters.random: Generates different combinations each time. (fastest)
- sorters.hash: Uses a hash-based method for reproducibility. (default)

- It receives `seed`.
- `seed` option decides the order of storing from unstored pairs.
Expand All @@ -119,8 +119,8 @@ Determines the order of combinations.
### criterion
Determines the efficiency of combinations.

- `criteria.simple`: it extracts any pairs that can be stored into the processing row.
- `criteria.greedy`: it attempts to make most efficient combinations. (default)
- `criteria.simple`: Quickly generates combinations.
- `criteria.greedy`: Attempts to minimize the number of combinations, but is more time-intensive. (default)
- It receives [tolerance](https://github.com/walkframe/covertable#tolerance) option.

While `criteria.simple` processes quickly, `criteria.greedy` makes fewer combinations.
Expand Down
10 changes: 9 additions & 1 deletion typescript/src/__tests__/pict.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { PictConstraintsLexer } from "../utils/pict";

describe('PictConstraintsLexer with single constraints', () => {
it('Blank', () => {
const lexer = new PictConstraintsLexer(``, true);
expect(lexer.filters.length).toBe(0);
expect(lexer.errors.length).toBe(0);

const row1 = { PRICE: 150, DISCOUNT: 'YES' };
expect(lexer.filter(row1)).toBe(true);
});

it('should filter correctly with LIKE and IN conditions', () => {
const lexer = new PictConstraintsLexer(`
IF [NAME] LIKE "Alic?" THEN [STATUS] IN {"Active", "Pending"} ELSE [AGE] > 20 OR [COUNTRY] = "USA";
Expand Down Expand Up @@ -355,7 +364,6 @@ describe('PictConstraintsLexer with invalid constraints', () => {
expect(lexer.errors.length).toBe(1);
expect(lexer.errors[0]).toBe('The leading "IF" is missing, found [NAME]');
});


it('Multiple invalid expressions', () => {
const lexer = new PictConstraintsLexer(`
Expand Down

0 comments on commit 9bdb036

Please sign in to comment.