{"id":21919727,"url":"https://github.com/gilf/story.js","last_synced_at":"2025-04-19T12:35:07.927Z","repository":{"id":3052271,"uuid":"4073900","full_name":"gilf/story.js","owner":"gilf","description":"story.js enables web developers to use client-side storages in a simple and consistent way. It includes abstraction layer on top of Web Storage API, IndexedDB API, Cookies API and In-Memory storage.","archived":false,"fork":false,"pushed_at":"2012-06-10T12:07:17.000Z","size":236,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-09T23:48:37.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jasny/bootstrap","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilf.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-19T10:06:32.000Z","updated_at":"2019-11-30T01:32:59.000Z","dependencies_parsed_at":"2022-09-21T08:40:53.973Z","dependency_job_id":null,"html_url":"https://github.com/gilf/story.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilf%2Fstory.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilf%2Fstory.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilf%2Fstory.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilf%2Fstory.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilf","download_url":"https://codeload.github.com/gilf/story.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226979168,"owners_count":17712574,"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-11-28T20:10:20.246Z","updated_at":"2024-11-28T20:10:20.793Z","avatar_url":"https://github.com/gilf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"story.js enables web developers to use client-side storages in a simple and consistent way. \nIt includes abstraction layer on top of Web Storage API, IndexedDB API, Cookies API and In-Memory storage.\nYou can use a very easy to learn API in order to master the library. \n\nSome code examples:\nIn order to use a storage in story.js you first retrieve it from the story object. For example, here is an example of retrieving the localStorage abstraction:\nvar storage = story.storage(story.StorageTypes.LOCAL_STORAGE);\n\nAfter you have the storage object you can use one of the following functions: get, getAll, contain, add, update, remove, and clear. \nEvery operation exposes a deferred object that can get a success and error callback.\nFor example, the following code shows how to use the localStorage abstraction with some API calls:\nvar storage = story.storage(story.StorageTypes.LOCAL_STORAGE);\nstorage.add(\"key\", \"value\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);});\nstorage.get(\"key\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\nstorage.contains(\"key\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\nstorage.update(\"key\", \"value1\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\nstorage.remove(\"key\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\nstorage.contains(\"key\").then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\nstorage.clear().then(function (data) {\n    console.log(data);\n}, function (error) {\n    console.log(error);\n});\n\nstory.js also includes a query object that exposes a query language that resembles LINQ. \nThe query language implementation include functions such as where, forEach, first, last and etc.\nThe query object is exposed as a plugin to the story.js library.\nFor example, the following code shows how to use the query object:\nar storage = story.storage(story.StorageTypes.IN_MEMORY);\nstorage.getAll().then(function (data) {\n    var items = storage.query.from(data).where(function (item) {\n        return item.key === \"key2\";\n    }).forEach(function (item) {\n        console.log(item.key + ' ' + item.value);\n    });\n}, function (error) {\n    console.log(error);\n}); \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilf%2Fstory.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilf%2Fstory.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilf%2Fstory.js/lists"}