@tadashi/mask
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -1,2 +0,3 @@ | ||
import hexID from '@tadashi/hex-id'; | ||
let _cc = 0; | ||
const _id = () => `c_${Math.trunc(Date.now() / 1000)}_${_cc++ & 0xFF}`; | ||
@@ -79,3 +80,3 @@ const map = new Map(); | ||
// Storage instance | ||
this.input[GUID] = hexID(); | ||
this.input[GUID] = _id(); | ||
instances.set(this.input[GUID], this); | ||
@@ -82,0 +83,0 @@ } |
@@ -6,80 +6,5 @@ (function (global, factory) { | ||
}(this, (function () { | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
let _cc = 0; | ||
const _id = () => `c_${Math.trunc(Date.now() / 1000)}_${_cc++ & 0xFF}`; | ||
function createCommonjsModule(fn, basedir, module) { | ||
return module = { | ||
path: basedir, | ||
exports: {}, | ||
require: function (path, base) { | ||
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); | ||
} | ||
}, fn(module, module.exports), module.exports; | ||
} | ||
function commonjsRequire () { | ||
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); | ||
} | ||
var index_umd = createCommonjsModule(function (module, exports) { | ||
(function (global, factory) { | ||
module.exports = factory() ; | ||
}(commonjsGlobal, (function () { | ||
/* globals globalThis */ | ||
const PROCESS_UNIQUE = (typeof globalThis.process === 'object' && globalThis.process.pid) || globalThis.crypto.getRandomValues(new Uint8Array(5)); | ||
let cc = Math.floor(Math.random() * 0xFFFFFF); | ||
function _next() { | ||
cc += 1 % 0xFFFFFF; | ||
return cc | ||
} | ||
function _toHex(view) { | ||
const arr = []; | ||
const len = view.byteLength; | ||
for (let i = 0; i < len; i++) { | ||
arr.push(view.getUint8(i).toString(16).padStart(2, '0')); | ||
} | ||
return arr.join('') | ||
} | ||
/** | ||
* Generate an ID (24 character hex string) | ||
* | ||
* @returns {string} returns a valid 24 character ObjectID hex string. | ||
*/ | ||
function hexID() { | ||
const time = ~~(Date.now() / 1000); | ||
const inc = _next(); | ||
const buffer = new ArrayBuffer(12); | ||
const view = new DataView(buffer); | ||
// 4-byte timestamp | ||
view.setUint8(3, time & 0xFF); | ||
view.setUint8(2, (time >> 8) & 0xFF); | ||
view.setUint8(1, (time >> 16) & 0xFF); | ||
view.setUint8(0, (time >> 24) & 0xFF); | ||
// 5-byte process unique | ||
view.setUint8(4, PROCESS_UNIQUE[0]); | ||
view.setUint8(5, PROCESS_UNIQUE[1]); | ||
view.setUint8(6, PROCESS_UNIQUE[2]); | ||
view.setUint8(7, PROCESS_UNIQUE[3]); | ||
view.setUint8(8, PROCESS_UNIQUE[4]); | ||
// 3-byte counter | ||
view.setUint8(11, inc & 0xFF); | ||
view.setUint8(10, (inc >> 8) & 0xFF); | ||
view.setUint8(9, (inc >> 16) & 0xFF); | ||
return _toHex(view) | ||
} | ||
return hexID; | ||
}))); | ||
}); | ||
const map = new Map(); | ||
@@ -161,3 +86,3 @@ map.set('9', /\d/); | ||
// Storage instance | ||
this.input[GUID] = index_umd(); | ||
this.input[GUID] = _id(); | ||
instances.set(this.input[GUID], this); | ||
@@ -164,0 +89,0 @@ } |
{ | ||
"name": "@tadashi/mask", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "The simple and tiny script for input mask", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
22386
261