Skip to content

Commit d6dc223

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 51ba192 commit d6dc223

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/node_modules/@stdlib/math/tools/unary/lib/validate.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222

2323
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25-
var contains = require( '@stdlib/assert/contains' );
25+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2626
var orders = require( '@stdlib/ndarray/orders' );
2727
var dtypes = require( '@stdlib/ndarray/dtypes' );
2828
var format = require( '@stdlib/string/format' );
2929

3030

3131
// VARIABLES //
3232

33-
var ORDERS = orders();
34-
var DTYPES = dtypes();
33+
var isOrder = contains( orders() );
34+
var isDType = contains( dtypes() );
3535

3636

3737
// MAIN //
@@ -62,13 +62,13 @@ function validate( opts, options ) {
6262
}
6363
if ( hasOwnProp( options, 'dtype' ) ) {
6464
opts.dtype = options.dtype;
65-
if ( !contains( DTYPES, opts.dtype ) ) {
65+
if ( !isDType( opts.dtype ) ) {
6666
return new TypeError( format( 'invalid option. `%s` option must be a recognized/supported data type. Option: `%s`.', 'dtype', opts.dtype ) );
6767
}
6868
}
6969
if ( hasOwnProp( options, 'order' ) ) {
7070
opts.order = options.order;
71-
if ( !contains( ORDERS, opts.order ) ) {
71+
if ( !isOrder( opts.order ) ) {
7272
return new TypeError( format( 'invalid option. `%s` option must be a recognized/supported data type. Option: `%s`.', 'order', opts.order ) );
7373
}
7474
}

lib/node_modules/@stdlib/math/tools/unary/lib/validate_options.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222

2323
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2424
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
25-
var contains = require( '@stdlib/assert/contains' );
25+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2626
var format = require( '@stdlib/string/format' );
2727
var POLICIES = require( './policies.json' );
2828

2929

30+
// VARIABLES //
31+
32+
var isPolicy = contains( POLICIES );
33+
34+
3035
// MAIN //
3136

3237
/**
@@ -54,7 +59,7 @@ function validate( opts, options ) {
5459
}
5560
if ( hasOwnProp( options, 'output_dtype_policy' ) ) {
5661
opts.policy = options.output_dtype_policy;
57-
if ( !contains( POLICIES, opts.policy ) ) {
62+
if ( !isPolicy( opts.policy ) ) {
5863
return new TypeError( format( 'invalid option. `%s` option must be a recognized/supported output array data type policy. Option: `%s`.', 'output_dtype_policy', opts.policy ) );
5964
}
6065
}

0 commit comments

Comments
 (0)