Skip to content

Commit

Permalink
chore: add new build
Browse files Browse the repository at this point in the history
  • Loading branch information
esroyo authored and carles-thn committed Aug 3, 2022
1 parent 79b50f7 commit 291f49b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
50 changes: 45 additions & 5 deletions dist/immortal-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,38 @@ __webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"CookieStore": () => (/* reexport */ CookieStore),
"DEFAULT_DATABASE_NAME": () => (/* reexport */ DEFAULT_DATABASE_NAME),
"DEFAULT_KEY_PREFIX": () => (/* reexport */ DEFAULT_KEY_PREFIX),
"DEFAULT_STORES": () => (/* reexport */ DEFAULT_STORES),
"ImmortalDB": () => (/* binding */ ImmortalDB),
"DEFAULT_STORE_NAME": () => (/* reexport */ DEFAULT_STORE_NAME),
"DEFAULT_VALUE": () => (/* reexport */ DEFAULT_VALUE),
"ImmortalDecoderError": () => (/* reexport */ ImmortalDecoderError),
"ImmortalEncoderError": () => (/* reexport */ ImmortalEncoderError),
"ImmortalStorage": () => (/* reexport */ ImmortalStorage),
"IndexedDbStore": () => (/* reexport */ IndexedDbStore),
"LocalStorageStore": () => (/* reexport */ LocalStorageStore),
"SessionStorageStore": () => (/* reexport */ SessionStorageStore)
});

;// CONCATENATED MODULE: ./src/errors/immortal-encoder-error.js
class ImmortalEncoderError extends Error {
constructor(message = 'Unable to encode the value to be stored') {
super(message);
this.name = 'ImmortalEncoderError';
}

}
;// CONCATENATED MODULE: ./src/errors/immortal-decoder-error.js
class ImmortalDecoderError extends Error {
constructor(message = 'Unable to decode the stored value') {
super(message);
this.name = 'ImmortalDecoderError';
}

}
;// CONCATENATED MODULE: ./src/errors/index.js


// EXTERNAL MODULE: ./node_modules/js-cookie/src/js.cookie.js
var js_cookie = __webpack_require__(808);
var js_cookie_default = /*#__PURE__*/__webpack_require__.n(js_cookie);
Expand Down Expand Up @@ -591,6 +614,7 @@ try {
;// CONCATENATED MODULE: ./src/immortal-storage.js



const FULFILLED = 'fulfilled';
const REJECTED = 'rejected';

Expand Down Expand Up @@ -650,19 +674,36 @@ class ImmortalStorage {
}

const [value] = validated[0];
const decodedValue = this.decoder(value);
let decodedValue;

try {
decodedValue = await this.decoder(value);
} catch (_) {
throw new ImmortalDecoderError();
}

try {
await this.set(key, decodedValue);
} catch (e) {}
} catch (error) {
if (error instanceof ImmortalEncoderError) {
throw error;
}
}

return decodedValue;
}

async set(key, value) {
await this.onReady;
const prefixedKey = this.prefix(key);
const encodedValue = await Promise.resolve(this.encoder(value));
let encodedValue;

try {
encodedValue = await this.encoder(value);
} catch (_) {
throw new ImmortalEncoderError();
}

const results = await Promise.allSettled(this.stores.map(store => store.set(prefixedKey, encodedValue)));
const rejections = results.filter(result => result.status === REJECTED);

Expand Down Expand Up @@ -704,7 +745,6 @@ class ImmortalStorage {



const ImmortalDB = new ImmortalStorage();

})();

Expand Down
2 changes: 1 addition & 1 deletion dist/immortal-db.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thehotelsnetwork/immortal-db",
"private": false,
"version": "2.1.2",
"version": "3.0.0",
"main": "dist/immortal-db.js",
"module": "src/index.js",
"types": "immortal-db.d.ts",
Expand Down

0 comments on commit 291f49b

Please sign in to comment.