UNPKG

babel-plugin-runtyper

Version:

Babel plugin for runtime type-checking in JavaScript

26 lines (21 loc) 499 B
'use strict'; const Base = require('./base'); const OPERATORS = { '-': 'minus', '*': 'multiply', '/': 'divide', '%': 'remainder', }; const ASSERT_NOT_NUMBERS = ` var lta = ta.toLowerCase(); var ltb = tb.toLowerCase(); if (lta !== 'number' || ltb !== 'number') { msg = 'Numeric operation with non-numeric value'; } `; module.exports = class NumericAssertion extends Base { constructor(options) { super(options, OPERATORS); this._buildTpl(ASSERT_NOT_NUMBERS); } };