5.0.0 • Published 3 years ago

temp-write v5.0.0

Weekly downloads
1,408,361
License
MIT
Repository
github
Last release
3 years ago

temp-write

Write string/buffer/stream to a random temp file

Install

$ npm install temp-write

Usage

import fs from 'node:fs';
import tempWrite from 'temp-write';

const filePath = tempWrite.sync('unicorn');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b'

fs.readFileSync(filePath, 'utf8');
//=> 'unicorn'

tempWrite.sync('unicorn', 'pony.png');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png'

tempWrite.sync('unicorn', 'rainbow/cake/pony.png');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png'

API

tempWrite(fileContent, filePath?)

Returns a Promise for the file path of the temp file.

tempWrite.sync(fileContent, filePath?)

Returns the file path of the temp file.

fileContent

Type: string | Buffer | stream.Readable

Data to write to the temp file. Streams are supported only with the async API.

filePath

Type: string\ Examples: 'img.png' 'foo/bar/baz.png'

Optionally supply a file path which is appended to the random path.

Related

  • tempy - Get a random temporary file or directory path

@megasaur/version@prisma/internals@prisma/sdk@essent/lernaairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112@ntt_app/react-native-custom-notificationreact-native-covid-sdkeslint-configuratorreact-native-printer-brotherscogoportutils@infinitebrahmanuniverse/nolb-temp-@everything-registry/sub-chunk-2887opn-clinpm_qwertynpm_one_12_34_1_npm_one_1_2_3npm_one_2_2mock-binnode-matlabpayutestingpeter.you.jqweui.test.publishopen-editor-cliprepend-fileprepend-to-js-fileasync-storage-replbin-exec-loader@cesargdm/prettier-stylelintblastengine@cotype/core@cotype/local-thumbnail-providerboltboomletboltifybolt-yarn-supportedbroccoli-closure-compiler@create-figma-plugin/buildcandlelabssdk@davidreinberger/lerna-version@cypress/fiddle@cybernaut/chrome@cybernaut/puppeteerchimyraastra-ufo-sdk@boneskull/gulp-jekyll@aw-web-design/lerna-core@aw-web-design/lerna-publish@aw-web-design/lerna-version@buganto/client@bahmutov/cypress-fiddleava-nock@atlaskit/lerna@wecraftapps/react-native-use-keyboardwinx-form-winx@adamwood/gulp-cssmin@amory/picture@amory/imagearifbudixztrueban-cli@taingo97/react-native-expo-key-rsa-kt@taingo97/react-native-expo-rsa@taingo97/react-native-rsa@taingo97/react-native-telpo-printer@types/temp-writeclosure-compiler-stream@goodforonefare/prettier-stylelint-formattercleanquirerfont2svgreact-native-create-video-thumbnailjsoo-binjamuskalimjson-safaril2forlernalcq.utilslazy-bee-uiimg-clipboardlerna-markmarijnissenlerna-customlerna-wodlink-to-import-climc-gulp-cssminmechanism-closure-compilermedia-sorterkeygiphykit-infra-testkit-infrastructurekit-infrastructure-testmagento-boilerplateluojia-cli-devreact-native-ytximkitreact-native-syan-photo-pickerreact-native-transtracker-libraryreact-native-test-module-hhhreac-native-arun-ramya-testprettier-stylelint-ballertvprettier-stylelint-formatter
5.0.0

3 years ago

4.0.0

5 years ago

3.4.0

6 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.1.0

8 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago