residue
Advanced tools
Comparing version 2.2.0 to 2.2.1
# Change Log | ||
## [2.2.0] | ||
## [2.2.1] | ||
- Introduced native binding | ||
- Added `version()` | ||
@@ -6,0 +7,0 @@ ## [2.1.0] |
@@ -17,4 +17,2 @@ // | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const util = require('util'); | ||
@@ -61,20 +59,16 @@ const residue_native = require('residue-native'); | ||
const loadConfiguration = (jsonOrFilename) => { | ||
if (typeof jsonOrFilename === 'object') { | ||
residue_native.configure(JSON.strigify(jsonOrFilename)); | ||
} else if (typeof jsonOrFilename === 'string' && jsonOrFilename.length > 0) { | ||
if (jsonOrFilename.trim()[0] === '{') { | ||
residue_native.configure(jsonOrFilename.trim()); | ||
} else { | ||
residue_native.configure(fs.readFileSync(path.resolve(jsonOrFilename), 'utf8')); | ||
} | ||
} else { | ||
console.log('Please select JSON or JSON filename that contains configurations'); | ||
const conf = CommonUtils.confJson(jsonOrFilename); | ||
if (conf === false) { | ||
console.error('Please select JSON or JSON filename that contains configurations'); | ||
return false; | ||
} | ||
residue_native.configure(conf); | ||
return true; | ||
}; | ||
exports.version = residue_native.version; | ||
exports.loadConfiguration = loadConfiguration; | ||
exports.connect = residue_native.connect; | ||
exports.version = residue_native.version; | ||
exports.disconnect = residue_native.disconnect; | ||
exports.isConnected = residue_native.is_connected; | ||
exports.getLogger = (id) => (new Logger(id)); |
@@ -14,2 +14,5 @@ // | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
"use strict"; | ||
@@ -38,2 +41,14 @@ | ||
exports.confJson = (jsonOrFilename) => { | ||
if (typeof jsonOrFilename === 'object') { | ||
return JSON.strigify(jsonOrFilename) | ||
} else if (typeof jsonOrFilename === 'string' && jsonOrFilename.length > 0) { | ||
if (jsonOrFilename.trim()[0] === '{') { | ||
return jsonOrFilename.trim(); | ||
} | ||
return fs.readFileSync(path.resolve(jsonOrFilename), 'utf8'); | ||
} | ||
return false; | ||
} | ||
// Various logging levels accepted by the server | ||
@@ -40,0 +55,0 @@ exports.LoggingLevels = { |
@@ -33,2 +33,3 @@ // | ||
} | ||
var pkg = require('./package.json'); | ||
const CommonUtils = require('./private/common'); | ||
@@ -482,7 +483,8 @@ | ||
const loadConfiguration = (jsonOrFilename) => { | ||
if (typeof jsonOrFilename === 'undefined') { | ||
Utils.log('Please select JSON or JSON filename that contains configurations'); | ||
const conf = CommonUtils.confJson(jsonOrFilename); | ||
if (conf === false) { | ||
console.error('Please select JSON or JSON filename that contains configurations'); | ||
return false; | ||
} | ||
Params.options = typeof jsonOrFilename === 'object' ? jsonOrFilename : JSON.parse(fs.readFileSync(path.resolve(jsonOrFilename), 'utf8')); | ||
Params.options = JSON.parse(conf); | ||
Utils.log('Configuration loaded'); | ||
@@ -627,6 +629,7 @@ return true; | ||
exports.version = () => pkg.version; | ||
exports.loadConfiguration = loadConfiguration; | ||
exports.connect = connect; | ||
exports.disconnect = disconnect; | ||
exports.isConnected = () => Params.connected; | ||
exports.getLogger = (id) => (new Logger(id)); | ||
exports.isConnected = () => Params.connected; |
{ | ||
"name": "residue", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Library to interact with residue server seamlessly.", | ||
@@ -5,0 +5,0 @@ "main": "lib/residue.js", |
35501
672