1- /// <reference types="node"/>
1+ /* eslint-disable @typescript-eslint/member-ordering */
2+ import { Buffer } from 'node:buffer' ;
23import { MergeExclusive , TypedArray } from 'type-fest' ;
34
4- declare namespace tempy {
5- type FileOptions = MergeExclusive <
6- {
7- /**
8- File extension.
9-
10- Mutually exclusive with the `name` option.
5+ export type FileOptions = MergeExclusive <
6+ {
7+ /**
8+ File extension.
119
12- _You usually won't need this option. Specify it only when actually needed._
13- */
14- readonly extension ?: string ;
15- } ,
16- {
17- /**
18- Filename.
10+ Mutually exclusive with the `name` option.
1911
20- Mutually exclusive with the `extension` option.
12+ _You usually won't need this option. Specify it only when actually needed._
13+ */
14+ readonly extension ?: string ;
15+ } ,
16+ {
17+ /**
18+ Filename.
2119
22- _You usually won't need this option. Specify it only when actually needed._
23- */
24- readonly name ?: string ;
25- }
26- > ;
20+ Mutually exclusive with the `extension` option.
2721
28- type DirectoryOptions = {
29- /**
30- _You usually won't need this option. Specify it only when actually needed._
22+ _You usually won't need this option. Specify it only when actually needed._
23+ */
24+ readonly name ?: string ;
25+ }
26+ > ;
3127
32- Directory prefix.
28+ export type DirectoryOptions = {
29+ /**
30+ Directory prefix.
3331
34- Useful for testing by making it easier to identify cache directories that are created.
35- */
36- readonly prefix ?: string ;
37- } ;
32+ _You usually won't need this option. Specify it only when actually needed._
3833
39- /**
40- The temporary path created by the function. Can be asynchronous.
34+ Useful for testing by making it easier to identify cache directories that are created.
4135 */
42- type TaskCallback < ReturnValueType > = ( tempPath : string ) => Promise < ReturnValueType > | ReturnValueType ;
43- }
36+ readonly prefix ?: string ;
37+ } ;
38+
39+ /**
40+ The temporary path created by the function. Can be asynchronous.
41+ */
42+ export type TaskCallback < ReturnValueType > = ( temporaryPath : string ) => Promise < ReturnValueType > | ReturnValueType ;
4443
4544declare const tempy : {
4645 file : {
@@ -51,22 +50,22 @@ declare const tempy: {
5150
5251 @example
5352 ```
54- import tempy = require( 'tempy') ;
53+ import tempy from 'tempy';
5554
5655 await tempy.file.task(tempFile => {
5756 console.log(tempFile);
5857 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4f504b9edb5ba0e89451617bf9f971dd'
5958 });
6059 ```
6160 */
62- task : < ReturnValueType > ( callback : tempy . TaskCallback < ReturnValueType > , options ?: tempy . FileOptions ) => Promise < ReturnValueType > ;
61+ task : < ReturnValueType > ( callback : TaskCallback < ReturnValueType > , options ?: FileOptions ) => Promise < ReturnValueType > ;
6362
6463 /**
6564 Get a temporary file path you can write to.
6665
6766 @example
6867 ```
69- import tempy = require( 'tempy') ;
68+ import tempy from 'tempy';
7069
7170 tempy.file();
7271 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4f504b9edb5ba0e89451617bf9f971dd'
@@ -81,7 +80,7 @@ declare const tempy: {
8180 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
8281 ```
8382 */
84- ( options ?: tempy . FileOptions ) : string ;
83+ ( options ?: FileOptions ) : string ;
8584 } ;
8685
8786 directory : {
@@ -92,21 +91,21 @@ declare const tempy: {
9291
9392 @example
9493 ```
95- import tempy = require( 'tempy') ;
94+ import tempy from 'tempy';
9695
9796 await tempy.directory.task(tempDirectory => {
9897 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
9998 })
10099 ```
101100 */
102- task : < ReturnValueType > ( callback : tempy . TaskCallback < ReturnValueType > , options ?: tempy . DirectoryOptions ) => Promise < ReturnValueType > ;
101+ task : < ReturnValueType > ( callback : TaskCallback < ReturnValueType > , options ?: DirectoryOptions ) => Promise < ReturnValueType > ;
103102
104103 /**
105104 Get a temporary directory path. The directory is created for you.
106105
107106 @example
108107 ```
109- import tempy = require( 'tempy') ;
108+ import tempy from 'tempy';
110109
111110 tempy.directory();
112111 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
@@ -115,7 +114,7 @@ declare const tempy: {
115114 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/name_3c085674ad31223b9653c88f725d6b41'
116115 ```
117116 */
118- ( options ?: tempy . DirectoryOptions ) : string ;
117+ ( options ?: DirectoryOptions ) : string ;
119118 } ;
120119
121120 write : {
@@ -126,41 +125,41 @@ declare const tempy: {
126125
127126 @example
128127 ```
129- import tempy = require( 'tempy') ;
128+ import tempy from 'tempy';
130129
131130 await tempy.write.task('🦄', tempFile => {
132131 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4f504b9edb5ba0e89451617bf9f971dd'
133132 });
134133 ```
135134 */
136- task : < ReturnValueType > ( fileContent : string | Buffer | TypedArray | DataView | NodeJS . ReadableStream , callback : tempy . TaskCallback < ReturnValueType > , options ?: tempy . FileOptions ) => Promise < ReturnValueType > ;
135+ task : < ReturnValueType > ( fileContent : string | Buffer | TypedArray | DataView | NodeJS . ReadableStream , callback : TaskCallback < ReturnValueType > , options ?: FileOptions ) => Promise < ReturnValueType > ;
137136
138137 /**
139138 Write data to a random temp file.
140139
141140 @example
142141 ```
143- import tempy = require( 'tempy') ;
142+ import tempy from 'tempy';
144143
145144 await tempy.write('🦄');
146145 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
147146 ```
148147 */
149- ( fileContent : string | Buffer | TypedArray | DataView | NodeJS . ReadableStream , options ?: tempy . FileOptions ) : Promise < string > ;
148+ ( fileContent : string | Buffer | TypedArray | DataView | NodeJS . ReadableStream , options ?: FileOptions ) : Promise < string > ;
150149 } ;
151150
152151 /**
153152 Synchronously write data to a random temp file.
154153
155154 @example
156155 ```
157- import tempy = require( 'tempy') ;
156+ import tempy from 'tempy';
158157
159158 tempy.writeSync('🦄');
160159 //=> '/private/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/2f3d094aec2cb1b93bb0f4cffce5ebd6'
161160 ```
162161 */
163- writeSync : ( fileContent : string | Buffer | TypedArray | DataView , options ?: tempy . FileOptions ) => string ;
162+ writeSync : ( fileContent : string | Buffer | TypedArray | DataView , options ?: FileOptions ) => string ;
164163
165164 /**
166165 Get the root temporary directory path.
@@ -170,4 +169,4 @@ declare const tempy: {
170169 readonly root : string ;
171170} ;
172171
173- export = tempy ;
172+ export default tempy ;
0 commit comments