Skip to content

Commit

Permalink
feat: Added util.generateOrderUniqueId function
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Aug 31, 2023
1 parent 20e88c4 commit 53aa925
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/util/generateOrderUniqueId.ts
@@ -0,0 +1,28 @@
/*!
* Copyright 2023 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export function generateOrderUniqueId(): string {
const timestamp = String(Date.now());
const randomPart = Math.random().toFixed(4).slice(-4);
const combinedValue = timestamp + randomPart;

const uniqueId =
typeof BigInt === 'function'
? BigInt(combinedValue)
: Number(combinedValue);

return uniqueId.toString(36).toUpperCase();
}
1 change: 1 addition & 0 deletions src/util/index.ts
Expand Up @@ -21,6 +21,7 @@ export * from './createWid';
export * from './downloadImage';
export * from './errors';
export * from './fetchDataFromPNG';
export * from './generateOrderUniqueId';
export * from './getVideoInfoFromBuffer';
export * from './isBase64';
export * from './resizeImage';
Expand Down

0 comments on commit 53aa925

Please sign in to comment.