forked from jakearchibald/idb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better build system & updated dependencies
- Loading branch information
1 parent
12f14cb
commit 4882cae
Showing
68 changed files
with
2,959 additions
and
3,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
dist | ||
node_modules | ||
.rpt2_cache | ||
test-build | ||
.ts-tmp | ||
build/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=async-iterators.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
'use strict'; | ||
|
||
var __chunk_1 = require('./chunk.js'); | ||
var wrapIdbValue = require('./wrap-idb-value.js'); | ||
|
||
const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance']; | ||
const methodMap = {}; | ||
const advanceResults = new WeakMap(); | ||
const ittrProxiedCursorToOriginalProxy = new WeakMap(); | ||
const cursorIteratorTraps = { | ||
get(target, prop) { | ||
if (!advanceMethodProps.includes(prop)) | ||
return target[prop]; | ||
let cachedFunc = methodMap[prop]; | ||
if (!cachedFunc) { | ||
cachedFunc = methodMap[prop] = function (...args) { | ||
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args)); | ||
}; | ||
} | ||
return cachedFunc; | ||
}, | ||
}; | ||
async function* iterate(...args) { | ||
// tslint:disable-next-line:no-this-assignment | ||
let cursor = this; | ||
if (!(cursor instanceof IDBCursor)) { | ||
cursor = await cursor.openCursor(...args); | ||
} | ||
if (!cursor) | ||
return; | ||
cursor = cursor; | ||
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps); | ||
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor); | ||
// Map this double-proxy back to the original, so other cursor methods work. | ||
__chunk_1.reverseTransformCache.set(proxiedCursor, __chunk_1.unwrap(cursor)); | ||
while (cursor) { | ||
yield proxiedCursor; | ||
// If one of the advancing methods was not called, call continue(). | ||
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue()); | ||
advanceResults.delete(proxiedCursor); | ||
} | ||
} | ||
function isIteratorProp(target, prop) { | ||
return ((prop === Symbol.asyncIterator && | ||
__chunk_1.instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) || | ||
(prop === 'iterate' && __chunk_1.instanceOfAny(target, [IDBIndex, IDBObjectStore]))); | ||
} | ||
__chunk_1.addTraps(oldTraps => ({ | ||
get(target, prop, receiver) { | ||
if (isIteratorProp(target, prop)) | ||
return iterate; | ||
return oldTraps.get(target, prop, receiver); | ||
}, | ||
has(target, prop) { | ||
return isIteratorProp(target, prop) || oldTraps.has(target, prop); | ||
}, | ||
const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance']; | ||
const methodMap = {}; | ||
const advanceResults = new WeakMap(); | ||
const ittrProxiedCursorToOriginalProxy = new WeakMap(); | ||
const cursorIteratorTraps = { | ||
get(target, prop) { | ||
if (!advanceMethodProps.includes(prop)) | ||
return target[prop]; | ||
let cachedFunc = methodMap[prop]; | ||
if (!cachedFunc) { | ||
cachedFunc = methodMap[prop] = function (...args) { | ||
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args)); | ||
}; | ||
} | ||
return cachedFunc; | ||
}, | ||
}; | ||
async function* iterate(...args) { | ||
// tslint:disable-next-line:no-this-assignment | ||
let cursor = this; | ||
if (!(cursor instanceof IDBCursor)) { | ||
cursor = await cursor.openCursor(...args); | ||
} | ||
if (!cursor) | ||
return; | ||
cursor = cursor; | ||
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps); | ||
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor); | ||
// Map this double-proxy back to the original, so other cursor methods work. | ||
wrapIdbValue.reverseTransformCache.set(proxiedCursor, wrapIdbValue.unwrap(cursor)); | ||
while (cursor) { | ||
yield proxiedCursor; | ||
// If one of the advancing methods was not called, call continue(). | ||
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue()); | ||
advanceResults.delete(proxiedCursor); | ||
} | ||
} | ||
function isIteratorProp(target, prop) { | ||
return ((prop === Symbol.asyncIterator && | ||
wrapIdbValue.instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) || | ||
(prop === 'iterate' && wrapIdbValue.instanceOfAny(target, [IDBIndex, IDBObjectStore]))); | ||
} | ||
wrapIdbValue.addTraps(oldTraps => ({ | ||
get(target, prop, receiver) { | ||
if (isIteratorProp(target, prop)) | ||
return iterate; | ||
return oldTraps.get(target, prop, receiver); | ||
}, | ||
has(target, prop) { | ||
return isIteratorProp(target, prop) || oldTraps.has(target, prop); | ||
}, | ||
})); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=database-extras.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.