new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/** PURE_IMPORTS_START tslib,_Subject,_scheduler_queue,_Subscription,_operators_observeOn,_util_ObjectUnsubscribedError,_SubjectSubscription PURE_IMPORTS_END */
|
||||
import * as tslib_1 from "tslib";
|
||||
import { Subject } from './Subject';
|
||||
import { queue } from './scheduler/queue';
|
||||
import { Subscription } from './Subscription';
|
||||
import { ObserveOnSubscriber } from './operators/observeOn';
|
||||
import { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';
|
||||
import { SubjectSubscription } from './SubjectSubscription';
|
||||
var ReplaySubject = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(ReplaySubject, _super);
|
||||
function ReplaySubject(bufferSize, windowTime, scheduler) {
|
||||
if (bufferSize === void 0) {
|
||||
bufferSize = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
if (windowTime === void 0) {
|
||||
windowTime = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
var _this = _super.call(this) || this;
|
||||
_this.scheduler = scheduler;
|
||||
_this._events = [];
|
||||
_this._infiniteTimeWindow = false;
|
||||
_this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
|
||||
_this._windowTime = windowTime < 1 ? 1 : windowTime;
|
||||
if (windowTime === Number.POSITIVE_INFINITY) {
|
||||
_this._infiniteTimeWindow = true;
|
||||
_this.next = _this.nextInfiniteTimeWindow;
|
||||
}
|
||||
else {
|
||||
_this.next = _this.nextTimeWindow;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
|
||||
if (!this.isStopped) {
|
||||
var _events = this._events;
|
||||
_events.push(value);
|
||||
if (_events.length > this._bufferSize) {
|
||||
_events.shift();
|
||||
}
|
||||
}
|
||||
_super.prototype.next.call(this, value);
|
||||
};
|
||||
ReplaySubject.prototype.nextTimeWindow = function (value) {
|
||||
if (!this.isStopped) {
|
||||
this._events.push(new ReplayEvent(this._getNow(), value));
|
||||
this._trimBufferThenGetEvents();
|
||||
}
|
||||
_super.prototype.next.call(this, value);
|
||||
};
|
||||
ReplaySubject.prototype._subscribe = function (subscriber) {
|
||||
var _infiniteTimeWindow = this._infiniteTimeWindow;
|
||||
var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
|
||||
var scheduler = this.scheduler;
|
||||
var len = _events.length;
|
||||
var subscription;
|
||||
if (this.closed) {
|
||||
throw new ObjectUnsubscribedError();
|
||||
}
|
||||
else if (this.isStopped || this.hasError) {
|
||||
subscription = Subscription.EMPTY;
|
||||
}
|
||||
else {
|
||||
this.observers.push(subscriber);
|
||||
subscription = new SubjectSubscription(this, subscriber);
|
||||
}
|
||||
if (scheduler) {
|
||||
subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
|
||||
}
|
||||
if (_infiniteTimeWindow) {
|
||||
for (var i = 0; i < len && !subscriber.closed; i++) {
|
||||
subscriber.next(_events[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < len && !subscriber.closed; i++) {
|
||||
subscriber.next(_events[i].value);
|
||||
}
|
||||
}
|
||||
if (this.hasError) {
|
||||
subscriber.error(this.thrownError);
|
||||
}
|
||||
else if (this.isStopped) {
|
||||
subscriber.complete();
|
||||
}
|
||||
return subscription;
|
||||
};
|
||||
ReplaySubject.prototype._getNow = function () {
|
||||
return (this.scheduler || queue).now();
|
||||
};
|
||||
ReplaySubject.prototype._trimBufferThenGetEvents = function () {
|
||||
var now = this._getNow();
|
||||
var _bufferSize = this._bufferSize;
|
||||
var _windowTime = this._windowTime;
|
||||
var _events = this._events;
|
||||
var eventsCount = _events.length;
|
||||
var spliceCount = 0;
|
||||
while (spliceCount < eventsCount) {
|
||||
if ((now - _events[spliceCount].time) < _windowTime) {
|
||||
break;
|
||||
}
|
||||
spliceCount++;
|
||||
}
|
||||
if (eventsCount > _bufferSize) {
|
||||
spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
|
||||
}
|
||||
if (spliceCount > 0) {
|
||||
_events.splice(0, spliceCount);
|
||||
}
|
||||
return _events;
|
||||
};
|
||||
return ReplaySubject;
|
||||
}(Subject));
|
||||
export { ReplaySubject };
|
||||
var ReplayEvent = /*@__PURE__*/ (function () {
|
||||
function ReplayEvent(time, value) {
|
||||
this.time = time;
|
||||
this.value = value;
|
||||
}
|
||||
return ReplayEvent;
|
||||
}());
|
||||
//# sourceMappingURL=ReplaySubject.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defer } from './defer';
|
||||
import { EMPTY } from './empty';
|
||||
export function iif(condition, trueResult = EMPTY, falseResult = EMPTY) {
|
||||
return defer(() => condition() ? trueResult : falseResult);
|
||||
}
|
||||
//# sourceMappingURL=iif.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"keyv","version":"3.1.0","files":{"LICENSE":{"checkedAt":1678887829930,"integrity":"sha512-b+puLzCIXN1sriNmN+8ZT+nrBidkN+NwwC6sZR4XADGYCrIB/16Klbe1wh8keI+pOAfWxPLPedX3F5Lm6KYf7w==","mode":420,"size":1068},"package.json":{"checkedAt":1678887830326,"integrity":"sha512-G5112QKCFbJcen5rHZfuhk0pTr17Jvn7ihYvYL3yJjOfAY9pKT5IxtA76zaQ0RPRfQRtI87ePMajVkLhKCWPnw==","mode":420,"size":1183},"README.md":{"checkedAt":1678887830327,"integrity":"sha512-8w275gg3bYDkRqHCxsj39DtPLaLwNtCxYfp8t7HF2qrX2vbRyYyLjC5xW4o5R8ZSs+BDDv8GCWYs1vyj11S/1Q==","mode":420,"size":10115},"src/index.js":{"checkedAt":1678887830330,"integrity":"sha512-EbPghWoIrm2g+bxX0jbbnSKLpSUzEuWwkpLZAjGwbOBWU4v/7upvLE+GDwyAmh3aZsiaY/kAnVkEX2nim8dDIQ==","mode":420,"size":2295}}}
|
||||
@@ -0,0 +1,39 @@
|
||||
/** PURE_IMPORTS_START _Observable,_Subscription PURE_IMPORTS_END */
|
||||
import { Observable } from '../Observable';
|
||||
import { Subscription } from '../Subscription';
|
||||
export function pairs(obj, scheduler) {
|
||||
if (!scheduler) {
|
||||
return new Observable(function (subscriber) {
|
||||
var keys = Object.keys(obj);
|
||||
for (var i = 0; i < keys.length && !subscriber.closed; i++) {
|
||||
var key = keys[i];
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
subscriber.next([key, obj[key]]);
|
||||
}
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
else {
|
||||
return new Observable(function (subscriber) {
|
||||
var keys = Object.keys(obj);
|
||||
var subscription = new Subscription();
|
||||
subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
|
||||
return subscription;
|
||||
});
|
||||
}
|
||||
}
|
||||
export function dispatch(state) {
|
||||
var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
|
||||
if (!subscriber.closed) {
|
||||
if (index < keys.length) {
|
||||
var key = keys[index];
|
||||
subscriber.next([key, obj[key]]);
|
||||
subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
|
||||
}
|
||||
else {
|
||||
subscriber.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=pairs.js.map
|
||||
@@ -0,0 +1,4 @@
|
||||
// Vibration API
|
||||
// http://www.w3.org/TR/vibration/
|
||||
// https://developer.mozilla.org/en/DOM/window.navigator.mozVibrate
|
||||
Modernizr.addTest('vibrate', !!Modernizr.prefixed('vibrate', navigator));
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K L H M N O"},C:{"1":"bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB","2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB DC EC"},D:{"1":"lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e"},E:{"1":"B C K L H 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F G A GC zB HC IC JC KC"},F:{"1":"cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB OC PC QC RC qB 9B SC rB"},G:{"1":"bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC YC ZC aC"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"2":"A B"},O:{"1":"uC"},P:{"1":"0C 1C 2C 3C 4C sB 5C 6C 7C","2":"I vC wC xC yC zC 0B"},Q:{"1":"1B"},R:{"1":"8C"},S:{"2":"9C"}},B:5,C:"prefers-reduced-motion media query"};
|
||||
@@ -0,0 +1,12 @@
|
||||
/** PURE_IMPORTS_START _ReplaySubject,_multicast PURE_IMPORTS_END */
|
||||
import { ReplaySubject } from '../ReplaySubject';
|
||||
import { multicast } from './multicast';
|
||||
export function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
|
||||
if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
|
||||
scheduler = selectorOrScheduler;
|
||||
}
|
||||
var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
|
||||
var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
|
||||
return function (source) { return multicast(function () { return subject; }, selector)(source); };
|
||||
}
|
||||
//# sourceMappingURL=publishReplay.js.map
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/publishLast"));
|
||||
//# sourceMappingURL=publishLast.js.map
|
||||
@@ -0,0 +1,3 @@
|
||||
import { OperatorFunction, MonoTypeOperatorFunction } from '../types';
|
||||
export declare function defaultIfEmpty<T>(defaultValue?: T): MonoTypeOperatorFunction<T>;
|
||||
export declare function defaultIfEmpty<T, R>(defaultValue?: R): OperatorFunction<T, T | R>;
|
||||
@@ -0,0 +1,998 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define('asyncStorage', ['module', 'exports', '../utils/isIndexedDBValid', '../utils/createBlob', '../utils/idb', '../utils/promise', '../utils/executeCallback', '../utils/executeTwoCallbacks', '../utils/normalizeKey', '../utils/getCallback'], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(module, exports, require('../utils/isIndexedDBValid'), require('../utils/createBlob'), require('../utils/idb'), require('../utils/promise'), require('../utils/executeCallback'), require('../utils/executeTwoCallbacks'), require('../utils/normalizeKey'), require('../utils/getCallback'));
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod, mod.exports, global.isIndexedDBValid, global.createBlob, global.idb, global.promise, global.executeCallback, global.executeTwoCallbacks, global.normalizeKey, global.getCallback);
|
||||
global.asyncStorage = mod.exports;
|
||||
}
|
||||
})(this, function (module, exports, _isIndexedDBValid, _createBlob, _idb, _promise, _executeCallback, _executeTwoCallbacks, _normalizeKey, _getCallback) {
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _isIndexedDBValid2 = _interopRequireDefault(_isIndexedDBValid);
|
||||
|
||||
var _createBlob2 = _interopRequireDefault(_createBlob);
|
||||
|
||||
var _idb2 = _interopRequireDefault(_idb);
|
||||
|
||||
var _promise2 = _interopRequireDefault(_promise);
|
||||
|
||||
var _executeCallback2 = _interopRequireDefault(_executeCallback);
|
||||
|
||||
var _executeTwoCallbacks2 = _interopRequireDefault(_executeTwoCallbacks);
|
||||
|
||||
var _normalizeKey2 = _interopRequireDefault(_normalizeKey);
|
||||
|
||||
var _getCallback2 = _interopRequireDefault(_getCallback);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
|
||||
// Some code originally from async_storage.js in
|
||||
// [Gaia](https://github.com/mozilla-b2g/gaia).
|
||||
|
||||
var DETECT_BLOB_SUPPORT_STORE = 'local-forage-detect-blob-support';
|
||||
var supportsBlobs = void 0;
|
||||
var dbContexts = {};
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
// Transaction Modes
|
||||
var READ_ONLY = 'readonly';
|
||||
var READ_WRITE = 'readwrite';
|
||||
|
||||
// Transform a binary string to an array buffer, because otherwise
|
||||
// weird stuff happens when you try to work with the binary string directly.
|
||||
// It is known.
|
||||
// From http://stackoverflow.com/questions/14967647/ (continues on next line)
|
||||
// encode-decode-image-with-base64-breaks-image (2013-04-21)
|
||||
function _binStringToArrayBuffer(bin) {
|
||||
var length = bin.length;
|
||||
var buf = new ArrayBuffer(length);
|
||||
var arr = new Uint8Array(buf);
|
||||
for (var i = 0; i < length; i++) {
|
||||
arr[i] = bin.charCodeAt(i);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
//
|
||||
// Blobs are not supported in all versions of IndexedDB, notably
|
||||
// Chrome <37 and Android <5. In those versions, storing a blob will throw.
|
||||
//
|
||||
// Various other blob bugs exist in Chrome v37-42 (inclusive).
|
||||
// Detecting them is expensive and confusing to users, and Chrome 37-42
|
||||
// is at very low usage worldwide, so we do a hacky userAgent check instead.
|
||||
//
|
||||
// content-type bug: https://code.google.com/p/chromium/issues/detail?id=408120
|
||||
// 404 bug: https://code.google.com/p/chromium/issues/detail?id=447916
|
||||
// FileReader bug: https://code.google.com/p/chromium/issues/detail?id=447836
|
||||
//
|
||||
// Code borrowed from PouchDB. See:
|
||||
// https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-adapter-idb/src/blobSupport.js
|
||||
//
|
||||
function _checkBlobSupportWithoutCaching(idb) {
|
||||
return new _promise2.default(function (resolve) {
|
||||
var txn = idb.transaction(DETECT_BLOB_SUPPORT_STORE, READ_WRITE);
|
||||
var blob = (0, _createBlob2.default)(['']);
|
||||
txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');
|
||||
|
||||
txn.onabort = function (e) {
|
||||
// If the transaction aborts now its due to not being able to
|
||||
// write to the database, likely due to the disk being full
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
resolve(false);
|
||||
};
|
||||
|
||||
txn.oncomplete = function () {
|
||||
var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
|
||||
var matchedEdge = navigator.userAgent.match(/Edge\//);
|
||||
// MS Edge pretends to be Chrome 42:
|
||||
// https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
|
||||
resolve(matchedEdge || !matchedChrome || parseInt(matchedChrome[1], 10) >= 43);
|
||||
};
|
||||
}).catch(function () {
|
||||
return false; // error, so assume unsupported
|
||||
});
|
||||
}
|
||||
|
||||
function _checkBlobSupport(idb) {
|
||||
if (typeof supportsBlobs === 'boolean') {
|
||||
return _promise2.default.resolve(supportsBlobs);
|
||||
}
|
||||
return _checkBlobSupportWithoutCaching(idb).then(function (value) {
|
||||
supportsBlobs = value;
|
||||
return supportsBlobs;
|
||||
});
|
||||
}
|
||||
|
||||
function _deferReadiness(dbInfo) {
|
||||
var dbContext = dbContexts[dbInfo.name];
|
||||
|
||||
// Create a deferred object representing the current database operation.
|
||||
var deferredOperation = {};
|
||||
|
||||
deferredOperation.promise = new _promise2.default(function (resolve, reject) {
|
||||
deferredOperation.resolve = resolve;
|
||||
deferredOperation.reject = reject;
|
||||
});
|
||||
|
||||
// Enqueue the deferred operation.
|
||||
dbContext.deferredOperations.push(deferredOperation);
|
||||
|
||||
// Chain its promise to the database readiness.
|
||||
if (!dbContext.dbReady) {
|
||||
dbContext.dbReady = deferredOperation.promise;
|
||||
} else {
|
||||
dbContext.dbReady = dbContext.dbReady.then(function () {
|
||||
return deferredOperation.promise;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _advanceReadiness(dbInfo) {
|
||||
var dbContext = dbContexts[dbInfo.name];
|
||||
|
||||
// Dequeue a deferred operation.
|
||||
var deferredOperation = dbContext.deferredOperations.pop();
|
||||
|
||||
// Resolve its promise (which is part of the database readiness
|
||||
// chain of promises).
|
||||
if (deferredOperation) {
|
||||
deferredOperation.resolve();
|
||||
return deferredOperation.promise;
|
||||
}
|
||||
}
|
||||
|
||||
function _rejectReadiness(dbInfo, err) {
|
||||
var dbContext = dbContexts[dbInfo.name];
|
||||
|
||||
// Dequeue a deferred operation.
|
||||
var deferredOperation = dbContext.deferredOperations.pop();
|
||||
|
||||
// Reject its promise (which is part of the database readiness
|
||||
// chain of promises).
|
||||
if (deferredOperation) {
|
||||
deferredOperation.reject(err);
|
||||
return deferredOperation.promise;
|
||||
}
|
||||
}
|
||||
|
||||
function _getConnection(dbInfo, upgradeNeeded) {
|
||||
return new _promise2.default(function (resolve, reject) {
|
||||
dbContexts[dbInfo.name] = dbContexts[dbInfo.name] || createDbContext();
|
||||
|
||||
if (dbInfo.db) {
|
||||
if (upgradeNeeded) {
|
||||
_deferReadiness(dbInfo);
|
||||
dbInfo.db.close();
|
||||
} else {
|
||||
return resolve(dbInfo.db);
|
||||
}
|
||||
}
|
||||
|
||||
var dbArgs = [dbInfo.name];
|
||||
|
||||
if (upgradeNeeded) {
|
||||
dbArgs.push(dbInfo.version);
|
||||
}
|
||||
|
||||
var openreq = _idb2.default.open.apply(_idb2.default, dbArgs);
|
||||
|
||||
if (upgradeNeeded) {
|
||||
openreq.onupgradeneeded = function (e) {
|
||||
var db = openreq.result;
|
||||
try {
|
||||
db.createObjectStore(dbInfo.storeName);
|
||||
if (e.oldVersion <= 1) {
|
||||
// Added when support for blob shims was added
|
||||
db.createObjectStore(DETECT_BLOB_SUPPORT_STORE);
|
||||
}
|
||||
} catch (ex) {
|
||||
if (ex.name === 'ConstraintError') {
|
||||
console.warn('The database "' + dbInfo.name + '"' + ' has been upgraded from version ' + e.oldVersion + ' to version ' + e.newVersion + ', but the storage "' + dbInfo.storeName + '" already exists.');
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
openreq.onerror = function (e) {
|
||||
e.preventDefault();
|
||||
reject(openreq.error);
|
||||
};
|
||||
|
||||
openreq.onsuccess = function () {
|
||||
resolve(openreq.result);
|
||||
_advanceReadiness(dbInfo);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function _getOriginalConnection(dbInfo) {
|
||||
return _getConnection(dbInfo, false);
|
||||
}
|
||||
|
||||
function _getUpgradedConnection(dbInfo) {
|
||||
return _getConnection(dbInfo, true);
|
||||
}
|
||||
|
||||
function _isUpgradeNeeded(dbInfo, defaultVersion) {
|
||||
if (!dbInfo.db) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var isNewStore = !dbInfo.db.objectStoreNames.contains(dbInfo.storeName);
|
||||
var isDowngrade = dbInfo.version < dbInfo.db.version;
|
||||
var isUpgrade = dbInfo.version > dbInfo.db.version;
|
||||
|
||||
if (isDowngrade) {
|
||||
// If the version is not the default one
|
||||
// then warn for impossible downgrade.
|
||||
if (dbInfo.version !== defaultVersion) {
|
||||
console.warn('The database "' + dbInfo.name + '"' + " can't be downgraded from version " + dbInfo.db.version + ' to version ' + dbInfo.version + '.');
|
||||
}
|
||||
// Align the versions to prevent errors.
|
||||
dbInfo.version = dbInfo.db.version;
|
||||
}
|
||||
|
||||
if (isUpgrade || isNewStore) {
|
||||
// If the store is new then increment the version (if needed).
|
||||
// This will trigger an "upgradeneeded" event which is required
|
||||
// for creating a store.
|
||||
if (isNewStore) {
|
||||
var incVersion = dbInfo.db.version + 1;
|
||||
if (incVersion > dbInfo.version) {
|
||||
dbInfo.version = incVersion;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// encode a blob for indexeddb engines that don't support blobs
|
||||
function _encodeBlob(blob) {
|
||||
return new _promise2.default(function (resolve, reject) {
|
||||
var reader = new FileReader();
|
||||
reader.onerror = reject;
|
||||
reader.onloadend = function (e) {
|
||||
var base64 = btoa(e.target.result || '');
|
||||
resolve({
|
||||
__local_forage_encoded_blob: true,
|
||||
data: base64,
|
||||
type: blob.type
|
||||
});
|
||||
};
|
||||
reader.readAsBinaryString(blob);
|
||||
});
|
||||
}
|
||||
|
||||
// decode an encoded blob
|
||||
function _decodeBlob(encodedBlob) {
|
||||
var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
|
||||
return (0, _createBlob2.default)([arrayBuff], { type: encodedBlob.type });
|
||||
}
|
||||
|
||||
// is this one of our fancy encoded blobs?
|
||||
function _isEncodedBlob(value) {
|
||||
return value && value.__local_forage_encoded_blob;
|
||||
}
|
||||
|
||||
// Specialize the default `ready()` function by making it dependent
|
||||
// on the current database operations. Thus, the driver will be actually
|
||||
// ready when it's been initialized (default) *and* there are no pending
|
||||
// operations on the database (initiated by some other instances).
|
||||
function _fullyReady(callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = self._initReady().then(function () {
|
||||
var dbContext = dbContexts[self._dbInfo.name];
|
||||
|
||||
if (dbContext && dbContext.dbReady) {
|
||||
return dbContext.dbReady;
|
||||
}
|
||||
});
|
||||
|
||||
(0, _executeTwoCallbacks2.default)(promise, callback, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Try to establish a new db connection to replace the
|
||||
// current one which is broken (i.e. experiencing
|
||||
// InvalidStateError while creating a transaction).
|
||||
function _tryReconnect(dbInfo) {
|
||||
_deferReadiness(dbInfo);
|
||||
|
||||
var dbContext = dbContexts[dbInfo.name];
|
||||
var forages = dbContext.forages;
|
||||
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
var forage = forages[i];
|
||||
if (forage._dbInfo.db) {
|
||||
forage._dbInfo.db.close();
|
||||
forage._dbInfo.db = null;
|
||||
}
|
||||
}
|
||||
dbInfo.db = null;
|
||||
|
||||
return _getOriginalConnection(dbInfo).then(function (db) {
|
||||
dbInfo.db = db;
|
||||
if (_isUpgradeNeeded(dbInfo)) {
|
||||
// Reopen the database for upgrading.
|
||||
return _getUpgradedConnection(dbInfo);
|
||||
}
|
||||
return db;
|
||||
}).then(function (db) {
|
||||
// store the latest db reference
|
||||
// in case the db was upgraded
|
||||
dbInfo.db = dbContext.db = db;
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
forages[i]._dbInfo.db = db;
|
||||
}
|
||||
}).catch(function (err) {
|
||||
_rejectReadiness(dbInfo, err);
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
// FF doesn't like Promises (micro-tasks) and IDDB store operations,
|
||||
// so we have to do it with callbacks
|
||||
function createTransaction(dbInfo, mode, callback, retries) {
|
||||
if (retries === undefined) {
|
||||
retries = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
|
||||
callback(null, tx);
|
||||
} catch (err) {
|
||||
if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
|
||||
return _promise2.default.resolve().then(function () {
|
||||
if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
|
||||
// increase the db version, to create the new ObjectStore
|
||||
if (dbInfo.db) {
|
||||
dbInfo.version = dbInfo.db.version + 1;
|
||||
}
|
||||
// Reopen the database for upgrading.
|
||||
return _getUpgradedConnection(dbInfo);
|
||||
}
|
||||
}).then(function () {
|
||||
return _tryReconnect(dbInfo).then(function () {
|
||||
createTransaction(dbInfo, mode, callback, retries - 1);
|
||||
});
|
||||
}).catch(callback);
|
||||
}
|
||||
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
|
||||
function createDbContext() {
|
||||
return {
|
||||
// Running localForages sharing a database.
|
||||
forages: [],
|
||||
// Shared database.
|
||||
db: null,
|
||||
// Database readiness (promise).
|
||||
dbReady: null,
|
||||
// Deferred operations on the database.
|
||||
deferredOperations: []
|
||||
};
|
||||
}
|
||||
|
||||
// Open the IndexedDB database (automatically creates one if one didn't
|
||||
// previously exist), using any options set in the config.
|
||||
function _initStorage(options) {
|
||||
var self = this;
|
||||
var dbInfo = {
|
||||
db: null
|
||||
};
|
||||
|
||||
if (options) {
|
||||
for (var i in options) {
|
||||
dbInfo[i] = options[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Get the current context of the database;
|
||||
var dbContext = dbContexts[dbInfo.name];
|
||||
|
||||
// ...or create a new context.
|
||||
if (!dbContext) {
|
||||
dbContext = createDbContext();
|
||||
// Register the new context in the global container.
|
||||
dbContexts[dbInfo.name] = dbContext;
|
||||
}
|
||||
|
||||
// Register itself as a running localForage in the current context.
|
||||
dbContext.forages.push(self);
|
||||
|
||||
// Replace the default `ready()` function with the specialized one.
|
||||
if (!self._initReady) {
|
||||
self._initReady = self.ready;
|
||||
self.ready = _fullyReady;
|
||||
}
|
||||
|
||||
// Create an array of initialization states of the related localForages.
|
||||
var initPromises = [];
|
||||
|
||||
function ignoreErrors() {
|
||||
// Don't handle errors here,
|
||||
// just makes sure related localForages aren't pending.
|
||||
return _promise2.default.resolve();
|
||||
}
|
||||
|
||||
for (var j = 0; j < dbContext.forages.length; j++) {
|
||||
var forage = dbContext.forages[j];
|
||||
if (forage !== self) {
|
||||
// Don't wait for itself...
|
||||
initPromises.push(forage._initReady().catch(ignoreErrors));
|
||||
}
|
||||
}
|
||||
|
||||
// Take a snapshot of the related localForages.
|
||||
var forages = dbContext.forages.slice(0);
|
||||
|
||||
// Initialize the connection process only when
|
||||
// all the related localForages aren't pending.
|
||||
return _promise2.default.all(initPromises).then(function () {
|
||||
dbInfo.db = dbContext.db;
|
||||
// Get the connection or open a new one without upgrade.
|
||||
return _getOriginalConnection(dbInfo);
|
||||
}).then(function (db) {
|
||||
dbInfo.db = db;
|
||||
if (_isUpgradeNeeded(dbInfo, self._defaultConfig.version)) {
|
||||
// Reopen the database for upgrading.
|
||||
return _getUpgradedConnection(dbInfo);
|
||||
}
|
||||
return db;
|
||||
}).then(function (db) {
|
||||
dbInfo.db = dbContext.db = db;
|
||||
self._dbInfo = dbInfo;
|
||||
// Share the final connection amongst related localForages.
|
||||
for (var k = 0; k < forages.length; k++) {
|
||||
var forage = forages[k];
|
||||
if (forage !== self) {
|
||||
// Self is already up-to-date.
|
||||
forage._dbInfo.db = dbInfo.db;
|
||||
forage._dbInfo.version = dbInfo.version;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getItem(key, callback) {
|
||||
var self = this;
|
||||
|
||||
key = (0, _normalizeKey2.default)(key);
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var req = store.get(key);
|
||||
|
||||
req.onsuccess = function () {
|
||||
var value = req.result;
|
||||
if (value === undefined) {
|
||||
value = null;
|
||||
}
|
||||
if (_isEncodedBlob(value)) {
|
||||
value = _decodeBlob(value);
|
||||
}
|
||||
resolve(value);
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Iterate over all items stored in database.
|
||||
function iterate(iterator, callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var req = store.openCursor();
|
||||
var iterationNumber = 1;
|
||||
|
||||
req.onsuccess = function () {
|
||||
var cursor = req.result;
|
||||
|
||||
if (cursor) {
|
||||
var value = cursor.value;
|
||||
if (_isEncodedBlob(value)) {
|
||||
value = _decodeBlob(value);
|
||||
}
|
||||
var result = iterator(value, cursor.key, iterationNumber++);
|
||||
|
||||
// when the iterator callback returns any
|
||||
// (non-`undefined`) value, then we stop
|
||||
// the iteration immediately
|
||||
if (result !== void 0) {
|
||||
resolve(result);
|
||||
} else {
|
||||
cursor.continue();
|
||||
}
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
function setItem(key, value, callback) {
|
||||
var self = this;
|
||||
|
||||
key = (0, _normalizeKey2.default)(key);
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
var dbInfo;
|
||||
self.ready().then(function () {
|
||||
dbInfo = self._dbInfo;
|
||||
if (toString.call(value) === '[object Blob]') {
|
||||
return _checkBlobSupport(dbInfo.db).then(function (blobSupport) {
|
||||
if (blobSupport) {
|
||||
return value;
|
||||
}
|
||||
return _encodeBlob(value);
|
||||
});
|
||||
}
|
||||
return value;
|
||||
}).then(function (value) {
|
||||
createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
|
||||
// The reason we don't _save_ null is because IE 10 does
|
||||
// not support saving the `null` type in IndexedDB. How
|
||||
// ironic, given the bug below!
|
||||
// See: https://github.com/mozilla/localForage/issues/161
|
||||
if (value === null) {
|
||||
value = undefined;
|
||||
}
|
||||
|
||||
var req = store.put(value, key);
|
||||
|
||||
transaction.oncomplete = function () {
|
||||
// Cast to undefined so the value passed to
|
||||
// callback/promise is the same as what one would get out
|
||||
// of `getItem()` later. This leads to some weirdness
|
||||
// (setItem('foo', undefined) will return `null`), but
|
||||
// it's not my fault localStorage is our baseline and that
|
||||
// it's weird.
|
||||
if (value === undefined) {
|
||||
value = null;
|
||||
}
|
||||
|
||||
resolve(value);
|
||||
};
|
||||
transaction.onabort = transaction.onerror = function () {
|
||||
var err = req.error ? req.error : req.transaction.error;
|
||||
reject(err);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function removeItem(key, callback) {
|
||||
var self = this;
|
||||
|
||||
key = (0, _normalizeKey2.default)(key);
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
// We use a Grunt task to make this safe for IE and some
|
||||
// versions of Android (including those used by Cordova).
|
||||
// Normally IE won't like `.delete()` and will insist on
|
||||
// using `['delete']()`, but we have a build step that
|
||||
// fixes this for us now.
|
||||
var req = store.delete(key);
|
||||
transaction.oncomplete = function () {
|
||||
resolve();
|
||||
};
|
||||
|
||||
transaction.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
|
||||
// The request will be also be aborted if we've exceeded our storage
|
||||
// space.
|
||||
transaction.onabort = function () {
|
||||
var err = req.error ? req.error : req.transaction.error;
|
||||
reject(err);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function clear(callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_WRITE, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var req = store.clear();
|
||||
|
||||
transaction.oncomplete = function () {
|
||||
resolve();
|
||||
};
|
||||
|
||||
transaction.onabort = transaction.onerror = function () {
|
||||
var err = req.error ? req.error : req.transaction.error;
|
||||
reject(err);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function length(callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var req = store.count();
|
||||
|
||||
req.onsuccess = function () {
|
||||
resolve(req.result);
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function key(n, callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
if (n < 0) {
|
||||
resolve(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var advanced = false;
|
||||
var req = store.openKeyCursor();
|
||||
|
||||
req.onsuccess = function () {
|
||||
var cursor = req.result;
|
||||
if (!cursor) {
|
||||
// this means there weren't enough keys
|
||||
resolve(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (n === 0) {
|
||||
// We have the first key, return it if that's what they
|
||||
// wanted.
|
||||
resolve(cursor.key);
|
||||
} else {
|
||||
if (!advanced) {
|
||||
// Otherwise, ask the cursor to skip ahead n
|
||||
// records.
|
||||
advanced = true;
|
||||
cursor.advance(n);
|
||||
} else {
|
||||
// When we get here, we've got the nth key.
|
||||
resolve(cursor.key);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function keys(callback) {
|
||||
var self = this;
|
||||
|
||||
var promise = new _promise2.default(function (resolve, reject) {
|
||||
self.ready().then(function () {
|
||||
createTransaction(self._dbInfo, READ_ONLY, function (err, transaction) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
try {
|
||||
var store = transaction.objectStore(self._dbInfo.storeName);
|
||||
var req = store.openKeyCursor();
|
||||
var keys = [];
|
||||
|
||||
req.onsuccess = function () {
|
||||
var cursor = req.result;
|
||||
|
||||
if (!cursor) {
|
||||
resolve(keys);
|
||||
return;
|
||||
}
|
||||
|
||||
keys.push(cursor.key);
|
||||
cursor.continue();
|
||||
};
|
||||
|
||||
req.onerror = function () {
|
||||
reject(req.error);
|
||||
};
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function dropInstance(options, callback) {
|
||||
callback = _getCallback2.default.apply(this, arguments);
|
||||
|
||||
var currentConfig = this.config();
|
||||
options = typeof options !== 'function' && options || {};
|
||||
if (!options.name) {
|
||||
options.name = options.name || currentConfig.name;
|
||||
options.storeName = options.storeName || currentConfig.storeName;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var promise;
|
||||
if (!options.name) {
|
||||
promise = _promise2.default.reject('Invalid arguments');
|
||||
} else {
|
||||
var isCurrentDb = options.name === currentConfig.name && self._dbInfo.db;
|
||||
|
||||
var dbPromise = isCurrentDb ? _promise2.default.resolve(self._dbInfo.db) : _getOriginalConnection(options).then(function (db) {
|
||||
var dbContext = dbContexts[options.name];
|
||||
var forages = dbContext.forages;
|
||||
dbContext.db = db;
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
forages[i]._dbInfo.db = db;
|
||||
}
|
||||
return db;
|
||||
});
|
||||
|
||||
if (!options.storeName) {
|
||||
promise = dbPromise.then(function (db) {
|
||||
_deferReadiness(options);
|
||||
|
||||
var dbContext = dbContexts[options.name];
|
||||
var forages = dbContext.forages;
|
||||
|
||||
db.close();
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
var forage = forages[i];
|
||||
forage._dbInfo.db = null;
|
||||
}
|
||||
|
||||
var dropDBPromise = new _promise2.default(function (resolve, reject) {
|
||||
var req = _idb2.default.deleteDatabase(options.name);
|
||||
|
||||
req.onerror = req.onblocked = function (err) {
|
||||
var db = req.result;
|
||||
if (db) {
|
||||
db.close();
|
||||
}
|
||||
reject(err);
|
||||
};
|
||||
|
||||
req.onsuccess = function () {
|
||||
var db = req.result;
|
||||
if (db) {
|
||||
db.close();
|
||||
}
|
||||
resolve(db);
|
||||
};
|
||||
});
|
||||
|
||||
return dropDBPromise.then(function (db) {
|
||||
dbContext.db = db;
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
var _forage = forages[i];
|
||||
_advanceReadiness(_forage._dbInfo);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
(_rejectReadiness(options, err) || _promise2.default.resolve()).catch(function () {});
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
promise = dbPromise.then(function (db) {
|
||||
if (!db.objectStoreNames.contains(options.storeName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newVersion = db.version + 1;
|
||||
|
||||
_deferReadiness(options);
|
||||
|
||||
var dbContext = dbContexts[options.name];
|
||||
var forages = dbContext.forages;
|
||||
|
||||
db.close();
|
||||
for (var i = 0; i < forages.length; i++) {
|
||||
var forage = forages[i];
|
||||
forage._dbInfo.db = null;
|
||||
forage._dbInfo.version = newVersion;
|
||||
}
|
||||
|
||||
var dropObjectPromise = new _promise2.default(function (resolve, reject) {
|
||||
var req = _idb2.default.open(options.name, newVersion);
|
||||
|
||||
req.onerror = function (err) {
|
||||
var db = req.result;
|
||||
db.close();
|
||||
reject(err);
|
||||
};
|
||||
|
||||
req.onupgradeneeded = function () {
|
||||
var db = req.result;
|
||||
db.deleteObjectStore(options.storeName);
|
||||
};
|
||||
|
||||
req.onsuccess = function () {
|
||||
var db = req.result;
|
||||
db.close();
|
||||
resolve(db);
|
||||
};
|
||||
});
|
||||
|
||||
return dropObjectPromise.then(function (db) {
|
||||
dbContext.db = db;
|
||||
for (var j = 0; j < forages.length; j++) {
|
||||
var _forage2 = forages[j];
|
||||
_forage2._dbInfo.db = db;
|
||||
_advanceReadiness(_forage2._dbInfo);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
(_rejectReadiness(options, err) || _promise2.default.resolve()).catch(function () {});
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
(0, _executeCallback2.default)(promise, callback);
|
||||
return promise;
|
||||
}
|
||||
|
||||
var asyncStorage = {
|
||||
_driver: 'asyncStorage',
|
||||
_initStorage: _initStorage,
|
||||
_support: (0, _isIndexedDBValid2.default)(),
|
||||
iterate: iterate,
|
||||
getItem: getItem,
|
||||
setItem: setItem,
|
||||
removeItem: removeItem,
|
||||
clear: clear,
|
||||
length: length,
|
||||
key: key,
|
||||
keys: keys,
|
||||
dropInstance: dropInstance
|
||||
};
|
||||
exports.default = asyncStorage;
|
||||
module.exports = exports['default'];
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
module.exports = function (obj, predicate) {
|
||||
var ret = {};
|
||||
var keys = Object.keys(obj);
|
||||
var isArr = Array.isArray(predicate);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var val = obj[key];
|
||||
|
||||
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
||||
ret[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"find.js","sources":["../../src/add/operator/find.ts"],"names":[],"mappings":";;AAAA,yCAAuC"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"1":"L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","2":"C K"},C:{"1":"7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB","2":"0 1 2 3 4 5 6 CC tB I u J E F G A B C K L H M N O v w x y z DC EC"},D:{"1":"FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB"},E:{"1":"C K L H qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F G A B GC zB HC IC JC KC 0B"},F:{"1":"2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d","2":"0 1 G B C H M N O v w x y z OC PC QC RC qB 9B SC rB"},G:{"1":"dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC YC ZC aC bC cC"},H:{"2":"nC"},I:{"1":"D","2":"tB I oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"1":"e","2":"A B C qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"2":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:4,C:"Beacon API"};
|
||||
@@ -0,0 +1,153 @@
|
||||
[
|
||||
{
|
||||
"name": "AppVeyor",
|
||||
"constant": "APPVEYOR",
|
||||
"env": "APPVEYOR",
|
||||
"pr": "APPVEYOR_PULL_REQUEST_NUMBER"
|
||||
},
|
||||
{
|
||||
"name": "Azure Pipelines",
|
||||
"constant": "AZURE_PIPELINES",
|
||||
"env": "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI",
|
||||
"pr": "SYSTEM_PULLREQUEST_PULLREQUESTID"
|
||||
},
|
||||
{
|
||||
"name": "Bamboo",
|
||||
"constant": "BAMBOO",
|
||||
"env": "bamboo_planKey"
|
||||
},
|
||||
{
|
||||
"name": "Bitbucket Pipelines",
|
||||
"constant": "BITBUCKET",
|
||||
"env": "BITBUCKET_COMMIT",
|
||||
"pr": "BITBUCKET_PR_ID"
|
||||
},
|
||||
{
|
||||
"name": "Bitrise",
|
||||
"constant": "BITRISE",
|
||||
"env": "BITRISE_IO",
|
||||
"pr": "BITRISE_PULL_REQUEST"
|
||||
},
|
||||
{
|
||||
"name": "Buddy",
|
||||
"constant": "BUDDY",
|
||||
"env": "BUDDY_WORKSPACE_ID",
|
||||
"pr": "BUDDY_EXECUTION_PULL_REQUEST_ID"
|
||||
},
|
||||
{
|
||||
"name": "Buildkite",
|
||||
"constant": "BUILDKITE",
|
||||
"env": "BUILDKITE",
|
||||
"pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
|
||||
},
|
||||
{
|
||||
"name": "CircleCI",
|
||||
"constant": "CIRCLE",
|
||||
"env": "CIRCLECI",
|
||||
"pr": "CIRCLE_PULL_REQUEST"
|
||||
},
|
||||
{
|
||||
"name": "Cirrus CI",
|
||||
"constant": "CIRRUS",
|
||||
"env": "CIRRUS_CI",
|
||||
"pr": "CIRRUS_PR"
|
||||
},
|
||||
{
|
||||
"name": "AWS CodeBuild",
|
||||
"constant": "CODEBUILD",
|
||||
"env": "CODEBUILD_BUILD_ARN"
|
||||
},
|
||||
{
|
||||
"name": "Codeship",
|
||||
"constant": "CODESHIP",
|
||||
"env": { "CI_NAME": "codeship" }
|
||||
},
|
||||
{
|
||||
"name": "Drone",
|
||||
"constant": "DRONE",
|
||||
"env": "DRONE",
|
||||
"pr": { "DRONE_BUILD_EVENT": "pull_request" }
|
||||
},
|
||||
{
|
||||
"name": "dsari",
|
||||
"constant": "DSARI",
|
||||
"env": "DSARI"
|
||||
},
|
||||
{
|
||||
"name": "GitLab CI",
|
||||
"constant": "GITLAB",
|
||||
"env": "GITLAB_CI"
|
||||
},
|
||||
{
|
||||
"name": "GoCD",
|
||||
"constant": "GOCD",
|
||||
"env": "GO_PIPELINE_LABEL"
|
||||
},
|
||||
{
|
||||
"name": "Hudson",
|
||||
"constant": "HUDSON",
|
||||
"env": "HUDSON_URL"
|
||||
},
|
||||
{
|
||||
"name": "Jenkins",
|
||||
"constant": "JENKINS",
|
||||
"env": ["JENKINS_URL", "BUILD_ID"],
|
||||
"pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
|
||||
},
|
||||
{
|
||||
"name": "Magnum CI",
|
||||
"constant": "MAGNUM",
|
||||
"env": "MAGNUM"
|
||||
},
|
||||
{
|
||||
"name": "Netlify CI",
|
||||
"constant": "NETLIFY",
|
||||
"env": "NETLIFY_BUILD_BASE",
|
||||
"pr": { "env": "PULL_REQUEST", "ne": "false" }
|
||||
},
|
||||
{
|
||||
"name": "Sail CI",
|
||||
"constant": "SAIL",
|
||||
"env": "SAILCI",
|
||||
"pr": "SAIL_PULL_REQUEST_NUMBER"
|
||||
},
|
||||
{
|
||||
"name": "Semaphore",
|
||||
"constant": "SEMAPHORE",
|
||||
"env": "SEMAPHORE",
|
||||
"pr": "PULL_REQUEST_NUMBER"
|
||||
},
|
||||
{
|
||||
"name": "Shippable",
|
||||
"constant": "SHIPPABLE",
|
||||
"env": "SHIPPABLE",
|
||||
"pr": { "IS_PULL_REQUEST": "true" }
|
||||
},
|
||||
{
|
||||
"name": "Solano CI",
|
||||
"constant": "SOLANO",
|
||||
"env": "TDDIUM",
|
||||
"pr": "TDDIUM_PR_ID"
|
||||
},
|
||||
{
|
||||
"name": "Strider CD",
|
||||
"constant": "STRIDER",
|
||||
"env": "STRIDER"
|
||||
},
|
||||
{
|
||||
"name": "TaskCluster",
|
||||
"constant": "TASKCLUSTER",
|
||||
"env": ["TASK_ID", "RUN_ID"]
|
||||
},
|
||||
{
|
||||
"name": "TeamCity",
|
||||
"constant": "TEAMCITY",
|
||||
"env": "TEAMCITY_VERSION"
|
||||
},
|
||||
{
|
||||
"name": "Travis CI",
|
||||
"constant": "TRAVIS",
|
||||
"env": "TRAVIS",
|
||||
"pr": { "env": "TRAVIS_PULL_REQUEST", "ne": "false" }
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const types_1 = require("./types");
|
||||
function createRejection(error, ...beforeErrorGroups) {
|
||||
const promise = (async () => {
|
||||
if (error instanceof types_1.RequestError) {
|
||||
try {
|
||||
for (const hooks of beforeErrorGroups) {
|
||||
if (hooks) {
|
||||
for (const hook of hooks) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
error = await hook(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error_) {
|
||||
error = error_;
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
})();
|
||||
const returnPromise = () => promise;
|
||||
promise.json = returnPromise;
|
||||
promise.text = returnPromise;
|
||||
promise.buffer = returnPromise;
|
||||
promise.on = returnPromise;
|
||||
return promise;
|
||||
}
|
||||
exports.default = createRejection;
|
||||
Reference in New Issue
Block a user