All Projects â†’ jaywcjlove â†’ Store.js

jaywcjlove / Store.js

Licence: mit
A simple, lightweight JavaScript API for handling browser localStorage , it is easy to pick up and use, has a reasonable footprint 2.36kb(gzipped: 1.04kb), and has no dependencies.

Programming Languages

javascript
184084 projects - #8 most used programming language
javascipt
17 projects

Projects that are alternatives of or similar to Store.js

Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+93.26%)
Mutual labels:  json, localstorage
Stormdb
🌩ī¸ StormDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database for NodeJS, the browser or Electron.
Stars: ✭ 406 (+9.43%)
Mutual labels:  json, localstorage
Proxy Storage
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
Stars: ✭ 10 (-97.3%)
Mutual labels:  json, localstorage
Vue Ls
đŸ’Ĩ Vue plugin for work with local storage, session storage and memory storage from Vue context
Stars: ✭ 468 (+26.15%)
Mutual labels:  json, localstorage
Lowdb
Simple to use local JSON database (supports Node, Electron and the browser)
Stars: ✭ 16,886 (+4451.48%)
Mutual labels:  json, localstorage
Newton Api
➗ A really micro micro-service for advanced math.
Stars: ✭ 358 (-3.5%)
Mutual labels:  json
Jaggr
JSON Aggregation CLI
Stars: ✭ 365 (-1.62%)
Mutual labels:  json
Arrow
🏹 Parse JSON with style
Stars: ✭ 355 (-4.31%)
Mutual labels:  json
Hashover Next
This branch will be HashOver 2.0
Stars: ✭ 353 (-4.85%)
Mutual labels:  json
Mymovies
A Flutter app which shows a list of popular movies.
Stars: ✭ 371 (+0%)
Mutual labels:  json
Jsondiffpatch
Diff & patch JavaScript objects
Stars: ✭ 3,951 (+964.96%)
Mutual labels:  json
Bigchaindb
Meet BigchainDB. The blockchain database.
Stars: ✭ 3,768 (+915.63%)
Mutual labels:  json
Ngrest
Fast and easy C++ RESTful WebServices framework
Stars: ✭ 357 (-3.77%)
Mutual labels:  json
Node Rest Client
REST API client from node.js
Stars: ✭ 365 (-1.62%)
Mutual labels:  json
5e Database
Database for the D&D 5th Edition API
Stars: ✭ 354 (-4.58%)
Mutual labels:  json
Json To Html Table
Simple Json to standard HTML table converter in fastest way
Stars: ✭ 367 (-1.08%)
Mutual labels:  json
Jqview
simplest possible native GUI for inspecting JSON objects with jq
Stars: ✭ 355 (-4.31%)
Mutual labels:  json
Tbox
🎁 A glib-like multi-platform c library
Stars: ✭ 3,800 (+924.26%)
Mutual labels:  json
Tswechat
A WeChat alternative. Written in Swift 5.
Stars: ✭ 3,674 (+890.3%)
Mutual labels:  json
Zjsonpatch
This is an implementation of RFC 6902 JSON Patch written in Java
Stars: ✭ 362 (-2.43%)
Mutual labels:  json

JavaScript localStorage

Build and test storejs Coverage Status GitHub issues GitHub forks GitHub stars store.js

A simple, lightweight JavaScript API for handling browser localStorage , it is easy to pick up and use, has a reasonable footprint 2.08kb(gzipped: 0.97kb), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks.

Features:

🚀 Has no dependencies
🌱 Works in all browsers
đŸ”Ĩ Heavily tested
đŸ“Ļ Supports AMD/CommonJS
đŸ’Ĩ store.min.js 2.08kb(gzipped: 0.97kb)

Usage

Installed via npm. You will need Node.js installed on your system.

$ npm install storejs --save
import store from 'storejs';

store('test', 'tank', 1)

Or manually download and link storejs in your HTML, It can also be downloaded via UNPKG or jsDelivr CDN:

<script src="https://unpkg.com/cookiejs/dist/cookie.min.js"></script>
<script type="text/javascript">
  store('test', 'tank');
</script>

Basic Usage

store(key, data);                 // Single storage string data
store({key: data, key2: data2});  // Bulk storage of multiple string data
store(key);             // Get `key` string data
store("?key");          // Determine if the `key` exists
store();                // Get all key/data
//store(false);đŸ”Ģ       // (Deprecated) because it is easy to empty the storage because of a null value or an error
//store(key, false); đŸ”Ģ  // (Deprecated)

store.set(key, data[, overwrite]);    // === store(key, data);
store.set({key: data, key2: data2})   // === store({key: data, key2: data});
store.get(key[, alt]);                // === store(key);
store.get("?key");                    // Determine if the `key` exists
store.get("key1", "key2", "key3");    // Get `key1`,`key2`,`key3` data
store.remove(key);                    // ===store(key,false)
store.clear();                      // Clean all key/data
store.keys();                       // Returns an array of all the keys
store.forEach(callback);            // Loop traversal, return false to end traversal
store.search(string);               // Search method

store.has(key); //⇒ Determine if there is a return true/false

//⇒ Provide callback method to process data
store('test', (key,val) => {
  console.log(val) // Processing the data obtained through the test here
  return [3,4,5] // Return data and set store
})

store(['key', 'key2'], (key) => {
  // Get data processing of multiple keys, return and save;
  console.log('key:', key)
  return '逐ä¸Ē更攚数捎'
})

Storage Event

Responding to storage changes with the StorageEvent

if(window.addEventListener){
  window.addEventListener("storage",handle_storage,false);
}else if(window.attachEvent){
  window.attachEvent("onstorage",handle_storage);
}
function handle_storage(e){
  if(!e){e=window.event;}
  //showStorage();
}
Property Type Description
key String The named key that was added, removed, or moddified
oldValue Any The previous value(now overwritten), or null if a new item was added
newValue Any The new value, or null if an item was added
url/uri String The page that called the method that triggered this change

Chained Call

store.set('ad', 234).get('ad')

TODO

  • [ ] store.get([key,key2]) Get method, return json
  • [ ] store([key,key2]) Get method, return json
  • [ ] onStorage Method test cases, and implementation

License

Licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].