{"id":13624487,"url":"https://github.com/tantaman/LargeLocalStorage","last_synced_at":"2025-04-16T00:32:26.336Z","repository":{"id":11143874,"uuid":"13510786","full_name":"tantaman/LargeLocalStorage","owner":"tantaman","description":"Problem: You need to store a large amount of key-value based data in IE, Chrome, Safari, AND Firefox","archived":false,"fork":false,"pushed_at":"2013-12-10T03:39:49.000Z","size":4661,"stargazers_count":530,"open_issues_count":8,"forks_count":48,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-11-07T12:09:17.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tantaman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-11T22:06:31.000Z","updated_at":"2024-10-30T10:07:56.000Z","dependencies_parsed_at":"2022-08-31T00:00:36.198Z","dependency_job_id":null,"html_url":"https://github.com/tantaman/LargeLocalStorage","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tantaman%2FLargeLocalStorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tantaman%2FLargeLocalStorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tantaman%2FLargeLocalStorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tantaman%2FLargeLocalStorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tantaman","download_url":"https://codeload.github.com/tantaman/LargeLocalStorage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223510300,"owners_count":17157306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:01:43.102Z","updated_at":"2024-11-08T13:30:34.091Z","avatar_url":"https://github.com/tantaman.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"LargeLocalStorage\n=================\n\n\n**Problem:** You need a large key-value store in the browser.\n\nTo make things worse: \n* DOMStorage only gives you 5mb\n* Chrome doesn't let you store blobs in IndexedDB\n* Safari doesn't support IndexedDB,\n* IE and Firefox both support IndexedDB but not the FilesystemAPI.\n\n`LargeLocalStorage` bridges all of that to give you a large capacity (up to several GB when authorized by the user) key-value store in the browser\n(IE 10, Chrome, Safari 6+, Firefox, Opera). \n\n* [docs](http://tantaman.github.io/LargeLocalStorage/doc/classes/LargeLocalStorage.html)\n* [tests](http://tantaman.github.io/LargeLocalStorage/test/)\n* [demo app](http://tantaman.github.io/LargeLocalStorage/examples/album/)\n\n## Basic Rundown / Examples\n\n### Creating a database\n\n```javascript\n// Specify desired capacity in bytes\nvar desiredCapacity = 125 * 1024 * 1024;\n\n// Create a 125MB key-value store\nvar storage = new LargeLocalStorage({size: desiredCapacity, name: 'myDb'});\n\n// Await initialization of the storage area\nstorage.initialized.then(function(grantedCapacity) {\n  // Check to see how much space the user authorized us to actually use.\n  // Some browsers don't indicate how much space was granted in which case\n  // grantedCapacity will be 1.\n  if (grantedCapacity != -1 \u0026\u0026 grantedCapacity != desiredCapacity) {\n  }\n});\n```\n  \n### Setting data\n\n```javascript  \n// You can set the contents of \"documents\" which are identified by a key.\n// Documents can only contains strings for their values but binary\n// data can be added as attachments.\n// All operations are asynchronous and return Q promises\nstorage.setContents('docKey', \"the contents...\").then(function() {\n  alert('doc created/updated');\n});\n  \n// Attachments can be added to documents.\n// Attachments are Blobs or any subclass of Blob (e.g, File).\n// Attachments can be added whether or not a corresponding document exists.\n// setAttachment returns a promise so you know when the set has completed.\nstorage.setAttachment('myDoc', 'titleImage', blob).then(function() {\n    alert('finished setting the titleImage attachment');\n});\n```\n\n### Retrieving Data\n\n```javascript\n// get the contents of a document\nstorage.getContents('myDoc').then(function(content) {\n});\n\n// Call getAttachment with the docKey and attachmentKey\nstorage.getAttachment('myDoc', 'titleImage').then(function(titleImage) {\n    // Create an image element with the retrieved attachment\n    // (or video or sound or whatever you decide to attach and use)\n    var img = new Image();\n    img.src = URL.createObjectURL(titleImage);\n    document.body.appendChild(img);\n    URL.revokeObjectURL(titleImage);\n});\n\n\n// If you just need a URL to your attachment you can get\n// the attachment URL instead of the attachment itself\nstorge.getAttachmentURL('somePreviouslySavedDoc', 'someAttachment').then(function(url) {\n  // do something with the attachment URL\n  // ...\n    \n  // revoke the URL\n  storage.revokeAttachmentURL(url);\n});\n```\n\n### Listing\n```javascript\n// You can do an ls to get all of the keys in your data store\nstorage.ls().then(function(listing) {\n  // listing is a list of all of the document keys\n  alert(listing);\n});\n  \n// Or get a listing of a document's attachments\nstorage.ls('somePreviouslySavedDoc').then(function(listing) {\n  // listing is a list of all attachments belonging to `somePreviouslySavedDoc`\n  alert(listing);\n});\n```\n\n### Removing\n```javascript\n// you can remove a document with rm\n// removing a document also removes all of that document's\n// attachments.\nstorage.rm('somePreviouslySavedDoc');\n  \n// you can also rm an attachment\nstorage.rmAttachment('someOtherDocKey', 'attachmentKey');\n\n// removals return promises as well so you know when the removal completes (or fails).\nstorage.rm('docKey').then(function() {\n  alert('Removed!');\n}, function(err) {\n  console.error('Failed removal');\n  console.error(err);\n});\n\n// clear the entire database\nstorage.clear();\n```\n\nMore:\n* Read the [docs](http://tantaman.github.io/LargeLocalStorage/doc/classes/LargeLocalStorage.html)\n* Run the [tests](http://tantaman.github.io/LargeLocalStorage/test/)\n* View the [demo app](http://tantaman.github.io/LargeLocalStorage/examples/album/)\n\n##Including\n\nInclude it on your page with a script tag:\n\n```\n\u003cscript src=\"path/to/LargeLocalStorage.js\"\u003e\u003c/script\u003e\n```\n\nOr load it as an amd module:\n\n```\ndefine(['components/lls/dist/LargeLocalStorage'], function(lls) {\n  var storage = new lls({size: 100 * 1024 * 1024});\n});\n```\n\nLLS depends on [Q](https://github.com/kriskowal/q) so you'll have to make sure you have that dependency.\n\n##Getting\ndownlad it directly\n\n* (dev) https://raw.github.com/tantaman/LargeLocalStorage/master/dist/LargeLocalStorage.js\n* (min) https://raw.github.com/tantaman/LargeLocalStorage/master/dist/LargeLocalStorage.min.js\n\nOr `bower install lls`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftantaman%2FLargeLocalStorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftantaman%2FLargeLocalStorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftantaman%2FLargeLocalStorage/lists"}