@voiceflow/common
Advanced tools
Comparing version 1.0.0 to 1.1.0
'use strict'; | ||
/* eslint-disable no-process-env */ | ||
const _ = require('lodash'); | ||
@@ -40,4 +41,28 @@ /** | ||
} | ||
/** | ||
* Check if object type | ||
* @param {object} object | ||
* @param {string} path | ||
* @param {string} type | ||
* @return {undefined} | ||
*/ | ||
static check(object, path, type) { | ||
if (typeof path !== 'string') { | ||
throw new Error('type check path is not defined'); | ||
} | ||
if (object === undefined) { | ||
throw new Error('type check object is not defined'); | ||
} | ||
// capitalize first letter of type | ||
type = type.charAt(0).toUpperCase() + type.slice(1); | ||
if (!_[(`is${type}`)](_.get(object, path))) { | ||
throw new Error(`${path} must be a ${type.toLowerCase()}`); | ||
} | ||
} | ||
} | ||
module.exports = Utils; |
{ | ||
"name": "@voiceflow/common", | ||
"description": "Junk drawer of utility functions", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Voiceflow", | ||
@@ -6,0 +6,0 @@ "bugs": { |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
10860
269
3