Northern Pileated Marmoset
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    closetpublic

    closet.js Build Status

    JSON persistent storage with methods chainability and callbacks for asynchronous use.

    Description

    Closet is a simple implementation of a persistend JSON storage. It supports method chainability and callbacks for asynchronous use.

    Basic example

    var closet = require('closet');
     
    closet.init('some.json');
    closet.set('a key','a value');
    console.log(closet.get('a key'));
    closet.persist();
    closet.del('a key');

    A slightly more complex example

    var closet = require('closet');
     
    closet
        .init('some.json')
        .load(function(res){
            if (res.code)
                console.log("Something happended!",res)
            else if (res) {
                console.log("File successfully loaded");
            } else {
                console.log("Storage not initialized");
            }
        })
        .set('pesco',33,function(key,value){
            console.log("Set ["+key+"]="+value);
        })
        .persist(function(res){
            if (res.code)
                console.log("Something happended!",res)
            else if (res) {
                console.log("File successfully saved");
            } else {
                console.log("Storage not initialized");
            }
        });

    Requirements

    Install

    npm install closet

    Tests

    npm install
    npm test

    License

    MIT License

    Copyright (C) 2012 Roberto Torella

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Keywords

    none

    install

    npm i closet

    Downloadsweekly downloads

    1

    version

    0.0.7

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar