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

@particle/tmp

v3.0.2

Published

Tools for working with temporary files and directories

Downloads

185

Readme

@particle/tmp

Tools for working with temporary files and directories.

Installation

npm install @particle/tmp --save
const tmp = require('@particle/tmp');

API

@particle/tmp


tmp.setGracefulCleanup ⇒ undefined

Enables cleanup of temporary files even when an uncaught exception occurs

Kind: static property of @particle/tmp
Example

tmp.setGracefulCleanup();

tmp.createDir([options]) ⇒ Promise.<(TmpDir|Error)>

Create a new directory within the user's temp dir

Kind: static method of @particle/tmp
Returns: Promise.<(TmpDir|Error)> - A resolved promise containing either info about the newly created directory or an error

| Param | Type | Description | | --- | --- | --- | | [options] | TmpOptions | Options object |

Example

const dir = await tmp.createDir();
dir.path; // '/path/to/the/new/tmp/dir'
await dir.cleanup(); // remove newly created temp directory

tmp.createFile([options]) ⇒ Promise.<(TmpFile|Error)>

Create a new file within the user's temp dir

Kind: static method of @particle/tmp
Returns: Promise.<(TmpFile|Error)> - A resolved promise containing either info about the newly created file or an error

| Param | Type | Description | | --- | --- | --- | | [options] | TmpOptions | Options object |

Example

const file = await tmp.createFile();
file.fd; // 61344
file.path; // '/path/to/the/new/tmp/file'
await file.cleanup(); // remove newly created temp file

@particle/tmp~TmpOptions : Object

Kind: inner typedef of @particle/tmp
Properties

| Name | Type | Default | Description | | --- | --- | --- | --- | | [mode] | string | "0600" | File mode to create with, uses 0600 on file creation and 0700 on directory creation by default | | [prefix] | string | "particle-" | Prefix assigned to created files and directories | | [dir] | string | "<based on environment>" | Temp directory location | | [tries] | number | 3 | Number of times to try getting a unique filename before giving up | | [keep] | boolean | false | Retain the created temporary file or directory | | [unsafeCleanup] | boolean | true | Recursively remove the created temporary directory, even when it's not empty |


@particle/tmp~TmpDir : Object

Kind: inner typedef of @particle/tmp
Properties

| Name | Type | Description | | --- | --- | --- | | path | string | Filename of newly created temp directory | | cleanup | function | Function to call to remove newly created temp directory |


@particle/tmp~TmpFile : Object

Kind: inner typedef of @particle/tmp
Properties

| Name | Type | Description | | --- | --- | --- | | path | string | Filename of newly created temp file | | fd | number | File descriptor of newly created temp file | | cleanup | function | Function to call to remove newly created temp file |


NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests