Skip to content

Commit 235140d

Browse files
committed
Changeset: Add new Builder.prototype.build() method
1 parent 441413a commit 235140d

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
@@ -2007,14 +2007,26 @@ class Builder {
20072007
return this;
20082008
}
20092009

2010-
toString() {
2010+
/**
2011+
* @returns {Changeset}
2012+
*/
2013+
build() {
20112014
/** @type {number} */
20122015
let lengthChange;
20132016
const serializedOps = exports.serializeOps((function* () {
20142017
lengthChange = yield* exports.canonicalizeOps(this._ops, true);
20152018
}).call(this));
2016-
const newLen = this._oldLen + lengthChange;
2017-
return exports.pack(this._oldLen, newLen, serializedOps, this._charBank.toString());
2019+
return {
2020+
oldLen: this._oldLen,
2021+
newLen: this._oldLen + lengthChange,
2022+
ops: serializedOps,
2023+
charBank: this._charBank.toString(),
2024+
};
2025+
}
2026+
2027+
toString() {
2028+
const {oldLen, newLen, ops, charBank} = this.build();
2029+
return exports.pack(oldLen, newLen, ops, charBank);
20182030
}
20192031
}
20202032
exports.Builder = Builder;

0 commit comments

Comments
 (0)