{"id":18774197,"url":"https://github.com/leny/pandri","last_synced_at":"2025-08-12T15:03:48.672Z","repository":{"id":13766588,"uuid":"16461430","full_name":"leny/pandri","owner":"leny","description":"In-memory key/value store, with json file backup.","archived":false,"fork":false,"pushed_at":"2019-10-22T18:51:40.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T21:47:11.008Z","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/leny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-02T19:33:05.000Z","updated_at":"2019-10-22T18:51:42.000Z","dependencies_parsed_at":"2022-09-26T19:43:09.249Z","dependency_job_id":null,"html_url":"https://github.com/leny/pandri","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/leny%2Fpandri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fpandri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fpandri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fpandri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leny","download_url":"https://codeload.github.com/leny/pandri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680988,"owners_count":19679509,"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-07T19:37:42.832Z","updated_at":"2025-02-19T15:18:19.218Z","avatar_url":"https://github.com/leny.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pandri\n\n![NPM version](http://img.shields.io/npm/v/pandri.svg) ![Build Status](http://img.shields.io/travis/leny/pandri.svg) ![Dependency Status](https://david-dm.org/leny/pandri.svg) ![Downloads counter](http://img.shields.io/npm/dm/pandri.svg) [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\nIn-memory key/value store, with json file backup.\n\n* * *\n\ncoded by leny\n\nstarted at 02/02/14\n\n* * *\n\n## Documentation\n\n\u003e This README is a *literate coffeescript* file, containing the documentation AND the code.\n\nAll the stores are stored in a private variable called _stores, the *in-memory storage*. :)\n\n    _stores = {}\n\n    FS = require \"fs\"\n    Path = require \"path\"\n    mkdirp = require \"mkdirp\"\n\n    module.exports = class Pandri\n\n### store = new Pandri( name [, path [, callback ] ] )\n\nCreate and return a **pandri store** object.\n\n        constructor: ( @name, @path = no, callback = no ) -\u003e\n\nStore the instance inside the in-memory storage.\n\n            @_content = {}\n\n            _stores[ @name ] = @\n\n#### store.name\n\nReturn the name of the store, use to find it in in-memory storage.\n\n#### store.path\n\nReturn the `path` used for `load()` and `save()` operations.\n\nThe parameters `path` and `callback`, if present, are used to make a direct call to `store.load()`.\n\n            @load @path, callback if @path\n\n### store.load( path [, callback ] )\n\nLoad a json file inside the store.\nIf the file doesn't exists, it will be create at the first call of `store.save()`.\nThe `path` is stored in `store.path`.\n\nThe callback will receive two parameters : `error` (if an error occures, unless it will be `null`), and `store`, the current store instance.\n\n        load: ( path, callback = no ) -\u003e\n            @path = path ? @path\n            readOptions =\n                encoding: \"utf-8\"\n            FS.readFile @path, readOptions, ( err, rawContent ) =\u003e\n                return callback and callback( err ) if err\n                try\n                    @_content = JSON.parse rawContent\n                catch err\n                    return callback and callback err\n                return callback and callback null, @\n\n### store.get( key )\n\nReturn the value associated to the `key` in the store, or `null` if it doesn't exists.\n\n        get: ( key ) -\u003e\n            @_content[ key ] ? null\n\n### store.set( key, value )\n\nAffect the `value` to the `key` in the store.\n\n        set: ( key, value ) -\u003e\n            @_content[ key ] = value\n\n### store.remove( key )\n\nDelete the `key` from the store.\n\n        remove: ( key ) -\u003e\n            delete @_content[ key ]\n\n### store.save( [ path [, callback ] ] )\n\nStore the data in the json `path`. The `path` is stored in `store.path`. If no path are given, the path from `store.path` is used.\n\nThe callback will receive two parameters : `error` (if an error occures, unless it will be `null`), and `store`, the current store instance.\n\n        save: ( path = no, callback = no ) -\u003e\n            callback = path if not callback and typeof path is \"function\"\n            @path = ( if typeof path is \"string\" then path else null ) ? @path\n            mkdirp Path.dirname( @path ), ( err ) =\u003e\n                return callback and callback err if err\n                FS.writeFile @path, JSON.stringify( @_content ), ( err ) =\u003e\n                    return callback and callback err if err\n                    callback and callback null, @\n\n### store.toJSON( [ beautify [, indentSize = 4 ] ] )\n\nReturn the (beautified or not) data of the store as json.\n\n        toJSON: ( beautify = no, indentSize = 4 ) -\u003e\n            JSON.stringify @_content, no, ( if beautify then indentSize else no )\n\n### store = Pandri.get( name )\n\n(**static method**) Retrieve a store from the memory.\nIf no store is found, return a new one.\n\n        @get: ( name ) -\u003e\n            _stores[ name ] ?= new Pandri name\n\n### Pandri.clear( name )\n\n(**static method**) Remove a store from the memory.\n**Note:** only clear the object in the memory. The target file remains unchanged.\n\n        @clear: ( name ) -\u003e\n            delete _stores[ name ]\n\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.\n\nLint and test your code using [Grunt](http://gruntjs.com/).\n\nThe **pandri** lib is an unique file, the present `README.md` file, compiled in `javascript` as a *literate coffeescript* file.\n\n## Release History\n\n* **2014-02-02** : starting project\n* **2014-02-03** : version 0.1.0\n    * Initial release\n* **2014-02-04** : version 0.1.1\n    * Bugfixes\n* **2014-02-04** : version 0.1.2\n    * Bugfixes\n* **2014-02-04** : version 0.1.3\n    * Remove `store.hasChange` property, saving at each call to `store.save()`\n    * Bugfixes\n\n\n## License\nCopyright (c) 2014 Leny\nLicensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fpandri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleny%2Fpandri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fpandri/lists"}