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

filename-temp-track

v3.0.1

Published

File name tracking in temporary directory and auto clean up

Downloads

68

Readme

File name tracking in temporary directory and auto clean up

Keeps track of filenames, saved in a temporary folder, and automatically cleans up by default in an hour

Useful when receiving files being uploaded, or downloaded, that needs to be cleaned up after some time or when the process exits

Install

npm install filename-temp-track

or

yarn filename-temp-track

Use

track(filename, cleanupTimeout, inDirectory)

Tracks a filename, under a temporary folder, and deletes it after an hour, by default.

  • filename: string with the file name. If inDirectory is false, this is the full path of the file to track. It can also be an object with all the same properties as the method signature (see second example below)
  • cleanuptimeout: number in ms after which to delete the file
  • inDirectory: boolean (default true)
  • Returns a Promise with the full path name, including the base temporary directory.

Example 1:

// Tracks for a filename, using the default timeout of an hour
ft.track('filename.xls')
  .then(function(pathName){ // pathName should be /tmp/sometemp/filename.xls});

Example 2:

// Tracks for a filename, using a custom timeout of a minute
ft.track({filename: 'filename.xls', cleanupTimeout: 1000 * 60})
  .then(function(pathName){ // pathName should be /tmp/sometemp/filename.xls});

cleanupFile(pathname)

Cleans up the pathname

  • pathname: is the full path name of the file to cleaned up
  • Returns a Promise

cleanupFileSync(pathname)

Cleans up the pathname (sync version)

  • pathname: is the full path name of the file to cleaned up
  • Returns undefined

cleanupAll()

Cleans up all the files being controlled by this module

cleanupAllSync()

Cleans up all the files being controlled by this module (sync version)

getFilesBeingTracked()

Returns the array of files being tracked

History

2.0.0

  • Refactor into Class
  • Adds inDirectory optional parameter

1.0.0

  • Initial version

Contributors

License

MIT - Copyright (c) 2017, 2019 - Luis Lobo Borobia [email protected]