mirror of
				https://github.com/Xahau/xahau.js.git
				synced 2025-11-04 04:55:48 +00:00 
			
		
		
		
	- Removes need for bundlers to polyfill the `Buffer` class. `UInt8Array` are used instead which are native to the browser and node. - Reduces bundle size 7.1kb gzipped and eliminates 4 runtime dependencies: `base-x`, `base64-js`, `buffer`, and `ieee754`. BREAKING CHANGE: All methods that previously took a `Buffer` now accept a `UInt8Array`. --------- Co-authored-by: Jackson Mills <jmills@ripple.com>
		
			
				
	
	
		
			33 lines
		
	
	
		
			939 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			939 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { stringToHex, hexToString } from '@xrplf/isomorphic/utils'
 | 
						|
 | 
						|
/**
 | 
						|
 * Converts a string to its hex equivalent. Useful for Memos.
 | 
						|
 *
 | 
						|
 * @param string - The string to convert to Hex.
 | 
						|
 * @returns The Hex equivalent of the string.
 | 
						|
 *
 | 
						|
 * @deprecated use `@xrplf/isomorphic/utils`'s `stringToHex`
 | 
						|
 *
 | 
						|
 * @category Utilities
 | 
						|
 */
 | 
						|
function convertStringToHex(string: string): string {
 | 
						|
  return stringToHex(string)
 | 
						|
}
 | 
						|
 | 
						|
/**
 | 
						|
 * Converts hex to its string equivalent. Useful to read the Domain field and some Memos.
 | 
						|
 *
 | 
						|
 * @param hex - The hex to convert to a string.
 | 
						|
 * @param encoding - The encoding to use. Defaults to 'utf8' (UTF-8). 'ascii' is also allowed.
 | 
						|
 * @returns The converted string.
 | 
						|
 *
 | 
						|
 * @deprecated use `@xrplf/isomorphic/utils`'s `hexToString`
 | 
						|
 *
 | 
						|
 * @category Utilities
 | 
						|
 */
 | 
						|
function convertHexToString(hex: string, encoding = 'utf8'): string {
 | 
						|
  return hexToString(hex, encoding)
 | 
						|
}
 | 
						|
 | 
						|
export { convertHexToString, convertStringToHex }
 |