check-types-mini
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -7,2 +7,9 @@ # Change Log | ||
## [2.3.0] - 2017-07-20 | ||
### Updated | ||
- All deps and removed few redundant ones, switching to ES6 counterparts. | ||
- Name in documentation and licenses | ||
### Added | ||
- .npmignore | ||
## [2.2.0] - 2017-07-04 | ||
@@ -62,1 +69,2 @@ ### Added | ||
[2.2.0]: https://github.com/codsen/check-types-mini/compare/v2.1.0...v2.2.0 | ||
[2.3.0]: https://github.com/codsen/check-types-mini/compare/v2.2.0...v2.3.0 |
'use strict' | ||
const type = require('type-detect') | ||
const objectAssign = require('object-assign') | ||
const clone = require('lodash.clonedeep') | ||
@@ -10,3 +9,2 @@ const includes = require('lodash.includes') | ||
const arrayiffyIfString = require('arrayiffy-if-string') | ||
const isObj = require('lodash.isplainobject') | ||
@@ -17,2 +15,3 @@ function checkTypes (obj, ref, opts) { | ||
function isStr (something) { return type(something) === 'string' } | ||
function isObj (something) { return type(something) === 'Object' } | ||
const NAMESFORANYTYPE = ['any', 'anything', 'every', 'everything', 'all', 'whatever', 'whatevs'] | ||
@@ -38,3 +37,3 @@ const isArr = Array.isArray | ||
if (existy(opts) && isObj(opts)) { | ||
opts = objectAssign(clone(defaults), opts) | ||
opts = Object.assign(clone(defaults), opts) | ||
} else { | ||
@@ -41,0 +40,0 @@ opts = clone(defaults) |
The MIT License (MIT) | ||
Copyright © 2017 Roy Reveltas / Codsen Ltd | ||
Copyright © 2017 Roy Revelt / Codsen Ltd | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of |
{ | ||
"name": "check-types-mini", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Check the types of your options object's values after user has customised them", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
"author": { | ||
"name": "Roy Reveltas", | ||
"name": "Roy Revelt", | ||
"email": "roy@codsen.com", | ||
@@ -43,5 +43,3 @@ "url": "codsen.com" | ||
"lodash.intersection": "*", | ||
"lodash.isplainobject": "*", | ||
"lodash.pullall": "*", | ||
"object-assign": "*", | ||
"type-detect": "^4.0.0" | ||
@@ -53,3 +51,3 @@ }, | ||
"coveralls": "*", | ||
"husky": "^0.14.2", | ||
"husky": "*", | ||
"nodemon": "*", | ||
@@ -56,0 +54,0 @@ "nyc": "^11.0.2", |
@@ -90,3 +90,3 @@ # check-types-mini | ||
1. b) Alternatively, you can skip defaults object and provide schema for each key via `opts.schema`. Just stick an object there, as a value, with all keys. Put allowed types in an array. | ||
2. `object-assign` cloned defaults onto the options object that comes from the input. | ||
2. `Object.assign` cloned defaults onto the options object that comes from the input. | ||
3. call `check-types-mini` with the above. | ||
@@ -97,3 +97,2 @@ 4. If input types mismatch, error will be `throw`n. | ||
const checkTypes = require('check-types-mini') | ||
const objectAssign = require('object-assign') | ||
const clone = require('lodash.clonedeep') | ||
@@ -107,3 +106,3 @@ | ||
// fill any settings with defaults if missing: | ||
opts = objectAssign(clone(defaults), opts) | ||
opts = Object.assign(clone(defaults), opts) | ||
// the check: | ||
@@ -166,3 +165,3 @@ checkTypes(opts, defaults, {msg: 'newLibrary/yourFunction(): [THROW_ID_01]', optsVarName: 'opts'}) | ||
When I was coding a new major version of [posthtml-ast-delete-object](https://github.com/codsen/posthtml-ast-delete-object) I had to update all the unit tests too. Previously, the settings were set using only one argument, Boolean-type. I had to change it to be a plain object. I noticed that when I missed updating some tests, their Booleans were `object-assign`ed into a default settings object and no alarm was being raised! That's not good. | ||
When I was coding a new major version of [posthtml-ast-delete-object](https://github.com/codsen/posthtml-ast-delete-object) I had to update all the unit tests too. Previously, the settings were set using only one argument, Boolean-type. I had to change it to be a plain object. I noticed that when I missed updating some tests, their Booleans were `Object.assign`ed into a default settings object and no alarm was being raised! That's not good. | ||
@@ -217,3 +216,3 @@ Then I came up with the idea to **enforce the keys of the object** to match the reference and/or schema keys in `options`. It's on by default because I can't imagine how you would end up with settings object that does not match your default settings object, key-wise, but if you don't like that, feel free to turn it off. It's `opts.enforceStrictKeyset` Boolean flag. | ||
> Copyright (c) 2017 Codsen Ltd, Roy Reveltas | ||
> Copyright (c) 2017 Codsen Ltd, Roy Revelt | ||
@@ -220,0 +219,0 @@ > Permission is hereby granted, free of charge, to any person obtaining a copy |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
6
5
25137
6
138
249
1
- Removedlodash.isplainobject@*
- Removedobject-assign@*
- Removedlodash.isplainobject@4.0.6(transitive)
- Removedobject-assign@4.1.1(transitive)