Skip to content

Commit af299c7

Browse files
committed
Changeset: Add new Builder.prototype.build() method
1 parent 3eafbd5 commit af299c7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/static/js/Changeset.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,14 +2013,26 @@ class Builder {
20132013
return this;
20142014
}
20152015

2016-
toString() {
2016+
/**
2017+
* @returns {Changeset}
2018+
*/
2019+
build() {
20172020
/** @type {number} */
20182021
let lengthChange;
20192022
const serializedOps = exports.serializeOps((function* () {
20202023
lengthChange = yield* exports.canonicalizeOps(this._ops, true);
20212024
}).call(this));
2022-
const newLen = this._oldLen + lengthChange;
2023-
return exports.pack(this._oldLen, newLen, serializedOps, this._charBank.toString());
2025+
return {
2026+
oldLen: this._oldLen,
2027+
newLen: this._oldLen + lengthChange,
2028+
ops: serializedOps,
2029+
charBank: this._charBank.toString(),
2030+
};
2031+
}
2032+
2033+
toString() {
2034+
const {oldLen, newLen, ops, charBank} = this.build();
2035+
return exports.pack(oldLen, newLen, ops, charBank);
20242036
}
20252037
}
20262038
exports.Builder = Builder;

0 commit comments

Comments
 (0)