Skip to content

Commit e03f8cd

Browse files
committed
refactor: use base array assertion utility
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4a1f629 commit e03f8cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/node_modules/@stdlib/ml/incr/kmeans/lib/validate.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2525
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2626
var isArrayLike = require( '@stdlib/assert/is-array-like-object' );
2727
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
28-
var contains = require( '@stdlib/assert/contains' );
28+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2929
var format = require( '@stdlib/string/format' );
3030
var METRICS = require( './metrics.json' );
3131
var INIT_METHODS = require( './init_methods.json' );
3232

3333

34+
// VARIABLES //
35+
36+
var isMetric = contains( METRICS );
37+
var isInitMethod = contains( INIT_METHODS );
38+
39+
3440
// MAIN //
3541

3642
/**
@@ -63,15 +69,15 @@ function validate( opts, options ) {
6369
}
6470
if ( hasOwnProp( options, 'metric' ) ) {
6571
opts.metric = options.metric;
66-
if ( !contains( METRICS, opts.metric ) ) {
72+
if ( !isMetric( opts.metric ) ) {
6773
return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'metric', METRICS.join( '", "' ), opts.metric ) );
6874
}
6975
}
7076
if ( hasOwnProp( options, 'init' ) ) {
7177
if ( !isArrayLike( options.init ) ) {
7278
return new TypeError( format( 'invalid option. `%s` option must be an array-like object. Option: `%s`.', 'init', options.init ) );
7379
}
74-
if ( !contains( INIT_METHODS, options.init[ 0 ] ) ) {
80+
if ( !isInitMethod( options.init[ 0 ] ) ) {
7581
return new TypeError( format( 'invalid option. `%s` option method must be one of the following: "%s". Option: `%s`.', 'init', INIT_METHODS.join( '", "' ), options.init[ 0 ] ) );
7682
}
7783
opts.init[ 0 ] = options.init[ 0 ];

0 commit comments

Comments
 (0)