{"id":27169097,"url":"https://github.com/naughtysora/naughty-storage","last_synced_at":"2025-07-26T11:09:15.373Z","repository":{"id":273757761,"uuid":"920208762","full_name":"NaughtySora/naughty-storage","owner":"NaughtySora","description":"Nodejs Storage- interfaces for inverting dependency of you application","archived":false,"fork":false,"pushed_at":"2025-01-26T12:01:09.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T14:42:03.816Z","etag":null,"topics":["async","dependency-inversion","filesystem","nodejs","storage"],"latest_commit_sha":null,"homepage":"","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/NaughtySora.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-21T18:48:12.000Z","updated_at":"2025-02-13T18:21:12.000Z","dependencies_parsed_at":"2025-01-22T20:29:41.944Z","dependency_job_id":null,"html_url":"https://github.com/NaughtySora/naughty-storage","commit_stats":null,"previous_names":["naughtysora/naughty-storage"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaughtySora%2Fnaughty-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaughtySora%2Fnaughty-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaughtySora%2Fnaughty-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaughtySora%2Fnaughty-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaughtySora","download_url":"https://codeload.github.com/NaughtySora/naughty-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247991090,"owners_count":21029627,"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":["async","dependency-inversion","filesystem","nodejs","storage"],"created_at":"2025-04-09T06:30:37.115Z","updated_at":"2025-07-26T11:09:15.352Z","avatar_url":"https://github.com/NaughtySora.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Naughty Storage\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/NaughtySora/naughty-storage/blob/master/LICENSE)\n[![snyk](https://snyk.io/test/github/NaughtySora/naughty-storage/badge.svg)](https://snyk.io/test/github/NaughtySora/naughty-storage)\n[![npm version](https://badge.fury.io/js/naughty-storage.svg)](https://badge.fury.io/js/naughty-storage)\n[![NPM Downloads](https://img.shields.io/npm/dm/naughty-storage)](https://www.npmjs.com/package/naughty-storage)\n[![NPM Downloads](https://img.shields.io/npm/dt/naughty-storage)](https://www.npmjs.com/package/naughty-storage)\n\n## Usage\n- Install: `npm install naughty-storage`\n- Require: `const utils = require('naughty-storage')`\n\n\n## Storages implement Map interface with async contract\n\n- Initial purpose to use different storages like - memory, file, and more to replace dependency in your project.\n- Also can be useful for convenient access to file system and much more.\n- Intially FileStorage **saves data into root package folder (node_modules)**, to change this use File.location(path) static method in root project file\n\n### change FileStorage root storage location\n```js\n\nconst main = () =\u003e {\n  //root project file\n  FileStorage.location(\"./\");\n  await startDB();\n  await startSomeServer();\n};\n```\n\n### pick - choose callback last err first contract function to put result into storage \n\n```js\nconst storage = new FileStorage(\"collection\");\nawait storage.pick(\"key\", fs.readFile, \"./path\");\nconst output = await storage.get(\"key\");\n```\n\n### get/set\n```js\nconst storage = new FileStorage(\"collection\");\nawait storage.set(\"key\", \"some valuable string\");\nconst data = await storage.get(\"key\");\n```\n\n### delete\n```js \nconst storage = new MemoryStorage(\"collection\");\nawait storage.set(\"key\", { greet: \"hello\" });\nawait storage.delete(\"key\"); // boolean\n```\n\n### iteration\n```js \nconst storage = FileStorage(\"collection\");\nawait storage.set(\"key\", {a: 1});\nawait storage.set(\"key-1\", {b: 2});\nawait storage.set(\"key-2\", {c: 3});\n\nfor await (const entry of storage) {\n  // [\"key\", {a: 1}]\n  // [\"key-1\", {b: 2}]\n  // [\"key-2\", {c: 3}]\n}\n\nfor await (const key of storage.keys()) {\n  // \"key\"\n  // \"key-1\"\n  // \"key-2\"\n}\n\nfor await (const value of storage.values()) {\n  // {a: 1}\n  // {b: 2}\n  // {c: 3}\n}\n```\n\n## Part of naughty stack\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaughtysora%2Fnaughty-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaughtysora%2Fnaughty-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaughtysora%2Fnaughty-storage/lists"}