lib/main.js
changed.
lib/validate.js
changed.
25 | 25 | var setReadOnly = require( '@stdlib/utils-define-read-only-property' ); |
|
26 | 26 | var quantileFactory = require( '@stdlib/stats-base-dists-normal-quantile' ).factory; |
|
27 | 27 | var cdfFactory = require( '@stdlib/stats-base-dists-normal-cdf' ).factory; |
|
28 | + | var format = require( '@stdlib/string-format' ); |
|
28 | 29 | var atanh = require( '@stdlib/math-base-special-atanh' ); |
|
29 | 30 | var tanh = require( '@stdlib/math-base-special-tanh' ); |
|
30 | 31 | var tCDF = require( '@stdlib/stats-base-dists-t-cdf' ); |
84 | 85 | var z; |
|
85 | 86 | ||
86 | 87 | if ( !isTypedArrayLike( x ) && !isNumberArray( x ) ) { |
|
87 | - | throw new TypeError( 'invalid argument. First argument `x` must be a numeric array. Value: `' + x + '`.' ); |
|
88 | + | throw new TypeError( format( 'invalid argument. First argument `x` must be a numeric array. Value: `%s`.', x ) ); |
|
88 | 89 | } |
|
89 | 90 | if ( !isTypedArrayLike( y ) && !isNumberArray( y ) ) { |
|
90 | - | throw new TypeError( 'invalid argument. Second argument `y` must be a numeric array. Value: `' + y + '`.' ); |
|
91 | + | throw new TypeError( format( 'invalid argument. Second argument `y` must be a numeric array. Value: `%s`.', y ) ); |
|
91 | 92 | } |
|
92 | 93 | n = x.length; |
|
93 | 94 | if ( n !== y.length ) { |
25 | 25 | var isnan = require( '@stdlib/assert-is-nan' ); |
|
26 | 26 | var indexOf = require( '@stdlib/utils-index-of' ); |
|
27 | 27 | var hasOwnProp = require( '@stdlib/assert-has-own-property' ); |
|
28 | + | var format = require( '@stdlib/string-format' ); |
|
28 | 29 | ||
29 | 30 | ||
30 | 31 | // VARIABLES // |
58 | 59 | */ |
|
59 | 60 | function validate( opts, options ) { |
|
60 | 61 | if ( !isObject( options ) ) { |
|
61 | - | return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' ); |
|
62 | + | return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); |
|
62 | 63 | } |
|
63 | 64 | if ( hasOwnProp( options, 'alpha' ) ) { |
|
64 | 65 | opts.alpha = options.alpha; |
68 | 69 | opts.alpha < 0.0 || |
|
69 | 70 | opts.alpha > 1.0 |
|
70 | 71 | ) { |
|
71 | - | return new TypeError( 'invalid option. `alpha` option must be a number in `[0,1]`. Option: `' + opts.alpha + '`.' ); |
|
72 | + | return new TypeError( format( 'invalid option. `%s` option must be a number in `[0,1]`. Option: `%s`.', 'alpha', opts.alpha ) ); |
|
72 | 73 | } |
|
73 | 74 | } |
|
74 | 75 | if ( hasOwnProp( options, 'alternative' ) ) { |
|
75 | 76 | opts.alternative = options.alternative; |
|
76 | 77 | if ( indexOf( alternative, opts.alternative ) === -1 ) { |
|
77 | - | return new TypeError( 'invalid option. `alternative` option must be one of the following: "' + alternative.join( '", "' ) + '". Option: `' + opts.alternative + '`.' ); |
|
78 | + | return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'alternative', alternative.join( '", "' ), opts.alternative ) ); |
|
78 | 79 | } |
|
79 | 80 | } |
|
80 | 81 | if ( hasOwnProp( options, 'rho' ) ) { |
85 | 86 | opts.rho < -1.0 || |
|
86 | 87 | opts.rho > 1.0 |
|
87 | 88 | ) { |
|
88 | - | return new TypeError( 'invalid option. `rho` option must be a number in [-1,1]. Option: `' + opts.rho + '`.' ); |
|
89 | + | return new TypeError( format( 'invalid option. `%s` option must be a number in [-1,1]. Option: `%s`.', 'rho', opts.rho ) ); |
|
89 | 90 | } |
|
90 | 91 | } |
|
91 | 92 | return null; |
Files | Coverage |
---|---|
lib | 100.00% |
Project Totals (5 files) | 100.00% |