1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | 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; }; }(); |
8 |
|
9 |
|
10 |
|
11 | var _bluebird = require('bluebird');
|
12 |
|
13 | var _bluebird2 = _interopRequireDefault(_bluebird);
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16 |
|
17 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function noop() {}
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | var Step = function () {
|
32 | function Step(pattern, fn) {
|
33 | var args = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
|
34 |
|
35 | _classCallCheck(this, Step);
|
36 |
|
37 | this.pattern = pattern;
|
38 | this.fn = fn;
|
39 | this.args = args;
|
40 | }
|
41 |
|
42 | _createClass(Step, [{
|
43 | key: 'match',
|
44 | value: function match(line) {
|
45 | return line.match(this.pattern);
|
46 | }
|
47 | }, {
|
48 | key: 'runWith',
|
49 | value: function runWith(context, line) {
|
50 | var _this = this;
|
51 |
|
52 | var cb = arguments.length <= 2 || arguments[2] === undefined ? noop : arguments[2];
|
53 |
|
54 | var args = !!line ? this.match(line).slice(1) : this.args;
|
55 | return _bluebird2.default.try(function () {
|
56 | return _this.fn.apply(context, args);
|
57 | }).asCallback(cb);
|
58 | }
|
59 | }]);
|
60 |
|
61 | return Step;
|
62 | }();
|
63 |
|
64 | exports.default = Step;
|
65 | module.exports = exports['default']; |
\ | No newline at end of file |