-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(deploy-tasks): added recommendation
- Loading branch information
Crisgarner
committed
Jun 5, 2024
1 parent
3cc00dc
commit 76c5652
Showing
7 changed files
with
18 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,10 @@ | ||
import { parse as uuidParse, stringify as uuidStringify } from "uuid"; | ||
|
||
/** | ||
* Converts a byte array to a hex string. Opposite of fromHexString(). | ||
*/ | ||
export function toHexString(bytes: Uint8Array): string { | ||
return Buffer.from(bytes).toString("hex"); | ||
} | ||
|
||
/** | ||
* Converts a hex string to a byte-array. Opposite of toHexString(). | ||
*/ | ||
export function fromHexString(hexString: string): Buffer { | ||
return Buffer.from(hexString, "hex"); | ||
} | ||
|
||
/** | ||
* Converts a number (as decimal string) to a UUID (as string) in the | ||
* format of uuid.stringify. | ||
*/ | ||
export function decStringToBigIntToUuid(value: string): string { | ||
let hexStr = BigInt(value).toString(16); | ||
while (hexStr.length < 32) { | ||
hexStr = `0${hexStr}`; | ||
} | ||
const buf = Buffer.from(hexStr, "hex"); | ||
return uuidStringify(buf); | ||
} | ||
import { parse as uuidParse } from "uuid"; | ||
|
||
/** | ||
* Converts a UUID string into a bigint. | ||
*/ | ||
export function uuidToBigInt(v: string): bigint { | ||
// a uuid is just a particular representation of 16 bytes | ||
const bytes: Uint8Array = uuidParse(v); | ||
const hex = `0x${Buffer.from(bytes).toString("hex")}`; | ||
return BigInt(hex); | ||
const bytes = uuidParse(v); | ||
return BigInt(`0x${Buffer.from(bytes).toString("hex")}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters