cafe-utility 10.28.1 → 10.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -0
- package/index.js +7 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ declare function randomLetterString(length: number, generator?: () => number): s
|
|
|
58
58
|
declare function randomAlphanumericString(length: number, generator?: () => number): string;
|
|
59
59
|
declare function randomRichAsciiString(length: number, generator?: () => number): string;
|
|
60
60
|
declare function randomUnicodeString(length: number, generator?: () => number): string;
|
|
61
|
+
declare function searchHex(string: string, length: number): string | null;
|
|
61
62
|
declare function randomHexString(length: number, generator?: () => number): string;
|
|
62
63
|
declare function asString(string: any): string;
|
|
63
64
|
declare function asNumber(number: any): number;
|
|
@@ -569,6 +570,7 @@ export declare const Types: {
|
|
|
569
570
|
export declare const Strings: {
|
|
570
571
|
tokenizeByCount: typeof tokenizeByCount;
|
|
571
572
|
tokenizeByLength: typeof tokenizeByLength;
|
|
573
|
+
searchHex: typeof searchHex;
|
|
572
574
|
randomHex: typeof randomHexString;
|
|
573
575
|
randomLetter: typeof randomLetterString;
|
|
574
576
|
randomAlphanumeric: typeof randomAlphanumericString;
|
package/index.js
CHANGED
|
@@ -439,6 +439,12 @@ function randomUnicodeString(length, generator = Math.random) {
|
|
|
439
439
|
return buffer
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
+
function searchHex(string, length) {
|
|
443
|
+
const regex = new RegExp(`[0-9a-f]{${length}}`, 'i')
|
|
444
|
+
const match = string.match(regex)
|
|
445
|
+
return match ? match[0] : null
|
|
446
|
+
}
|
|
447
|
+
|
|
442
448
|
function randomHexString(length, generator = Math.random) {
|
|
443
449
|
let buffer = ''
|
|
444
450
|
for (let i = 0; i < length; i++) {
|
|
@@ -3002,6 +3008,7 @@ exports.Types = {
|
|
|
3002
3008
|
exports.Strings = {
|
|
3003
3009
|
tokenizeByCount,
|
|
3004
3010
|
tokenizeByLength,
|
|
3011
|
+
searchHex,
|
|
3005
3012
|
randomHex: randomHexString,
|
|
3006
3013
|
randomLetter: randomLetterString,
|
|
3007
3014
|
randomAlphanumeric: randomAlphanumericString,
|