All files tokenValidator.js

83.33% Statements 25/30
56.25% Branches 9/16
100% Functions 8/8
81.25% Lines 13/16

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    1x       1x   1x   1x   1x   1x     1x     14x           14x           14x 644x             14x           1x  
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Eif (protoProps) defineProperties(Constructor.prototype, protoProps); Iif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
var RESERVED_WORDS = ['break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'new', 'null', 'return', 'super', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'var', 'void', 'while', 'with', 'as', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield'];
 
var TokenValidator = exports.TokenValidator = function () {
  function TokenValidator() {
    _classCallCheck(this, TokenValidator);
  }
 
  _createClass(TokenValidator, [{
    key: 'validate',
    value: function validate(key) {
      Iif (!key) {
        return {
          isValid: false,
          message: 'empty token'
        };
      }
      Iif (!/^[$_a-zA-Z][0-9a-zA-Z$_]*$/.test(key)) {
        return {
          isValid: false,
          message: key + ' is not valid TypeScript variable name.'
        };
      }
      Iif (RESERVED_WORDS.some(function (w) {
        return w === key;
      })) {
        return {
          isValid: false,
          message: key + ' is TypeScript reserved word.'
        };
      }
      return {
        isValid: true
      };
    }
  }]);
 
  return TokenValidator;
}();