first commit
This commit is contained in:
128
node_modules/cuid/dist/cuid.js
generated
vendored
Normal file
128
node_modules/cuid/dist/cuid.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.cuid = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||
/**
|
||||
* cuid.js
|
||||
* Collision-resistant UID generator for browsers and node.
|
||||
* Sequential for fast db lookups and recency sorting.
|
||||
* Safe for element IDs and server-side lookups.
|
||||
*
|
||||
* Extracted from CLCTR
|
||||
*
|
||||
* Copyright (c) Eric Elliott 2012
|
||||
* MIT License
|
||||
*/
|
||||
|
||||
var fingerprint = require('./lib/fingerprint.js');
|
||||
var pad = require('./lib/pad.js');
|
||||
var getRandomValue = require('./lib/getRandomValue.js');
|
||||
|
||||
var c = 0,
|
||||
blockSize = 4,
|
||||
base = 36,
|
||||
discreteValues = Math.pow(base, blockSize);
|
||||
|
||||
function randomBlock () {
|
||||
return pad((getRandomValue() *
|
||||
discreteValues << 0)
|
||||
.toString(base), blockSize);
|
||||
}
|
||||
|
||||
function safeCounter () {
|
||||
c = c < discreteValues ? c : 0;
|
||||
c++; // this is not subliminal
|
||||
return c - 1;
|
||||
}
|
||||
|
||||
function cuid () {
|
||||
// Starting with a lowercase letter makes
|
||||
// it HTML element ID friendly.
|
||||
var letter = 'c', // hard-coded allows for sequential access
|
||||
|
||||
// timestamp
|
||||
// warning: this exposes the exact date and time
|
||||
// that the uid was created.
|
||||
timestamp = (new Date().getTime()).toString(base),
|
||||
|
||||
// Prevent same-machine collisions.
|
||||
counter = pad(safeCounter().toString(base), blockSize),
|
||||
|
||||
// A few chars to generate distinct ids for different
|
||||
// clients (so different computers are far less
|
||||
// likely to generate the same id)
|
||||
print = fingerprint(),
|
||||
|
||||
// Grab some more chars from Math.random()
|
||||
random = randomBlock() + randomBlock();
|
||||
|
||||
return letter + timestamp + counter + print + random;
|
||||
}
|
||||
|
||||
cuid.slug = function slug () {
|
||||
var date = new Date().getTime().toString(36),
|
||||
counter = safeCounter().toString(36).slice(-4),
|
||||
print = fingerprint().slice(0, 1) +
|
||||
fingerprint().slice(-1),
|
||||
random = randomBlock().slice(-2);
|
||||
|
||||
return date.slice(-2) +
|
||||
counter + print + random;
|
||||
};
|
||||
|
||||
cuid.isCuid = function isCuid (stringToCheck) {
|
||||
if (typeof stringToCheck !== 'string') return false;
|
||||
if (stringToCheck.startsWith('c')) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
cuid.isSlug = function isSlug (stringToCheck) {
|
||||
if (typeof stringToCheck !== 'string') return false;
|
||||
var stringLength = stringToCheck.length;
|
||||
if (stringLength >= 7 && stringLength <= 10) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
cuid.fingerprint = fingerprint;
|
||||
|
||||
module.exports = cuid;
|
||||
|
||||
},{"./lib/fingerprint.js":2,"./lib/getRandomValue.js":3,"./lib/pad.js":4}],2:[function(require,module,exports){
|
||||
var pad = require('./pad.js');
|
||||
|
||||
var env = typeof window === 'object' ? window : self;
|
||||
var globalCount = Object.keys(env).length;
|
||||
var mimeTypesLength = navigator.mimeTypes ? navigator.mimeTypes.length : 0;
|
||||
var clientId = pad((mimeTypesLength +
|
||||
navigator.userAgent.length).toString(36) +
|
||||
globalCount.toString(36), 4);
|
||||
|
||||
module.exports = function fingerprint () {
|
||||
return clientId;
|
||||
};
|
||||
|
||||
},{"./pad.js":4}],3:[function(require,module,exports){
|
||||
|
||||
var getRandomValue;
|
||||
|
||||
var crypto = typeof window !== 'undefined' &&
|
||||
(window.crypto || window.msCrypto) ||
|
||||
typeof self !== 'undefined' &&
|
||||
self.crypto;
|
||||
|
||||
if (crypto) {
|
||||
var lim = Math.pow(2, 32) - 1;
|
||||
getRandomValue = function () {
|
||||
return Math.abs(crypto.getRandomValues(new Uint32Array(1))[0] / lim);
|
||||
};
|
||||
} else {
|
||||
getRandomValue = Math.random;
|
||||
}
|
||||
|
||||
module.exports = getRandomValue;
|
||||
|
||||
},{}],4:[function(require,module,exports){
|
||||
module.exports = function pad (num, size) {
|
||||
var s = '000000000' + num;
|
||||
return s.substr(s.length - size);
|
||||
};
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
1
node_modules/cuid/dist/cuid.min.js
generated
vendored
Normal file
1
node_modules/cuid/dist/cuid.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).cuid=e()}}(function(){return function o(f,u,s){function a(n,e){if(!u[n]){if(!f[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(l)return l(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var i=u[n]={exports:{}};f[n][0].call(i.exports,function(e){return a(f[n][1][e]||e)},i,i.exports,o,f,u,s)}return u[n].exports}for(var l="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,n,t){var i=e("./lib/fingerprint.js"),r=e("./lib/pad.js"),o=e("./lib/getRandomValue.js"),f=0,u=4,s=36,a=Math.pow(s,u);function l(){return r((o()*a<<0).toString(s),u)}function d(){return f=f<a?f:0,++f-1}function p(){return"c"+(new Date).getTime().toString(s)+r(d().toString(s),u)+i()+(l()+l())}p.slug=function(){var e=(new Date).getTime().toString(36),n=d().toString(36).slice(-4),t=i().slice(0,1)+i().slice(-1),r=l().slice(-2);return e.slice(-2)+n+t+r},p.isCuid=function(e){return"string"==typeof e&&!!e.startsWith("c")},p.isSlug=function(e){if("string"!=typeof e)return!1;var n=e.length;return 7<=n&&n<=10},p.fingerprint=i,n.exports=p},{"./lib/fingerprint.js":2,"./lib/getRandomValue.js":3,"./lib/pad.js":4}],2:[function(e,n,t){var r=e("./pad.js"),i="object"==typeof window?window:self,o=Object.keys(i).length,f=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+o.toString(36),4);n.exports=function(){return f}},{"./pad.js":4}],3:[function(e,n,t){var r,i="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(i){var o=Math.pow(2,32)-1;r=function(){return Math.abs(i.getRandomValues(new Uint32Array(1))[0]/o)}}else r=Math.random;n.exports=r},{}],4:[function(e,n,t){n.exports=function(e,n){var t="000000000"+e;return t.substr(t.length-n)}},{}]},{},[1])(1)});
|
||||
Reference in New Issue
Block a user