@aws-amplify/core
Version:
Core category of aws-amplify
1 lines • 2.62 kB
Source Map (JSON)
{"version":3,"file":"KeyValueStorage.mjs","sources":["../../../src/storage/KeyValueStorage.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PlatformNotSupportedError } from '../errors';\n/**\n * @internal\n */\nexport class KeyValueStorage {\n constructor(storage) {\n this.storage = storage;\n }\n /**\n * This is used to set a specific item in storage\n * @param {string} key - the key for the item\n * @param {object} value - the value\n * @returns {string} value that was set\n */\n async setItem(key, value) {\n if (!this.storage)\n throw new PlatformNotSupportedError();\n this.storage.setItem(key, value);\n }\n /**\n * This is used to get a specific key from storage\n * @param {string} key - the key for the item\n * This is used to clear the storage\n * @returns {string} the data item\n */\n async getItem(key) {\n if (!this.storage)\n throw new PlatformNotSupportedError();\n return this.storage.getItem(key);\n }\n /**\n * This is used to remove an item from storage\n * @param {string} key - the key being set\n * @returns {string} value - value that was deleted\n */\n async removeItem(key) {\n if (!this.storage)\n throw new PlatformNotSupportedError();\n this.storage.removeItem(key);\n }\n /**\n * This is used to clear the storage\n * @returns {string} nothing\n */\n async clear() {\n if (!this.storage)\n throw new PlatformNotSupportedError();\n this.storage.clear();\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAEA;AACA;AACA;AACO,MAAM,eAAe,CAAC;AAC7B,IAAI,WAAW,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;AAC9B,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO;AACzB,YAAY,MAAM,IAAI,yBAAyB,EAAE;AACjD,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE;AACvB,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO;AACzB,YAAY,MAAM,IAAI,yBAAyB,EAAE;AACjD,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,UAAU,CAAC,GAAG,EAAE;AAC1B,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO;AACzB,YAAY,MAAM,IAAI,yBAAyB,EAAE;AACjD,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO;AACzB,YAAY,MAAM,IAAI,yBAAyB,EAAE;AACjD,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;AAC5B;AACA;;;;"}