Ctor single arg: allow plain object, reject null/undefined

Thank you @kub1x
This commit is contained in:
Lovell Fuller
2017-05-06 19:03:14 +01:00
parent 39a21787b7
commit c41d755441
14 changed files with 104 additions and 79 deletions

View File

@@ -16,6 +16,14 @@ const object = function (val) {
return typeof val === 'object';
};
/**
* Is this value a plain object?
* @private
*/
const plainObject = function (val) {
return object(val) && Object.prototype.toString.call(val) === '[object Object]';
};
/**
* Is this value a function?
* @private
@@ -98,6 +106,7 @@ const invalidParameterError = function (name, expected, actual) {
module.exports = {
defined: defined,
object: object,
plainObject: plainObject,
fn: fn,
bool: bool,
buffer: buffer,