summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/misc/uniqid.js.map
blob: 27dd6f54bd7c938edbf71dec751cfa82a36c8a6b (plain) (blame)
1
{"version":3,"sources":["../../../src/php/misc/uniqid.js"],"names":["module","exports","uniqid","prefix","moreEntropy","retId","_formatSeed","seed","reqWidth","parseInt","toString","length","slice","Array","join","$global","window","global","$locutus","php","uniqidSeed","Math","floor","random","Date","getTime","toFixed"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,MAAT,CAAiBC,MAAjB,EAAyBC,WAAzB,EAAsC;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAI,OAAOD,MAAP,KAAkB,WAAtB,EAAmC;AACjCA,aAAS,EAAT;AACD;;AAED,MAAIE,KAAJ;AACA,MAAIC,cAAc,SAAdA,WAAc,CAAUC,IAAV,EAAgBC,QAAhB,EAA0B;AAC1CD,WAAOE,SAASF,IAAT,EAAe,EAAf,EAAmBG,QAAnB,CAA4B,EAA5B,CAAP,CAD0C,CACH;AACvC,QAAIF,WAAWD,KAAKI,MAApB,EAA4B;AAC1B;AACA,aAAOJ,KAAKK,KAAL,CAAWL,KAAKI,MAAL,GAAcH,QAAzB,CAAP;AACD;AACD,QAAIA,WAAWD,KAAKI,MAApB,EAA4B;AAC1B;AACA,aAAOE,MAAM,KAAKL,WAAWD,KAAKI,MAArB,CAAN,EAAoCG,IAApC,CAAyC,GAAzC,IAAgDP,IAAvD;AACD;AACD,WAAOA,IAAP;AACD,GAXD;;AAaA,MAAIQ,UAAW,OAAOC,MAAP,KAAkB,WAAlB,GAAgCA,MAAhC,GAAyCC,MAAxD;AACAF,UAAQG,QAAR,GAAmBH,QAAQG,QAAR,IAAoB,EAAvC;AACA,MAAIA,WAAWH,QAAQG,QAAvB;AACAA,WAASC,GAAT,GAAeD,SAASC,GAAT,IAAgB,EAA/B;;AAEA,MAAI,CAACD,SAASC,GAAT,CAAaC,UAAlB,EAA8B;AAC5B;AACAF,aAASC,GAAT,CAAaC,UAAb,GAA0BC,KAAKC,KAAL,CAAWD,KAAKE,MAAL,KAAgB,SAA3B,CAA1B;AACD;AACDL,WAASC,GAAT,CAAaC,UAAb;;AAEA;AACAf,UAAQF,MAAR;AACAE,WAASC,YAAYG,SAAS,IAAIe,IAAJ,GAAWC,OAAX,KAAuB,IAAhC,EAAsC,EAAtC,CAAZ,EAAuD,CAAvD,CAAT;AACA;AACApB,WAASC,YAAYY,SAASC,GAAT,CAAaC,UAAzB,EAAqC,CAArC,CAAT;AACA,MAAIhB,WAAJ,EAAiB;AACf;AACAC,aAAS,CAACgB,KAAKE,MAAL,KAAgB,EAAjB,EAAqBG,OAArB,CAA6B,CAA7B,EAAgChB,QAAhC,EAAT;AACD;;AAED,SAAOL,KAAP;AACD,CAvDD","file":"uniqid.js","sourcesContent":["module.exports = function uniqid (prefix, moreEntropy) {\n  //  discuss at: http://locutus.io/php/uniqid/\n  // original by: Kevin van Zonneveld (http://kvz.io)\n  //  revised by: Kankrelune (http://www.webfaktory.info/)\n  //      note 1: Uses an internal counter (in locutus global) to avoid collision\n  //   example 1: var $id = uniqid()\n  //   example 1: var $result = $id.length === 13\n  //   returns 1: true\n  //   example 2: var $id = uniqid('foo')\n  //   example 2: var $result = $id.length === (13 + 'foo'.length)\n  //   returns 2: true\n  //   example 3: var $id = uniqid('bar', true)\n  //   example 3: var $result = $id.length === (23 + 'bar'.length)\n  //   returns 3: true\n\n  if (typeof prefix === 'undefined') {\n    prefix = ''\n  }\n\n  var retId\n  var _formatSeed = function (seed, reqWidth) {\n    seed = parseInt(seed, 10).toString(16) // to hex str\n    if (reqWidth < seed.length) {\n      // so long we split\n      return seed.slice(seed.length - reqWidth)\n    }\n    if (reqWidth > seed.length) {\n      // so short we pad\n      return Array(1 + (reqWidth - seed.length)).join('0') + seed\n    }\n    return seed\n  }\n\n  var $global = (typeof window !== 'undefined' ? window : global)\n  $global.$locutus = $global.$locutus || {}\n  var $locutus = $global.$locutus\n  $locutus.php = $locutus.php || {}\n\n  if (!$locutus.php.uniqidSeed) {\n    // init seed with big random int\n    $locutus.php.uniqidSeed = Math.floor(Math.random() * 0x75bcd15)\n  }\n  $locutus.php.uniqidSeed++\n\n  // start with prefix, add current milliseconds hex string\n  retId = prefix\n  retId += _formatSeed(parseInt(new Date().getTime() / 1000, 10), 8)\n  // add seed hex string\n  retId += _formatSeed($locutus.php.uniqidSeed, 5)\n  if (moreEntropy) {\n    // for more entropy we add a float lower to 10\n    retId += (Math.random() * 10).toFixed(8).toString()\n  }\n\n  return retId\n}\n"]}