@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/fireproof.mjs
CHANGED
@@ -41709,12 +41709,21 @@ class DbIndex {
|
|
41709
41709
|
applyMapFn (mapFn, name) {
|
41710
41710
|
if (typeof mapFn === 'string') {
|
41711
41711
|
this.mapFnString = mapFn;
|
41712
|
+
// make a regex that matches strings that only have letters, numbers, and spaces
|
41713
|
+
const regex = /^[a-zA-Z0-9 ]+$/;
|
41714
|
+
// if the string matches the regex, make a function that returns the value at that key
|
41715
|
+
if (regex.test(mapFn)) {
|
41716
|
+
this.mapFn = (doc, emit) => {
|
41717
|
+
if (doc[mapFn]) emit(doc[mapFn]);
|
41718
|
+
};
|
41719
|
+
this.includeDocsDefault = true;
|
41720
|
+
}
|
41712
41721
|
} else {
|
41713
41722
|
this.mapFn = mapFn;
|
41714
41723
|
this.mapFnString = mapFn.toString();
|
41715
41724
|
}
|
41716
41725
|
const matches = /=>\s*(.*)/.exec(this.mapFnString);
|
41717
|
-
this.includeDocsDefault = matches && matches.length > 0;
|
41726
|
+
this.includeDocsDefault = this.includeDocsDefault || (matches && matches.length > 0);
|
41718
41727
|
this.name = name || this.makeName();
|
41719
41728
|
}
|
41720
41729
|
|