Skip to content

Commit 4369c80

Browse files
committed
fix iterators
(cherry picked from commit 07178e4)
1 parent 0038407 commit 4369c80

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎ImageScript.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export class Image {
8787
/**
8888
* Yields an [x,y,color] array for every pixel in the image
8989
* @yields {[number, number, number]} The coordinates and color of the pixel
90-
* @returns {void}
9190
*/
9291
* iterateWithColors() {
9392
let offset = 0;
@@ -1320,12 +1319,17 @@ export class GIF extends Array {
13201319
return `GIF<${this.width}x${this.height}x${this.duration}ms>`;
13211320
}
13221321

1322+
* [Symbol.iterator]() {
1323+
for (let i = 0; i < this.length; i++)
1324+
yield this[i];
1325+
}
1326+
13231327
/**
13241328
* The GIFs duration (in ms)
13251329
* @return {number}
13261330
*/
13271331
get duration() {
1328-
return [...this].reduce((acc, frame) => acc + frame.duration, 0);
1332+
return this.reduce((acc, frame) => acc + frame.duration, 0);
13291333
}
13301334

13311335
/**

0 commit comments

Comments
 (0)