{"_id":"seraphim","_rev":"101-b7c7903ddf2343de7fa176d9bebdc875","name":"seraphim","description":"Configuration loader","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.0":{"name":"seraphim","version":"0.0.0","description":"Your personal configuration guard","keywords":["configuration","file","environment","cli"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"_id":"seraphim@0.0.0","dist":{"shasum":"1ca5c99dbc2486774af3205c28472722a8902dad","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.0.0.tgz","integrity":"sha512-mC6WmdSqImobwXoEnu4B/TLXkO8QTEpuw67WDvtak17CRyAIYZycp9Gkn94e/U4TpTZ/hSqGXcKd9pCdFtQzPA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICcuEiPnWs7XuTpgENtbEkV/kiGTFtK9aCULC0F7PWXiAiA2iRAII650DdGs3K+EcOwDZ1eUxbogTrQ8Avlax8MB0g=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{}},"0.0.1":{"name":"seraphim","version":"0.0.1","description":"Configuration loader","keywords":["configuration","file","environment","cli","object","merge"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"dependencies":{"deferred-queue":"*"},"devDependencies":{"argp":"*","js-yaml":"*","properties":"*"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"_id":"seraphim@0.0.1","dist":{"shasum":"ca76ea63aaa6b2788997ae4399d164f172ab35e8","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.0.1.tgz","integrity":"sha512-6/ezxtYFLyRr3pbhimjOnpvYVUvM54QM7AyVvE1kLmBkCoO9feHlPLaiYOV5sWShL1ST4mE3jEx6giEPf5ovTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqqusSBWJX6bGZpgtE9EgDhswuByO2/b1Vkc/LKNOUAgIgNOoBeTyGdZ8UPn2yAZHP4/7SPBwP9GD5XlbK+qtNeVc="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{}},"0.0.2":{"name":"seraphim","version":"0.0.2","description":"Configuration loader","keywords":["configuration","file","environment","cli","object","merge"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"dependencies":{"deferred-queue":"*"},"devDependencies":{"argp":"*","js-yaml":"*","properties":"*"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"_id":"seraphim@0.0.2","dist":{"shasum":"0f6f3f46afbb6a9202e594783a0b30046b68c4fe","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.0.2.tgz","integrity":"sha512-1dWqcq0t+BZn5MA4NG/3IL/vpOlvLDvJLDD91lu4tn9wy4ctKgP3ROsJw1fUWZw79BQY9apzPnkSoxv7ZW6KwQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH5wwSlkg3SutllTFxIvMq2WbW65kS0LITL++SI2TsQVAiEAiP1a6eqNf0ks/5bGh6IcJ2RTxAZ51k/FtHbCqHSGMzA="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{}},"0.0.3":{"name":"seraphim","version":"0.0.3","description":"Configuration loader","keywords":["configuration","file","environment","cli","object","merge"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"dependencies":{"deferred-queue":"*"},"devDependencies":{"argp":"*","js-yaml":"*","properties":"*"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"_id":"seraphim@0.0.3","dist":{"shasum":"ffa11e0be6f1f2d090bd8914509e6efdb410e3f9","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.0.3.tgz","integrity":"sha512-SKorebQ4NcMhsx3tcmcIHEqMRGO7QxMY5TiCm2od+i07uTqrlv4Pu7zRLLtIih8fI7DBsdBXAkrHqWIxF71wUQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDXJACpi8TphrAF1o23z5fEbmQfWLYKMPu5ya79l12YDQIgKot9BhPBh5RLa4tzxDaA0aLa21bvFS8AsK9c6aTsruU="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{}},"0.0.4":{"name":"seraphim","version":"0.0.4","description":"Configuration loader","keywords":["configuration","file","environment","cli","object","merge","cascade"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"dependencies":{"deferred-queue":"0.5.x"},"devDependencies":{"argp":"*","js-yaml":"*","properties":"*"},"scripts":{"test":"node test/index"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"homepage":"https://github.com/gagle/node-seraphim","_id":"seraphim@0.0.4","dist":{"shasum":"6f848018c2d44d3421037bd6df268375db3f97f2","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.0.4.tgz","integrity":"sha512-Tj4jlCzeRTB7WGu73e4nndEKhhH3CyPLVXT/dPI8bgWstbuOdscAr3OPhnQFw4Mnv7bO1FGgNHhZs5Yq9K/w6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhMh6tuPKn1/kD6Z86rnPVOnvVI6XFBEtm7dgb/UNybwIgQBfokTUiPEGj8QaaqOpN15DBaWVsR8c0T6zFqWBci7Q="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{}},"0.1.0":{"name":"seraphim","version":"0.1.0","description":"Configuration loader","keywords":["configuration","file","environment","cli","object","merge","cascade"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"engines":{"node":">=0.10"},"dependencies":{"deferred-queue":"0.5.x"},"devDependencies":{"argp":"*","js-yaml":"*","properties":"*"},"scripts":{"test":"node test/index"},"license":"MIT","main":"lib","bugs":{"url":"https://github.com/gagle/node-seraphim/issues"},"homepage":"https://github.com/gagle/node-seraphim","_id":"seraphim@0.1.0","dist":{"shasum":"35e4ebadf894a2d33211645e73a627de781d3fdb","tarball":"https://registry.npmjs.org/seraphim/-/seraphim-0.1.0.tgz","integrity":"sha512-8i87X36Y/mU5Jz2sCmFD5SATqK7HSPdzE/6aqKP+TEbD8YES3dqrA5qOY6YakMW3qKa6un5VQxGS7miAHrxTYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDYVmlLDaMbpyprU10XDPidl3lhC8ICPgtBPsM/2j5PvwIhAPz6HvpvXR6h2+N5hZhuzefzc3QwFm30TvrWr0vC5bWY"}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}]}},"readme":"seraphim\r\n========\r\n\r\n#### Configuration loader ####\r\n\r\n[![NPM version](https://badge.fury.io/js/seraphim.png)](http://badge.fury.io/js/seraphim \"Fury Version Badge\")\r\n[![Build Status](https://secure.travis-ci.org/gagle/node-seraphim.png)](http://travis-ci.org/gagle/node-seraphim \"Travis CI Badge\")\r\n[![Dependency Status](https://david-dm.org/gagle/node-seraphim.png)](https://david-dm.org/gagle/node-seraphim \"David Dependency Manager Badge\")\r\n\r\n[![NPM installation](https://nodei.co/npm/seraphim.png?mini=true)](https://nodei.co/npm/seraphim \"NodeICO Badge\")\r\n\r\nLoading configuration files in Node.js have always been a very tedious task, especially when you need to merge objects in cascade, load files asynchronously, load data from external sources like a database, redis, etc., read the CLI options and the environment variables, etc.\r\n\r\nThis module brings to you a powerful API for loading and merging your configuration data in a few lines.\r\n\r\n```javascript\r\nvar seraphim = require (\"seraphim\");\r\n\r\nseraphim.createVault ()\r\n    .on (\"error\", function (error){\r\n      console.error (error);\r\n    })\r\n    .on (\"end\", function (config){\r\n      console.log (config);\r\n      /*\r\n      {\r\n        web: {\r\n          log: {\r\n            type: \"circular\",\r\n            backup: \"1week\"\r\n          },\r\n          hostname: \"a.b.c\",\r\n          port: 1234\r\n        }\r\n      }\r\n      */\r\n    })\r\n    //Default settings\r\n    .load (\"default.json\")\r\n    //NODE_ENV (development) settings\r\n    .load (process.env.NODE_ENV + \".json\")\r\n    //Override/merge the previous settings with any object, eg: CLI options\r\n    .load ({ web: { hostname: \"a.b.c\" } });\r\n```\r\n\r\n```\r\n//default.json\r\n{\r\n  \"web\": {\r\n    \"log\": {\r\n      \"type\": \"circular\",\r\n      \"backup\": \"1week\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n```\r\n//development.json\r\n{\r\n  \"web\": {\r\n    \"hostname\": \"1.2.3.4\",\r\n    \"port\": 1234\r\n  }\r\n}\r\n```\r\n\r\nCheck this [complete example](https://github.com/gagle/node-seraphim/tree/master/examples/complete) for further details.\r\n\r\n#### Functions ####\r\n\r\n- [_module_.createVault([options]) : Seraphim](#createVault)\r\n\r\n#### Objects ####\r\n\r\n- [Seraphim](#seraphim_object)\r\n\r\n---\r\n\r\n<a name=\"createVault\"></a>\r\n___module_.createVault([options]) : Seraphim__\r\n\r\nReturns a new [Seraphim](#seraphim_object) instance.\r\n\r\nOptions are:\r\n\r\n- __extensionError__ - _Boolean_  \r\n  Set it to false if unknown extensions shouldn't emit an error. Default is true.\r\n\r\n---\r\n\r\n<a name=\"seraphim_object\"></a>\r\n__Seraphim__\r\n\r\n__Events__\r\n\r\n- [end](#event_end)\r\n- [error](#event_error)\r\n\r\n__Methods__\r\n\r\n- [Seraphim#extension(extension, fn) : Seraphim](#extension)\r\n- [Seraphim#get() : Object](#get)\r\n- [Seraphim#load(resource[, onLoad]) : Seraphim](#load)\r\n- [Seraphim#merge(o1[, o2]) : undefined | Object](#merge)\r\n\r\n---\r\n\r\n<a name=\"event_end\"></a>\r\n__end__\r\n\r\nArguments: `config`.\r\n\r\nThis event is emitted multiple times, when there are no more pending tasks to load.\r\n\r\n`config` is the final merged object.\r\n\r\nLook at the [end-event.js](https://github.com/gagle/node-seraphim/blob/master/examples/end-event.js) example for further details.\r\n\r\n<a name=\"event_error\"></a>\r\n__error__\r\n\r\nArguments: `error`.\r\n\r\nEmitted when an error occurs.\r\n\r\n---\r\n\r\n<a name=\"extension\"></a>\r\n__Seraphim#extension(extension, fn) : Seraphim__\r\n\r\nAllows you to load files with an extension different from .json using the [load()](#load) function.\r\n\r\n`extension` is a string or an array of strings.\r\n\r\n`fn` is the function that is called when the file to load has the same `extension`. It has two arguments: the path of the file and a callback. The callback must be called with two parameters: the error and the object with the configuration data.\r\n\r\n```javascript\r\nseraphim.createVault ()\r\n    .on (\"error\", function (error){\r\n      console.error (error);\r\n    })\r\n    .on (\"end\", function (config){\r\n      ...\r\n    })\r\n    .extension ([\".yaml\", \".yml\"], function (p, cb){\r\n      fs.readFile (p, { encoding: \"utf8\" }, function (error, data){\r\n        if (error) return cb (error);\r\n        var obj = parseFile (data);\r\n        cb (null, obj);\r\n      });\r\n    })\r\n    .load (\"file1.yaml\")\r\n    .load (\"file2.yml\");\r\n```\r\n\r\n<a name=\"get\"></a>\r\n__Seraphim#get() : Object__\r\n\r\nReturns the internal merged object.\r\n\r\n<a name=\"load\"></a>\r\n__Seraphim#load(resource[, onLoad]) : Seraphim__\r\n\r\nLoads and merges a resource. `resource` can be a string, object or function.\r\n\r\n__String__\r\n\r\nIt must be a valid file path.\r\n\r\n```javascript\r\n.load (\"file.json\");\r\n```\r\n\r\n__Object__\r\n\r\n```javascript\r\n.load ({ a: { b: 1 } });\r\n```\r\n\r\n__Function__\r\n\r\nSynchronous. Return the object to be merged. Errors thrown here are catched and forwarded to the `error` event. If a falsy value is returned (null, undefined, false, etc.) it won't be merged.\r\n\r\n```javascript\r\n.load (function (){\r\n  if (condition){\r\n    return { a: 1 };\r\n  }\r\n});\r\n```\r\n\r\nAsynchronous. Use the callback to load the next resource. The first parameter is the error, the second is the object to be merged.\r\n\r\n```javascript\r\n.load (function (cb){\r\n  process.nextTick (function (){\r\n    cb (null, { a: 1 });\r\n  });\r\n});\r\n```\r\n\r\n`onLoad` is a callback that is executed when `load()` finishes. It has two arguments: the object to be merged and a callback. The callback allows you to execute any asynchronous function between two `load()` calls. Please note that if you use the `onLoad` callback the object is not merged automatically and you'll need to merge it explicitly. This callback it's also try-catched, errors thrown inside the `onLoad` callback are redirected to the `error` event.\r\n\r\n```javascript\r\n.load (\"file.json\", function (o, cb){\r\n  //'o' is the json object\r\n  var me = this;\r\n  asyncFn (function (error, foo){\r\n    //The error is forwarded to the \"error\" event\r\n    if (error) return cb (error);\r\n    if (foo) o.bar = \"baz\";\r\n    me.merge (o);\r\n    cb ();\r\n  });\r\n});\r\n```\r\n\r\nThe `onLoad` function can be used to [load files without an extension](https://github.com/gagle/node-seraphim/tree/master/examples/load-files-without-extension).\r\n\r\n<a name=\"merge\"></a>\r\n__Seraphim#merge(o1[, o2]) : undefined | Object__\r\n\r\nIf `o2` is not used, `o1` is merged with the internal object.  \r\nIf `o2` is used, `o2` is merged with `o1` and `o1` is returned.\r\n\r\n```javascript\r\nconsole.log (vault.merge ({ a: 1, b: 1 }, { a: 2 }));\r\n//{ a: 2, b: 1 }\r\n```","maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"time":{"modified":"2022-06-26T17:52:58.986Z","created":"2013-10-06T19:17:21.854Z","0.0.0":"2013-10-06T19:17:26.607Z","0.0.1":"2013-10-14T12:34:04.033Z","0.0.2":"2013-10-14T13:02:22.125Z","0.0.3":"2013-10-16T14:32:40.845Z","0.0.4":"2014-01-13T11:40:18.516Z","0.1.0":"2014-02-06T20:08:02.279Z"},"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-seraphim.git"},"readmeFilename":"README.md","users":{"irnnr":true}}