Update husky
parent
a05657a4ca
commit
60ab6e6f3c
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npm test
|
||||||
|
|
@ -196693,18 +196693,10 @@ module.exports = eval("require")("utf-8-validate");
|
||||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||||
|
|
||||||
let crypto = __webpack_require__(33373)
|
let crypto = __webpack_require__(33373)
|
||||||
|
|
||||||
let { urlAlphabet } = __webpack_require__(53861)
|
let { urlAlphabet } = __webpack_require__(53861)
|
||||||
|
const POOL_SIZE_MULTIPLIER = 128
|
||||||
// It is best to make fewer, larger requests to the crypto module to
|
|
||||||
// avoid system call overhead. So, random numbers are generated in a
|
|
||||||
// pool. The pool is a Buffer that is larger than the initial random
|
|
||||||
// request size by this multiplier. The pool is enlarged if subsequent
|
|
||||||
// requests exceed the maximum buffer size.
|
|
||||||
const POOL_SIZE_MULTIPLIER = 32
|
|
||||||
let pool, poolOffset
|
let pool, poolOffset
|
||||||
|
let fillPool = bytes => {
|
||||||
let random = bytes => {
|
|
||||||
if (!pool || pool.length < bytes) {
|
if (!pool || pool.length < bytes) {
|
||||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
||||||
crypto.randomFillSync(pool)
|
crypto.randomFillSync(pool)
|
||||||
|
|
@ -196713,64 +196705,36 @@ let random = bytes => {
|
||||||
crypto.randomFillSync(pool)
|
crypto.randomFillSync(pool)
|
||||||
poolOffset = 0
|
poolOffset = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = pool.subarray(poolOffset, poolOffset + bytes)
|
|
||||||
poolOffset += bytes
|
poolOffset += bytes
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
let random = bytes => {
|
||||||
|
fillPool(bytes)
|
||||||
|
return pool.subarray(poolOffset - bytes, poolOffset)
|
||||||
|
}
|
||||||
let customRandom = (alphabet, size, getRandom) => {
|
let customRandom = (alphabet, size, getRandom) => {
|
||||||
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
|
||||||
// values closer to the alphabet size. The bitmask calculates the closest
|
|
||||||
// `2^31 - 1` number, which exceeds the alphabet size.
|
|
||||||
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
||||||
// Though, the bitmask solution is not perfect since the bytes exceeding
|
|
||||||
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
|
||||||
// the random bytes redundancy has to be satisfied.
|
|
||||||
|
|
||||||
// Note: every hardware random generator call is performance expensive,
|
|
||||||
// because the system call for entropy collection takes a lot of time.
|
|
||||||
// So, to avoid additional system calls, extra bytes are requested in advance.
|
|
||||||
|
|
||||||
// Next, a step determines how many random bytes to generate.
|
|
||||||
// The number of random bytes gets decided upon the ID size, mask,
|
|
||||||
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
|
||||||
// according to benchmarks).
|
|
||||||
let step = Math.ceil((1.6 * mask * size) / alphabet.length)
|
let step = Math.ceil((1.6 * mask * size) / alphabet.length)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
let id = ''
|
let id = ''
|
||||||
while (true) {
|
while (true) {
|
||||||
let bytes = getRandom(step)
|
let bytes = getRandom(step)
|
||||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
||||||
let i = step
|
let i = step
|
||||||
while (i--) {
|
while (i--) {
|
||||||
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
id += alphabet[bytes[i] & mask] || ''
|
||||||
if (id.length === size) return id
|
if (id.length === size) return id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)
|
let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)
|
||||||
|
|
||||||
let nanoid = (size = 21) => {
|
let nanoid = (size = 21) => {
|
||||||
let bytes = random(size)
|
fillPool(size)
|
||||||
let id = ''
|
let id = ''
|
||||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
for (let i = poolOffset - size; i < poolOffset; i++) {
|
||||||
while (size--) {
|
id += urlAlphabet[pool[i] & 63]
|
||||||
// It is incorrect to use bytes exceeding the alphabet size.
|
|
||||||
// The following mask reduces the random byte in the 0-255 value
|
|
||||||
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
||||||
// as empty string fallback or magic numbers, is unneccessary because
|
|
||||||
// the bitmask trims bytes down to the alphabet size.
|
|
||||||
id += urlAlphabet[bytes[size] & 63]
|
|
||||||
}
|
}
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -196779,11 +196743,8 @@ module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
||||||
/***/ 53861:
|
/***/ 53861:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
|
|
||||||
// optimize the gzip compression for this alphabet.
|
|
||||||
let urlAlphabet =
|
let urlAlphabet =
|
||||||
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'
|
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||||
|
|
||||||
module.exports = { urlAlphabet }
|
module.exports = { urlAlphabet }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
|
@ -11,7 +11,8 @@
|
||||||
"build": "tsc && ncc build lib --source-map --license licenses.txt",
|
"build": "tsc && ncc build lib --source-map --license licenses.txt",
|
||||||
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
|
"lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
|
||||||
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
"format": "prettier --write \"src/**/*.{js,ts}\"",
|
||||||
"test": "jest"
|
"test": "jest",
|
||||||
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
|
|
@ -20,7 +21,7 @@
|
||||||
"aws-sdk": "^2.812.0",
|
"aws-sdk": "^2.812.0",
|
||||||
"base-64": "^1.0.0",
|
"base-64": "^1.0.0",
|
||||||
"kubernetes-client": "^9.0.0",
|
"kubernetes-client": "^9.0.0",
|
||||||
"nanoid": "3.1.20",
|
"nanoid": "^3.1.20",
|
||||||
"semver": "^7.3.5"
|
"semver": "^7.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -35,7 +36,7 @@
|
||||||
"eslint-plugin-jest": "^24.1.3",
|
"eslint-plugin-jest": "^24.1.3",
|
||||||
"eslint-plugin-prettier": "^3.3.1",
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
"eslint-plugin-unicorn": "^28.0.2",
|
"eslint-plugin-unicorn": "^28.0.2",
|
||||||
"husky": "4.2.5",
|
"husky": "^7.0.4",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-circus": "^26.6.3",
|
"jest-circus": "^26.6.3",
|
||||||
"js-yaml": "^3.14.0",
|
"js-yaml": "^3.14.0",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue