Работа над BookManager

This commit is contained in:
Book Pauk
2019-01-14 02:41:35 +07:00
parent 4e336c6c6d
commit 25441262b9
2 changed files with 62 additions and 25 deletions

View File

@@ -1,3 +1,19 @@
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export function stringToHex(str) {
let result = '';
for (let i = 0; i < str.length; i++) {
result += str.charCodeAt(i).toString(16);
}
return result;
}
export function hexToString(str) {
let result = '';
for (let i = 0; i < str.length; i += 2) {
result += String.fromCharCode(parseInt(str.substr(i, 2), 16));
}
return result;
}