Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mktemp

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mktemp - npm Package Compare versions

Comparing version 0.3.5 to 0.4.0

5

HISTORY.md

@@ -0,1 +1,6 @@

# 0.4.0 / 2015-02-16
- supported Promise
- changed to use power-assert from expect.js
# 0.3.5 / 2014-06-25

@@ -2,0 +7,0 @@

@@ -10,2 +10,4 @@ var fs = require('fs'),

* @param {Function} callback callback function.
* @throws {TypeError} cannot use Promise and callback function is not found.
* @return {Promise} Promise.
*/

@@ -15,2 +17,18 @@ function createFile(template, callback) {

// callback is not a Function
if (typeof callback !== 'function') {
// can use Promise
if (typeof Promise === 'function') {
// return Promise
return new Promise(function(resolve, reject) {
createFile(template, function(err, filename) {
(err) ? reject(err) : resolve(filename);
});
});
} else {
// throw TypeError when cannot use Promise
throw new TypeError('callback function required');
}
}
fs.open(filename, 'ax+', 384 /*=0600*/, function(err, fd) {

@@ -78,2 +96,4 @@ if (err) {

* @param {Function} callback callback function.
* @throws {TypeError} cannot use Promise and callback function is not found.
* @return {Promise} Promise.
*/

@@ -83,2 +103,18 @@ function createDir(template, callback) {

// callback is not a Function
if (typeof callback !== 'function') {
// can use Promise
if (typeof Promise === 'function') {
// return Promise
return new Promise(function(resolve, reject) {
createDir(template, function(err, dirname) {
(err) ? reject(err) : resolve(dirname);
});
});
} else {
// throw TypeError when cannot use Promise
throw new TypeError('callback function required');
}
}
fs.mkdir(dirname, 448 /*=0700*/, function(err) {

@@ -85,0 +121,0 @@ if (err) {

16

package.json
{
"name": "mktemp",
"version": "0.3.5",
"version": "0.4.0",
"author": "sasa+1 <sasaplus1@gmail.com>",

@@ -16,11 +16,15 @@ "contributors": [

},
"directories": {
"test": "test/"
},
"scripts": {
"fix": "fixjsstyle --flagfile .closurelinter -r ./lib -r ./test ./index.js",
"lint": "gjslint --flagfile .closurelinter -r ./lib -r ./test ./index.js",
"fix": "fixjsstyle --flagfile .closurelinter -r .",
"lint": "gjslint --flagfile .closurelinter -r .",
"test": "mocha"
},
"devDependencies": {
"expect.js": "^0.3.1",
"mocha": "^1.20.1",
"sinon": "^1.10.2"
"intelli-espower-loader": "^0.6.0",
"mocha": "^2.1.0",
"power-assert": "^0.10.1",
"sinon": "^1.12.2"
},

@@ -27,0 +31,0 @@ "engines": {

@@ -41,2 +41,28 @@ # mktemp

if support Promise, can use Promise style.
```js
var mktemp = require('mktemp');
mktemp
.createFile('XXXXX.txt')
.then(function(path) {
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
})
.catch(function(err) {
console.error(err);
});
mktemp
.createDir('XXXXX')
.then(function(path) {
// path match a /^[\da-zA-Z]{5}$/
console.log(path);
})
.catch(function(err) {
console.error(err);
});
```
mktemp functions are replace to random string from placeholder "X" in template. see example:

@@ -52,3 +78,3 @@

### createFile(template, callback)
### createFile(template[, callback])

@@ -62,5 +88,6 @@ * `template`

create blank file of unique filename.
permission is `0600`.
create blank file of unique filename. permission is `0600`.
it throws TypeError if node.js unsupported Promise and callback is not a function.
### createFileSync(template)

@@ -75,3 +102,3 @@

### createDir(template, callback)
### createDir(template[, callback])

@@ -85,5 +112,6 @@ * `template`

create directory of unique dirname.
permission is `0700`.
create directory of unique dirname. permission is `0700`.
it throws TypeError if node.js unsupported Promise and callback is not a function.
### createDirSync(template)

@@ -90,0 +118,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc