@universal-productions/lib-client-elrn-js
Version:
javascript library to interact with ardor elrn child chain
16 lines (15 loc) • 498 B
JavaScript
export default function stringToByteArray(str) {
return (!str) ?
Promise.reject(new Error('Please provide a valid input string')) :
new Promise((resolve, reject) => {
try {
str = unescape(encodeURIComponent(str)); //temporary
var bytes = new Array(str.length);
for (var i = 0; i < str.length; ++i)
bytes[i] = str.charCodeAt(i);
resolve(bytes);
} catch (err) {
reject(err);
}
});
};