Helper library for key-value-based storage

open-source
storage
filesystem

#1

Just as a quick tip: If you need simple key-value-based storage for your plugin, I’ve written a little helper which serves as an abstraction layer for dealing with this.

You can find it at https://github.com/pklaschka/xd-storage-helper. It is MIT-Licensed and automatically serializes “serializable” objects (via JSON.stringify()). Additionally, instead of returning “null” when nothing is stored, you can pass it a default value that gets returned and saved when nothing was saved in this key (so you don’t have to deal with such special cases if you don’t want to).

It is very easy to use, has JSDoc-comments (so you get help and autocompletion with many IDEs) and is also documented on https://github.com/pklaschka/xd-storage-helper/blob/master/README.md. Therefore, you shouldn’t have any problems using it.

PS: It also got featured in the xd-awesome list :tada: (still so happy about that one – I just had to mention it – sorry :wink:)


#2

Thanks for your library, BTW – It is truly awesome :slight_smile:


#3

I gave this repo (and a few others) a shoutout on stage at the Adobe Open Source Summit last week. I’ve got a blog post coming that will link to it as well.

Thanks for the contributions you’re making back to the community through open source projects!


#4

I’m excited to announce that I’ve just published the storage helper to npm, so you can also easily integrate it when you have a bundler like webpack configured for your plugin. Then, you can just run

npm i xd-storage-helper

or

yarn add xd-storage-helper

to install it and access it by using

const storageHelper = require('xd-storage-helper');

As before, I still support “plain-old” plugins by just copying the storage-helper.js file from the GitHub-Repo as before.


#5

I just fixed a small, but pretty severe bug, that lead to the data not actually getting saved (that had happened because I had refactored something :innocent:). Therefore, if it didn’t work for you before, please reinstall the package and it should work as expected (I’ve now also added some Unit tests to make sure that doesn’t happen again)…


#6

And – yet another update :wink:. I’ve now included typescript definitions (to use it with typescript) and improved the performance of reading operations (i.e. storageHelper.get(...) – it now doesn’t read the contents of the file again every time .get() gets called).

You can – as always – find the new release (v1.2.0) on npm as well as on GitHub – Release notes and the GitHub release can be found at https://github.com/pklaschka/xd-storage-helper/releases/tag/v1.2.0.