mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
1 line
26 KiB
JSON
1 line
26 KiB
JSON
|
|
{"ast":null,"code":"(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = global || self, factory(global.idb = {}));\n})(this, function (exports) {\n 'use strict';\n\n function toArray(arr) {\n return Array.prototype.slice.call(arr);\n }\n function promisifyRequest(request) {\n return new Promise(function (resolve, reject) {\n request.onsuccess = function () {\n resolve(request.result);\n };\n request.onerror = function () {\n reject(request.error);\n };\n });\n }\n function promisifyRequestCall(obj, method, args) {\n var request;\n var p = new Promise(function (resolve, reject) {\n request = obj[method].apply(obj, args);\n promisifyRequest(request).then(resolve, reject);\n });\n p.request = request;\n return p;\n }\n function promisifyCursorRequestCall(obj, method, args) {\n var p = promisifyRequestCall(obj, method, args);\n return p.then(function (value) {\n if (!value) return;\n return new Cursor(value, p.request);\n });\n }\n function proxyProperties(ProxyClass, targetProp, properties) {\n properties.forEach(function (prop) {\n Object.defineProperty(ProxyClass.prototype, prop, {\n get: function () {\n return this[targetProp][prop];\n },\n set: function (val) {\n this[targetProp][prop] = val;\n }\n });\n });\n }\n function proxyRequestMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function (prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function () {\n return promisifyRequestCall(this[targetProp], prop, arguments);\n };\n });\n }\n function proxyMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function (prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function () {\n return this[targetProp][prop].apply(this[targetProp], arguments);\n };\n });\n }\n function proxyCursorRequestMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function (prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function () {\n return promisifyCursorRequestCall(this[targetProp], prop, arguments);\n };\n });\n }\n function Index(index) {\n this._index = index;\n }\n proxyProperties(Index, '_index', ['name', 'keyPath', 'multiEntry', 'unique']);\n proxyRequestMethods(Index, '_index', IDBIndex, ['get', 'getKey', 'getAll', 'getAllKeys', 'count']);\n proxyCursorRequestMethods(Index, '_index', IDBIndex, ['openCursor', 'openKeyCursor']);\n function Cursor(cursor, request) {\n this._cursor = cursor;\n this._request = request;\n }\n proxyProperties(Cursor, '_cursor', ['direction', 'key', 'primaryKey', 'value']);\n proxyRequestMethods(Cursor, '_cursor', IDBCursor, ['update', 'delete']);\n\n // proxy 'next' methods\n ['advance', 'continue', 'continuePrimaryKey'].forEach(function (methodName) {\n if (!(methodName in IDBCursor.prototype)) return;\n Cursor.prototype[methodName] = function () {\n var cursor = this;\n var args = arguments;\n return Promise.resolve().then(function () {\n cursor._cursor[methodName].apply(cursor._cursor, args);\n return promisifyRequest(cursor._request).then(function (value) {\n if (!value) return;\n return new Cursor(value, cursor._request);\n });\n });\n };\n });\n function ObjectStore(store) {\n this._store = store;\n }\n ObjectStore.prototype.createIndex = function () {\n return new Index(this._store.createIndex.apply(this._store, arguments));\n };\n ObjectStore.prototype.index = function () {\n return new Index(this._store.index.apply(this._store, arguments));\n };\n proxyProperties(ObjectStore, '_store', ['name', 'keyPath', 'inde
|