-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
52 lines (44 loc) · 1.31 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export interface Code {
/** Food Name. */
name: string,
/** Food Code. */
code: string
}
/**
* Loads corpus to enable queries.
* [📦](https://www.npmjs.com/package/@ifct2017/codes)
* @returns corpus {name ⇒ {name, code}}
*/
export function load(): Promise<Map<string, Code>>;
/**
* Generates PostgreSQL statements for creating table w/ data.
* [📦](https://www.npmjs.com/package/@ifct2017/codes)
* @returns CREATE TABLE, INSERT, CREATE VIEW, CREATE INDEX statements
*/
export function sql(tab: string='codes', opt: object={}): Promise<string>;
/**
* Gives path of CSV data file.
* [📦](https://www.npmjs.com/package/@ifct2017/codes)
* @returns .../index.csv
*/
export function csv(): string;
/**
* Finds matching codes of an name/code query.
* [📦](https://www.npmjs.com/package/@ifct2017/codes)
* @param txt name/code query
* @returns matches [{name, code}]
* @example
* ```javascript
* codes('mango green');
* codes('Raw mango');
* // [ { name: 'Mango, green, raw (Common)', code: 'D057' } ]
*
* codes('what is food code of atta?');
* codes('atta code');
* // [ { name: 'Atta (H., P.)', code: 'A019' },
* // { name: 'Gahama atta (O.)', code: 'A019' },
* // { name: 'Wheat flour, atta (Common)', code: 'A019' } ]
* ```
*/
function codes(txt: string): [Code];
export = codes;