Sha256: f1c9a0be94c214257106ce353a0c46ebbf259377ea0097b0b389cd04d123486a

Contents?: true

Size: 1.65 KB

Versions: 23

Compression:

Stored size: 1.65 KB

Contents

import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";

var Range = /*#__PURE__*/function () {
  _createClass(Range, null, [{
    key: "copy",
    value: function copy(orig) {
      return new Range(orig.start, orig.end);
    }
  }]);

  function Range(start, end) {
    _classCallCheck(this, Range);

    this.start = start;
    this.end = end || start;
  }

  _createClass(Range, [{
    key: "isEmpty",
    value: function isEmpty() {
      return typeof this.start !== 'number' || !this.end || this.end <= this.start;
    }
    /**
     * Set `origStart` and `origEnd` to point to the original source range for
     * this node, which may differ due to dropped CR characters.
     *
     * @param {number[]} cr - Positions of dropped CR characters
     * @param {number} offset - Starting index of `cr` from the last call
     * @returns {number} - The next offset, matching the one found for `origStart`
     */

  }, {
    key: "setOrigRange",
    value: function setOrigRange(cr, offset) {
      var start = this.start,
          end = this.end;

      if (cr.length === 0 || end <= cr[0]) {
        this.origStart = start;
        this.origEnd = end;
        return offset;
      }

      var i = offset;

      while (i < cr.length) {
        if (cr[i] > start) break;else ++i;
      }

      this.origStart = start + i;
      var nextOffset = i;

      while (i < cr.length) {
        // if end was at \n, it should now be at \r
        if (cr[i] >= end) break;else ++i;
      }

      this.origEnd = end + i;
      return nextOffset;
    }
  }]);

  return Range;
}();

export { Range as default };

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.6 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.5 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.4 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.3 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.2 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.1 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3.5 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-5.0.0 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3.4 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3.3 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3.2 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3.1 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.3 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.2.3 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.2.2 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.2.1 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.2 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.1.9 node_modules/yaml/browser/dist/cst/Range.js
trusty-cms-4.1.8 node_modules/yaml/browser/dist/cst/Range.js