svelte-countup
Advanced tools
Comparing version 0.2.3 to 0.2.4
104
lib/index.js
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('crypto')) : | ||
typeof define === 'function' && define.amd ? define(['crypto'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.CountUp = factory(global.crypto)); | ||
})(this, (function (crypto) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.CountUp = factory()); | ||
})(this, (function () { 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto); | ||
function noop() { } | ||
@@ -280,24 +276,76 @@ function run(fn) { | ||
let urlAlphabet = | ||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'; | ||
// Unique ID creation requires a high quality random # generator. In the browser we therefore | ||
// require the crypto API and do not support built-in fallback to lower quality random number | ||
// generators (like Math.random()). | ||
var getRandomValues; | ||
var rnds8 = new Uint8Array(16); | ||
function rng() { | ||
// lazy load so that environments that need to polyfill have a chance to do so | ||
if (!getRandomValues) { | ||
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, | ||
// find the complete implementation of crypto (msCrypto) on IE11. | ||
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); | ||
let random = bytes => | ||
new Promise((resolve, reject) => { | ||
crypto__default["default"].randomFill(Buffer.allocUnsafe(bytes), (err, buf) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(buf); | ||
} | ||
}); | ||
}); | ||
let nanoid = (size = 21) => | ||
random(size).then(bytes => { | ||
let id = ''; | ||
while (size--) { | ||
id += urlAlphabet[bytes[size] & 63]; | ||
if (!getRandomValues) { | ||
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); | ||
} | ||
return id | ||
}); | ||
} | ||
return getRandomValues(rnds8); | ||
} | ||
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; | ||
function validate(uuid) { | ||
return typeof uuid === 'string' && REGEX.test(uuid); | ||
} | ||
/** | ||
* Convert array of 16 byte values to UUID string format of the form: | ||
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | ||
*/ | ||
var byteToHex = []; | ||
for (var i = 0; i < 256; ++i) { | ||
byteToHex.push((i + 0x100).toString(16).substr(1)); | ||
} | ||
function stringify(arr) { | ||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
// Note: Be careful editing this code! It's been tuned for performance | ||
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 | ||
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one | ||
// of the following: | ||
// - One or more input array values don't map to a hex octet (leading to | ||
// "undefined" in the uuid) | ||
// - Invalid input values for the RFC `version` or `variant` fields | ||
if (!validate(uuid)) { | ||
throw TypeError('Stringified UUID is invalid'); | ||
} | ||
return uuid; | ||
} | ||
function v4(options, buf, offset) { | ||
options = options || {}; | ||
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` | ||
rnds[6] = rnds[6] & 0x0f | 0x40; | ||
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided | ||
if (buf) { | ||
offset = offset || 0; | ||
for (var i = 0; i < 16; ++i) { | ||
buf[offset + i] = rnds[i]; | ||
} | ||
return buf; | ||
} | ||
return stringify(rnds); | ||
} | ||
const defaultOptions = { | ||
@@ -416,3 +464,3 @@ root: null, | ||
function instance($$self, $$props, $$invalidate) { | ||
const id = nanoid(); | ||
const id = v4(); | ||
let isInView; | ||
@@ -419,0 +467,0 @@ let { value } = $$props; |
{ | ||
"name": "svelte-countup", | ||
"componentname": "CountUp", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"main": "lib/index.js", | ||
@@ -25,5 +25,5 @@ "module": "lib/index.mjs", | ||
"dependencies": { | ||
"nanoid": "^3.3.1", | ||
"svelte-inview": "^3.0.0" | ||
"svelte-inview": "^3.0.0", | ||
"uuid": "^8.3.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
40468
1018
+ Addeduuid@^8.3.2
+ Addeduuid@8.3.2(transitive)
- Removednanoid@^3.3.1
- Removednanoid@3.3.7(transitive)