"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/unique-slug/index.js" (8 Mar 2017, 692 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict'
    2 var crypto = require('crypto')
    3 var MurmurHash3 = require('imurmurhash')
    4 
    5 module.exports = function (uniq) {
    6   if (uniq) {
    7     var hash = new MurmurHash3(uniq)
    8     return ('00000000' + hash.result().toString(16)).substr(-8)
    9   } else {
   10     // Called without a callback, because this interface should neither block
   11     // nor error (by contrast with randomBytes which will throw an exception
   12     // without enough entropy).
   13     //
   14     // However, due to a change in Node 0.10.27+, pseudoRandomBytes is now the
   15     // same as randomBytes, and may in fact block in situations where
   16     // insufficent entropy is available.
   17     return crypto.pseudoRandomBytes(4).toString('hex')
   18   }
   19 }