Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

vault

LocalStorage API with automatic JSON support

Subscribe to updates I use vault


Statistics on vault

Number of watchers on Github 80
Number of open issues 1
Average time to close an issue about 3 hours
Main language JavaScript
Average time to merge a PR 8 days
Open pull requests 0+
Closed pull requests 0+
Last commit about 4 years ago
Repo Created over 5 years ago
Repo Last Updated over 1 year ago
Size 205 KB
Organization / Authortoddmotto
Contributors3
Page Updated
Do you use vault? Leave a review!
View vault activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating vault for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Vault.js Build Status

Vault is a 0.4KB standalone localStorage API with automatic JSON support. The HTML5 spec permits localStorage to only accept a String as value of an Object property, Vault makes it possible to store entire JavaScript Objects. Vault uses a faster Object lookup than the suggested API methods.

IE8 supports localStorage, therefore Vault can be used with IE8+, but note browser storage limitations in IE8 compared to modern browsers.

Storing Objects

Vault allows you to automatically store JavaScript Objects and not just strings (default localStorage behaviour), allowing you to do the following:

var blink182 = {
  founded: '1992',
  formed: 'California',
  members: ['Tom Delonge', 'Mark Hoppus', 'Travis Barker']
};
vault.set('someBand', blink182);

set API

To set data into localStorage, you must use the set() API. There are two arguments, key for the Object's key, and value for the key value:

vault.set(key, value);

Example:

// localStorage, object key = name, value = 'Tom Delonge'
vault.set('name', 'Tom Delonge');

get API

Obtaining set data is easy with the get() API, simply reference a previously set key with key:

vault.get(key);

Example:

// getting 'name' from localStorage
// returns 'Tom Delonge'
vault.get('name');

remove API

Removing set data is easy with the remove() API, again reference a previously set key with key:

vault.remove(key);

Example:

// removes 'name' from localStorage
vault.remove('name');

empty API

It's a good idea to empty the user's localStorage when possible to avoid overloading it, there are limits which differ per browser. Specifically modern browsers allow around 5MB but IE versions are limited. IE8 also supports localStorage and Vault.

vault.empty();

Installing with Bower

To install Vault into your project using Bower, use the GitHub repository hook:

bower install https://github.com/toddmotto/vault.git

Manual installation

Drop your files into your required folders, make sure you're using the files from the dist folder, which is the compiled production-ready code. Ensure you place the script before the closing </body> tag so the DOM tree is populated when the script runs.

<body>
    <!-- html content above -->
    <script src="dist/vault.js"></script>
  <script>
  vault.set('name', 'Tom Delonge');
  </script>
</body>

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp.

Release history

  • 1.3.0
    • Fix bug with setting/getting falsy values
    • Slight restructure to internal API
  • 1.2.0
    • Lowercase module definition
    • Move to Gulp
  • 1.1.0
    • Remove sessionStorage support, localStorage can be cleared upon leaving if necessary
    • Ditch Web Storage API (set/get/remove) syntax and use native Object lookups for better performance
    • Add AMD support
  • 1.0.0
    • Initial release
vault open issues Ask a question     (View All Issues)
  • about 4 years Publish vault to npm?
vault questions on Stackoverflow (View All Questions)
  • In maven pom.xml always have to change version of vault plugin
  • Sd card corrupted while using vault
  • Reading vault secrets from consul-template
  • Open Media Vault Rsync syntax
  • SQL TD EKM Azure Key Vault - can't restore encrypted database
  • INTERNAL SERVICE ERROR when using stored card in Paypal Vault
  • knife, solo and vault - data_bag_item.rb:129:in `from_hash': undefined method `delete' for nil:NilClass (NoMethodError)
  • Azure Key Vault to Manage Secrets In Production and Development
  • SQL Azure IaaS encryption using Key Vault and a certificate
  • How Do I Create a Production Client Authentication Certificate for Azure Key Vault?
  • Azure Key Vault Access Policy Doesn't Work For Groups
  • Acquire Azure Key Vault Secret Using Integrated Security
  • Data Vault 2.0 in SQL Server
  • How to automate ansible vault decryption?
  • unable to delete glacier vault because not empty, but not able to delete archives
  • Cannot download Azure Site Recovery Vault Settings File
  • Azure VM with Bit-locker now fails to decrypt due to Azure Key Vault internal error?
  • Change Azure Backup Vault Redundancy
  • Data vault for NoSQL
  • Is symmetric encryption possible with Microsoft Azure Key Vault?
  • Azure Key Vault Physical HSM
  • Listing the archives from Amazon Glacier Vault in C#.NET
  • Can I create a CSR from Azure Key Vault?
  • Ansible: can I use a ssh key encrypted in the vault?
  • Chef Knife vault not decrypting correctly
  • Windows Azure key vault ad authentication fails for some projects
  • Hashicorp Vault for file storage?
  • Time series extraction from ghcn data vault
  • WSO2 ESB Secure Vault: Change Default KeyStore Password
  • Chef vault - error accessing vault item during kitchen converge
vault list of languages used
Other projects in JavaScript