diff --git a/src/_utils.ts b/src/_utils.ts index a9c3c9a4..9bba95b0 100644 --- a/src/_utils.ts +++ b/src/_utils.ts @@ -35,7 +35,7 @@ export function stringify(value: any): string { return String(value); } - if (isPureObject(value)) { + if (isPureObject(value) || Array.isArray(value)) { return JSON.stringify(value); } diff --git a/test/storage.test.ts b/test/storage.test.ts index f83bd0f6..3e129d1a 100644 --- a/test/storage.test.ts +++ b/test/storage.test.ts @@ -109,4 +109,9 @@ describe("utils", () => { // Get keys from sub-storage expect(await mntStorage.getKeys("foo")).toStrictEqual(["foo:x", "foo:y"]); }); + + it("stringify", () => { + const storage = createStorage(); + expect(async () => await storage.setItem("foo", [])).not.toThrow(); + }); });