@fireproof/core 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/db-index.js +11 -1
- package/dist/src/fireproof.d.ts +1 -1
- package/dist/src/fireproof.js +10 -1
- package/dist/src/fireproof.js.map +1 -1
- package/dist/src/fireproof.mjs +10 -1
- package/dist/src/fireproof.mjs.map +1 -1
- package/dist/src/import.js +29 -0
- package/dist/src/loader.js +15 -122
- package/dist/src/storage/base.js +348 -0
- package/dist/src/storage/browser.js +61 -0
- package/dist/src/storage/filesystem.js +65 -0
- package/dist/src/storage/rest.js +58 -0
- package/dist/src/storage/ucan.js +0 -0
- package/package.json +1 -1
- package/src/db-index.js +10 -1
package/dist/src/db-index.js
CHANGED
@@ -127,13 +127,23 @@ export class DbIndex {
|
|
127
127
|
applyMapFn(mapFn, name) {
|
128
128
|
if (typeof mapFn === 'string') {
|
129
129
|
this.mapFnString = mapFn;
|
130
|
+
// make a regex that matches strings that only have letters, numbers, and spaces
|
131
|
+
const regex = /^[a-zA-Z0-9 ]+$/;
|
132
|
+
// if the string matches the regex, make a function that returns the value at that key
|
133
|
+
if (regex.test(mapFn)) {
|
134
|
+
this.mapFn = (doc, emit) => {
|
135
|
+
if (doc[mapFn])
|
136
|
+
emit(doc[mapFn]);
|
137
|
+
};
|
138
|
+
this.includeDocsDefault = true;
|
139
|
+
}
|
130
140
|
}
|
131
141
|
else {
|
132
142
|
this.mapFn = mapFn;
|
133
143
|
this.mapFnString = mapFn.toString();
|
134
144
|
}
|
135
145
|
const matches = /=>\s*(.*)/.exec(this.mapFnString);
|
136
|
-
this.includeDocsDefault = matches && matches.length > 0;
|
146
|
+
this.includeDocsDefault = this.includeDocsDefault || (matches && matches.length > 0);
|
137
147
|
this.name = name || this.makeName();
|
138
148
|
}
|
139
149
|
makeName() {
|
package/dist/src/fireproof.d.ts
CHANGED
package/dist/src/fireproof.js
CHANGED
@@ -41711,12 +41711,21 @@ class DbIndex {
|
|
41711
41711
|
applyMapFn (mapFn, name) {
|
41712
41712
|
if (typeof mapFn === 'string') {
|
41713
41713
|
this.mapFnString = mapFn;
|
41714
|
+
// make a regex that matches strings that only have letters, numbers, and spaces
|
41715
|
+
const regex = /^[a-zA-Z0-9 ]+$/;
|
41716
|
+
// if the string matches the regex, make a function that returns the value at that key
|
41717
|
+
if (regex.test(mapFn)) {
|
41718
|
+
this.mapFn = (doc, emit) => {
|
41719
|
+
if (doc[mapFn]) emit(doc[mapFn]);
|
41720
|
+
};
|
41721
|
+
this.includeDocsDefault = true;
|
41722
|
+
}
|
41714
41723
|
} else {
|
41715
41724
|
this.mapFn = mapFn;
|
41716
41725
|
this.mapFnString = mapFn.toString();
|
41717
41726
|
}
|
41718
41727
|
const matches = /=>\s*(.*)/.exec(this.mapFnString);
|
41719
|
-
this.includeDocsDefault = matches && matches.length > 0;
|
41728
|
+
this.includeDocsDefault = this.includeDocsDefault || (matches && matches.length > 0);
|
41720
41729
|
this.name = name || this.makeName();
|
41721
41730
|
}
|
41722
41731
|
|