mentie 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,11 +28,11 @@ export const require_props = ( obj={}, required_properties=[], error_on_fail=tru
28
28
  const keys = Object.keys( obj )
29
29
 
30
30
  // Check that required props are present
31
- const contains_all_required = required_properties.every( key => keys.includes( key ) )
31
+ const missing_properties = required_properties.filter( prop => !keys.includes( prop ) )
32
32
 
33
33
  // If properties are missing, throw errors or return false
34
- if( error_on_fail && !contains_all_required ) throw new Error( `Missing required properties on object` )
35
- if( !contains_all_required ) return false
34
+ if( error_on_fail && !missing_properties.length ) throw new Error( `Missing required properties on object: ${ missing_properties.join( ', ' ) }` )
35
+ if( !missing_properties.length ) return false
36
36
 
37
37
  // If all good, return true
38
38
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",