Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Options to auto-manage special objects likeDate,Map andSet#556

cyrilletuzi started this conversation inGeneral
Discussion options

As stated in theserialization guide:

In most cases, this library usesindexedDB storage, which allows any value type. But in special cases (like in Firefox / IE private mode, see thebrowser support guide for details), the library will fall back tolocalStorage, where JSON serialization will happen.

Everything can be serialized (JSON.stringify()), but when you unserialize (JSON.parse()), you'll only get a JSON, ie. a primitive type, an array or aliteral object.

So if you store an instance of a specific class inlocalStorage, likeDate,Map,Set orBlob, what you'll get then with.setItem() won't be aMap,Set orBlob, but just a literal object.

So, it's safer tostick to JSON-compatible values.

The library could add options to manageDate,Map orSet automatically.

It requires:

  1. API design,
  2. time: I don't have time currently to implement new features, sosponsoring or community PRs are welcomed (after having agreed on the API design)
You must be logged in to vote

Replies: 2 comments

Comment options

cyrilletuzi
Jun 15, 2020
Maintainer Author

Closing this issue as adding this would complicate the API for a small enhancement. StoringDate,Map andSet is already working forindexedDb (which is 99% of cases), and safely storing them forlocalStorage is easy anddocumented.

You must be logged in to vote
0 replies
Comment options

cyrilletuzi
Nov 5, 2020
Maintainer Author

Reopening this issue as it may be allowed by#483

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
1 participant
@cyrilletuzi
Converted from issue

This discussion was converted from issue #137 on February 12, 2021 16:27.


[8]ページ先頭

©2009-2025 Movatter.jp