offset.js 481 B

123456789101112131415
  1. "use strict";
  2. exports.__esModule = true;
  3. var point_1 = require("../factories/point");
  4. function transformOffset(offset, context) {
  5. // istanbul ignore next
  6. if (offset < 0) {
  7. offset = 0;
  8. }
  9. else if (offset > context.text.length) {
  10. offset = context.text.length;
  11. }
  12. var location = context.locator.locationForIndex(offset);
  13. return point_1.createPoint(offset, location.line + 1, location.column + 1);
  14. }
  15. exports.transformOffset = transformOffset;