diff --git a/package.json b/package.json index 248bb81..82abf3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tua-storage", - "version": "1.8.1", + "version": "1.8.2", "description": "🏗 A common storage for web(localStorage), for RN(AsyncStorage), for mini-program(wx) or just memory cache(Node.js)", "main": "dist/tua-storage.cjs.js", "module": "dist/tua-storage.esm.js", diff --git a/src/storageEngines/asyncStorage.js b/src/storageEngines/asyncStorage.js index 8d56aea..e15a2fb 100644 --- a/src/storageEngines/asyncStorage.js +++ b/src/storageEngines/asyncStorage.js @@ -1,6 +1,6 @@ // @ts-check -import { logger } from '../utils' +import { logger, stringify } from '../utils' import { ERROR_MSGS } from '../constants' /** @@ -28,7 +28,7 @@ export default function formatMethodsByAS () { .catch(logger.error) ) const _getItem = bindFnToSE(getItem) - const _setItem = bindFnToSE(setItem) + const _setItem = (key, data) => bindFnToSE(setItem)(key, stringify(data)) const _getAllKeys = bindFnToSE(getAllKeys) const _removeItem = bindFnToSE(removeItem) const _getInfo = () => _getAllKeys().then(keys => ({ keys })) diff --git a/test/AsyncStorage.test.js b/test/AsyncStorage.test.js index d68868f..1edd159 100644 --- a/test/AsyncStorage.test.js +++ b/test/AsyncStorage.test.js @@ -139,7 +139,7 @@ describe('async methods', () => { // storage expect(store.size).toBe(1) - expect(stringify(store.get(targetKey))).toBe(expectedVal) + expect(store.get(targetKey)).toBe(expectedVal) }) test('remove some undefined items', async () => { @@ -157,7 +157,7 @@ describe('async methods', () => { // storage expect(store.size).toBe(1) - expect(stringify(store.get(targetKey))).toBe(expectedVal) + expect(store.get(targetKey)).toBe(expectedVal) }) test('get storage info', async () => {