Review fixes

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-03-04 14:32:33 -05:00
parent da5e1b2b57
commit 32a5cfe584
2 changed files with 15 additions and 8 deletions

View File

@ -4,6 +4,7 @@ define(function(require) {
var WSQL_VERSION = require('src/constants').WSQL_VERSION; var WSQL_VERSION = require('src/constants').WSQL_VERSION;
var WSQL_SIZE = require('src/constants').WSQL_SIZE; var WSQL_SIZE = require('src/constants').WSQL_SIZE;
var WSQL_DESC = require('src/constants').WSQL_DESC; var WSQL_DESC = require('src/constants').WSQL_DESC;
var u8toArray = require('src/shared').u8toArray;
function WebSQLContext(db, isReadOnly) { function WebSQLContext(db, isReadOnly) {
var that = this; var that = this;
@ -62,14 +63,7 @@ define(function(require) {
if(Object.prototype.toString.call(value) === "[object Uint8Array]") { if(Object.prototype.toString.call(value) === "[object Uint8Array]") {
value = { value = {
__isUint8Array: true, __isUint8Array: true,
__array: (function() { __array: u8toArray(value)
var array = [];
var vlen = value.length;
for(var i = 0; i < vlen; i++) {
array[i] = value[i];
}
return array;
}())
}; };
} }
value = JSON.stringify(value); value = JSON.stringify(value);

View File

@ -15,9 +15,22 @@ define(function(require) {
function nop() {} function nop() {}
/**
* Convert a Uint8Array to a regular array
*/
function u8toArray(u8) {
var array = [];
var len = u8.length;
for(var i = 0; i < len; i++) {
array[i] = u8[i];
}
return array;
}
return { return {
guid: guid, guid: guid,
hash: hash, hash: hash,
u8toArray: u8toArray,
nop: nop nop: nop
}; };