@@ -24,6 +24,7 @@ var isCollection = require( '@stdlib/assert-is-collection' );
24
24
var isInteger = require ( '@stdlib/assert-is-integer' ) . isPrimitive ;
25
25
var isString = require ( '@stdlib/assert-is-string' ) . isPrimitive ;
26
26
var isnan = require ( '@stdlib/assert-is-nan' ) . isPrimitive ;
27
+ var format = require ( '@stdlib/string-format' ) ;
27
28
28
29
29
30
// MAIN //
@@ -73,14 +74,14 @@ function contains( val, searchValue, position ) {
73
74
var pos ;
74
75
var i ;
75
76
if ( ! isCollection ( val ) && ! isString ( val ) ) {
76
- throw new TypeError ( 'invalid argument. First argument must be array-like. Value: `' + val + '`.' ) ;
77
+ throw new TypeError ( format ( 'invalid argument. First argument must be array-like. Value: `%s`.' , val ) ) ;
77
78
}
78
79
if ( arguments . length < 2 ) {
79
80
throw new Error ( 'insufficient input arguments. Must provide a search value.' ) ;
80
81
}
81
82
if ( arguments . length > 2 ) {
82
83
if ( ! isInteger ( position ) ) {
83
- throw new TypeError ( 'invalid argument. Third argument must be an integer. Value: `' + position + '`.' ) ;
84
+ throw new TypeError ( format ( 'invalid argument. Third argument must be an integer. Value: `%s`.' , position ) ) ;
84
85
}
85
86
pos = position ;
86
87
if ( pos < 0 ) {
@@ -91,7 +92,7 @@ function contains( val, searchValue, position ) {
91
92
}
92
93
if ( isString ( val ) ) {
93
94
if ( ! isString ( searchValue ) ) {
94
- throw new TypeError ( 'invalid argument. Second argument must be a string primitive. Value: `' + searchValue + '`.' ) ;
95
+ throw new TypeError ( format ( 'invalid argument. Second argument must be a string primitive. Value: `%s`.' , searchValue ) ) ;
95
96
}
96
97
return val . indexOf ( searchValue , pos ) !== - 1 ;
97
98
}
0 commit comments