{"id":15840018,"url":"https://github.com/linusu/fs-temp","last_synced_at":"2026-03-04T01:03:02.614Z","repository":{"id":20941937,"uuid":"24230317","full_name":"LinusU/fs-temp","owner":"LinusU","description":"Temporary files and directories in Node.js","archived":false,"fork":false,"pushed_at":"2024-03-17T15:42:33.000Z","size":49,"stargazers_count":4,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-27T04:16:49.542Z","etag":null,"topics":["hacktoberfest","temporary"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LinusU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-19T13:13:23.000Z","updated_at":"2022-02-12T20:10:33.000Z","dependencies_parsed_at":"2024-06-11T18:55:44.925Z","dependency_job_id":"4eca2e7b-aa9c-4070-a3f1-7cbb55c5df9b","html_url":"https://github.com/LinusU/fs-temp","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":0.08108108108108103,"last_synced_commit":"cbda7828f686c3c6380bf494a49b974237bf0cd3"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Ffs-temp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Ffs-temp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Ffs-temp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Ffs-temp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LinusU","download_url":"https://codeload.github.com/LinusU/fs-temp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232501172,"owners_count":18533301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","temporary"],"created_at":"2024-10-05T16:41:06.456Z","updated_at":"2026-03-04T01:03:02.561Z","avatar_url":"https://github.com/LinusU.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# fs-temp\n\n`fs-temp` is a quick and simple way to create temporary files and directories.\n\nWhy another one? I know that there are already libraries doing similar things,\nbut I felt that their implementation was unnecessary complicated. I also wanted\na quick way to turn a buffer into a file.\n\n## Installation\n\n```sh\nnpm install --save fs-temp\n```\n\n## Usage\n\n```js\nimport temp from 'fs-temp'\n\nconst data = Buffer.from('testing 1 2 3')\nconst path = temp.writeFileSync(data)\n\n// `path` now holds the path to a file with the specified `data`\n```\n\n```js\nimport temp from 'fs-temp'\n\nconst path = temp.template('linusu-%s').mkdirSync()\n\n// `path` now holds the path to a directory with the prefix 'linusu-'\n```\n\n## Promise support\n\nIf you import `fs-temp/promises` you'll receive an alternative API where all\nfunctions that takes callbacks are replaced by `Promise`-returning functions.\n\n```js\nimport temp from 'fs-temp/promises'\n\nconst data = Buffer.from('testing 1 2 3')\nconst path = await temp.writeFile(data)\n\n// `path` now holds the path to a file with the specified `data`\n```\n\n## API\n\nThe api mimics the one provided by `fs` very closely.\n\n### `open(flags[, mode], callback)`\n\nAsynchronous file open.\n\n`flags` is either `'w'` (only writing) or `'w+'` (writing and reading).\n\nThe callback gets two arguments `(err, obj)`. `obj` has `fd` and `path`.\n\n### `openSync(flags[, mode])`\n\nSynchronous version of `.open()`, returns `obj` with `fd` and `path`.\n\n### `mkdir([mode, ]callback)`\n\nCreates an empty directory.\n\nThe callback gets two arguments `(err, path)`.\n\n### `mkdirSync([mode])`\n\nSynchronous version of `.mkdir()`, returns `path`.\n\n### `writeFile(data[, encoding], callback)`\n\nAsynchronously writes data to a file. `data` can be a string or a buffer. The\n`encoding` argument is ignored if `data` is a buffer. It defaults to `'utf8'`.\n\nThe callback gets two arguments `(err, path)`.\n\n### `writeFileSync(data[, encoding])`\n\nSynchronous version of `.writeFileSync()`, returns `path`.\n\n### `createWriteStream([options])`\n\nCreates and returns a `fs.WriteStream` that will write it's content to a\ntemporary file. This functions performs a little bit of blocking IO in order to\nopen the file initially.\n\n### `template(template)`\n\nReturns a copy of the module that uses the specified `template` when generating\nfile names. `template` should be a string where `%s` will be replaced with some\nrandom characters (e.g. `'linusu-%s'`).\n\nThe string should contain `%s` exactly once. If you want to include a literal\npercent sign, escape it with another one, e.g. `'%%string'` becomes `'%string'`.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Linus Unnebäck\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinusu%2Ffs-temp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinusu%2Ffs-temp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinusu%2Ffs-temp/lists"}