git.iko.soy/purescript-indexed-DB
on master help sign in
add Show instances for other foreign types
commitaeca81c760e0e64379939ec2b57c022543b76c10 authorKtorZ <matthias.benkort@gmail.com> dateThu 29 Jun 2017, 18:02 (9 years ago) parent889b776
2 files changed+52−2
src/Database/IndexedDB/Core.js+33−2 src/Database/IndexedDB/Core.purs+19
src/Database/IndexedDB/Core.js+33−2
@@ -1,15 +1,46 @@
1+const toArray = function toArray(xs) {
2+ return Array.prototype.slice.apply(xs);
3+};
4+
5+
6+exports._showCursor = function _showCursor(cursor) {
7+ return '(IDBCursor ' +
8+ '{ direction: ' + cursor.direction +
9+ ', key: ' + cursor.key +
10+ ', primaryKey: ' + cursor.primaryKey +
11+ ' })';
12+};
13+
114exports._showDatabase = function _showDatabase(db) {
215 return '(IDBDatabase ' +
316 '{ name: ' + db.name +
4− ', objectStoreNames: [' + exports.toArray(db.objectStoreNames).join(', ') + ']' +
17+ ', objectStoreNames: [' + toArray(db.objectStoreNames).join(', ') + ']' +
518 ', version: ' + db.version +
619 ' })';
720};
821
22+exports._showIndex = function _showIndex(index) {
23+ return '(IDBIndex ' +
24+ '{ name: ' + index.name +
25+ ', keyPath: ' + index.keyPath +
26+ ', multiEntry: ' + index.multiEntry +
27+ ', unique: ' + index.unique +
28+ ' })';
29+};
30+
31+exports._showKeyRange = function _showKeyRange(range) {
32+ return '(IDBKeyRange ' +
33+ '{ lower: ' + range.lower +
34+ ', upper: ' + range.upper +
35+ ', lowerOpen: ' + range.lowerOpen +
36+ ', upperOpen: ' + range.upperOpen +
37+ ' })';
38+};
39+
940exports._showObjectStore = function _showObjectStore(store) {
1041 return '(IDBObjectStore ' +
1142 '{ autoIncrement: ' + store.autoIncrement +
12− ', indexNames: [' + exports.toArray(store.indexNames).join(', ') + ']' +
43+ ', indexNames: [' + toArray(store.indexNames).join(', ') + ']' +
1344 ', keyPath: ' + store.keyPath +
1445 ', name: ' + store.name +
1546 ' })';
src/Database/IndexedDB/Core.purs+19
@@ -59,11 +59,30 @@ foreign import data Transaction :: Type
5959foreign import data ValueCursor :: Type
6060
6161
62+foreign import _showCursor :: forall cursor. cursor -> String
63+instance showKeyCursor :: Show KeyCursor where
64+ show = _showCursor
65+
66+
67+instance showValueCursor :: Show ValueCursor where
68+ show = _showCursor
69+
70+
6271foreign import _showDatabase :: Database -> String
6372instance showDatabase :: Show Database where
6473 show = _showDatabase
6574
6675
76+foreign import _showIndex :: Index -> String
77+instance showIndex :: Show Index where
78+ show = _showIndex
79+
80+
81+foreign import _showKeyRange :: KeyRange -> String
82+instance showKeyRange :: Show KeyRange where
83+ show = _showKeyRange
84+
85+
6786foreign import _showObjectStore :: ObjectStore -> String
6887instance showObjectStore :: Show ObjectStore where
6988 show = _showObjectStore