Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

confort

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confort - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

test/res/conf.cson

9

CHANGELOG.md

@@ -8,2 +8,10 @@ # Confort Changelog

## [v0.1.1] - 2019-09-23
### Added
- support to CSON file type
### Changed
- layering to merge objects recursively instead of shallow replacing the keys
## [v0.1.0] - 2019-07-30

@@ -13,1 +21,2 @@ - First officially published version.

[v0.1.0]: https://gitlab.com/GCSBOSS/confort/-/tags/v0.1.0
[v0.1.1]: https://gitlab.com/GCSBOSS/confort/-/tags/v0.1.1

4

lib/conf-loader.js

@@ -6,2 +6,3 @@

const YAML = require('yaml');
const CSON = require('cson-parser');
const assert = require('assert');

@@ -12,3 +13,4 @@

yaml: conf => YAML.parse(fs.readFileSync(conf, 'utf8')),
json: conf => JSON.parse(fs.readFileSync(conf, 'utf8'))
json: conf => JSON.parse(fs.readFileSync(conf, 'utf8')),
cson: conf => CSON.parse(fs.readFileSync(conf, 'utf8'))
}

@@ -15,0 +17,0 @@

const fs = require('fs');
const assert = require('assert');
const deepmerge = require('deepmerge');
const EventEmitter = require('events');

@@ -46,3 +47,5 @@ const loadConf = require('./conf-loader');

this.object = { ...this.object, ...pathOrObject };
this.object = deepmerge(this.object, pathOrObject, {
arrayMerge: (a, b) => b
});

@@ -49,0 +52,0 @@ setupWatches.bind(this)();

{
"name": "confort",
"version": "0.1.0",
"version": "0.1.1",
"description": "A library for incrementally build config objects through layering config files in many formats.",

@@ -33,2 +33,4 @@ "main": "lib/main.js",

"dependencies": {
"cson-parser": "^4.0.2",
"deepmerge": "^4.0.0",
"toml": "^3.0.0",

@@ -35,0 +37,0 @@ "yaml": "^1.6.0"

@@ -6,7 +6,7 @@ # [Confort](https://gitlab.com/GCSBOSS/confort)

- Support native objects directly
- Support native objects input directly
- Load config files
- Merge configs chronologically
- Option to watch changes in loaded config files
- Supported formats so far: TOML, JSON and YAML
- Supported formats so far: TOML, JSON, CSON and YAML

@@ -13,0 +13,0 @@ ## Get Started

@@ -33,2 +33,7 @@ const fs = require('fs');

});
it('Should properly load an CSON file and generate an object', () => {
let obj = loadConf('./test/res/conf.cson');
assert.strictEqual(obj.key, 'value');
});
});

@@ -68,2 +73,10 @@

it('Should merge objects instead of just replacing', () => {
let conf = new Confort({ key: { a: 'b', e: [ 0 ] } });
conf.addLayer({ key: { c: 'd', e: [ 1 ] } });
assert.strictEqual(conf.object.key.a, 'b');
assert.strictEqual(conf.object.key.c, 'd');
assert.strictEqual(conf.object.key.e[0], 1);
});
it('Should load conf file when path is specified', () => {

@@ -70,0 +83,0 @@ let conf = new Confort('./test/res/conf.toml');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc