UNPKG

1.78 kBTypeScriptView Raw
1export interface Carbohydrate {
2 /** S. No. */
3 sno: string,
4 /** Carbohydrate. */
5 carbohydrate: string,
6 /** Equivalent after Hydrolysis (g/100g). */
7 hydrolysis: number,
8 /** Conversion to monosaccharide equivalent. */
9 monosaccharide: number
10}
11
12
13/**
14 * Loads corpus to enable queries.
15 * [📦](https://www.npmjs.com/package/@ifct2017/carbohydrates)
16 * @returns corpus {sno ⇒ {sno, carbohydrate, hydrolysis, monosaccharide}}
17 */
18export function load() : Map<string, Carbohydrate>;
19
20
21/**
22 * Generates PostgreSQL statements for creating table w/ data.
23 * [📦](https://www.npmjs.com/package/@ifct2017/carbohydrates)
24 * @returns CREATE TABLE, INSERT, CREATE VIEW, CREATE INDEX statements
25 */
26 export function sql(tab: string='carbohydrates', opt: object={}) : string;
27
28
29/**
30 * Gives path of CSV data file.
31 * [📦](https://www.npmjs.com/package/@ifct2017/carbohydrates)
32 * @returns .../index.csv
33 */
34 export function csv() : string;
35
36
37/**
38 * Finds matching carbohydrates of an sno/carbohydrate query.
39 * [📦](https://www.npmjs.com/package/@ifct2017/carbohydrates)
40 * @param txt sno/carbohydrate query
41 * @returns matches [{sno, carbohydrate, hydrolysis, monosaccharide}]
42 * @example
43 * ```javascript
44 * carbohydrates('monosaccharide');
45 * carbohydrates('Glucose');
46 * // [ { sno: '1',
47 * // carbohydrate: 'Monosaccharides e.g. glucose',
48 * // hydrolysis: 100,
49 * // monosaccharide: 1 } ]
50 *
51 * carbohydrates('what is carbohydrate conversion factor of disaccharides?');
52 * carbohydrates('maltose conversion factor');
53 * // [ { sno: '2',
54 * // carbohydrate: 'Disaccharides e.g. sucrose, lactose, maltose',
55 * // hydrolysis: 105,
56 * // monosaccharide: 1.05 } ]
57 * ```
58 */
59function carbohydrates(txt: string): [Carbohydrate];
60export = carbohydrates;