Comparing version 1.0.0 to 1.0.1
@@ -111,3 +111,3 @@ 'use strict'; | ||
openUnique(filename, options, (err, fd) => { | ||
openUnique(filename, options, (err, fd, newPath) => { | ||
if (err) { | ||
@@ -117,3 +117,3 @@ cb(err); | ||
let buffer = Buffer.isBuffer(data) ? data : new Buffer('' + data, options.encoding || 'utf8'); | ||
writeAll(fd, buffer, 0, buffer.length, 0, cb); | ||
writeAll(fd, buffer, 0, buffer.length, 0, (...args) => cb.apply(null, args.concat(newPath))); | ||
} | ||
@@ -120,0 +120,0 @@ }); |
@@ -27,3 +27,3 @@ { | ||
}, | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
} |
@@ -13,5 +13,5 @@ # fsu (fs unique) | ||
```js | ||
var fsu = require('fsu'); | ||
const fsu = require('fsu'); | ||
fsu.openUnique("text{_###}.txt", (err, fd) => { | ||
fsu.openUnique("text{_###}.txt", (err, fd, path) => { | ||
//now we can use file descriptor as usual | ||
@@ -25,6 +25,6 @@ }); | ||
```js | ||
var fsu = require('fsu'); | ||
const fsu = require('fsu'); | ||
fsu.writeFileUnique("text{_###}.txt", "test", err => { | ||
console.log("Done"); | ||
fsu.writeFileUnique("text{_###}.txt", "test", (err, path) => { | ||
console.log("Done", path); | ||
}); | ||
@@ -37,6 +37,9 @@ ``` | ||
```js | ||
var fsu = require('fsu'); | ||
var stream = fsu.createWriteStreamUnique("text{_###}.txt"); | ||
const fsu = require('fsu'); | ||
let stream = fsu.createWriteStreamUnique("text{_###}.txt"); | ||
``` | ||
## new path | ||
Stream has a `path` property that contains a new path | ||
## force path creation | ||
@@ -43,0 +46,0 @@ Add `force = true` to options, and it will recursively create directories if they are not exist. |
@@ -7,5 +7,4 @@ 'use strict'; | ||
fsu.writeFileUnique('test/test{_file###}.txt', 'test', { force: true }, err => { | ||
fsu.writeFileUnique('test/test{_file###}.txt', 'test', { force: true }, (err, path) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
@@ -12,0 +11,0 @@ fs.createReadStream('readme.md').pipe(stream); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8173
57
150