Skip to content

Commit 7828066

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

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
@@ -1988,14 +1988,26 @@ class Builder {
19881988
return this;
19891989
}
19901990

1991-
toString() {
1991+
/**
1992+
* @returns {Changeset}
1993+
*/
1994+
build() {
19921995
/** @type {number} */
19931996
let lengthChange;
19941997
const serializedOps = exports.serializeOps((function* () {
19951998
lengthChange = yield* exports.canonicalizeOps(this._ops, true);
19961999
}).call(this));
1997-
const newLen = this._oldLen + lengthChange;
1998-
return exports.pack(this._oldLen, newLen, serializedOps, this._charBank.toString());
2000+
return {
2001+
oldLen: this._oldLen,
2002+
newLen: this._oldLen + lengthChange,
2003+
ops: serializedOps,
2004+
charBank: this._charBank.toString(),
2005+
};
2006+
}
2007+
2008+
toString() {
2009+
const {oldLen, newLen, ops, charBank} = this.build();
2010+
return exports.pack(oldLen, newLen, ops, charBank);
19992011
}
20002012
}
20012013
exports.Builder = Builder;

0 commit comments

Comments
 (0)