{"_id":"@aerox0/simple-storage","_rev":"2-c63ba8aa788f9c48d6ed61caab07c8e4","name":"@aerox0/simple-storage","dist-tags":{"latest":"3.0.6"},"versions":{"3.0.1":{"name":"@aerox0/simple-storage","version":"3.0.1","description":"This is a simple file storage package that helps you to save data into file in formats like plaintext, json, yaml or even create your own formatter.","repository":{"type":"git","url":"git+https://github.com/aerox0/simple-storage.git"},"license":"MIT","bugs":{"url":"https://github.com/aerox0/simple-storage/issues"},"main":"./script/mod.js","module":"./esm/mod.js","exports":{".":{"import":"./esm/mod.js","require":"./script/mod.js"}},"dependencies":{"@deno/shim-deno":"~0.18.0"},"devDependencies":{"@types/node":"^20.9.0"},"_id":"@aerox0/simple-storage@3.0.1","gitHead":"c6ed006b0f34b926e15ac4e0475ac0c0f3286cdc","types":"./script/mod.d.ts","homepage":"https://github.com/aerox0/simple-storage#readme","_nodeVersion":"22.1.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-/KSQEq6GKqYFMdLv4IFGVC1PQk1SEEQy+KRcDGiV9Z9r+awsjPHJb1mXOhNnHq6ay5b2GwKyXFb8Z3u4jJLTsw==","shasum":"053bba7858d4ed7073ace65eb27c2b2387579d95","tarball":"https://registry.npmjs.org/@aerox0/simple-storage/-/simple-storage-3.0.1.tgz","fileCount":659,"unpackedSize":827850,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFxKBadNetuWH0fmtAOQDRPYX08ikUHWKcShOgCqoNMhAiEArkMoz08hiS/C2pLPIRqKO29GmUnDgf0trrQ1wHJfYi8="}]},"_npmUser":{"name":"aerox0","email":"maerox1@gmail.com"},"directories":{},"maintainers":[{"name":"aerox0","email":"maerox1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-storage_3.0.1_1716140346785_0.48917466618671224"},"_hasShrinkwrap":false},"3.0.5":{"name":"@aerox0/simple-storage","version":"3.0.5","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","description":"A simple API for creating a type-safe fetcher with Zod","scripts":{"dev":"vitest","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts","lint":"tsc","release":"bun run build && changeset publish"},"keywords":["file","storage","json","yaml"],"author":{"name":"aerox0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aerox0/simple-storage.git"},"bugs":{"url":"https://github.com/aerox0/simple-storage/issues"},"devDependencies":{"@changesets/cli":"^2.26.0","@types/bun":"^1.1.2","tsup":"^6.5.0","typescript":"^5.4.5","vitest":"^0.28.4"},"dependencies":{"yaml":"^2.4.2"},"_id":"@aerox0/simple-storage@3.0.5","gitHead":"cc291efe6601e01f2416d7191123bee94b1b3f2d","homepage":"https://github.com/aerox0/simple-storage#readme","_nodeVersion":"22.1.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-b+osNbJXSWX2jugOiobBoxksWxKcFN6fHSnW2DOyKZKqNieo44dXdyf6ZeupGVW+jLdcPQvU9XWG+jBOttqgrg==","shasum":"7b190d8296f7cb7714855f10b14fd8f561fda489","tarball":"https://registry.npmjs.org/@aerox0/simple-storage/-/simple-storage-3.0.5.tgz","fileCount":17,"unpackedSize":583331,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAcI4R+vFANIeW0AB6xZVjF1u4i1SW04SbW/gcVdeXXSAiEA1qSJpIynvTEfcwXUTrOYOj3Zhd68mTRBvfu9VznxXnw="}]},"_npmUser":{"name":"aerox0","email":"maerox1@gmail.com"},"directories":{},"maintainers":[{"name":"aerox0","email":"maerox1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-storage_3.0.5_1716144239025_0.3296924105279626"},"_hasShrinkwrap":false},"3.0.6":{"name":"@aerox0/simple-storage","version":"3.0.6","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","description":"This is a simple file storage package that helps you to save data into file in formats like plaintext, json, yaml or even create your own formatter.","scripts":{"dev":"vitest","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts","lint":"tsc","release":"bun run build && changeset publish"},"keywords":["file","storage","json","yaml"],"author":{"name":"aerox0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/aerox0/simple-storage.git"},"bugs":{"url":"https://github.com/aerox0/simple-storage/issues"},"devDependencies":{"@changesets/cli":"^2.26.0","@types/bun":"^1.1.2","tsup":"^6.5.0","typescript":"^5.4.5","vitest":"^0.28.4"},"dependencies":{"yaml":"^2.4.2"},"_id":"@aerox0/simple-storage@3.0.6","gitHead":"030ab71085bb1050c856ba770cb348b9221de30c","homepage":"https://github.com/aerox0/simple-storage#readme","_nodeVersion":"22.1.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-O3TfFSD2ixT54cU9++2PKAszn0AmkODd/HPcMIU6V71rdw/uqhfIK+p/VYkSooYXEd510Hu6KGjDbqzNf47k9w==","shasum":"848af02b545b71deb064819ba9ba5921d286c522","tarball":"https://registry.npmjs.org/@aerox0/simple-storage/-/simple-storage-3.0.6.tgz","fileCount":17,"unpackedSize":583425,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDmjw9Lalmq8cfKxSMl8k554p/92z8DjfawdT9ZxdIDnAiEAqOLKt4UtWccXiPJoXojVTQH3Ml9XysmIqimaIWoK1/4="}]},"_npmUser":{"name":"aerox0","email":"maerox1@gmail.com"},"directories":{},"maintainers":[{"name":"aerox0","email":"maerox1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-storage_3.0.6_1716144577948_0.2740025836660771"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-19T17:39:06.702Z","3.0.1":"2024-05-19T17:39:06.978Z","modified":"2024-05-19T18:49:38.352Z","3.0.5":"2024-05-19T18:43:59.281Z","3.0.6":"2024-05-19T18:49:38.136Z"},"maintainers":[{"name":"aerox0","email":"maerox1@gmail.com"}],"description":"This is a simple file storage package that helps you to save data into file in formats like plaintext, json, yaml or even create your own formatter.","homepage":"https://github.com/aerox0/simple-storage#readme","repository":{"type":"git","url":"git+https://github.com/aerox0/simple-storage.git"},"bugs":{"url":"https://github.com/aerox0/simple-storage/issues"},"license":"MIT","readme":"# Description\n\nThis is a simple file storage package that helps you to save data into file in formats like plaintext, json, yaml or even create your own formatter.\n\n## Instrucitons\n\n### How to install\n\n```\n<!-- With npm -->\nnpm install @aerox0/simple-storage\n\n```\n\n### How to use\n\nBasic Example\n\n```ts\nimport { JsonStorage } from '@aerox0/simple-storage';\nimport { YamlStorage } from '@aerox0/simple-storage';\nimport { TextStorage } from '@aerox0/simple-storage';\n\nconst storage = new JsonStorage(\"test.json\", {\n  name: \"John\",\n  age: 25,\n});\n// OR you can define the storage using typescript\nconst storage = new JsonStorage<{name: string, age: number}>(\"test.json\")\nstorage.data = {name: \"John\", age: 25};\n\nawait storage.init(); // will create the file and dir if do not exists with the default content\n\nstorage.data.age = 17;\nawait storage.save(); // will save the data into the file\n\nawait storage.load(); // will load the data from the file into storage.data\n```\n\nExample Using Middlewares and Validation\n\n```ts\nimport { JsonStorage } from '@aerox0/simple-storage';\n\nconst storage = new JsonStorage(\"test.json\", {\n  name: \"John\",\n  age: 25,\n});\n\nstorage.middleware.use((data) => {\n  if (data.age < 18) {\n    throw new Error(\"You must be at least 18 years old to use this program.\");\n  }\n});\n\n// will throw an error if the number is lower than 18\nawait storage.init()\nawait storage.save()\nawait storage.validate()\nawait storage.load()\n\n// also you can validate by passing the data to validate\nawait storage.validate({age: 17}) // will validate only the data from argument\nawait storage.validate() // will validate data from storage.data\n```\n\nCreate your own Storage\n\n```ts\nimport { StorageBase } from '@aerox0/simple-storage';\n\nclass EncryptedJsonStorage extends StorageBase {\n  constructor(filePath: string, data = {} as T) {\n\t\tsuper(filePath, data);\n\t}\n\n\tasync stringify(data: T): Promise<string> {\n    const te = new TextEncoder();\n\t\treturn te.encode(JSON.stringify(data));\n\t}\n\n\tasync parse(rawData: string): Promise<T> {\n    const td = new TextDecoder();\n\t\treturn JSON.parse(td.decode(rawData));\n\t}\n}\n```\n","readmeFilename":"README.md","keywords":["file","storage","json","yaml"],"author":{"name":"aerox0"}}