summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/uuid/lib/sha1.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/uuid/lib/sha1.js')
-rw-r--r--deps/npm/node_modules/uuid/lib/sha1.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/deps/npm/node_modules/uuid/lib/sha1.js b/deps/npm/node_modules/uuid/lib/sha1.js
index e8771ce540..0b54b25072 100644
--- a/deps/npm/node_modules/uuid/lib/sha1.js
+++ b/deps/npm/node_modules/uuid/lib/sha1.js
@@ -3,19 +3,23 @@
var crypto = require('crypto');
function sha1(bytes) {
- // support modern Buffer API
- if (typeof Buffer.from === 'function') {
- if (Array.isArray(bytes)) bytes = Buffer.from(bytes);
- else if (typeof bytes === 'string') bytes = Buffer.from(bytes, 'utf8');
- }
+ if (typeof Buffer.from === 'function') {
+ // Modern Buffer API
+ if (Array.isArray(bytes)) {
+ bytes = Buffer.from(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = Buffer.from(bytes, 'utf8');
+ }
+ } else {
+ // Pre-v4 Buffer API
+ if (Array.isArray(bytes)) {
+ bytes = new Buffer(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = new Buffer(bytes, 'utf8');
+ }
+ }
- // support pre-v4 Buffer API
- else {
- if (Array.isArray(bytes)) bytes = new Buffer(bytes);
- else if (typeof bytes === 'string') bytes = new Buffer(bytes, 'utf8');
- }
-
- return crypto.createHash('sha1').update(bytes).digest();
+ return crypto.createHash('sha1').update(bytes).digest();
}
module.exports = sha1;