processor.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. exports.__esModule = true;
  3. 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; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4. var _parser = require('./parser');
  5. var _parser2 = _interopRequireDefault(_parser);
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8. var Processor = function () {
  9. function Processor(func) {
  10. _classCallCheck(this, Processor);
  11. this.func = func || function noop() {};
  12. return this;
  13. }
  14. Processor.prototype.process = function process(selectors) {
  15. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16. var input = new _parser2.default({
  17. css: selectors,
  18. error: function error(e) {
  19. throw new Error(e);
  20. },
  21. options: options
  22. });
  23. this.res = input;
  24. this.func(input);
  25. return this;
  26. };
  27. _createClass(Processor, [{
  28. key: 'result',
  29. get: function get() {
  30. return String(this.res);
  31. }
  32. }]);
  33. return Processor;
  34. }();
  35. exports.default = Processor;
  36. module.exports = exports['default'];