UNPKG

@aws-amplify/core

Version:

Core category of aws-amplify

1 lines • 3.48 kB
{"version":3,"file":"SyncKeyValueStorage.mjs","sources":["../../../src/storage/SyncKeyValueStorage.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar _SyncKeyValueStorage_storage;\nimport { __classPrivateFieldGet, __classPrivateFieldSet } from \"tslib\";\nimport { PlatformNotSupportedError } from '../errors';\n/**\n * @internal\n */\nexport class SyncKeyValueStorage {\n constructor(storage) {\n _SyncKeyValueStorage_storage.set(this, void 0);\n __classPrivateFieldSet(this, _SyncKeyValueStorage_storage, storage, \"f\");\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 */\n setItem(key, value) {\n if (!__classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\"))\n throw new PlatformNotSupportedError();\n __classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\").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 * @returns {string | null} the data item\n */\n getItem(key) {\n if (!__classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\"))\n throw new PlatformNotSupportedError();\n return __classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\").getItem(key);\n }\n /**\n * This is used to remove an item from storage\n * @param {string} key - the key being set\n */\n removeItem(key) {\n if (!__classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\"))\n throw new PlatformNotSupportedError();\n __classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\").removeItem(key);\n }\n /**\n * This is used to clear the storage\n */\n clear() {\n if (!__classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\"))\n throw new PlatformNotSupportedError();\n __classPrivateFieldGet(this, _SyncKeyValueStorage_storage, \"f\").clear();\n }\n}\n_SyncKeyValueStorage_storage = new WeakMap();\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA,IAAI,4BA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