atomically
Advanced tools
Comparing version 1.3.0 to 1.3.1
"use strict"; | ||
/* IMPORT */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const crypto = require("crypto"); | ||
const path = require("path"); | ||
@@ -13,5 +12,5 @@ const consts_1 = require("../consts"); | ||
create: (filePath) => { | ||
const hash = crypto.randomBytes(3).toString('hex'), // 6 random hex characters | ||
const randomness = `000000${Math.floor(Math.random() * 16777215).toString(16)}`.slice(-6), // 6 random-enough hex characters | ||
timestamp = Date.now().toString().slice(-10), // 10 precise timestamp digits | ||
prefix = 'tmp-', suffix = `.${prefix}${timestamp}${hash}`, tempPath = `${filePath}${suffix}`; | ||
prefix = 'tmp-', suffix = `.${prefix}${timestamp}${randomness}`, tempPath = `${filePath}${suffix}`; | ||
return tempPath; | ||
@@ -18,0 +17,0 @@ }, |
{ | ||
"name": "atomically", | ||
"description": "Read and write files atomically and reliably.", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "dist/index.d.ts", |
/* IMPORT */ | ||
import * as crypto from 'crypto'; | ||
import * as path from 'path'; | ||
@@ -20,6 +19,6 @@ import {LIMIT_BASENAME_LENGTH} from '../consts'; | ||
const hash = crypto.randomBytes ( 3 ).toString ( 'hex' ), // 6 random hex characters | ||
const randomness = `000000${Math.floor ( Math.random () * 16777215 ).toString ( 16 )}`.slice ( -6 ), // 6 random-enough hex characters | ||
timestamp = Date.now ().toString ().slice ( -10 ), // 10 precise timestamp digits | ||
prefix = 'tmp-', | ||
suffix = `.${prefix}${timestamp}${hash}`, | ||
suffix = `.${prefix}${timestamp}${randomness}`, | ||
tempPath = `${filePath}${suffix}`; | ||
@@ -26,0 +25,0 @@ |
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
87698
1933