Skip to content

Conversation

@danyg
Copy link

@danyg danyg commented Jan 15, 2026

instead of relying on the global provided one as is deprecated in some systems

setImmediate has been deprecated in the WebAPI so is not present in some systems (jest / mocha to name a few)

This PR rely on using the provided node:timers setImmediate (which is provided since node v0.9) instead, so yauzl can be agnostic and won't require consumers to set a polyfill to be able to use the library.

Copilot AI review requested due to automatic review settings January 15, 2026 10:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates yauzl to use setImmediate from the node:timers module instead of relying on the global setImmediate, which has been deprecated in the Web API and is not available in some testing environments like Jest and Mocha.

Changes:

  • Imports setImmediate from node:timers module in index.js and fd-slicer.js
  • Adds a test to verify the library works when global setImmediate is undefined
  • Applies code formatting changes throughout the test file (spacing adjustments for consistency)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
index.js Imports setImmediate from node:timers module at the top and applies formatting fixes to function expressions
fd-slicer.js Imports setImmediate from node:timers module at the top and applies formatting fixes to function expressions
test/test.js Sets global setImmediate to undefined to simulate environments without it, and applies extensive formatting changes to ensure consistency
Comments suppressed due to low confidence (1)

index.js:637

  • Avoid automated semicolon insertion (95% of all statements in the enclosing function have an explicit semicolon).
          var hundredNanoSecondsSince1601 = 4294967296 * data.readInt32LE(cursor + 4) + data.readUInt32LE(cursor)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danyg
Copy link
Author

danyg commented Jan 15, 2026

Formatting changes removed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant