range.js 338 B

1234567891011121314151617181920212223
  1. class Range {
  2. /**
  3. * @param {number} pos
  4. * @param {number} length
  5. */
  6. constructor(pos, length) {
  7. this.pos = pos
  8. this.length = length
  9. }
  10. toRaw() {
  11. return {
  12. pos: this.pos,
  13. length: this.length
  14. }
  15. }
  16. static fromRaw(raw) {
  17. return new Range(raw.pos, raw.length)
  18. }
  19. }
  20. module.exports = Range