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

rmby

v1.1.1

Published

A zero-dependency library with a fluent interface for removing files asynchronously by certain filters

Downloads

7

Readme

rmby

npm Build Status codecov NPM

rmby ("remove by") is a zero-dependency Node.js library with a fluent interface for removing files asynchronously by certain aspects.

Installation

Node.js v10 or higher is required

$ npm i --save rmby
$ yarn add rmby

Usage

The RemoveFiles class is all you need. You can navigate yourself through the API by chaining methods, since the API provides a fluent interface. On the API section you can see more details about the usage.

// JavaScript
const { remove } = require("rmby");

// TypeScript
import { remove } from "rmby";

API

In order to run your remove query, you have to call the run() method at the end of your chain. This method will remove all files that match with your filter criteria and will return a Promise<string[]> containing every file path that has been removed. If your filter cannot find matches, it will just return an empty array.

Remove Files By Time

Files can be removed by a time difference in milliseconds, seconds, minutes or hours. The time difference is always checked against the current time.

// Remove all files that are older than 12 hours
remove().from("/some/path/to/dir").byTime().olderThan(12).hours().run();

Remove Files By Name

Files can be removed regarding its name without considering the file extension. You can remove files that match exactly, start with, end with, or include the name that you provide.

// Remove all files that start with "React"
remove().from("/some/path/to/dir").byName().thatStartsWith("React").run();

Remove Files By Extension

Files can be removed regarding their file extension. You can remove files that match exactly with the extension you provide.

// Remove all .log files
remove().from("/some/path/to/dir").byExtension(".log").run();

Remove Files By Combination

Files can be removed by combining the available filters. Therefore you can create more specific filters for your remove use case.

// Remove all log files that start with "app" and are older than 12 hours
remove()
  .from("/some/path/to/dir")
  .byName()
  .thatStartsWith("app")
  .and()
  .byExtension(".log")
  .and()
  .byTime()
  .olderThan(12)
  .hours()
  .run();

Development

rmby is developed with TypeScript. The master branch is used for development. Stable releases are always tagged with the latest version.

Testing

rmby is using Jest as a JavaScript Testing Framework. For testing, run npm test. For code coverage, run npm run test:cov. We have currently 100% code coverage and aim to stick with it.

Philosophy

The philosophy is to provide an easy to use library for file removal in Node.js, without dependencies and with a very declarative API. The fluent interface should guide the user through its use case.

People

rmby is currently maintained by Yadullah Duman

License

MIT