Comparing version 1.0.1 to 1.0.2
13
index.js
@@ -6,3 +6,10 @@ "use strict"; | ||
function toString(str) { | ||
return _.has(str, 'toString') ? str.toString() : ''+str; | ||
try { | ||
return _.has(str, 'toString') ? str.toString() : ''+str; | ||
} catch (err) { | ||
// some properties of mysql connection pools are objects that | ||
// cannot be converted to a primitive type using ''+str | ||
// mimic util.inspect() by simply returning an empty object string | ||
return '{}'; | ||
} | ||
} | ||
@@ -17,3 +24,3 @@ | ||
return obj; | ||
} else if (_.isNumber(obj)) { | ||
} else if (_.isNumber(obj) || _.isBoolean(obj) || _.isRegExp(obj)) { | ||
return toString(obj); | ||
@@ -25,3 +32,3 @@ } else if (_.isObject(obj)) { | ||
r.push(key + '=' + val); | ||
} else if (_.isObject(val)) { | ||
} else if (_.isObject(val) && !_.isRegExp(val)) { | ||
_.each(val, function (innerVal, innerKey) { | ||
@@ -28,0 +35,0 @@ if (_.isNull(innerVal) || _.isUndefined(innerVal)) { |
@@ -5,3 +5,3 @@ MIT License | ||
``` | ||
Copyright (C) 2015 SSi Micro, Ltd. and other contributors. | ||
Copyright (C) 2015, 2016 SSi Micro, Ltd. and other contributors. | ||
@@ -8,0 +8,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "logformat", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "stringify objects into searchable strings", | ||
@@ -30,8 +30,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "^3.10.1" | ||
"lodash": "^4.5.0" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "^0.3.1", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.3.4" | ||
"jshint": "^2.9.1", | ||
"mocha": "^2.4.5" | ||
}, | ||
@@ -38,0 +38,0 @@ "jshintConfig": { |
@@ -67,22 +67,2 @@ # logformat | ||
``` | ||
Copyright (C) 2015 SSi Micro, Ltd. and other contributors. | ||
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. | ||
``` | ||
See [LICENSE.md](https://github.com/ssimicro/logformat/blob/master/LICENCE.md) |
@@ -23,2 +23,12 @@ "use strict"; | ||
}); | ||
it('should return a regular express as a string when given a RegExp', function () { | ||
expect(logformat(/^foobar$/)).to.be('/^foobar$/'); | ||
expect(logformat(new RegExp("^foobar$"))).to.be('/^foobar$/'); | ||
}); | ||
it('should return true/false when given true/false', function () { | ||
var obj = { is_it_true: true }; | ||
expect(logformat(obj.is_it_true)).to.be('true'); | ||
expect(logformat(true)).to.be('true'); | ||
expect(logformat(false)).to.be('false'); | ||
}); | ||
it('should return a string of key=value pairs for objects', function () { | ||
@@ -44,4 +54,5 @@ expect(logformat({ | ||
'a test' // maps to mno.2="a test" | ||
] | ||
})).to.be('foo=undefined bar=null abc=true def="Hello, World!" ghi=cheese jkl.a=null jkl.b=undefined jkl.c=howdy jkl.d="apple sauce" jkl.f=4,life mno.0=this mno.1=is mno.2="a test"'); | ||
], | ||
pqr: /^foobar$/ // maps to pqr="/^foobar$/" | ||
})).to.be('foo=undefined bar=null abc=true def="Hello, World!" ghi=cheese jkl.a=null jkl.b=undefined jkl.c=howdy jkl.d="apple sauce" jkl.f=4,life mno.0=this mno.1=is mno.2="a test" pqr=/^foobar$/'); | ||
}); | ||
@@ -60,2 +71,1 @@ it('should return a string of key=value pairs for arrays', function () { | ||
}); | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108
8961
68
+ Addedlodash@4.17.21(transitive)
- Removedlodash@3.10.1(transitive)
Updatedlodash@^4.5.0