sindresorhus/trash

Add `trash.sync()`

Enteleform opened this issue · 5 comments

Please consider adding trash.sync() as a synchronous option.

It would be convenient for users of fs-extra to pair its sync/async functions appropriately with trash.

The trash operation can be slow, so it would not be recommended for anything other than scripts or CLIs. PR welcome.

Pomax commented

Late to the party, but remember that await is supported by lots of things, including Node.js, so if you need trash.sync: already covered by Javascript itself (thanks to trash returning a promise)

Late to the party, but remember that await is supported by lots of things, including Node.js, so if you need trash.sync: already covered by Javascript itself (thanks to trash returning a promise)

@Pomax sorry but i dont understand yet. how do javascript cover trash.sync by promise?

@Pomax wait, did you mean this?

async function doMyThings() {
  // do some things...

  // ... then sync trash, but wait for that to finish before doing more things...
  await trash('myfiles');

  // ... and then do more things once trash has finished.
}

trash.sync() not available yet, as mentioned from this issue title

Pomax commented

sorry, was thinking of something else: the current README.md already covers exactly what I wrote about 2 years ago: https://github.com/sindresorhus/trash#usage