2.0.6 • Published 5 years ago

@coolgk/tmp v2.0.6

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

@coolgk/tmp

a javascript / typescript module

npm install @coolgk/tmp

wrapper functions, generate tmp file or folders

Report bugs here: https://github.com/coolgk/node-utils/issues

Examples

import { generateFile, generateDir, generateTmpName } from '@coolgk/tmp';
// OR
// const { generateFile, generateDir, generateTmpName } = require('@coolgk/tmp');

generateFile({dir: '/tmp/test'}).then((r) => console.log('file', r));
    // file { path: '/tmp/test/1512307052908140480ZZj6J0LOIJb.tmp' }

generateDir({dir: '/tmp/test'}).then((r) => console.log('dir',r));
    // dir { path: '/tmp/test/1512307052918140484Pnv1m95ZS2b' }

generateTmpName({dir: '/tmp/test'}).then((r) => console.log('name', r));
    // name { path: '/tmp/test/151230705292114048hb3XIds0FO9Y' }

Functions

generateFile(options) ⇒ promise

Kind: global function
Returns: promise - - { path: ..., cleanupCallback: ... } calling cleanupCallback() removes the generated file

ParamTypeDefaultDescription
optionsobject
options.modenumber0600the file mode to create with, defaults to 0600 on file and 0700 on directory
options.prefixstring"Date.now()"the optional prefix, fallbacks to tmp- if not provided
options.postfixstring"'.tmp'"the optional postfix, fallbacks to .tmp on file creation
options.dirstring"/tmp"the optional temporary directory, fallbacks to system default
options.keepbooleanfalseif to keep the file

generateDir(options) ⇒ promise

Kind: global function
Returns: promise - - { path: ..., cleanupCallback: ... } calling cleanupCallback() removes the generated file

ParamTypeDefaultDescription
optionsobject
options.modenumber0600the file mode to create with, defaults to 0600 on file and 0700 on directory
options.prefixstring"Date.now()"the optional prefix, fallbacks to tmp- if not provided
options.postfixstring"'.tmp'"the optional postfix, fallbacks to .tmp on file creation
options.dirstring"/tmp"the optional temporary directory, fallbacks to system default
options.keepbooleanfalseif to keep the file

generateTmpName(options) ⇒ promise

Kind: global function
Returns: promise - - { path: ... }

ParamTypeDefaultDescription
optionsobject
options.modenumber0600the file mode to create with, defaults to 0600 on file and 0700 on directory
options.prefixstring"Date.now()"the optional prefix, fallbacks to tmp- if not provided
options.postfixstring"'.tmp'"the optional postfix, fallbacks to .tmp on file creation
options.dirstring"/tmp"the optional temporary directory, fallbacks to system default
2.0.6

5 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago