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.flock
→lock
Deno.flockSync
→lockSync
Deno.fsync
→sync
Deno.fsyncSync
→syncSync
Deno.ftruncate
→truncate
Deno.ftruncateSync
→truncateSync
Deno.funlock
→unlock
Deno.funlockSync
→unlockSync
Deno.fdatasync
→syncData
Deno.fdatasyncSync
→syncDataSync
Deno.futime
→utime
Deno.futimeSync
→utimeSync
Deno.fstat
→stat
Deno.fstateSync
→statSync
Deno.seek
→seek
Deno.seekSync
→seekSync
Deno.read
→read
Deno.readSync
→readSync
Deno.write
→write
Deno.writeSync
→writeSync
Deno.close
→close
Deno.shutdown
→closeWrite
Deno.isatty
->isTerminal
,
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community