All files / data_handler checks.ts

50% Statements 13/26
0% Branches 0/14
33.33% Functions 6/18
50% Lines 12/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 684x   4x         4x                   4x   11x     11x     1x 1x   1x       4x                                 4x     4x                              
import {options} from './export_params'
 
export const group_checks: {[index: string]: Function} = {
  '!': function (this: string, v: string): boolean {
    return this !== v
  },
  '=': function (this: string, v: string): boolean {
    return this === v
  },
  includes: function (v: string): boolean {
    return -1 !== this.indexOf(v)
  },
  excludes: function (v: string): boolean {
    return -1 === this.indexOf(v)
  },
}
 
export const export_checks: {[index: string]: Function} = {
  file_format: function (a: string): boolean {
    return -1 === options.file_format.indexOf(a)
  },
  table_format: function (a: string): boolean {
    return -1 === options.table_format.indexOf(a)
  },
  include: function (a: string, vars: {[index: string]: string}): string {
    for (let i = a.length; i--; ) {
      Iif (!(a[i] in vars)) return a[i]
    }
    return ''
  },
}
 
export const value_checks: {[index: string]: Function} = {
  '!': function (a: number): boolean {
    return !a || -1 == a
  },
  '': function (a: number): boolean {
    return !!a && -1 != a
  },
  '=': function (a: number, b: number): boolean {
    return a === b
  },
  '!=': function (a: number, b: number): boolean {
    return a != b
  },
  '>': function (a: number, b: number): boolean {
    return a > b
  },
  '<': function (a: number, b: number): boolean {
    return a < b
  },
  '>=': function (a: number, b: number): boolean {
    return a >= b
  },
  '<=': function (a: number, b: number): boolean {
    return a <= b
  },
  equals: function (s: number, e: string | number): boolean {
    return !s || -1 == s || s === e
  },
  includes: function (s: (string | number)[], e: string | number): boolean {
    return !s || !s.length || -1 !== s.indexOf(e)
  },
  excludes: function (s: (string | number)[], e: string | number): boolean {
    return !s || !s.length || -1 === s.indexOf(e)
  },
}