protobufjs 6.8.4 → 6.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +2 -2
  3. package/cli/node_modules/os-tmpdir/index.js +25 -0
  4. package/cli/node_modules/os-tmpdir/license +21 -0
  5. package/cli/node_modules/os-tmpdir/readme.md +32 -0
  6. package/cli/node_modules/tmp/LICENSE +21 -0
  7. package/cli/node_modules/tmp/README.md +314 -0
  8. package/cli/node_modules/tmp/lib/tmp.js +611 -0
  9. package/cli/pbjs.d.ts +1 -1
  10. package/cli/pbjs.js +11 -1
  11. package/cli/pbts.d.ts +1 -1
  12. package/cli/pbts.js +36 -7
  13. package/cli/targets/proto.js +1 -1
  14. package/cli/targets/static.js +3 -6
  15. package/dist/light/protobuf.js +143 -64
  16. package/dist/light/protobuf.js.map +1 -1
  17. package/dist/light/protobuf.min.js +3 -3
  18. package/dist/light/protobuf.min.js.map +1 -1
  19. package/dist/minimal/protobuf.js +23 -14
  20. package/dist/minimal/protobuf.js.map +1 -1
  21. package/dist/minimal/protobuf.min.js +3 -3
  22. package/dist/minimal/protobuf.min.js.map +1 -1
  23. package/dist/protobuf.js +268 -90
  24. package/dist/protobuf.js.map +1 -1
  25. package/dist/protobuf.min.js +3 -3
  26. package/dist/protobuf.min.js.map +1 -1
  27. package/ext/descriptor/index.d.ts +0 -1
  28. package/ext/descriptor/index.js +3 -0
  29. package/index.d.ts +57 -16
  30. package/package-lock.json +4579 -3191
  31. package/package.json +122 -125
  32. package/src/common.js +22 -1
  33. package/src/converter.js +9 -3
  34. package/src/enum.js +17 -5
  35. package/src/field.js +17 -4
  36. package/src/index-light.js +2 -2
  37. package/src/index-minimal.js +1 -1
  38. package/src/mapfield.js +9 -5
  39. package/src/message.js +1 -1
  40. package/src/method.js +14 -4
  41. package/src/namespace.js +14 -10
  42. package/src/object.js +1 -0
  43. package/src/oneof.js +14 -4
  44. package/src/parse.js +11 -3
  45. package/src/reader.js +2 -4
  46. package/src/root.js +3 -2
  47. package/src/service.js +8 -4
  48. package/src/tokenize.js +92 -22
  49. package/src/type.js +10 -5
  50. package/src/util/minimal.js +11 -2
  51. package/google/protobuf/field_mask.json +0 -21
  52. package/google/protobuf/field_mask.proto +0 -7
package/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ # [6.8.8](https://github.com/dcodeIO/protobuf.js/releases/tag/6.8.8)
2
+
3
+ ## Fixed
4
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/3001425b0d896d14188307cd0cc84ce195ad9e04) Persist recent index.d.ts changes in JSDoc<br />
5
+
6
+ # [6.8.7](https://github.com/dcodeIO/protobuf.js/releases/tag/6.8.7)
7
+
8
+ ## Fixed
9
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/e8449c4bf1269a2cc423708db6f0b47a383d33f0) Fix package browser field descriptor ([#1046](https://github.com/dcodeIO/protobuf.js/issues/1046))<br />
10
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/996b3fa0c598ecc73302bfc39208c44830f07b1a) Fix static codegen issues with uglifyjs3<br />
11
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/a06317139b92fdd8c6b3b188fb7b9704dc8ccbf1) Fix lint issues / pbts on windows<br />
12
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/a927a6646e8fdddebcb3e13bc8b28b041b3ee40a) Fix empty 'bytes' field decoding, now using Buffer where applicable ([#1020](https://github.com/dcodeIO/protobuf.js/issues/1020))<br />
13
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/f13a81fb41fbef2ce9dcee13f23b7276c83fbcfd) Fix circular dependency of Namespace and Enum ([#994](https://github.com/dcodeIO/protobuf.js/issues/994))<br />
14
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/c05c58fad61c16e5ce20ca19758e4782cdd5d2e3) Ignore optional commas in aggregate options ([#999](https://github.com/dcodeIO/protobuf.js/issues/999))<br />
15
+
16
+ ## New
17
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/36fc964b8db1e4372c76b1baf9f03857cd875b07) Make Message<T> have a default type param ([#1086](https://github.com/dcodeIO/protobuf.js/issues/1086))<br />
18
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/996b3fa0c598ecc73302bfc39208c44830f07b1a) Explicitly define service method names when generating static code, see [#857](https://github.com/dcodeIO/protobuf.js/issues/857)<br />
19
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/07c5d59e1da8c5533a39007ba332928206281408) Also handle services in ext/descriptor ([#1001](https://github.com/dcodeIO/protobuf.js/issues/1001))<br />
20
+
21
+ ## CLI
22
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/2c5ef95818a310243f88ffba0331cd47ee603c0a) Extend list of ignored ESLint rules for pbjs, fixes [#1085](https://github.com/dcodeIO/protobuf.js/issues/1085)<br />
23
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/8576b49ad3e55b8beae2a8f044c51040484eef12) Fix declared return type of pbjs/pbts callback ([#1025](https://github.com/dcodeIO/protobuf.js/issues/1025))<br />
24
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/9fceaa69667895e609a3ed78eb2efa7a0ecfb890) Added an option to pbts to allow custom imports ([#1038](https://github.com/dcodeIO/protobuf.js/issues/1038))<br />
25
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/65d113b0079fa2570837f3cf95268ce24714a248) Get node executable path from process.execPath ([#1018](https://github.com/dcodeIO/protobuf.js/issues/1018))<br />
26
+
27
+ ## Other
28
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/b611875cfbc1f98d8973a2e86f1506de84f00049) Slim down CI testing and remove some not ultimately necesssary dependencies with audit issues<br />
29
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/812b38ddabb35e154f9ff94f32ad8ce2a70310f1) Move global handling to util, see [#995](https://github.com/dcodeIO/protobuf.js/issues/995)<br />
30
+
31
+ # [6.8.6](https://github.com/dcodeIO/protobuf.js/releases/tag/6.8.6)
32
+
33
+ ## Fixed
34
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/2ee1028d631a328e152d7e09f2a0e0c5c83dc2aa) Fix typeRefRe being vulnerable to ReDoS<br />
35
+
36
+ # [6.8.5](https://github.com/dcodeIO/protobuf.js/releases/tag/6.8.6)
37
+
38
+ ## New
39
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/462132f222d8febb8211d839635aad5b82dc6315) Preserve comments when serializing/deserializing with toJSON and fromJSON. ([#983](https://github.com/dcodeIO/protobuf.js/issues/983))<br />
40
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/d29c0caa715a14214fc755b3cf10ac119cdaf199) Add more details to some frequent error messages ([#962](https://github.com/dcodeIO/protobuf.js/issues/962))<br />
41
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/8400f87ad8ed2b47e659bc8bb6c3cf2467802425) Add IParseOptions#alternateCommentMode ([#968](https://github.com/dcodeIO/protobuf.js/issues/968))<br />
42
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/d6e3b9e218896ec1910e02448b5ee87e4d96ede6) Added field_mask to built-in common wrappers ([#982](https://github.com/dcodeIO/protobuf.js/issues/982))<br />
43
+
44
+ ## Other
45
+ [:hash:](https://github.com/dcodeIO/protobuf.js/commit/635fef013fbb3523536d92c690ffd7d84829db35) Remove code climate config in order to use 'in-app' config instead<br />
46
+
1
47
  # [6.8.4](https://github.com/dcodeIO/protobuf.js/releases/tag/6.8.4)
2
48
 
3
49
  ## Other
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1><p align="center"><img alt="protobuf.js" src="https://github.com/dcodeIO/protobuf.js/raw/master/pbjs.png" width="120" height="104" /></p></h1>
2
- <p align="center"><a href="https://npmjs.org/package/protobufjs"><img src="https://img.shields.io/npm/v/protobufjs.svg" alt=""></a> <a href="https://travis-ci.org/dcodeIO/protobuf.js"><img src="https://travis-ci.org/dcodeIO/protobuf.js.svg?branch=master" alt=""></a> <a href="https://codeclimate.com/github/dcodeIO/protobuf.js/coverage"><img src="https://codeclimate.com/github/dcodeIO/protobuf.js/badges/coverage.svg" /></a> <a href="https://npmjs.org/package/protobufjs"><img src="https://img.shields.io/npm/dm/protobufjs.svg" alt=""></a> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=Open%20Source%20Software%20Donation&item_number=dcodeIO%2Fprotobuf.js"><img alt="donate ❤" src="https://img.shields.io/badge/donate-❤-ff2244.svg"></a></p>
2
+ <p align="center"><a href="https://npmjs.org/package/protobufjs"><img src="https://img.shields.io/npm/v/protobufjs.svg" alt=""></a> <a href="https://travis-ci.org/dcodeIO/protobuf.js"><img src="https://travis-ci.org/dcodeIO/protobuf.js.svg?branch=master" alt=""></a> <a href="https://npmjs.org/package/protobufjs"><img src="https://img.shields.io/npm/dm/protobufjs.svg" alt=""></a> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=Open%20Source%20Software%20Donation&item_number=dcodeIO%2Fprotobuf.js"><img alt="donate ❤" src="https://img.shields.io/badge/donate-❤-ff2244.svg"></a></p>
3
3
 
4
4
  **Protocol Buffers** are a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more, originally designed at Google ([see](https://developers.google.com/protocol-buffers/)).
5
5
 
@@ -869,7 +869,7 @@ By default, protobuf.js integrates into any browserify build-process without req
869
869
 
870
870
  ```js
871
871
  var Long = ...;
872
-
872
+
873
873
  protobuf.util.Long = Long;
874
874
  protobuf.configure();
875
875
  ```
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ var isWindows = process.platform === 'win32';
3
+ var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
4
+
5
+ // https://github.com/nodejs/node/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43
6
+ module.exports = function () {
7
+ var path;
8
+
9
+ if (isWindows) {
10
+ path = process.env.TEMP ||
11
+ process.env.TMP ||
12
+ (process.env.SystemRoot || process.env.windir) + '\\temp';
13
+ } else {
14
+ path = process.env.TMPDIR ||
15
+ process.env.TMP ||
16
+ process.env.TEMP ||
17
+ '/tmp';
18
+ }
19
+
20
+ if (trailingSlashRe.test(path)) {
21
+ path = path.slice(0, -1);
22
+ }
23
+
24
+ return path;
25
+ };
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # os-tmpdir [![Build Status](https://travis-ci.org/sindresorhus/os-tmpdir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-tmpdir)
2
+
3
+ > Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) [ponyfill](https://ponyfill.com)
4
+
5
+ Use this instead of `require('os').tmpdir()` to get a consistent behavior on different Node.js versions (even 0.8).
6
+
7
+
8
+ ## Install
9
+
10
+ ```
11
+ $ npm install --save os-tmpdir
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ const osTmpdir = require('os-tmpdir');
19
+
20
+ osTmpdir();
21
+ //=> '/var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T'
22
+ ```
23
+
24
+
25
+ ## API
26
+
27
+ See the [`os.tmpdir()` docs](https://nodejs.org/api/os.html#os_os_tmpdir).
28
+
29
+
30
+ ## License
31
+
32
+ MIT © [Sindre Sorhus](https://sindresorhus.com)
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 KARASZI István
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,314 @@
1
+ # Tmp
2
+
3
+ A simple temporary file and directory creator for [node.js.][1]
4
+
5
+ [![Build Status](https://travis-ci.org/raszi/node-tmp.svg?branch=master)](https://travis-ci.org/raszi/node-tmp)
6
+ [![Dependencies](https://david-dm.org/raszi/node-tmp.svg)](https://david-dm.org/raszi/node-tmp)
7
+ [![npm version](https://badge.fury.io/js/tmp.svg)](https://badge.fury.io/js/tmp)
8
+ [![API documented](https://img.shields.io/badge/API-documented-brightgreen.svg)](https://raszi.github.io/node-tmp/)
9
+ [![Known Vulnerabilities](https://snyk.io/test/npm/tmp/badge.svg)](https://snyk.io/test/npm/tmp)
10
+
11
+ ## About
12
+
13
+ This is a [widely used library][2] to create temporary files and directories
14
+ in a [node.js][1] environment.
15
+
16
+ Tmp offers both an asynchronous and a synchronous API. For all API calls, all
17
+ the parameters are optional. There also exists a promisified version of the
18
+ API, see (5) under references below.
19
+
20
+ Tmp uses crypto for determining random file names, or, when using templates,
21
+ a six letter random identifier. And just in case that you do not have that much
22
+ entropy left on your system, Tmp will fall back to pseudo random numbers.
23
+
24
+ You can set whether you want to remove the temporary file on process exit or
25
+ not, and the destination directory can also be set.
26
+
27
+ ## How to install
28
+
29
+ ```bash
30
+ npm install tmp
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Please also check [API docs][4].
36
+
37
+ ### Asynchronous file creation
38
+
39
+ Simple temporary file creation, the file will be closed and unlinked on process exit.
40
+
41
+ ```javascript
42
+ var tmp = require('tmp');
43
+
44
+ tmp.file(function _tempFileCreated(err, path, fd, cleanupCallback) {
45
+ if (err) throw err;
46
+
47
+ console.log('File: ', path);
48
+ console.log('Filedescriptor: ', fd);
49
+
50
+ // If we don't need the file anymore we could manually call the cleanupCallback
51
+ // But that is not necessary if we didn't pass the keep option because the library
52
+ // will clean after itself.
53
+ cleanupCallback();
54
+ });
55
+ ```
56
+
57
+ ### Synchronous file creation
58
+
59
+ A synchronous version of the above.
60
+
61
+ ```javascript
62
+ var tmp = require('tmp');
63
+
64
+ var tmpobj = tmp.fileSync();
65
+ console.log('File: ', tmpobj.name);
66
+ console.log('Filedescriptor: ', tmpobj.fd);
67
+
68
+ // If we don't need the file anymore we could manually call the removeCallback
69
+ // But that is not necessary if we didn't pass the keep option because the library
70
+ // will clean after itself.
71
+ tmpobj.removeCallback();
72
+ ```
73
+
74
+ Note that this might throw an exception if either the maximum limit of retries
75
+ for creating a temporary name fails, or, in case that you do not have the permission
76
+ to write to the directory where the temporary file should be created in.
77
+
78
+ ### Asynchronous directory creation
79
+
80
+ Simple temporary directory creation, it will be removed on process exit.
81
+
82
+ If the directory still contains items on process exit, then it won't be removed.
83
+
84
+ ```javascript
85
+ var tmp = require('tmp');
86
+
87
+ tmp.dir(function _tempDirCreated(err, path, cleanupCallback) {
88
+ if (err) throw err;
89
+
90
+ console.log('Dir: ', path);
91
+
92
+ // Manual cleanup
93
+ cleanupCallback();
94
+ });
95
+ ```
96
+
97
+ If you want to cleanup the directory even when there are entries in it, then
98
+ you can pass the `unsafeCleanup` option when creating it.
99
+
100
+ ### Synchronous directory creation
101
+
102
+ A synchronous version of the above.
103
+
104
+ ```javascript
105
+ var tmp = require('tmp');
106
+
107
+ var tmpobj = tmp.dirSync();
108
+ console.log('Dir: ', tmpobj.name);
109
+ // Manual cleanup
110
+ tmpobj.removeCallback();
111
+ ```
112
+
113
+ Note that this might throw an exception if either the maximum limit of retries
114
+ for creating a temporary name fails, or, in case that you do not have the permission
115
+ to write to the directory where the temporary directory should be created in.
116
+
117
+ ### Asynchronous filename generation
118
+
119
+ It is possible with this library to generate a unique filename in the specified
120
+ directory.
121
+
122
+ ```javascript
123
+ var tmp = require('tmp');
124
+
125
+ tmp.tmpName(function _tempNameGenerated(err, path) {
126
+ if (err) throw err;
127
+
128
+ console.log('Created temporary filename: ', path);
129
+ });
130
+ ```
131
+
132
+ ### Synchronous filename generation
133
+
134
+ A synchronous version of the above.
135
+
136
+ ```javascript
137
+ var tmp = require('tmp');
138
+
139
+ var name = tmp.tmpNameSync();
140
+ console.log('Created temporary filename: ', name);
141
+ ```
142
+
143
+ ## Advanced usage
144
+
145
+ ### Asynchronous file creation
146
+
147
+ Creates a file with mode `0644`, prefix will be `prefix-` and postfix will be `.txt`.
148
+
149
+ ```javascript
150
+ var tmp = require('tmp');
151
+
152
+ tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) {
153
+ if (err) throw err;
154
+
155
+ console.log('File: ', path);
156
+ console.log('Filedescriptor: ', fd);
157
+ });
158
+ ```
159
+
160
+ ### Synchronous file creation
161
+
162
+ A synchronous version of the above.
163
+
164
+ ```javascript
165
+ var tmp = require('tmp');
166
+
167
+ var tmpobj = tmp.fileSync({ mode: 0644, prefix: 'prefix-', postfix: '.txt' });
168
+ console.log('File: ', tmpobj.name);
169
+ console.log('Filedescriptor: ', tmpobj.fd);
170
+ ```
171
+
172
+ ### Controlling the Descriptor
173
+
174
+ As a side effect of creating a unique file `tmp` gets a file descriptor that is
175
+ returned to the user as the `fd` parameter. The descriptor may be used by the
176
+ application and is closed when the `removeCallback` is invoked.
177
+
178
+ In some use cases the application does not need the descriptor, needs to close it
179
+ without removing the file, or needs to remove the file without closing the
180
+ descriptor. Two options control how the descriptor is managed:
181
+
182
+ * `discardDescriptor` - if `true` causes `tmp` to close the descriptor after the file
183
+ is created. In this case the `fd` parameter is undefined.
184
+ * `detachDescriptor` - if `true` causes `tmp` to return the descriptor in the `fd`
185
+ parameter, but it is the application's responsibility to close it when it is no
186
+ longer needed.
187
+
188
+ ```javascript
189
+ var tmp = require('tmp');
190
+
191
+ tmp.file({ discardDescriptor: true }, function _tempFileCreated(err, path, fd, cleanupCallback) {
192
+ if (err) throw err;
193
+ // fd will be undefined, allowing application to use fs.createReadStream(path)
194
+ // without holding an unused descriptor open.
195
+ });
196
+ ```
197
+
198
+ ```javascript
199
+ var tmp = require('tmp');
200
+
201
+ tmp.file({ detachDescriptor: true }, function _tempFileCreated(err, path, fd, cleanupCallback) {
202
+ if (err) throw err;
203
+
204
+ cleanupCallback();
205
+ // Application can store data through fd here; the space used will automatically
206
+ // be reclaimed by the operating system when the descriptor is closed or program
207
+ // terminates.
208
+ });
209
+ ```
210
+
211
+ ### Asynchronous directory creation
212
+
213
+ Creates a directory with mode `0755`, prefix will be `myTmpDir_`.
214
+
215
+ ```javascript
216
+ var tmp = require('tmp');
217
+
218
+ tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) {
219
+ if (err) throw err;
220
+
221
+ console.log('Dir: ', path);
222
+ });
223
+ ```
224
+
225
+ ### Synchronous directory creation
226
+
227
+ Again, a synchronous version of the above.
228
+
229
+ ```javascript
230
+ var tmp = require('tmp');
231
+
232
+ var tmpobj = tmp.dirSync({ mode: 0750, prefix: 'myTmpDir_' });
233
+ console.log('Dir: ', tmpobj.name);
234
+ ```
235
+
236
+ ### mkstemp like, asynchronously
237
+
238
+ Creates a new temporary directory with mode `0700` and filename like `/tmp/tmp-nk2J1u`.
239
+
240
+ ```javascript
241
+ var tmp = require('tmp');
242
+
243
+ tmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) {
244
+ if (err) throw err;
245
+
246
+ console.log('Dir: ', path);
247
+ });
248
+ ```
249
+
250
+ ### mkstemp like, synchronously
251
+
252
+ This will behave similarly to the asynchronous version.
253
+
254
+ ```javascript
255
+ var tmp = require('tmp');
256
+
257
+ var tmpobj = tmp.dirSync({ template: '/tmp/tmp-XXXXXX' });
258
+ console.log('Dir: ', tmpobj.name);
259
+ ```
260
+
261
+ ### Asynchronous filename generation
262
+
263
+ The `tmpName()` function accepts the `prefix`, `postfix`, `dir`, etc. parameters also:
264
+
265
+ ```javascript
266
+ var tmp = require('tmp');
267
+
268
+ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, function _tempNameGenerated(err, path) {
269
+ if (err) throw err;
270
+
271
+ console.log('Created temporary filename: ', path);
272
+ });
273
+ ```
274
+
275
+ ### Synchronous filename generation
276
+
277
+ The `tmpNameSync()` function works similarly to `tmpName()`.
278
+
279
+ ```javascript
280
+ var tmp = require('tmp');
281
+ var tmpname = tmp.tmpNameSync({ template: '/tmp/tmp-XXXXXX' });
282
+ console.log('Created temporary filename: ', tmpname);
283
+ ```
284
+
285
+ ## Graceful cleanup
286
+
287
+ One may want to cleanup the temporary files even when an uncaught exception
288
+ occurs. To enforce this, you can call the `setGracefulCleanup()` method:
289
+
290
+ ```javascript
291
+ var tmp = require('tmp');
292
+
293
+ tmp.setGracefulCleanup();
294
+ ```
295
+
296
+ ## Options
297
+
298
+ All options are optional :)
299
+
300
+ * `mode`: the file mode to create with, it fallbacks to `0600` on file creation and `0700` on directory creation
301
+ * `prefix`: the optional prefix, fallbacks to `tmp-` if not provided
302
+ * `postfix`: the optional postfix, fallbacks to `.tmp` on file creation
303
+ * `template`: [`mkstemp`][3] like filename template, no default
304
+ * `dir`: the optional temporary directory, fallbacks to system default (guesses from environment)
305
+ * `tries`: how many times should the function try to get a unique filename before giving up, default `3`
306
+ * `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`, means delete
307
+ * Please keep in mind that it is recommended in this case to call the provided `cleanupCallback` function manually.
308
+ * `unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false`
309
+
310
+ [1]: http://nodejs.org/
311
+ [2]: https://www.npmjs.com/browse/depended/tmp
312
+ [3]: http://www.kernel.org/doc/man-pages/online/pages/man3/mkstemp.3.html
313
+ [4]: https://raszi.github.io/node-tmp/
314
+ [5]: https://github.com/benjamingr/tmp-promise