Skip to content

Commit 6be6e01

Browse files
committed
Changeset: Add new Builder.prototype.build() method
1 parent 951ef83 commit 6be6e01

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
@@ -1991,14 +1991,26 @@ class Builder {
19911991
return this;
19921992
}
19931993

1994-
toString() {
1994+
/**
1995+
* @returns {Changeset}
1996+
*/
1997+
build() {
19951998
/** @type {number} */
19961999
let lengthChange;
19972000
const serializedOps = exports.serializeOps((function* () {
19982001
lengthChange = yield* exports.canonicalizeOps(this._ops, true);
19992002
}).call(this));
2000-
const newLen = this._oldLen + lengthChange;
2001-
return exports.pack(this._oldLen, newLen, serializedOps, this._charBank.toString());
2003+
return {
2004+
oldLen: this._oldLen,
2005+
newLen: this._oldLen + lengthChange,
2006+
ops: serializedOps,
2007+
charBank: this._charBank.toString(),
2008+
};
2009+
}
2010+
2011+
toString() {
2012+
const {oldLen, newLen, ops, charBank} = this.build();
2013+
return exports.pack(oldLen, newLen, ops, charBank);
20022014
}
20032015
}
20042016
exports.Builder = Builder;

0 commit comments

Comments
 (0)