Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 1x 1x 1x 1x 1x 10x 10x 10x 10x 80x 10x 16x 4x 2x 2x 4x 2x 6x 2x 2x 6x 2x 6x 6x 6x 4x 1x 4x 4x 4x 4x 1x | const { mkdtemp, mkdtempSync, writeFile, writeFileSync } = require('fs');
const { tmpdir } = require('os');
const { join } = require('path');
const { randomBytes } = require('crypto');
const { fromCallback } = require('universalify');
function randomString (count = 8) {
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const bytes = randomBytes(count);
const value = [];
for (var i = 0; i < count; i++) {
value.push(chars[bytes[i] % chars.length]);
}
return value.join('');
}
function tempPathPrefix (prefix = 'tmp', suffix = '') {
return join(tmpdir(), `${prefix}.${suffix}`);
}
function mktempDir (prefix, callback) {
if (!callback && typeof prefix === 'function') {
callback = prefix;
prefix = undefined;
}
return mkdtemp(tempPathPrefix(prefix), callback);
}
function mktempDirSync (prefix) {
return mkdtempSync(tempPathPrefix(prefix));
}
function mktempFile (options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
if (typeof options === 'string') {
options = { prefix: options };
}
const { content = '', prefix } = options || {};
const file = tempPathPrefix(prefix, randomString());
return writeFile(file, content, { mode: 0o600 }, err => callback(err, file));
}
function mktempFileSync (options) {
if (typeof options === 'string') {
options = { prefix: options };
}
const { content = '', prefix } = options || {};
const file = tempPathPrefix(prefix, randomString());
writeFileSync(file, content, { mode: 0o600 });
return file;
}
module.exports = {
mktempDir: fromCallback(mktempDir),
mktempDirSync,
mktempFile: fromCallback(mktempFile),
mktempFileSync
};
|