• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sovrin / onia / 7057071066

01 Dec 2023 07:26AM UTC coverage: 100.0%. Remained the same
7057071066

push

github

sovrin
chore(package): version

24 of 24 branches covered (100.0%)

Branch coverage included in aggregate %.

90 of 90 relevant lines covered (100.0%)

27.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/utils.ts
1
import {Parser} from './types';
2

3
/**
4
 *
5
 */
6
export const flatten = () => (haystack: any[]) => haystack.flat(1);
2✔
7

8
/**
9
 *
10
 */
11
export const pop = () => (haystack: any[]) => haystack.pop();
9✔
12

13
/**
14
 *
15
 */
16
export const shift = () => (haystack: any[]) => haystack.shift();
1✔
17

18
/**
19
 *
20
 */
21
export const join = () => (haystack: string[]) => haystack.join('');
2✔
22

23
/**
24
 *
25
 */
26
export const int = () => (number: string) => parseInt(number);
14✔
27

28
/**
29
 *
30
 */
31
export const float = () => (number: string) => parseFloat(number);
1✔
32

33
/**
34
 *
35
 * @param values
36
 */
37
export const filter = (values: (string | Parser<any>)[]) => (haystack: any[]) => {
4✔
38
    const lookup = values.map((value) => value.toString())
11✔
39
        .filter(Boolean)
40
    ;
41

42
    return haystack.filter((value) => value !== null)
25✔
43
        .filter((element) => !lookup.includes(element))
19✔
44
        .filter((element) => element != undefined)
10✔
45
    ;
46
};
47

48
/**
49
 *
50
 * @param fns
51
 */
52
export const pipe = (...fns) => (x) => fns.reduce((y, f) => f(y), x);
12✔
53

54
/**
55
 *
56
 * @param parser
57
 * @param fns
58
 */
59
export const define = <T>(parser: T, fns: Record<string, (() => any) | string>): T => {
1✔
60
    for (const key in fns) {
122✔
61
        const {[key]: value} = fns;
152✔
62

63
        Object.defineProperty(parser, key, {
152✔
64
            value,
65
        });
66
    }
67

68
    return parser;
122✔
69
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc