GithubHelp home page GithubHelp logo

zadarkside / simplestorage Goto Github PK

View Code? Open in Web Editor NEW
304.0 304.0 54.0 60 KB

Cross-browser key-value store database to store data locally in the browser. Simpler fork of jStorage

License: The Unlicense

JavaScript 68.15% HTML 31.85%

simplestorage's Introduction

Metrics

simplestorage's People

Contributors

andris9 avatar appleboy avatar avdg avatar fishdrowned avatar jorrit avatar lukasdrgon avatar proteamer avatar rafeememon avatar waynebloss avatar will-e-yams avatar xuefeng-zhu avatar zadarkside avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplestorage's Issues

Default value in get() function

Hi,

I like Simplestorage.But the [defaultValue] in get() function is missing ...
I must copy the jstorage code (one line ...) on every new version
if you can add this little but "required" option :)

Regards
Frédérik

Auto Storage?

I'm testing out simpleStorage.

I see you have a timer for length of time to persist.

I am wondering if an automated storing option to this software, might be more appropriate.

Example: Local Storage allows you to set an interval option to auto store. How might I do that with simpleStorage to accomplish the same thing, basically an auto store of a data/js var with simpleStorage js?

Maybe an addition? Or needed feature?

[enhancement request] add set key option: session

Please consider adding another option for setting keys: session.
Similar to jQuery cookie, this would clear that key on browser close (or on re-open, if not technically possible on close).

Might require using cookies internally to figure out when browser was closed/open.

Question: collision problem

If two sites both use simpleStorage for caching data, and they each decide to give the same key to different items, they would clobber each other, correct?

Maybe this means domain name + port should be automatically added to the key?

Thoughts?

.min.js where ?

I cant find minified version of simpleStorage.please update

npm support

It would be useful to publish this repo on npm, for use with npm and browserify.

bump version to 0.2.1 - update npm

I just noticed the hasKey() method, and updated my project (using npm -> webpack to include simplestorage.js from node_modules). Cross-referenced the npm package simplestorage.js with the github repo - both have same version - but only the repo has the updated method.

Confusing to have two files with same version containing different data.

Not sure what the normal process is, but could you update the npm package to reflect the changes in github? Thanks!

Suggestion, different way of handling the data

IF the stored data set is getting big, then adding 1 small item requires to stringify the whole data set... :(

Take the data outside the simplestore object and put it directly in the localstorage.
This will improve performance by a great deal..

cheerio

Better detection on Safari

Hello,

Using localStorage on Safari on iOS will result in JS errors when in private mode:
http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-safari-quota-exceeded-err-dom-exception-22-an
http://stackoverflow.com/questions/13208878/localstorage-not-accessible-in-ios-6-safari

Would you please consider a better detection of localStorage actually working, and if not, handle as if not available instead of erroring?
e.g. simpleStorage.get() could return undefined

Thanks

key character limitations

I haven't been able to isolate this to simpleStorage yet, but I thought it might be worth a question here. I am using symbols as well as alphanumeric characters in my keys, and it seems to be creating some issues. Specifically, it seems that a key with :, {, or } causes simpleStorage to lose track of where data stops and starts, and it goes into some sort of loop until storage space is exhausted. For example, if a key were "abc=:fg}" it would cause a problem.

When I look at localStorage.simpleStorage, I see some of my keys repeating hundreds of times.

I certainly don't think this is an issue with simpleStorage (since using symbols within keys is a little...odd), but it would be nice to document what can and can't be used.

could you provide a package.json for npm support

could you provide a package.json for npm support?
maybe I did it wrong. node/npm is new to me but:

npm install andris/simpleStorage --save-dev
failed to install into my node_modules dir.
It just left the package in my /tmp dir

npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli 'andris9/simpleStorage',
1 verbose cli '--save-dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink /usr/bin/node
5 verbose readDependencies using package.json deps
6 verbose cache add [ 'andris9/simpleStorage', null ]
7 verbose cache add name=undefined spec="andris9/simpleStorage" args=["andris9/simpleStorage",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url slashes: null,
8 verbose parsed url auth: null,
8 verbose parsed url host: null,
8 verbose parsed url port: null,
8 verbose parsed url hostname: null,
8 verbose parsed url hash: null,
8 verbose parsed url search: null,
8 verbose parsed url query: null,
8 verbose parsed url pathname: 'andris9/simpleStorage',
8 verbose parsed url path: 'andris9/simpleStorage',
8 verbose parsed url href: 'andris9/simpleStorage' }
9 silly lockFile 08b95450-andris9-simpleStorage andris9/simpleStorage
10 verbose lock andris9/simpleStorage /home/me/.npm/08b95450-andris9-simpleStorage.lock
11 info maybeGithub Attempting andris9/simpleStorage from git://github.com/andris9/simpleStorage
12 silly lockFile 13dfc454-github-com-andris9-simpleStorage git://github.com/andris9/simpleStorage
13 verbose lock git://github.com/andris9/simpleStorage /home/me/.npm/13dfc454-github-com-andris9-simpleStorage.lock
14 verbose addRemoteGit [ 'git://github.com/andris9/simpleStorage', 'master' ]
15 verbose git clone git://github.com/andris9/simpleStorage Cloning into bare repository '/home/me/.npm/_git-remotes/git-github-com-andris9-simpleStorage-13dfc454'...
16 verbose git fetch -a origin (git://github.com/andris9/simpleStorage)
17 verbose git rev-list -n1 master 621893c
18 verbose resolved git url git://github.com/andris9/simpleStorage#621893c4db81ec8d1a830911aec79b2dfdb2f461
19 verbose tar unpack /home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/tmp.tgz
20 silly lockFile 4ff9b9cd-150-0-003355482593178749-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/package
21 verbose lock tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/package /home/me/.npm/4ff9b9cd-150-0-003355482593178749-package.lock
22 silly lockFile 56c0a4d5-150-0-003355482593178749-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/tmp.tgz
23 verbose lock tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/tmp.tgz /home/me/.npm/56c0a4d5-150-0-003355482593178749-tmp-tgz.lock
24 silly gunzTarPerm modes [ '755', '644' ]
25 silly gunzTarPerm extractEntry
26 silly gunzTarPerm modified mode [ '', 509, 493 ]
27 silly gunzTarPerm extractEntry .travis.yml
28 silly gunzTarPerm modified mode [ '.travis.yml', 436, 420 ]
29 silly gunzTarPerm extractEntry CHANGELOG.md
30 silly gunzTarPerm modified mode [ 'CHANGELOG.md', 436, 420 ]
31 silly gunzTarPerm extractEntry LICENSE
32 silly gunzTarPerm modified mode [ 'LICENSE', 436, 420 ]
33 silly gunzTarPerm extractEntry README.md
34 silly gunzTarPerm modified mode [ 'README.md', 436, 420 ]
35 silly gunzTarPerm extractEntry bower.json
36 silly gunzTarPerm modified mode [ 'bower.json', 436, 420 ]
37 silly gunzTarPerm extractEntry example/
38 silly gunzTarPerm modified mode [ 'example/', 509, 493 ]
39 silly gunzTarPerm extractEntry example/index.html
40 silly gunzTarPerm modified mode [ 'example/index.html', 436, 420 ]
41 silly gunzTarPerm extractEntry simpleStorage.js
42 silly gunzTarPerm modified mode [ 'simpleStorage.js', 436, 420 ]
43 silly gunzTarPerm extractEntry tests/
44 silly gunzTarPerm modified mode [ 'tests/', 509, 493 ]
45 silly gunzTarPerm extractEntry tests/index.html
46 silly gunzTarPerm modified mode [ 'tests/index.html', 436, 420 ]
47 silly gunzTarPerm extractEntry tests/tests.js
48 silly gunzTarPerm modified mode [ 'tests/tests.js', 436, 420 ]
49 silly lockFile 4ff9b9cd-150-0-003355482593178749-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/package
50 silly lockFile 4ff9b9cd-150-0-003355482593178749-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/package
51 silly lockFile 56c0a4d5-150-0-003355482593178749-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/tmp.tgz
52 silly lockFile 56c0a4d5-150-0-003355482593178749-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438792150-0.003355482593178749/tmp.tgz
53 silly lockFile 13dfc454-github-com-andris9-simpleStorage git://github.com/andris9/simpleStorage
54 silly lockFile 13dfc454-github-com-andris9-simpleStorage git://github.com/andris9/simpleStorage
55 info maybeGithub Attempting andris9/simpleStorage from git+ssh://[email protected]:andris9/simpleStorage
56 silly lockFile e525de65-github-com-andris9-simpleStorage git+ssh://[email protected]:andris9/simpleStorage
57 verbose lock git+ssh://[email protected]:andris9/simpleStorage /home/me/.npm/e525de65-github-com-andris9-simpleStorage.lock
58 verbose addRemoteGit [ '[email protected]:andris9/simpleStorage', 'master' ]
59 verbose git clone [email protected]:andris9/simpleStorage Cloning into bare repository '/home/me/.npm/_git-remotes/git-github-com-andris9-simpleStorage-899419a2'...
60 verbose git fetch -a origin ([email protected]:andris9/simpleStorage)
61 verbose git rev-list -n1 master 621893c
62 verbose resolved git url git+ssh://[email protected]:andris9/simpleStorage#621893c4db81ec8d1a830911aec79b2dfdb2f461
63 verbose tar unpack /home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/tmp.tgz
64 silly lockFile 87ba7c69-4957-0-20818886999040842-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/package
65 verbose lock tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/package /home/me/.npm/87ba7c69-4957-0-20818886999040842-package.lock
66 silly lockFile 395db80c-4957-0-20818886999040842-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/tmp.tgz
67 verbose lock tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/tmp.tgz /home/me/.npm/395db80c-4957-0-20818886999040842-tmp-tgz.lock
68 silly gunzTarPerm modes [ '755', '644' ]
69 silly gunzTarPerm extractEntry
70 silly gunzTarPerm modified mode [ '', 509, 493 ]
71 silly gunzTarPerm extractEntry .travis.yml
72 silly gunzTarPerm modified mode [ '.travis.yml', 436, 420 ]
73 silly gunzTarPerm extractEntry CHANGELOG.md
74 silly gunzTarPerm modified mode [ 'CHANGELOG.md', 436, 420 ]
75 silly gunzTarPerm extractEntry LICENSE
76 silly gunzTarPerm modified mode [ 'LICENSE', 436, 420 ]
77 silly gunzTarPerm extractEntry README.md
78 silly gunzTarPerm modified mode [ 'README.md', 436, 420 ]
79 silly gunzTarPerm extractEntry bower.json
80 silly gunzTarPerm modified mode [ 'bower.json', 436, 420 ]
81 silly gunzTarPerm extractEntry example/
82 silly gunzTarPerm modified mode [ 'example/', 509, 493 ]
83 silly gunzTarPerm extractEntry example/index.html
84 silly gunzTarPerm modified mode [ 'example/index.html', 436, 420 ]
85 silly gunzTarPerm extractEntry simpleStorage.js
86 silly gunzTarPerm modified mode [ 'simpleStorage.js', 436, 420 ]
87 silly gunzTarPerm extractEntry tests/
88 silly gunzTarPerm modified mode [ 'tests/', 509, 493 ]
89 silly gunzTarPerm extractEntry tests/index.html
90 silly gunzTarPerm modified mode [ 'tests/index.html', 436, 420 ]
91 silly gunzTarPerm extractEntry tests/tests.js
92 silly gunzTarPerm modified mode [ 'tests/tests.js', 436, 420 ]
93 silly lockFile 87ba7c69-4957-0-20818886999040842-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/package
94 silly lockFile 87ba7c69-4957-0-20818886999040842-package tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/package
95 silly lockFile 395db80c-4957-0-20818886999040842-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/tmp.tgz
96 silly lockFile 395db80c-4957-0-20818886999040842-tmp-tgz tar:///home/me/tmp/npm-22308-9haBb96U/1393438794957-0.20818886999040842/tmp.tgz
97 silly lockFile 899419a2-github-com-andris9-simpleStorage [email protected]:andris9/simpleStorage
98 silly lockFile 08b95450-andris9-simpleStorage andris9/simpleStorage
99 silly lockFile 08b95450-andris9-simpleStorage andris9/simpleStorage
100 error addLocal Could not install andris9/simpleStorage
101 error Error: ENOENT, stat 'andris9/simpleStorage'
102 error If you need help, you may report this entire log,
102 error including the npm and node versions, at:
102 error http://github.com/isaacs/npm/issues
103 error System Linux 3.5.0-23-generic
104 error command "/usr/bin/node" "/usr/bin/npm" "install" "andris9/simpleStorage" "--save-dev"
105 error cwd /home/me/workspace/play/d3/WebContent
106 error node -v v0.10.25
107 error npm -v 1.3.24
108 error path andris9/simpleStorage
109 error code ENOENT
110 error errno 34
111 verbose exit [ 34, true ]

Possible to store data outside the simpleStorage object?

jStorage is great, and I think simpleStorage is great for a more minimal footprint. The concern I have with both scripts is the dependency that would result from using either. The key/value data is stored within the jStorage/simpleStorage object. This makes it difficult to transition from or to simpleStorage when visitors have pre-existing localStorage data already set in the browser.

Using localStorage directly, or other storage wrappers, the key/value data is stored at the root/top-level by default. I understand your rationale for doing it differently (such as supporting TTL), but would you consider modifying it so that the key/value data is stored at the root/top-level instead? Or perhaps mirror the data to break the dependency, or track TTL separately? Or whatever else would work to allow folks to seamlessly transition to using simpleStorage?

Thanks.

Create global defaults object

Support global defaults object with access to the following properties:

  • global TTL
  • storage location ( local [default] | session )

SimpleStorage maybe not ready?

I'm using this to check if user already visited the web page to do some stuff on first visit only

if (typeof simpleStorage.get('visited') != 'string')

This is called in jQuery's $(document).ready(...)

On the (slower and crappier) test-server this works just fine, but on the production server the statement is always true. Also I don't have the possibility to different scenarios on the production server because, well, it is a production server.

[bug] a key is saved when other key is set

test 1: works great

simpleStorage.set("sa", [1,2,3])
var a = simpleStorage.get("sa")
a.shift()
simpleStorage.get("sa")
[2,3] //expected, points to same object

//refresh page
simpleStorage.get("sa")
[1,2,3]
//perfect

test 2: "sa" key is saved when "whatever" key is saved

simpleStorage.set("sa", [1,2,3])
var a = simpleStorage.get("sa")
a.shift()
simpleStorage.get("sa")
[2,3] //expected, points to same object
simpleStorage.set("whatever", "abc")

//refresh page
simpleStorage.get("sa")
[2,3]
//bug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.