code refactoring

This commit is contained in:
Rodolphe Breard 2013-02-27 15:37:08 +01:00
parent e78c5f919e
commit 5ee9143b71
12 changed files with 445 additions and 246 deletions

21
third-party/ab-str.js vendored
View file

@ -1,21 +0,0 @@
//
// Renato Mangini
// http://updates.html5rocks.com/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
// http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
//
// Edited by Rodolphe Breard
// - Using Uint8Array instead of Uint16Array
//
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
}
function str2ab(str) {
var buf = new ArrayBuffer(str.length);
var bufView = new Uint8Array(buf);
for (var i=0, strLen=str.length; i<strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
}