Skip to content

Commit

Permalink
fix(async-storage): stringify data
Browse files Browse the repository at this point in the history
  • Loading branch information
BuptStEve committed Jan 18, 2021
1 parent bf5a740 commit 8794a91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/storageEngines/asyncStorage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { logger } from '../utils'
import { logger, stringify } from '../utils'
import { ERROR_MSGS } from '../constants'

/**
Expand Down Expand Up @@ -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 }))
Expand Down
4 changes: 2 additions & 2 deletions test/AsyncStorage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit 8794a91

Please sign in to comment.