old-value.js 818 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. var utils = require('./utils');
  4. var OldValue = function () {
  5. function OldValue(unprefixed, prefixed, string, regexp) {
  6. _classCallCheck(this, OldValue);
  7. this.unprefixed = unprefixed;
  8. this.prefixed = prefixed;
  9. this.string = string || prefixed;
  10. this.regexp = regexp || utils.regexp(prefixed);
  11. }
  12. /**
  13. * Check, that value contain old value
  14. */
  15. OldValue.prototype.check = function check(value) {
  16. if (value.indexOf(this.string) !== -1) {
  17. return !!value.match(this.regexp);
  18. }
  19. return false;
  20. };
  21. return OldValue;
  22. }();
  23. module.exports = OldValue;