old-value.js 675 B

123456789101112131415161718192021222324252627282930
  1. (function() {
  2. var OldValue, utils;
  3. utils = require('./utils');
  4. OldValue = (function() {
  5. function OldValue(unprefixed, prefixed, string, regexp) {
  6. this.unprefixed = unprefixed;
  7. this.prefixed = prefixed;
  8. this.string = string;
  9. this.regexp = regexp;
  10. this.regexp || (this.regexp = utils.regexp(this.prefixed));
  11. this.string || (this.string = this.prefixed);
  12. }
  13. OldValue.prototype.check = function(value) {
  14. if (value.indexOf(this.string) !== -1) {
  15. return !!value.match(this.regexp);
  16. } else {
  17. return false;
  18. }
  19. };
  20. return OldValue;
  21. })();
  22. module.exports = OldValue;
  23. }).call(this);