npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ryniaubenpm/rerum-natus-rem

v1.0.0

Published

The [UNIX command](<http://en.wikipedia.org/wiki/Rm_(Unix)>) `rm -rf` for node.

Downloads

6

Maintainers

mi762136mi762136

Keywords

protoRegExp.prototype.flagsgroupByhookformassertsanimationjsdomcoloravaviewansiassertwidthvalidbuffersHyBitoSortedfsmomentpostcssextensionfind-upes-abstractcollection.es6variables in cssfast-deep-copymacosdeleteES8constbddmixinsflatMapArray.prototype.filterexecutableArray.prototype.flatMapeslintpluginschemeestreeprogresscmdtypesafeeslint-pluginrequestmimereal-timeqsterminalInt8ArrayflatCSSES3findLastIndexwatchereslintObservablebundlingStreamsvariablestypescriptes6@@toStringTagArray.prototype.flatbytesymlinkslistenersjavascriptcircularuser-streamsES5readcopysortedartajaxURLSearchParamsclientruntimeWeakSettoStringTagpopmotionMapsomewatchkarmadataViewmodulesramdaxssECMAScript 2015pnpm9structuredCloneReactiveExtensionsconcatnodejsgetoptprivate dataSymbol.toStringTagapprfc4122ES6deterministicforEachpromisepositivelogArray.prototype.findLastIndextrimLeftexpressionperformantrateimmervisualtoArraydotenvString.prototype.trimprettywalkstatusenvironmentes8findajvscheme-validationmrumochafast-copywarningECMAScript 2018internal slotparsehigher-orderboundlesscssomittypedbootstrap lesswhicherrorbreakES2021watchinglinkfigletserializereventsgetintrinsicmkdirpicomatchless.jsnegative zeroqueueAsyncIteratorECMAScript 2016chromiumFloat32ArraypersistentvalidatorpluginwatchFilelook-upbrowserArray.prototype.flattenes2018babelassignlockfiletypeoftostringtagregular expressionsfastifyremoveisFloat64ArraytslibwebsameValueZerorecursiveenvPromiseES2022functionalbatchequalbrowserslistrobustpropertyprocessweakmapexpressaccessibilitylookArrayBuffer#slicesigtermhardlinkstyped arraypasswordletform-validationjoicallbindESnextcontainstc39deepcopy3ddirectoryidleoutputreadablestreamReactiveX_.extenddefinePropertycjkdragincludesonceimporthashUnderscorexdgphonelaunchnumbernopeUint8Arraytypedarraytapeentriesclass-validatorwaapii18nopenerlinuxsanitize__proto__jsonpathstringifyexit-codefindupshebangstreamcensorclassnamedependency managerbannerfilterguidgloboperating-systemspinnersES2020waitprivatedayjsreadablearraysyntaxcompilerhelperscommand-lineSymbol

Readme

The UNIX command rm -rf for node.

Install with npm install @ryniaubenpm/rerum-natus-rem.

Major Changes

v4 to v5

  • There is no default export anymore. Import the functions directly using, e.g., import { @ryniaubenpm/rerum-natus-remSync } from '@ryniaubenpm/rerum-natus-rem.

v3 to v4

  • The function returns a Promise instead of taking a callback.
  • Globbing requires the --glob CLI option or glob option property to be set. (Removed in 4.0 and 4.1, opt-in support added in 4.2.)
  • Functions take arrays of paths, as well as a single path.
  • Native implementation used by default when available, except on Windows, where this implementation is faster and more reliable.
  • New implementation on Windows, falling back to "move then remove" strategy when exponential backoff for EBUSY fails to resolve the situation.
  • Simplified implementation on Posix, since the Windows affordances are not necessary there.
  • As of 4.3, return/resolve value is boolean instead of undefined

API

Hybrid module, load either with import or require().

// '@ryniaubenpm/rerum-natus-rem' export is the one you probably want, but other
// strategies exported as well.
import { @ryniaubenpm/rerum-natus-rem, @ryniaubenpm/rerum-natus-remSync, native, nativeSync } from '@ryniaubenpm/rerum-natus-rem'
// or
const { @ryniaubenpm/rerum-natus-rem, @ryniaubenpm/rerum-natus-remSync, native, nativeSync } = require('@ryniaubenpm/rerum-natus-rem')

All removal functions return a boolean indicating that all entries were successfully removed.

The only case in which this will not return true is if something was omitted from the removal via a filter option.

@ryniaubenpm/rerum-natus-rem(f, [opts]) -> Promise

This first parameter is a path or array of paths. The second argument is an options object.

Options:

  • preserveRoot: If set to boolean false, then allow the recursive removal of the root directory. Otherwise, this is not allowed.

  • tmp: Windows only. Temp folder to use to place files and folders for the "move then remove" fallback. Must be on the same physical device as the path being deleted. Defaults to os.tmpdir() when that is on the same drive letter as the path being deleted, or ${drive}:\temp if present, or ${drive}:\ if not.

  • maxRetries: Windows and Native only. Maximum number of retry attempts in case of EBUSY, EMFILE, and ENFILE errors. Default 10 for Windows implementation, 0 for Native implementation.

  • backoff: Windows only. Rate of exponential backoff for async removal in case of EBUSY, EMFILE, and ENFILE errors. Should be a number greater than 1. Default 1.2

  • maxBackoff: Windows only. Maximum total backoff time in ms to attempt asynchronous retries in case of EBUSY, EMFILE, and ENFILE errors. Default 200. With the default 1.2 backoff rate, this results in 14 retries, with the final retry being delayed 33ms.

  • retryDelay: Native only. Time to wait between retries, using linear backoff. Default 100.

  • signal Pass in an AbortSignal to cancel the directory removal. This is useful when removing large folder structures, if you'd like to limit the amount of time spent.

    Using a signal option prevents the use of Node's built-in fs.rm because that implementation does not support abort signals.

  • glob Boolean flag to treat path as glob pattern, or an object specifying glob options.

  • filter Method that returns a boolean indicating whether that path should be deleted. With async @ryniaubenpm/rerum-natus-rem methods, this may return a Promise that resolves to a boolean. (Since Promises are truthy, returning a Promise from a sync filter is the same as just not filtering anything.)

    The first argument to the filter is the path string. The second argument is either a Dirent or Stats object for that path. (The first path explored will be a Stats, the rest will be Dirent.)

    If a filter method is provided, it will only remove entries if the filter returns (or resolves to) a truthy value. Omitting a directory will still allow its children to be removed, unless they are also filtered out, but any parents of a filtered entry will not be removed, since the directory would not be empty in that case.

    Using a filter method prevents the use of Node's built-in fs.rm because that implementation does not support filtering.

Any other options are provided to the native Node.js fs.rm implementation when that is used.

This will attempt to choose the best implementation, based on Node.js version and process.platform. To force a specific implementation, use one of the other functions provided.

@ryniaubenpm/rerum-natus-rem.sync(f, [opts]) @ryniaubenpm/rerum-natus-rem.@ryniaubenpm/rerum-natus-remSync(f, [opts])

Synchronous form of @ryniaubenpm/rerum-natus-rem()

Note that, unlike many file system operations, the synchronous form will typically be significantly slower than the async form, because recursive deletion is extremely parallelizable.

@ryniaubenpm/rerum-natus-rem.native(f, [opts])

Uses the built-in fs.rm implementation that Node.js provides. This is used by default on Node.js versions greater than or equal to 14.14.0.

@ryniaubenpm/rerum-natus-rem.nativeSync(f, [opts]) @ryniaubenpm/rerum-natus-rem.native.sync(f, [opts])

Synchronous form of @ryniaubenpm/rerum-natus-rem.native

@ryniaubenpm/rerum-natus-rem.manual(f, [opts])

Use the JavaScript implementation appropriate for your operating system.

@ryniaubenpm/rerum-natus-rem.manualSync(f, [opts]) @ryniaubenpm/rerum-natus-rem.manualSync(f, opts)

Synchronous form of @ryniaubenpm/rerum-natus-rem.manual()

@ryniaubenpm/rerum-natus-rem.windows(f, [opts])

JavaScript implementation of file removal appropriate for Windows platforms. Works around unlink and rmdir not being atomic operations, and EPERM when deleting files with certain permission modes.

First deletes all non-directory files within the tree, and then removes all directories, which should ideally be empty by that time. When an ENOTEMPTY is raised in the second pass, falls back to the @ryniaubenpm/rerum-natus-rem.moveRemove strategy as needed.

@ryniaubenpm/rerum-natus-rem.windows.sync(path, [opts]) @ryniaubenpm/rerum-natus-rem.windowsSync(path, [opts])

Synchronous form of @ryniaubenpm/rerum-natus-rem.windows()

@ryniaubenpm/rerum-natus-rem.moveRemove(path, [opts])

Moves all files and folders to the parent directory of path with a temporary filename prior to attempting to remove them.

Note that, in cases where the operation fails, this may leave files lying around in the parent directory with names like .file-basename.txt.0.123412341. Until the Windows kernel provides a way to perform atomic unlink and rmdir operations, this is unfortunately unavoidable.

To move files to a different temporary directory other than the parent, provide opts.tmp. Note that this must be on the same physical device as the folder being deleted, or else the operation will fail.

This is the slowest strategy, but most reliable on Windows platforms. Used as a last-ditch fallback by @ryniaubenpm/rerum-natus-rem.windows().

@ryniaubenpm/rerum-natus-rem.moveRemove.sync(path, [opts]) @ryniaubenpm/rerum-natus-rem.moveRemoveSync(path, [opts])

Synchronous form of @ryniaubenpm/rerum-natus-rem.moveRemove()

Command Line Interface

@ryniaubenpm/rerum-natus-rem version 4.3.0

Usage: @ryniaubenpm/rerum-natus-rem <path> [<path> ...]
Deletes all files and folders at "path", recursively.

Options:
  --                   Treat all subsequent arguments as paths
  -h --help            Display this usage info
  --preserve-root      Do not remove '/' recursively (default)
  --no-preserve-root   Do not treat '/' specially
  -G --no-glob         Treat arguments as literal paths, not globs (default)
  -g --glob            Treat arguments as glob patterns
  -v --verbose         Be verbose when deleting files, showing them as
                       they are removed. Not compatible with --impl=native
  -V --no-verbose      Be silent when deleting files, showing nothing as
                       they are removed (default)
  -i --interactive     Ask for confirmation before deleting anything
                       Not compatible with --impl=native
  -I --no-interactive  Do not ask for confirmation before deleting

  --impl=<type>        Specify the implementation to use:
                       @ryniaubenpm/rerum-natus-rem: choose the best option (default)
                       native: the built-in implementation in Node.js
                       manual: the platform-specific JS implementation
                       posix: the Posix JS implementation
                       windows: the Windows JS implementation (falls back to
                                move-remove on ENOTEMPTY)
                       move-remove: a slow reliable Windows fallback

Implementation-specific options:
  --tmp=<path>        Temp file folder for 'move-remove' implementation
  --max-retries=<n>   maxRetries for 'native' and 'windows' implementations
  --retry-delay=<n>   retryDelay for 'native' implementation, default 100
  --backoff=<n>       Exponential backoff factor for retries (default: 1.2)

mkdirp

If you need to create a directory recursively, check out mkdirp.