image-to-pixel 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! image-to-pixel v3.0.1 | MIT | https://github.com/Tezumie/Image-to-Pixel */
1
+ /*! image-to-pixel v3.2.0 | MIT | https://github.com/Tezumie/Image-to-Pixel */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2490,17 +2490,21 @@ async function forEachFrame(video, opts) {
2490
2490
  await videoReady(video);
2491
2491
  const wasPaused = video.paused;
2492
2492
  video.pause();
2493
- const times = frameTimes({ duration: video.duration, ...opts });
2494
- for (let i = 0; i < times.length; i++) {
2495
- if (opts.signal && opts.signal.aborted) throw new DOMException("Aborted", "AbortError");
2496
- await seekTo(video, times[i]);
2497
- await opts.onFrame({ index: i, time: times[i], total: times.length });
2493
+ const times = Array.isArray(opts.times) ? opts.times.filter((t) => Number.isFinite(t)).slice(0, opts.maxFrames ?? Infinity) : frameTimes({ duration: video.duration, ...opts });
2494
+ try {
2495
+ for (let i = 0; i < times.length; i++) {
2496
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
2497
+ await seekTo(video, times[i]);
2498
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
2499
+ await opts.onFrame({ index: i, time: times[i], total: times.length });
2500
+ }
2501
+ } finally {
2502
+ if (!wasPaused) video.play().catch(() => {
2503
+ });
2498
2504
  }
2499
- if (!wasPaused) video.play().catch(() => {
2500
- });
2501
2505
  return times.length;
2502
2506
  }
2503
2507
 
2504
2508
  // lib/index.js
2505
- var VERSION = true ? "3.0.1" : "dev";
2509
+ var VERSION = true ? "3.2.0" : "dev";
2506
2510
  //# sourceMappingURL=image-to-pixel.cjs.map