Deno Refactor Resource Ids

/icons/calendar.svg

Last update

Dec 1, 2024

In Deno v2, resource IDs are being deprecated. Most users do not directly interact with resource IDs, so we are moving towards a model where resources are referenced by native JavaScript objects. This codemod automates the process of updating your code to align with this change.

This codemod turns old Deno method calls that takes resource ID's as a argument to their new equivalents.

Before

Deno.flock(file1.rid, ...args);
Deno.fsyncSync(file2.rid);
Deno.writeSync(file3.rid, data);
Deno.close(file.rid);

After

file3.lock(...args);
file2.syncSync();
file3.writeSync(data);
file.close();

Method Mappings

The following mappings are applied by the codemod:

  • Deno.flocklock
  • Deno.flockSynclockSync
  • Deno.fsyncsync
  • Deno.fsyncSyncsyncSync
  • Deno.ftruncatetruncate
  • Deno.ftruncateSynctruncateSync
  • Deno.funlockunlock
  • Deno.funlockSyncunlockSync
  • Deno.fdatasyncsyncData
  • Deno.fdatasyncSyncsyncDataSync
  • Deno.futimeutime
  • Deno.futimeSyncutimeSync
  • Deno.fstatstat
  • Deno.fstateSyncstatSync
  • Deno.seekseek
  • Deno.seekSyncseekSync
  • Deno.readread
  • Deno.readSyncreadSync
  • Deno.writewrite
  • Deno.writeSyncwriteSync
  • Deno.closeclose
  • Deno.shutdowncloseWrite
  • Deno.isatty -> isTerminal,

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now