victor-dev-toolbox
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -1121,3 +1121,3 @@ interface CountryInterface { | ||
declare function timeStampHasExpired(id: string, seconds: number): boolean; | ||
declare function generateRandomString(length: number): string; | ||
declare function generateRandomString(len?: number): string; | ||
@@ -1124,0 +1124,0 @@ /** |
{ | ||
"name": "victor-dev-toolbox", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "", | ||
@@ -20,2 +20,3 @@ "main": "./dist/index.js", | ||
"@types/qrcode": "^1.5.5", | ||
"javascript-obfuscator": "^4.1.1", | ||
"tsup": "^8.1.0", | ||
@@ -22,0 +23,0 @@ "typescript": "^5.4.5" |
@@ -9,6 +9,7 @@ import { API_NotificationInterface, API_ResponseInterface, FieldValueInterface, NotificationTypes } from "../interfaces"; | ||
export function prepareApiResponse(response: Partial<API_ResponseInterface>): API_ResponseInterface { | ||
const { data, notification, statusCode } = response; | ||
return { | ||
data: response.data, | ||
notification: response.notification, | ||
statusCode: response.statusCode, | ||
data, | ||
notification, | ||
statusCode, | ||
}; | ||
@@ -15,0 +16,0 @@ } |
@@ -111,1 +111,2 @@ /* eslint-disable prettier/prettier */ | ||
import { generateRandomNumber } from "./numbers.functions"; | ||
const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
// const characters = chars; | ||
@@ -25,2 +26,15 @@ | ||
export function generateUniqueId(): string { | ||
let id = generateId(); | ||
// Keep generating a new ID if the current one contains profanity | ||
// while (hasProfanity(id)) { | ||
// id = generateId(); | ||
// } | ||
return id; | ||
} | ||
function generateId() { | ||
const date = new Date().toString(); | ||
@@ -44,3 +58,2 @@ const now = new Date(date).getTime(); | ||
// const randomPart1 = generateRandomString(6); | ||
// const randomPart2 = generateRandomString(6); | ||
const validationPart = createValidationPart(date) | ||
@@ -94,2 +107,4 @@ | ||
function createValidationPart(timeStamp: string): string { | ||
// | ||
@@ -104,4 +119,6 @@ const time = new Date(timeStamp).getTime(); | ||
const randomPart = generateRandomString(6); | ||
const randomPart2 = generateRandomString(6); | ||
const validationPart = `${remainder}_${base}_${randomPart}`; | ||
const validationPart = `${remainder}_${base}_${randomPart}_${randomPart2}`; | ||
return validationPart; | ||
@@ -120,3 +137,5 @@ | ||
export function generateRandomString(length: number): string { | ||
export function generateRandomString(len?: number): string { | ||
const randomNumber = generateRandomNumber({ from: 6, to: 9 }); | ||
const length = len || randomNumber; | ||
let result = ''; | ||
@@ -123,0 +142,0 @@ const charactersLength = characters.length; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
479781
70
10037
5