Skip to content

Commit 7d4284d

Browse files
committed
Move _makeOffsetsArray() method to a util function.
1 parent 490a9aa commit 7d4284d

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

packages/ckeditor5-engine/src/model/nodelist.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export default class NodeList implements Iterable<Node> {
177177
}
178178

179179
const nodesArray = Array.from( nodes );
180-
const offsetsArray = this._makeOffsetsArray( nodesArray );
180+
const offsetsArray = makeOffsetsArray( nodesArray );
181181

182182
let offset = this.indexToOffset( index );
183183

@@ -194,23 +194,6 @@ export default class NodeList implements Iterable<Node> {
194194
}
195195
}
196196

197-
/**
198-
* Creates an array of nodes in the format as in {@link module:engine/model/nodelist~NodeList#_offsetToNode}, i.e. one node will
199-
* occupy multiple items if its offset is greather than one.
200-
*/
201-
private _makeOffsetsArray( nodes: Array<Node> ): Array<Node> {
202-
const offsets: Array<Node> = [];
203-
204-
for ( const node of nodes ) {
205-
const start = offsets.length;
206-
207-
offsets.length += node.offsetSize;
208-
offsets.fill( node, start );
209-
}
210-
211-
return offsets;
212-
}
213-
214197
/**
215198
* Removes one or more nodes starting at the given index.
216199
*
@@ -258,3 +241,20 @@ export default class NodeList implements Iterable<Node> {
258241
return this._nodes.map( node => node.toJSON() );
259242
}
260243
}
244+
245+
/**
246+
* Creates an array of nodes in the format as in {@link module:engine/model/nodelist~NodeList#_offsetToNode}, i.e. one node will
247+
* occupy multiple items if its offset is greather than one.
248+
*/
249+
function makeOffsetsArray( nodes: Array<Node> ): Array<Node> {
250+
const offsets: Array<Node> = [];
251+
252+
for ( const node of nodes ) {
253+
const start = offsets.length;
254+
255+
offsets.length += node.offsetSize;
256+
offsets.fill( node, start );
257+
}
258+
259+
return offsets;
260+
}

0 commit comments

Comments
 (0)