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 __defProp = Object.defineProperty;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __esm = (fn, res) => function __init() {
@@ -2401,19 +2401,23 @@ async function forEachFrame(video, opts) {
2401
2401
  await videoReady(video);
2402
2402
  const wasPaused = video.paused;
2403
2403
  video.pause();
2404
- const times = frameTimes({ duration: video.duration, ...opts });
2405
- for (let i = 0; i < times.length; i++) {
2406
- if (opts.signal && opts.signal.aborted) throw new DOMException("Aborted", "AbortError");
2407
- await seekTo(video, times[i]);
2408
- await opts.onFrame({ index: i, time: times[i], total: times.length });
2404
+ const times = Array.isArray(opts.times) ? opts.times.filter((t) => Number.isFinite(t)).slice(0, opts.maxFrames ?? Infinity) : frameTimes({ duration: video.duration, ...opts });
2405
+ try {
2406
+ for (let i = 0; i < times.length; i++) {
2407
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
2408
+ await seekTo(video, times[i]);
2409
+ if (opts.signal?.aborted) throw new DOMException("Aborted", "AbortError");
2410
+ await opts.onFrame({ index: i, time: times[i], total: times.length });
2411
+ }
2412
+ } finally {
2413
+ if (!wasPaused) video.play().catch(() => {
2414
+ });
2409
2415
  }
2410
- if (!wasPaused) video.play().catch(() => {
2411
- });
2412
2416
  return times.length;
2413
2417
  }
2414
2418
 
2415
2419
  // lib/index.js
2416
- var VERSION = true ? "3.0.1" : "dev";
2420
+ var VERSION = true ? "3.2.0" : "dev";
2417
2421
  export {
2418
2422
  ASPECTS,
2419
2423
  DEFAULTS,