Skip to content

Commit

Permalink
Tweak stat API description
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Dec 6, 2023
1 parent 26696ea commit a039e11
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions docs/articles/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,31 @@ statApi.suggestion(6); // .[foo=|]
Output format:

```ts
suggestion(): Array<{
context: 'path' | 'key' | 'value' | 'in-value' | 'value-subset' | 'var',
from: number,
to: number,
text: string,
values: Set<any>,
related: Set<any> | null
}> | null
stat(): Array<{
context: 'path' | 'key' | 'value' | 'in-value' | 'value-subset' | 'var' | 'assertion',
from: number,
to: number,
text: string,
values: Set<any>,
related: Set<any> | null
}> | null
```

- `suggestion(pos: number, options?)`

Returns suggesion values grouped by a type or `null` if there is no any suggestions. The following options are supported (all are optional):
- `limit` (default: `Infinity`) – a max number of the values that should be returned for each value type (`"property"`, `"value"` or `"variable"`)
Returns suggesion values grouped by a type or `null` if there is no any suggestions. The following `options` are supported (all are optional):
- `limit` (default: `Infinity`) – a max number of the values that should be returned for each value type (`"property"`, `"value"`, `"variable"`, `"assertion"`)
- `sort` (default: `false`) – a comparator function (should take 2 arguments and return a negative number, `0` or a positive number) for value list sorting, makes sence when `limit` is used
- `filter` (default: `function`) – a filter function factory (`pattern => value => <expr>`) to discard values from the result when returns a falsy value (default is equivalent to `patttern => value => String(value).toLowerCase().includes(pattern)`)
Output format:
```ts
suggestion(): Array<{
type: 'property' | 'value' | 'variable',
from: number,
to: number,
text: string,
suggestions: Array<string | number>
}> | null
suggestion(): Array<{
type: 'property' | 'value' | 'variable' | 'assertion',
from: number,
to: number,
text: string,
suggestions: Array<string | number>
}> | null
```

0 comments on commit a039e11

Please sign in to comment.