{
  "name": "temp",
  "description": "Temporary files and directories",
  "tags": [
    "temporary",
    "temp",
    "tempfile",
    "tempdir",
    "tmpfile",
    "tmpdir",
    "security"
  ],
  "version": "0.5.1",
  "author": {
    "name": "Bruce Williams",
    "email": "bruce@codefluency.com"
  },
  "directories": {
    "lib": "lib"
  },
  "engines": [
    "node >=0.8.0"
  ],
  "main": "./lib/temp",
  "dependencies": {
    "rimraf": "~2.1.4"
  },
  "devDependencies": {},
  "repository": {
    "type": "git",
    "url": "git://github.com/bruce/node-temp.git"
  },
  "readme": "node-temp -- temporary files and directories for node.js\n========================================================\n\nHandles generating a unique file/directory name under the appropriate\nsystem temporary directory, changing the file to an appropriate mode,\nand supports automatic removal.\n\n`temp` has a similar API to the `fs` module.\n\nSynopsis\n--------\n\nYou can create temporary files with `open` and `openSync`, temporary\ndirectories with `mkdir` and `mkdirSync`, or you can get a unique name\nin the system temporary directory with `path`.\n\nWorking copies of the following examples can be found under the\n`examples` directory.\n\n### Temporary Files\n\nTo create a temporary file use `open` or `openSync`, passing\nthem an optional prefix, suffix, or both (see below for details on\naffixes). The object passed to the callback (or returned) has\n`path` and `fd` keys:\n\n```javascript\n{ path: \"/path/to/file\",\n, fd: theFileDescriptor\n}\n```\n\nIn this example we write to a temporary file and call out to `grep` and\n`wc -l` to determine the number of time `foo` occurs in the text.  The\ntemporary file is chmod'd `0600` and cleaned up automatically when the\nprocess at exit:\n\n```javascript\nvar temp = require('temp'),\n    fs   = require('fs'),\n    util  = require('util'),\n    exec = require('child_process').exec;\n\n// Fake data\nvar myData = \"foo\\nbar\\nfoo\\nbaz\";\n\n// Process the data (note: error handling omitted)\ntemp.open('myprefix', function(err, info) {\n  fs.write(info.fd, myData);\n  fs.close(info.fd, function(err) {\n    exec(\"grep foo '\" + info.path + \"' | wc -l\", function(err, stdout) {\n      util.puts(stdout.trim());\n    });\n  });\n});\n```\n\n### Temporary Directories\n\nTo create a temporary directory, use `mkdir` or `mkdirSync`, passing\nit an optional prefix, suffix, or both (see below for details on affixes).\n\nIn this example we create a temporary directory, write to a file\nwithin it, call out to an external program to create a PDF, and read\nthe result.  While the external process creates a lot of additional\nfiles, the temporary directory is removed automatically at exit:\n\n```javascript\nvar temp = require('../lib/temp'),\n    fs   = require('fs'),\n    util = require('util'),\n    path = require('path'),\n    exec = require('child_process').exec;\n\n// For use with ConTeXt, http://wiki.contextgarden.net\nvar myData = \"\\\\starttext\\nHello World\\n\\\\stoptext\";\n\ntemp.mkdir('pdfcreator', function(err, dirPath) {\n  var inputPath = path.join(dirPath, 'input.tex')\n  fs.writeFile(inputPath, myData, function(err) {\n    if (err) throw err;\n    process.chdir(dirPath);\n    exec(\"texexec '\" + inputPath + \"'\", function(err) {\n      if (err) throw err;\n      fs.readFile(path.join(dirPath, 'input.pdf'), function(err, data) {\n        if (err) throw err;\n        sys.print(data);\n      });\n    });\n  });\n});\n```\n\n### Temporary Streams\n\nTo create a temporary WriteStream, use 'createWriteStream', which sits\non top of `fs.createWriteStream`. The return value is a\n`fs.WriteStream` whose `path` is registered for removal when\n`temp.cleanup` is called.\n\n```javascript\nvar temp = require('temp');\n\nvar stream = temp.createWriteStream();\nstream.write(\"Some data\");\n// Maybe do some other things\nstream.end();\n```\n\n### Affixes\n\nYou can provide custom prefixes and suffixes when creating temporary\nfiles and directories. If you provide a string, it is used as the prefix\nfor the temporary name. If you provide an object with `prefix` and\n`suffix` keys, they are used for the temporary name.\n\nHere are some examples:\n\n* `\"aprefix\"`: A simple prefix, prepended to the filename; this is\n  shorthand for:\n* `{prefix: \"aprefix\"}`: A simple prefix, prepended to the filename\n* `{suffix: \".asuffix\"}`: A suffix, appended to the filename\n  (especially useful when the file needs to be named with specific\n  extension for use with an external program).\n* `{prefix: \"myprefix\", suffix: \"mysuffix\"}`: Customize both affixes\n* `null`: Use the defaults for files and directories (prefixes `\"f-\"`\n  and `\"d-\"`, respectively, no suffixes).\n\nIn this simple example we read a `pdf`, write it to a temporary file with\na `.pdf` extension, and close it.\n\n```javascript\nvar fs   = require('fs'),\n    temp = require('temp');\n\nfs.readFile('/path/to/source.pdf', function(err, data) {\n  temp.open({suffix: '.pdf'}, function(err, info) {\n    if (err) throw err;\n    fs.write(info.fd, contents);\n    fs.close(info.fd, function(err) {\n      if (err) throw err;\n      // Do something with the file\n    });\n  });\n});\n```\n\n### Just a path, please\n\nIf you just want a unique name in your temporary directory, use\n`path`:\n\n```javascript\nvar fs = require('fs');\nvar tempName = temp.path({suffix: '.pdf'});\n// Do something with tempName\n```\n    \nNote: The file isn't created for you, and the  mode is not changed  -- and it\nwill not be removed automatically at exit.  If you use `path`, it's\nall up to you.\n\nCompatibility\n-------------\n\nWorks with Node.js v0.6.0 on OS X.  Please let me know if you have\nproblems running it on a later version of Node.js or\nhave platform problems.\n\nInstallation\n------------\n\nInstall it using [npm](http://github.com/isaacs/npm):\n\n    $ npm install temp\n\nOr get it directly from:\nhttp://github.com/bruce/node-temp\n\nTesting\n-------\n\nFor now, run `test/test-temp.js`:\n\n    $ node test/test-temp.js\n\nContributing\n------------\n\nYou can find the repository at:\nhttp://github.com/bruce/node-temp\n\nIssues/Feature Requests can be submitted at:\nhttp://github.com/bruce/node-temp/issues\n\nI'd really like to hear your feedback, and I'd love to receive your\npull-requests!\n\nCopyright\n---------\n\nCopyright (c) 2010-2012 Bruce Williams. See LICENSE for details.\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/bruce/node-temp/issues"
  },
  "homepage": "https://github.com/bruce/node-temp#readme",
  "_id": "temp@0.5.1",
  "_shasum": "77ab19c79aa7b593cbe4fac2441768cad987b8df",
  "_resolved": "https://registry.npmjs.org/temp/-/temp-0.5.1.tgz",
  "_from": "https://registry.npmjs.org/temp/-/temp-0.5.1.tgz"
}
