Comparing version 0.7.1 to 1.0.0
@@ -42,3 +42,3 @@ /// <reference types="node"/> | ||
*/ | ||
type TaskCallback = (tempPath: string) => Promise<void> | void; | ||
type TaskCallback<ReturnValueType> = (tempPath: string) => Promise<ReturnValueType> | ReturnValueType; | ||
} | ||
@@ -63,3 +63,3 @@ | ||
*/ | ||
task: (callback: tempy.TaskCallback, options?: tempy.FileOptions) => Promise<void>; | ||
task: <ReturnValueType>(callback: tempy.TaskCallback<ReturnValueType>, options?: tempy.FileOptions) => Promise<ReturnValueType>; | ||
@@ -104,3 +104,3 @@ /** | ||
*/ | ||
task: (callback: tempy.TaskCallback, options?: tempy.DirectoryOptions) => Promise<void>; | ||
task: <ReturnValueType>(callback: tempy.TaskCallback<ReturnValueType>, options?: tempy.DirectoryOptions) => Promise<ReturnValueType>; | ||
@@ -139,3 +139,3 @@ /** | ||
*/ | ||
task: (fileContent: string | Buffer | TypedArray | DataView | NodeJS.ReadableStream, callback: tempy.TaskCallback, options?: tempy.FileOptions) => Promise<void>; | ||
task: <ReturnValueType>(fileContent: string | Buffer | TypedArray | DataView | NodeJS.ReadableStream, callback: tempy.TaskCallback<ReturnValueType>, options?: tempy.FileOptions) => Promise<ReturnValueType>; | ||
@@ -142,0 +142,0 @@ /** |
@@ -21,4 +21,5 @@ 'use strict'; | ||
const result = await tempyFunction(...arguments_.slice(0, extraArguments), options); | ||
await callback(result); | ||
const returnValue = await callback(result); | ||
await del(result, {force: true}); | ||
return returnValue; | ||
}; | ||
@@ -25,0 +26,0 @@ |
{ | ||
"name": "tempy", | ||
"version": "0.7.1", | ||
"version": "1.0.0", | ||
"description": "Get a random temporary file or directory path", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -40,3 +40,3 @@ # tempy [![Build Status](https://travis-ci.com/sindresorhus/tempy.svg?branch=master)](https://travis-ci.com/github/sindresorhus/tempy) | ||
The `callback` resolves with a temporary file path you can write to. The file is automatically cleaned up after the callback is executed. Returns a promise that resolves after the callback is executed and the file is cleaned up. | ||
The `callback` resolves with a temporary file path you can write to. The file is automatically cleaned up after the callback is executed. Returns a promise that resolves with the return value of the callback after it is executed and the file is cleaned up. | ||
@@ -73,3 +73,3 @@ #### callback | ||
The `callback` resolves with a temporary directory path you can write to. The directory is automatically cleaned up after the callback is executed. Returns a promise that resolves after the callback is executed and the directory is cleaned up. | ||
The `callback` resolves with a temporary directory path you can write to. The directory is automatically cleaned up after the callback is executed. Returns a promise that resolves with the return value of the callback after it is executed and the directory is cleaned up. | ||
@@ -102,3 +102,3 @@ ##### callback | ||
Write data to a random temp file. The file is automatically cleaned up after the callback is executed. Returns a promise that resolves after the callback is executed and the file is cleaned up. | ||
Write data to a random temp file. The file is automatically cleaned up after the callback is executed. Returns a promise that resolves with the return value of the callback after it is executed and the file is cleaned up. | ||
@@ -105,0 +105,0 @@ ##### fileContent |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12647
189
1