mentioned purpose, added better usage example, added more formatting
This commit is contained in:
		
							parent
							
								
									d3538718b9
								
							
						
					
					
						commit
						1e2bf28341
					
				
							
								
								
									
										22
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								README.md
									
									
									
									
									
								
							@ -3,9 +3,23 @@ localStorage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
An inefficient, but as W3C-compliant as possible using only pure JavaScript, `localStorage` implementation.
 | 
					An inefficient, but as W3C-compliant as possible using only pure JavaScript, `localStorage` implementation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var localStorage = require('localStorage');
 | 
					Purpose
 | 
				
			||||||
 | 
					----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This is meant for the purpose of being able to run unit-tests and such for browser-y modules in node.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Usage
 | 
				
			||||||
 | 
					----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var localStorage = require('localStorage')
 | 
				
			||||||
 | 
					      , myValue = { foo: 'bar', baz: 'quux' }
 | 
				
			||||||
 | 
					      ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    localStorage.setItem('myKey', JSON.stringify(myValue));
 | 
				
			||||||
 | 
					    myValue = localStorage.getItem('myKey');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
API
 | 
					API
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  * getItem(key)
 | 
					  * getItem(key)
 | 
				
			||||||
  * setItem(key, value)
 | 
					  * setItem(key, value)
 | 
				
			||||||
@ -15,6 +29,7 @@ API
 | 
				
			|||||||
  * length
 | 
					  * length
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Tests
 | 
					Tests
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    0 === localStorage.length;
 | 
					    0 === localStorage.length;
 | 
				
			||||||
    null === localStorage.getItem('doesn't exist');
 | 
					    null === localStorage.getItem('doesn't exist');
 | 
				
			||||||
@ -36,5 +51,6 @@ Tests
 | 
				
			|||||||
TODO / Bugs
 | 
					TODO / Bugs
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Does not persist.
 | 
					  * Does not persist.
 | 
				
			||||||
  Doesn't not emit `Storage` events
 | 
					    * could use `fs.readFileSync` at load and an occasional `fs.writeFile` to write-out localStorage.json
 | 
				
			||||||
 | 
					  * Doesn't not emit `Storage` events
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user