Skip to content

Commit ce6941d

Browse files
committed
Changeset: Add new Builder.prototype.build() method
1 parent a7750fd commit ce6941d

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
@@ -1993,14 +1993,26 @@ class Builder {
19931993
return this;
19941994
}
19951995

1996-
toString() {
1996+
/**
1997+
* @returns {Changeset}
1998+
*/
1999+
build() {
19972000
/** @type {number} */
19982001
let lengthChange;
19992002
const serializedOps = exports.serializeOps((function* () {
20002003
lengthChange = yield* exports.canonicalizeOps(this._ops, true);
20012004
}).call(this));
2002-
const newLen = this._oldLen + lengthChange;
2003-
return exports.pack(this._oldLen, newLen, serializedOps, this._charBank.toString());
2005+
return {
2006+
oldLen: this._oldLen,
2007+
newLen: this._oldLen + lengthChange,
2008+
ops: serializedOps,
2009+
charBank: this._charBank.toString(),
2010+
};
2011+
}
2012+
2013+
toString() {
2014+
const {oldLen, newLen, ops, charBank} = this.build();
2015+
return exports.pack(oldLen, newLen, ops, charBank);
20042016
}
20052017
}
20062018
exports.Builder = Builder;

0 commit comments

Comments
 (0)