From ab6b9d5e9b1b4ee9e06842d89d66ad360fa3394d Mon Sep 17 00:00:00 2001 From: Prasenjeet121 Date: Wed, 9 Sep 2020 10:13:16 +0530 Subject: [PATCH] added tests --- build/cjs/index.d.ts | 4 +- build/cjs/index.d.ts.map | 2 +- build/cjs/index.js | 114 ++++++++++++++++++++++++----- build/esm/index.d.ts | 4 +- build/esm/index.d.ts.map | 2 +- build/esm/index.js | 114 ++++++++++++++++++++++++----- build/iife/index-min.js | 2 +- coverage/clover.xml | 67 +++++++++-------- coverage/coverage-final.json | 2 +- coverage/lcov-report/index.html | 20 ++--- coverage/lcov-report/utils.js.html | 23 +++--- coverage/lcov.info | 89 +++++++++++----------- src/tests/utils.js | 2 +- 13 files changed, 299 insertions(+), 146 deletions(-) diff --git a/build/cjs/index.d.ts b/build/cjs/index.d.ts index c00100d..59cf8b8 100644 --- a/build/cjs/index.d.ts +++ b/build/cjs/index.d.ts @@ -1,5 +1,5 @@ import { DOMException, ArrayBufferView, IDBKeyRange, DOMStringList, IDBTransactionMode, IDBArrayKey, IDBValidKey, IDBCursor, IDBCursorDirection, IDBObjectStore, IDBTransaction, IDBObjectStoreParameters, IDBIndexParameters } from './main-interface'; -export declare function isIndexDbSupported(): boolean; +export declare function isIndexedDBSupported(): boolean; declare class IDBTransactionWrapper { private IDBTransaction; /** Returns the transaction's connection. */ @@ -228,7 +228,7 @@ declare class IDBCursorWrapper { /** * Advances the cursor to the next record in range matching or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index. */ - continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): Promise; + continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): Promise; /** * Delete the record pointed at by the cursor with a new value. * diff --git a/build/cjs/index.d.ts.map b/build/cjs/index.d.ts.map index 4dc71c9..e9f6127 100644 --- a/build/cjs/index.d.ts.map +++ b/build/cjs/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"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UlE;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,GAAG;qBAEqB,GAAG;mBAAa,gBAAgB;;CASzE"} \ No newline at end of file diff --git a/build/cjs/index.js b/build/cjs/index.js index d8509b6..3ac4f02 100644 --- a/build/cjs/index.js +++ b/build/cjs/index.js @@ -55,7 +55,7 @@ function __generator(thisArg, body) { } } -function isIndexDbSupported() { +function isIndexedDBSupported() { if (!window.indexedDB) { console.log("Your browser doesn't support a stable version of IndexedDB. some of the features will not be available."); return false; @@ -219,16 +219,41 @@ var IDBIndexWrapper = /** @class */ (function () { */ IDBIndexWrapper.prototype.openCursor = function (query, direction) { var _this = this; + var cursorWrapper = []; var request = this.IDBIndex.openCursor(query, direction); return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opening cursor on indexed object store called - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - console.log(event.target.result.value, 'hhhhhhhhh'); - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -238,14 +263,40 @@ var IDBIndexWrapper = /** @class */ (function () { IDBIndexWrapper.prototype.openKeyCursor = function (query, direction) { var _this = this; var request = this.IDBIndex.openKeyCursor(query, direction); + var cursorWrapper = []; return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opening key cursor on indexed object store called - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -499,10 +550,11 @@ var IDBObjectStoreWrapper = /** @class */ (function () { var curWrapper = cursorWrapper[cursorWrapper.length - 1]; if (new_cursor) { var insCursorWrapper = new IDBCursorWrapper(new_cursor); - cursorWrapper.push(insCursorWrapper); curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); } else { + // end of the cursor value is null curWrapper.cursorMoved(null, null); } } @@ -515,14 +567,40 @@ var IDBObjectStoreWrapper = /** @class */ (function () { IDBObjectStoreWrapper.prototype.openKeyCursor = function (query, direction) { var _this = this; var request = this.IDBObjectStore.openKeyCursor(query, direction); + var cursorWrapper = []; return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opeing the key cursor from the object store - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor no item to continue + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -589,7 +667,7 @@ var IDBDatabaseWrapper = /** @class */ (function () { /** Open the database connection to IndexDB */ function openDB(database_name, version, upgradeCallback) { return new Promise(function (resolve, reject) { - if (isIndexDbSupported()) { + if (isIndexedDBSupported()) { if (is_number_float(version)) { reject('Invalid Version Number | Only Integer is supported'); } @@ -690,15 +768,13 @@ var IDBCursorWrapper = /** @class */ (function () { */ IDBCursorWrapper.prototype.continuePrimaryKey = function (key, primaryKey) { return __awaiter(this, void 0, void 0, function () { + var _this = this; return __generator(this, function (_a) { - try { - this.IDBCursor.continuePrimaryKey(key, primaryKey); - return [2 /*return*/, new IDBCursorWrapper(this.IDBCursor)]; - } - catch (error) { - return [2 /*return*/, null]; - } - return [2 /*return*/]; + return [2 /*return*/, new Promise(function (resolve, reject) { + _this.cursor_movement_promise.reject = reject; + _this.cursor_movement_promise.resolve = resolve; + _this.IDBCursor.continuePrimaryKey(key, primaryKey); + })]; }); }); }; @@ -746,5 +822,5 @@ var IDBCursorWrapper = /** @class */ (function () { return IDBCursorWrapper; }()); -exports.isIndexDbSupported = isIndexDbSupported; +exports.isIndexedDBSupported = isIndexedDBSupported; exports.openDB = openDB; diff --git a/build/esm/index.d.ts b/build/esm/index.d.ts index c00100d..59cf8b8 100644 --- a/build/esm/index.d.ts +++ b/build/esm/index.d.ts @@ -1,5 +1,5 @@ import { DOMException, ArrayBufferView, IDBKeyRange, DOMStringList, IDBTransactionMode, IDBArrayKey, IDBValidKey, IDBCursor, IDBCursorDirection, IDBObjectStore, IDBTransaction, IDBObjectStoreParameters, IDBIndexParameters } from './main-interface'; -export declare function isIndexDbSupported(): boolean; +export declare function isIndexedDBSupported(): boolean; declare class IDBTransactionWrapper { private IDBTransaction; /** Returns the transaction's connection. */ @@ -228,7 +228,7 @@ declare class IDBCursorWrapper { /** * Advances the cursor to the next record in range matching or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index. */ - continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): Promise; + continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): Promise; /** * Delete the record pointed at by the cursor with a new value. * diff --git a/build/esm/index.d.ts.map b/build/esm/index.d.ts.map index 4dc71c9..e9f6127 100644 --- a/build/esm/index.d.ts.map +++ b/build/esm/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,wBAAwB,EACxB,kBAAkB,EACrB,MAAM,kBAAkB,CAAA;AAEzB,wBAAgB,kBAAkB,YAOjC;AAcD,cAAM,qBAAqB;IAiBX,OAAO,CAAC,cAAc;IAhBlC,4CAA4C;IAC5C,SAAgB,EAAE,EAAE,kBAAkB,CAAA;IAEtC,8FAA8F;IAC9F,SAAgB,KAAK,EAAE,YAAY,CAAA;IAEnC,oIAAoI;IACpI,SAAgB,IAAI,EAAE,kBAAkB,CAAA;IAExC,qJAAqJ;IACrJ,SAAgB,gBAAgB,EAAE,aAAa,CAAA;IAE/C,SAAgB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7C,SAAgB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAC7C,SAAgB,cAAc,EAAE,OAAO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AG,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAAC;gBAEvB,SAAS,EAAE,SAAS;IAalC,WAAW,CAAC,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAYjD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM;IAQ3B;;OAEG;IACG,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW;IAQhC;;OAEG;IACG,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW;IAQlE;;;;MAIE;IACI,MAAM;gBAEqB,IAAI;mBAAa,gBAAgB;;IAUlE;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,GAAG;qBAEqB,GAAG;mBAAa,gBAAgB;;CASzE"} \ No newline at end of file diff --git a/build/esm/index.js b/build/esm/index.js index 7c8b467..d08fff6 100644 --- a/build/esm/index.js +++ b/build/esm/index.js @@ -51,7 +51,7 @@ function __generator(thisArg, body) { } } -function isIndexDbSupported() { +function isIndexedDBSupported() { if (!window.indexedDB) { console.log("Your browser doesn't support a stable version of IndexedDB. some of the features will not be available."); return false; @@ -215,16 +215,41 @@ var IDBIndexWrapper = /** @class */ (function () { */ IDBIndexWrapper.prototype.openCursor = function (query, direction) { var _this = this; + var cursorWrapper = []; var request = this.IDBIndex.openCursor(query, direction); return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opening cursor on indexed object store called - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - console.log(event.target.result.value, 'hhhhhhhhh'); - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -234,14 +259,40 @@ var IDBIndexWrapper = /** @class */ (function () { IDBIndexWrapper.prototype.openKeyCursor = function (query, direction) { var _this = this; var request = this.IDBIndex.openKeyCursor(query, direction); + var cursorWrapper = []; return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opening key cursor on indexed object store called - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -495,10 +546,11 @@ var IDBObjectStoreWrapper = /** @class */ (function () { var curWrapper = cursorWrapper[cursorWrapper.length - 1]; if (new_cursor) { var insCursorWrapper = new IDBCursorWrapper(new_cursor); - cursorWrapper.push(insCursorWrapper); curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); } else { + // end of the cursor value is null curWrapper.cursorMoved(null, null); } } @@ -511,14 +563,40 @@ var IDBObjectStoreWrapper = /** @class */ (function () { IDBObjectStoreWrapper.prototype.openKeyCursor = function (query, direction) { var _this = this; var request = this.IDBObjectStore.openKeyCursor(query, direction); + var cursorWrapper = []; return new Promise(function (resolve, reject) { request.onerror = function (err) { err.preventDefault(); err.stopPropagation(); - reject(err + " - Error while opeing the key cursor from the object store - " + _this.name); + if (cursorWrapper.length === 0) { + reject(err + " - Error while opeing the cursor from the object store - " + _this.name); + } + else { + // notify the observer + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + curWrapper.cursorMoved(null, err); + } }; request.onsuccess = function (event) { - resolve(new IDBCursorWrapper(event.target.result)); + var new_cursor = event.target.result; + if (cursorWrapper.length === 0) { + // when no continue or advance is called + cursorWrapper.push(new IDBCursorWrapper(new_cursor)); + resolve(cursorWrapper[cursorWrapper.length - 1]); + } + else { + // when continue or advance is called this part will get called + var curWrapper = cursorWrapper[cursorWrapper.length - 1]; + if (new_cursor) { + var insCursorWrapper = new IDBCursorWrapper(new_cursor); + curWrapper.cursorMoved(insCursorWrapper, null); + cursorWrapper.push(insCursorWrapper); + } + else { + // end of the cursor no item to continue + curWrapper.cursorMoved(null, null); + } + } }; }); }; @@ -585,7 +663,7 @@ var IDBDatabaseWrapper = /** @class */ (function () { /** Open the database connection to IndexDB */ function openDB(database_name, version, upgradeCallback) { return new Promise(function (resolve, reject) { - if (isIndexDbSupported()) { + if (isIndexedDBSupported()) { if (is_number_float(version)) { reject('Invalid Version Number | Only Integer is supported'); } @@ -686,15 +764,13 @@ var IDBCursorWrapper = /** @class */ (function () { */ IDBCursorWrapper.prototype.continuePrimaryKey = function (key, primaryKey) { return __awaiter(this, void 0, void 0, function () { + var _this = this; return __generator(this, function (_a) { - try { - this.IDBCursor.continuePrimaryKey(key, primaryKey); - return [2 /*return*/, new IDBCursorWrapper(this.IDBCursor)]; - } - catch (error) { - return [2 /*return*/, null]; - } - return [2 /*return*/]; + return [2 /*return*/, new Promise(function (resolve, reject) { + _this.cursor_movement_promise.reject = reject; + _this.cursor_movement_promise.resolve = resolve; + _this.IDBCursor.continuePrimaryKey(key, primaryKey); + })]; }); }); }; @@ -742,4 +818,4 @@ var IDBCursorWrapper = /** @class */ (function () { return IDBCursorWrapper; }()); -export { isIndexDbSupported, openDB }; +export { isIndexedDBSupported, openDB }; diff --git a/build/iife/index-min.js b/build/iife/index-min.js index 0d9543a..dbc095c 100644 --- a/build/iife/index-min.js +++ b/build/iife/index-min.js @@ -12,4 +12,4 @@ var ipdb=function(e){"use strict"; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */function t(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}c((n=n.apply(e,t||[])).next())}))}function r(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1] - - - + + + - + - - + - - - - - - - + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - + - + - + - - - - + + + - - + + + diff --git a/coverage/coverage-final.json b/coverage/coverage-final.json index 3b6ac87..c5120c5 100644 --- a/coverage/coverage-final.json +++ b/coverage/coverage-final.json @@ -1,2 +1,2 @@ -{"C:\\Users\\Prasenjeet Symon\\Desktop\\lib\\prasenjeet-symon\\indexed-pdb\\src\\tests\\utils.js": {"path":"C:\\Users\\Prasenjeet Symon\\Desktop\\lib\\prasenjeet-symon\\indexed-pdb\\src\\tests\\utils.js","statementMap":{"0":{"start":{"line":2,"column":4},"end":{"line":2,"column":40}},"1":{"start":{"line":6,"column":4},"end":{"line":25,"column":6}},"2":{"start":{"line":7,"column":8},"end":{"line":24,"column":10}},"3":{"start":{"line":8,"column":12},"end":{"line":23,"column":13}},"4":{"start":{"line":9,"column":16},"end":{"line":20,"column":17}},"5":{"start":{"line":12,"column":49},"end":{"line":12,"column":128}},"6":{"start":{"line":13,"column":20},"end":{"line":17,"column":21}},"7":{"start":{"line":14,"column":24},"end":{"line":14,"column":42}},"8":{"start":{"line":16,"column":24},"end":{"line":16,"column":66}},"9":{"start":{"line":19,"column":20},"end":{"line":19,"column":82}},"10":{"start":{"line":22,"column":16},"end":{"line":22,"column":62}},"11":{"start":{"line":30,"column":21},"end":{"line":30,"column":56}},"12":{"start":{"line":31,"column":16},"end":{"line":31,"column":61}},"13":{"start":{"line":32,"column":30},"end":{"line":32,"column":57}},"14":{"start":{"line":33,"column":32},"end":{"line":33,"column":65}},"15":{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},"16":{"start":{"line":35,"column":8},"end":{"line":35,"column":34}},"17":{"start":{"line":37,"column":8},"end":{"line":37,"column":20}},"18":{"start":{"line":43,"column":21},"end":{"line":43,"column":56}},"19":{"start":{"line":44,"column":16},"end":{"line":44,"column":61}},"20":{"start":{"line":45,"column":30},"end":{"line":45,"column":57}},"21":{"start":{"line":46,"column":21},"end":{"line":46,"column":62}},"22":{"start":{"line":47,"column":4},"end":{"line":51,"column":5}},"23":{"start":{"line":48,"column":8},"end":{"line":48,"column":23}},"24":{"start":{"line":50,"column":8},"end":{"line":50,"column":19}},"25":{"start":{"line":55,"column":21},"end":{"line":55,"column":56}},"26":{"start":{"line":56,"column":16},"end":{"line":56,"column":61}},"27":{"start":{"line":57,"column":30},"end":{"line":57,"column":57}},"28":{"start":{"line":58,"column":36},"end":{"line":58,"column":69}},"29":{"start":{"line":59,"column":4},"end":{"line":63,"column":5}},"30":{"start":{"line":60,"column":8},"end":{"line":60,"column":38}},"31":{"start":{"line":62,"column":8},"end":{"line":62,"column":19}},"32":{"start":{"line":68,"column":21},"end":{"line":68,"column":56}},"33":{"start":{"line":69,"column":16},"end":{"line":69,"column":61}},"34":{"start":{"line":70,"column":30},"end":{"line":70,"column":57}},"35":{"start":{"line":71,"column":21},"end":{"line":71,"column":53}},"36":{"start":{"line":72,"column":4},"end":{"line":72,"column":19}},"37":{"start":{"line":77,"column":21},"end":{"line":77,"column":56}},"38":{"start":{"line":78,"column":16},"end":{"line":78,"column":61}},"39":{"start":{"line":79,"column":30},"end":{"line":79,"column":57}},"40":{"start":{"line":80,"column":26},"end":{"line":80,"column":69}},"41":{"start":{"line":81,"column":4},"end":{"line":81,"column":24}},"42":{"start":{"line":85,"column":21},"end":{"line":85,"column":56}},"43":{"start":{"line":86,"column":16},"end":{"line":86,"column":61}},"44":{"start":{"line":87,"column":30},"end":{"line":87,"column":57}},"45":{"start":{"line":88,"column":25},"end":{"line":88,"column":61}},"46":{"start":{"line":89,"column":4},"end":{"line":89,"column":23}},"47":{"start":{"line":93,"column":21},"end":{"line":93,"column":56}},"48":{"start":{"line":94,"column":16},"end":{"line":94,"column":61}},"49":{"start":{"line":95,"column":30},"end":{"line":95,"column":57}},"50":{"start":{"line":96,"column":21},"end":{"line":96,"column":23}},"51":{"start":{"line":97,"column":4},"end":{"line":104,"column":6}},"52":{"start":{"line":98,"column":8},"end":{"line":101,"column":9}},"53":{"start":{"line":99,"column":12},"end":{"line":99,"column":38}},"54":{"start":{"line":100,"column":12},"end":{"line":100,"column":18}},"55":{"start":{"line":102,"column":8},"end":{"line":102,"column":35}},"56":{"start":{"line":103,"column":8},"end":{"line":103,"column":47}},"57":{"start":{"line":106,"column":4},"end":{"line":106,"column":19}},"58":{"start":{"line":110,"column":0},"end":{"line":120,"column":1}}},"fnMap":{"0":{"name":"connect_to_database","decl":{"start":{"line":1,"column":15},"end":{"line":1,"column":34}},"loc":{"start":{"line":1,"column":50},"end":{"line":3,"column":1}},"line":1},"1":{"name":"create_new_table","decl":{"start":{"line":5,"column":9},"end":{"line":5,"column":25}},"loc":{"start":{"line":5,"column":53},"end":{"line":26,"column":1}},"line":5},"2":{"name":"(anonymous_2)","decl":{"start":{"line":6,"column":23},"end":{"line":6,"column":24}},"loc":{"start":{"line":6,"column":44},"end":{"line":25,"column":5}},"line":6},"3":{"name":"(anonymous_3)","decl":{"start":{"line":7,"column":38},"end":{"line":7,"column":39}},"loc":{"start":{"line":7,"column":59},"end":{"line":24,"column":9}},"line":7},"4":{"name":"add_new_single_row_to_table","decl":{"start":{"line":29,"column":15},"end":{"line":29,"column":42}},"loc":{"start":{"line":29,"column":76},"end":{"line":39,"column":1}},"line":29},"5":{"name":"read_single_row_from_table","decl":{"start":{"line":42,"column":15},"end":{"line":42,"column":41}},"loc":{"start":{"line":42,"column":82},"end":{"line":52,"column":1}},"line":42},"6":{"name":"update_single_row_to_table","decl":{"start":{"line":54,"column":15},"end":{"line":54,"column":41}},"loc":{"start":{"line":54,"column":75},"end":{"line":64,"column":1}},"line":54},"7":{"name":"get_all_rows_from_the_table","decl":{"start":{"line":67,"column":15},"end":{"line":67,"column":42}},"loc":{"start":{"line":67,"column":70},"end":{"line":73,"column":1}},"line":67},"8":{"name":"delete_single_row_from_table","decl":{"start":{"line":76,"column":15},"end":{"line":76,"column":43}},"loc":{"start":{"line":76,"column":84},"end":{"line":82,"column":1}},"line":76},"9":{"name":"add_multiple_rows_at_time","decl":{"start":{"line":84,"column":15},"end":{"line":84,"column":40}},"loc":{"start":{"line":84,"column":74},"end":{"line":90,"column":1}},"line":84},"10":{"name":"fetch_all_rows_using_cursor","decl":{"start":{"line":92,"column":15},"end":{"line":92,"column":42}},"loc":{"start":{"line":92,"column":70},"end":{"line":107,"column":1}},"line":92},"11":{"name":"get_item","decl":{"start":{"line":97,"column":55},"end":{"line":97,"column":63}},"loc":{"start":{"line":97,"column":71},"end":{"line":104,"column":5}},"line":97}},"branchMap":{"0":{"loc":{"start":{"line":8,"column":12},"end":{"line":23,"column":13}},"type":"if","locations":[{"start":{"line":8,"column":12},"end":{"line":23,"column":13}},{"start":{"line":8,"column":12},"end":{"line":23,"column":13}}],"line":8},"1":{"loc":{"start":{"line":9,"column":16},"end":{"line":20,"column":17}},"type":"if","locations":[{"start":{"line":9,"column":16},"end":{"line":20,"column":17}},{"start":{"line":9,"column":16},"end":{"line":20,"column":17}}],"line":9},"2":{"loc":{"start":{"line":13,"column":20},"end":{"line":17,"column":21}},"type":"if","locations":[{"start":{"line":13,"column":20},"end":{"line":17,"column":21}},{"start":{"line":13,"column":20},"end":{"line":17,"column":21}}],"line":13},"3":{"loc":{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},"type":"if","locations":[{"start":{"line":34,"column":4},"end":{"line":38,"column":5}},{"start":{"line":34,"column":4},"end":{"line":38,"column":5}}],"line":34},"4":{"loc":{"start":{"line":47,"column":4},"end":{"line":51,"column":5}},"type":"if","locations":[{"start":{"line":47,"column":4},"end":{"line":51,"column":5}},{"start":{"line":47,"column":4},"end":{"line":51,"column":5}}],"line":47},"5":{"loc":{"start":{"line":59,"column":4},"end":{"line":63,"column":5}},"type":"if","locations":[{"start":{"line":59,"column":4},"end":{"line":63,"column":5}},{"start":{"line":59,"column":4},"end":{"line":63,"column":5}}],"line":59},"6":{"loc":{"start":{"line":98,"column":8},"end":{"line":101,"column":9}},"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":101,"column":9}},{"start":{"line":98,"column":8},"end":{"line":101,"column":9}}],"line":98}},"s":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0]},"inputSourceMap":null,"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"186dd79bb229d0b1a0838f049246377be30768c7"} +{"C:\\Users\\Prasenjeet Symon\\Desktop\\lib\\prasenjeet-symon\\indexed-pdb\\src\\tests\\utils.js": {"path":"C:\\Users\\Prasenjeet Symon\\Desktop\\lib\\prasenjeet-symon\\indexed-pdb\\src\\tests\\utils.js","statementMap":{"0":{"start":{"line":2,"column":4},"end":{"line":2,"column":40}},"1":{"start":{"line":7,"column":4},"end":{"line":26,"column":6}},"2":{"start":{"line":8,"column":8},"end":{"line":25,"column":10}},"3":{"start":{"line":9,"column":12},"end":{"line":24,"column":13}},"4":{"start":{"line":10,"column":16},"end":{"line":21,"column":17}},"5":{"start":{"line":13,"column":49},"end":{"line":13,"column":128}},"6":{"start":{"line":14,"column":20},"end":{"line":18,"column":21}},"7":{"start":{"line":15,"column":24},"end":{"line":15,"column":42}},"8":{"start":{"line":17,"column":24},"end":{"line":17,"column":66}},"9":{"start":{"line":20,"column":20},"end":{"line":20,"column":82}},"10":{"start":{"line":23,"column":16},"end":{"line":23,"column":62}},"11":{"start":{"line":31,"column":21},"end":{"line":31,"column":56}},"12":{"start":{"line":32,"column":16},"end":{"line":32,"column":61}},"13":{"start":{"line":33,"column":30},"end":{"line":33,"column":57}},"14":{"start":{"line":34,"column":32},"end":{"line":34,"column":65}},"15":{"start":{"line":35,"column":4},"end":{"line":39,"column":5}},"16":{"start":{"line":36,"column":8},"end":{"line":36,"column":34}},"17":{"start":{"line":38,"column":8},"end":{"line":38,"column":20}},"18":{"start":{"line":44,"column":21},"end":{"line":44,"column":56}},"19":{"start":{"line":45,"column":16},"end":{"line":45,"column":61}},"20":{"start":{"line":46,"column":30},"end":{"line":46,"column":57}},"21":{"start":{"line":47,"column":21},"end":{"line":47,"column":62}},"22":{"start":{"line":48,"column":4},"end":{"line":52,"column":5}},"23":{"start":{"line":49,"column":8},"end":{"line":49,"column":23}},"24":{"start":{"line":51,"column":8},"end":{"line":51,"column":19}},"25":{"start":{"line":56,"column":21},"end":{"line":56,"column":56}},"26":{"start":{"line":57,"column":16},"end":{"line":57,"column":61}},"27":{"start":{"line":58,"column":30},"end":{"line":58,"column":57}},"28":{"start":{"line":59,"column":36},"end":{"line":59,"column":69}},"29":{"start":{"line":60,"column":4},"end":{"line":64,"column":5}},"30":{"start":{"line":61,"column":8},"end":{"line":61,"column":38}},"31":{"start":{"line":63,"column":8},"end":{"line":63,"column":19}},"32":{"start":{"line":69,"column":21},"end":{"line":69,"column":56}},"33":{"start":{"line":70,"column":16},"end":{"line":70,"column":61}},"34":{"start":{"line":71,"column":30},"end":{"line":71,"column":57}},"35":{"start":{"line":72,"column":21},"end":{"line":72,"column":53}},"36":{"start":{"line":73,"column":4},"end":{"line":73,"column":19}},"37":{"start":{"line":78,"column":21},"end":{"line":78,"column":56}},"38":{"start":{"line":79,"column":16},"end":{"line":79,"column":61}},"39":{"start":{"line":80,"column":30},"end":{"line":80,"column":57}},"40":{"start":{"line":81,"column":26},"end":{"line":81,"column":69}},"41":{"start":{"line":82,"column":4},"end":{"line":82,"column":24}},"42":{"start":{"line":86,"column":21},"end":{"line":86,"column":56}},"43":{"start":{"line":87,"column":16},"end":{"line":87,"column":61}},"44":{"start":{"line":88,"column":30},"end":{"line":88,"column":57}},"45":{"start":{"line":89,"column":25},"end":{"line":89,"column":61}},"46":{"start":{"line":90,"column":4},"end":{"line":90,"column":23}},"47":{"start":{"line":94,"column":21},"end":{"line":94,"column":56}},"48":{"start":{"line":95,"column":16},"end":{"line":95,"column":61}},"49":{"start":{"line":96,"column":30},"end":{"line":96,"column":57}},"50":{"start":{"line":97,"column":21},"end":{"line":97,"column":23}},"51":{"start":{"line":98,"column":4},"end":{"line":105,"column":6}},"52":{"start":{"line":99,"column":8},"end":{"line":102,"column":9}},"53":{"start":{"line":101,"column":12},"end":{"line":101,"column":18}},"54":{"start":{"line":103,"column":8},"end":{"line":103,"column":35}},"55":{"start":{"line":104,"column":8},"end":{"line":104,"column":47}},"56":{"start":{"line":107,"column":4},"end":{"line":107,"column":19}},"57":{"start":{"line":111,"column":0},"end":{"line":121,"column":1}}},"fnMap":{"0":{"name":"connect_to_database","decl":{"start":{"line":1,"column":15},"end":{"line":1,"column":34}},"loc":{"start":{"line":1,"column":50},"end":{"line":3,"column":1}},"line":1},"1":{"name":"create_new_table","decl":{"start":{"line":6,"column":9},"end":{"line":6,"column":25}},"loc":{"start":{"line":6,"column":53},"end":{"line":27,"column":1}},"line":6},"2":{"name":"(anonymous_2)","decl":{"start":{"line":7,"column":23},"end":{"line":7,"column":24}},"loc":{"start":{"line":7,"column":44},"end":{"line":26,"column":5}},"line":7},"3":{"name":"(anonymous_3)","decl":{"start":{"line":8,"column":38},"end":{"line":8,"column":39}},"loc":{"start":{"line":8,"column":59},"end":{"line":25,"column":9}},"line":8},"4":{"name":"add_new_single_row_to_table","decl":{"start":{"line":30,"column":15},"end":{"line":30,"column":42}},"loc":{"start":{"line":30,"column":76},"end":{"line":40,"column":1}},"line":30},"5":{"name":"read_single_row_from_table","decl":{"start":{"line":43,"column":15},"end":{"line":43,"column":41}},"loc":{"start":{"line":43,"column":82},"end":{"line":53,"column":1}},"line":43},"6":{"name":"update_single_row_to_table","decl":{"start":{"line":55,"column":15},"end":{"line":55,"column":41}},"loc":{"start":{"line":55,"column":75},"end":{"line":65,"column":1}},"line":55},"7":{"name":"get_all_rows_from_the_table","decl":{"start":{"line":68,"column":15},"end":{"line":68,"column":42}},"loc":{"start":{"line":68,"column":70},"end":{"line":74,"column":1}},"line":68},"8":{"name":"delete_single_row_from_table","decl":{"start":{"line":77,"column":15},"end":{"line":77,"column":43}},"loc":{"start":{"line":77,"column":84},"end":{"line":83,"column":1}},"line":77},"9":{"name":"add_multiple_rows_at_time","decl":{"start":{"line":85,"column":15},"end":{"line":85,"column":40}},"loc":{"start":{"line":85,"column":74},"end":{"line":91,"column":1}},"line":85},"10":{"name":"fetch_all_rows_using_cursor","decl":{"start":{"line":93,"column":15},"end":{"line":93,"column":42}},"loc":{"start":{"line":93,"column":70},"end":{"line":108,"column":1}},"line":93},"11":{"name":"get_item","decl":{"start":{"line":98,"column":55},"end":{"line":98,"column":63}},"loc":{"start":{"line":98,"column":72},"end":{"line":105,"column":5}},"line":98}},"branchMap":{"0":{"loc":{"start":{"line":9,"column":12},"end":{"line":24,"column":13}},"type":"if","locations":[{"start":{"line":9,"column":12},"end":{"line":24,"column":13}},{"start":{"line":9,"column":12},"end":{"line":24,"column":13}}],"line":9},"1":{"loc":{"start":{"line":10,"column":16},"end":{"line":21,"column":17}},"type":"if","locations":[{"start":{"line":10,"column":16},"end":{"line":21,"column":17}},{"start":{"line":10,"column":16},"end":{"line":21,"column":17}}],"line":10},"2":{"loc":{"start":{"line":14,"column":20},"end":{"line":18,"column":21}},"type":"if","locations":[{"start":{"line":14,"column":20},"end":{"line":18,"column":21}},{"start":{"line":14,"column":20},"end":{"line":18,"column":21}}],"line":14},"3":{"loc":{"start":{"line":35,"column":4},"end":{"line":39,"column":5}},"type":"if","locations":[{"start":{"line":35,"column":4},"end":{"line":39,"column":5}},{"start":{"line":35,"column":4},"end":{"line":39,"column":5}}],"line":35},"4":{"loc":{"start":{"line":48,"column":4},"end":{"line":52,"column":5}},"type":"if","locations":[{"start":{"line":48,"column":4},"end":{"line":52,"column":5}},{"start":{"line":48,"column":4},"end":{"line":52,"column":5}}],"line":48},"5":{"loc":{"start":{"line":60,"column":4},"end":{"line":64,"column":5}},"type":"if","locations":[{"start":{"line":60,"column":4},"end":{"line":64,"column":5}},{"start":{"line":60,"column":4},"end":{"line":64,"column":5}}],"line":60},"6":{"loc":{"start":{"line":99,"column":8},"end":{"line":102,"column":9}},"type":"if","locations":[{"start":{"line":99,"column":8},"end":{"line":102,"column":9}},{"start":{"line":99,"column":8},"end":{"line":102,"column":9}}],"line":99}},"s":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0},"b":{"0":[0,0],"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0]},"inputSourceMap":null,"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"18e415607a259d6a17c4210292da2506f5cd5ffd"} } diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html index 09038ec..618ba67 100644 --- a/coverage/lcov-report/index.html +++ b/coverage/lcov-report/index.html @@ -23,9 +23,9 @@

All files

- 1.69% + 1.72% Statements - 1/59 + 1/58
@@ -44,9 +44,9 @@

All files

- 1.69% + 1.72% Lines - 1/59 + 1/58
@@ -74,17 +74,17 @@

All files

utils.js - +
- 1.69% - 1/59 + 1.72% + 1/58 0% 0/14 0% 0/12 - 1.69% - 1/59 + 1.72% + 1/58 @@ -95,7 +95,7 @@

All files

diff --git a/coverage/lcov-report/utils.js.html b/coverage/lcov-report/utils.js.html index d8263a6..6be7739 100644 --- a/coverage/lcov-report/utils.js.html +++ b/coverage/lcov-report/utils.js.html @@ -23,9 +23,9 @@

All files utils.js

- 1.69% + 1.72% Statements - 1/59 + 1/58
@@ -44,9 +44,9 @@

All files utils.js

- 1.69% + 1.72% Lines - 1/59 + 1/58
@@ -176,11 +176,13 @@

All files utils.js

117 118 119 -120  +120 +121          +        @@ -274,7 +276,7 @@

All files utils.js

      -  +        @@ -299,6 +301,7 @@

All files utils.js

return ipdb.openDB(database_name, 1) }   +  function create_new_table(database_name, table_name) { return new Promise((resolve, reject) => { ipdb.openDB(database_name, 2, function (upgradeDB) { @@ -391,9 +394,9 @@

All files utils.js

const tnx = database.transaction(table_name, 'readwrite') const test_object_store = tnx.objectStore(table_name) const all_rows = [] - await test_object_store.openCursor().then(function get_item(cursor){ - if(!cursor){ - console.log('null cursor') + await test_object_store.openCursor().then(function get_item(cursor) { + if (!cursor) { return } all_rows.push(cursor.value) @@ -421,7 +424,7 @@

All files utils.js

diff --git a/coverage/lcov.info b/coverage/lcov.info index 46be585..c4109b8 100644 --- a/coverage/lcov.info +++ b/coverage/lcov.info @@ -1,17 +1,17 @@ TN: SF:src\tests\utils.js FN:1,connect_to_database -FN:5,create_new_table -FN:6,(anonymous_2) -FN:7,(anonymous_3) -FN:29,add_new_single_row_to_table -FN:42,read_single_row_from_table -FN:54,update_single_row_to_table -FN:67,get_all_rows_from_the_table -FN:76,delete_single_row_from_table -FN:84,add_multiple_rows_at_time -FN:92,fetch_all_rows_using_cursor -FN:97,get_item +FN:6,create_new_table +FN:7,(anonymous_2) +FN:8,(anonymous_3) +FN:30,add_new_single_row_to_table +FN:43,read_single_row_from_table +FN:55,update_single_row_to_table +FN:68,get_all_rows_from_the_table +FN:77,delete_single_row_from_table +FN:85,add_multiple_rows_at_time +FN:93,fetch_all_rows_using_cursor +FN:98,get_item FNF:12 FNH:0 FNDA:0,connect_to_database @@ -27,80 +27,79 @@ FNDA:0,add_multiple_rows_at_time FNDA:0,fetch_all_rows_using_cursor FNDA:0,get_item DA:2,0 -DA:6,0 DA:7,0 DA:8,0 DA:9,0 -DA:12,0 +DA:10,0 DA:13,0 DA:14,0 -DA:16,0 -DA:19,0 -DA:22,0 -DA:30,0 +DA:15,0 +DA:17,0 +DA:20,0 +DA:23,0 DA:31,0 DA:32,0 DA:33,0 DA:34,0 DA:35,0 -DA:37,0 -DA:43,0 +DA:36,0 +DA:38,0 DA:44,0 DA:45,0 DA:46,0 DA:47,0 DA:48,0 -DA:50,0 -DA:55,0 +DA:49,0 +DA:51,0 DA:56,0 DA:57,0 DA:58,0 DA:59,0 DA:60,0 -DA:62,0 -DA:68,0 +DA:61,0 +DA:63,0 DA:69,0 DA:70,0 DA:71,0 DA:72,0 -DA:77,0 +DA:73,0 DA:78,0 DA:79,0 DA:80,0 DA:81,0 -DA:85,0 +DA:82,0 DA:86,0 DA:87,0 DA:88,0 DA:89,0 -DA:93,0 +DA:90,0 DA:94,0 DA:95,0 DA:96,0 DA:97,0 DA:98,0 DA:99,0 -DA:100,0 -DA:102,0 +DA:101,0 DA:103,0 -DA:106,0 -DA:110,1 -LF:59 +DA:104,0 +DA:107,0 +DA:111,1 +LF:58 LH:1 -BRDA:8,0,0,0 -BRDA:8,0,1,0 -BRDA:9,1,0,0 -BRDA:9,1,1,0 -BRDA:13,2,0,0 -BRDA:13,2,1,0 -BRDA:34,3,0,0 -BRDA:34,3,1,0 -BRDA:47,4,0,0 -BRDA:47,4,1,0 -BRDA:59,5,0,0 -BRDA:59,5,1,0 -BRDA:98,6,0,0 -BRDA:98,6,1,0 +BRDA:9,0,0,0 +BRDA:9,0,1,0 +BRDA:10,1,0,0 +BRDA:10,1,1,0 +BRDA:14,2,0,0 +BRDA:14,2,1,0 +BRDA:35,3,0,0 +BRDA:35,3,1,0 +BRDA:48,4,0,0 +BRDA:48,4,1,0 +BRDA:60,5,0,0 +BRDA:60,5,1,0 +BRDA:99,6,0,0 +BRDA:99,6,1,0 BRF:14 BRH:0 end_of_record diff --git a/src/tests/utils.js b/src/tests/utils.js index 8183c47..1fa5913 100644 --- a/src/tests/utils.js +++ b/src/tests/utils.js @@ -97,7 +97,7 @@ async function fetch_all_rows_using_cursor(database_name, table_name) { const all_rows = [] await test_object_store.openCursor().then(function get_item(cursor) { if (!cursor) { - console.log('null cursor') + return } all_rows.push(cursor.value)