diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 71a93720..00000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-03-16T08:56:20.660Z diff --git a/any-by-right/lib/any_by_right.js b/any-by-right/lib/any_by_right.js index dbb79c0d..0fdb6cdc 100644 --- a/any-by-right/lib/any_by_right.js +++ b/any-by-right/lib/any_by_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -51,10 +52,10 @@ function anyByRight( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = len-1; i >= 0; i-- ) { diff --git a/any-by/lib/main.js b/any-by/lib/main.js index 2e6073d4..4ca3b526 100644 --- a/any-by/lib/main.js +++ b/any-by/lib/main.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -51,10 +52,10 @@ function anyBy( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/any/lib/main.js b/any/lib/main.js index 96db40ba..021aa3fb 100644 --- a/any/lib/main.js +++ b/any/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -42,7 +43,7 @@ function any( collection ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. Must provide a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a collection. Value: `%s`.', collection ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/append/lib/append.js b/append/lib/append.js index 638ea40f..3c3189e3 100644 --- a/append/lib/append.js +++ b/append/lib/append.js @@ -24,6 +24,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isCollection = require( '@stdlib/assert/is-collection' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var appendArray = require( './append_array.js' ); var appendObject = require( './append_object.js' ); var appendTypedArray = require( './append_typed_array.js' ); @@ -55,7 +56,7 @@ var appendTypedArray = require( './append_typed_array.js' ); */ function append( collection1, collection2 ) { if ( !isCollection( collection2 ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object. Value: `'+collection2+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', collection2 ) ); } if ( isArray( collection1 ) ) { return appendArray( collection1, collection2 ); @@ -74,7 +75,7 @@ function append( collection1, collection2 ) { ) { return appendObject( collection1, collection2 ); } - throw new TypeError( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `'+collection1+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection1 ) ); } diff --git a/argument-function/lib/argument_function.js b/argument-function/lib/argument_function.js index c18cbb68..ed42cecf 100644 --- a/argument-function/lib/argument_function.js +++ b/argument-function/lib/argument_function.js @@ -21,6 +21,7 @@ // MODULES // var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -46,7 +47,7 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).is */ function wrap( idx ) { if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( 'invalid argument. Must provide a nonnegative integer. Value: `'+idx+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); } return argn; diff --git a/async/any-by-right/lib/factory.js b/async/any-by-right/lib/factory.js index 3b37f270..aaf15083 100644 --- a/async/any-by-right/lib/factory.js +++ b/async/any-by-right/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function anyByRightAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/any-by/lib/factory.js b/async/any-by/lib/factory.js index 20bdfb70..a0385040 100644 --- a/async/any-by/lib/factory.js +++ b/async/any-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function anyByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/bifurcate-by/lib/factory.js b/async/bifurcate-by/lib/factory.js index 70808087..99d8e34c 100644 --- a/async/bifurcate-by/lib/factory.js +++ b/async/bifurcate-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -105,7 +106,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -126,10 +127,10 @@ function factory( options, predicate ) { */ function bifurcateByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/count-by/lib/factory.js b/async/count-by/lib/factory.js index 73d63190..453d8fc1 100644 --- a/async/count-by/lib/factory.js +++ b/async/count-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -104,7 +105,7 @@ function factory( options, indicator ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -125,10 +126,10 @@ function factory( options, indicator ) { */ function countByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/do-until/lib/do_until_async.js b/async/do-until/lib/do_until_async.js index 01d78ec0..6e9bbee4 100644 --- a/async/do-until/lib/do_until_async.js +++ b/async/do-until/lib/do_until_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function doUntilAsync( fcn, predicate, done, thisArg ) { var args; var idx; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); } args = []; idx = 0; diff --git a/async/do-while/lib/do_while_async.js b/async/do-while/lib/do_while_async.js index d05aed86..094136bf 100644 --- a/async/do-while/lib/do_while_async.js +++ b/async/do-while/lib/do_while_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function doWhileAsync( fcn, predicate, done, thisArg ) { var args; var idx; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); } args = []; idx = 0; diff --git a/async/every-by-right/lib/factory.js b/async/every-by-right/lib/factory.js index 226ae5bb..6d0c9913 100644 --- a/async/every-by-right/lib/factory.js +++ b/async/every-by-right/lib/factory.js @@ -23,6 +23,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); var PINF = require( '@stdlib/constants/float64/pinf' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function everyByRightAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/every-by/lib/factory.js b/async/every-by/lib/factory.js index 42952f65..d5457c50 100644 --- a/async/every-by/lib/factory.js +++ b/async/every-by/lib/factory.js @@ -23,6 +23,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); var PINF = require( '@stdlib/constants/float64/pinf' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function everyByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/for-each-right/lib/factory.js b/async/for-each-right/lib/factory.js index ab041d33..4cafab36 100644 --- a/async/for-each-right/lib/factory.js +++ b/async/for-each-right/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -106,7 +107,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -127,10 +128,10 @@ function factory( options, fcn ) { */ function forEachRightAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/for-each/lib/factory.js b/async/for-each/lib/factory.js index 8f33c1ee..2799d917 100644 --- a/async/for-each/lib/factory.js +++ b/async/for-each/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -106,7 +107,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -127,10 +128,10 @@ function factory( options, fcn ) { */ function forEachAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/group-by/lib/factory.js b/async/group-by/lib/factory.js index f00a3f94..ae49c2ab 100644 --- a/async/group-by/lib/factory.js +++ b/async/group-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -105,7 +106,7 @@ function factory( options, indicator ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -126,10 +127,10 @@ function factory( options, indicator ) { */ function groupByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/if-else/lib/if_else_async.js b/async/if-else/lib/if_else_async.js index 187ba5fd..6c72c0ab 100644 --- a/async/if-else/lib/if_else_async.js +++ b/async/if-else/lib/if_else_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,10 +56,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function ifelseAsync( predicate, x, y, done ) { if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } predicate( clbk ); diff --git a/async/if-then/lib/if_then_async.js b/async/if-then/lib/if_then_async.js index e8eca213..cf224957 100644 --- a/async/if-then/lib/if_then_async.js +++ b/async/if-then/lib/if_then_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -71,16 +72,16 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function ifthenAsync( predicate, x, y, done ) { if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', x ) ); } if ( !isFunction( y ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+y+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', y ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } predicate( clbk1 ); diff --git a/async/inmap-right/lib/factory.js b/async/inmap-right/lib/factory.js index 5271e90d..5b201117 100644 --- a/async/inmap-right/lib/factory.js +++ b/async/inmap-right/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -105,7 +106,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -126,10 +127,10 @@ function factory( options, fcn ) { */ function inmapRightAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/inmap/lib/factory.js b/async/inmap/lib/factory.js index d51acbad..f2e45dd0 100644 --- a/async/inmap/lib/factory.js +++ b/async/inmap/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -105,7 +106,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -126,10 +127,10 @@ function factory( options, fcn ) { */ function inmapAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/map-function/lib/factory.js b/async/map-function/lib/factory.js index a13e39bb..25002d19 100644 --- a/async/map-function/lib/factory.js +++ b/async/map-function/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -87,7 +88,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -108,10 +109,10 @@ function factory( options, fcn ) { */ function mapFunAsync( n, done ) { if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( 'invalid argument. Number of function invocations must be a nonnegative integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Number of function invocations must be a nonnegative integer. Value: `%s`.', n ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( n, opts, f, clbk ); diff --git a/async/map-keys/lib/factory.js b/async/map-keys/lib/factory.js index 747395b5..acbfc431 100644 --- a/async/map-keys/lib/factory.js +++ b/async/map-keys/lib/factory.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -106,7 +107,7 @@ function factory( options, transform ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,7 +131,7 @@ function factory( options, transform ) { throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'.`' ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( obj, opts, f, clbk ); diff --git a/async/map-values/lib/factory.js b/async/map-values/lib/factory.js index 35d436ce..7d385fb3 100644 --- a/async/map-values/lib/factory.js +++ b/async/map-values/lib/factory.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -103,7 +104,7 @@ function factory( options, transform ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -127,7 +128,7 @@ function factory( options, transform ) { throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'.`' ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( obj, opts, f, clbk ); diff --git a/async/none-by-right/lib/factory.js b/async/none-by-right/lib/factory.js index 7b5acb96..601e39c5 100644 --- a/async/none-by-right/lib/factory.js +++ b/async/none-by-right/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function noneByRightAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/none-by/lib/factory.js b/async/none-by/lib/factory.js index 00ce8e3d..79416010 100644 --- a/async/none-by/lib/factory.js +++ b/async/none-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -130,10 +131,10 @@ function factory( options, predicate ) { */ function noneByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/reduce-right/lib/factory.js b/async/reduce-right/lib/factory.js index 0837e38d..7b5787be 100644 --- a/async/reduce-right/lib/factory.js +++ b/async/reduce-right/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series === void 0 && opts.limit === void 0 ) { opts.series = true; @@ -134,10 +135,10 @@ function factory( options, fcn ) { */ function reduceRightAsync( collection, initial, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, initial, opts, f, clbk ); diff --git a/async/reduce/lib/factory.js b/async/reduce/lib/factory.js index d43aaefc..e6d09745 100644 --- a/async/reduce/lib/factory.js +++ b/async/reduce/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -109,7 +110,7 @@ function factory( options, fcn ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series === void 0 && opts.limit === void 0 ) { opts.series = true; @@ -134,10 +135,10 @@ function factory( options, fcn ) { */ function reduceAsync( collection, initial, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, initial, opts, f, clbk ); diff --git a/async/series-waterfall/lib/factory.js b/async/series-waterfall/lib/factory.js index 386e2766..162e5130 100644 --- a/async/series-waterfall/lib/factory.js +++ b/async/series-waterfall/lib/factory.js @@ -22,6 +22,7 @@ var isFunctionArray = require( '@stdlib/assert/is-function-array' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -64,10 +65,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function factory( fcns, clbk, thisArg ) { if ( !isFunctionArray( fcns ) ) { - throw new TypeError( 'invalid argument. First argument must be a function array. Value: `' + fcns + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function array. Value: `%s`.', fcns ) ); } if ( !isFunction( clbk ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + clbk + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); } return waterfall; diff --git a/async/some-by-right/lib/factory.js b/async/some-by-right/lib/factory.js index 0e40f347..7a120be6 100644 --- a/async/some-by-right/lib/factory.js +++ b/async/some-by-right/lib/factory.js @@ -23,6 +23,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -110,7 +111,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -133,13 +134,13 @@ function factory( options, predicate ) { */ function someByRightAsync( collection, n, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isPositiveInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, n, opts, f, clbk ); diff --git a/async/some-by/lib/factory.js b/async/some-by/lib/factory.js index de1da450..0ed63b01 100644 --- a/async/some-by/lib/factory.js +++ b/async/some-by/lib/factory.js @@ -23,6 +23,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -110,7 +111,7 @@ function factory( options, predicate ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -133,13 +134,13 @@ function factory( options, predicate ) { */ function someByAsync( collection, n, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isPositiveInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, n, opts, f, clbk ); diff --git a/async/tabulate-by/lib/factory.js b/async/tabulate-by/lib/factory.js index 8b4c9c1f..30d76c60 100644 --- a/async/tabulate-by/lib/factory.js +++ b/async/tabulate-by/lib/factory.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var validate = require( './validate.js' ); var limit = require( './limit.js' ); @@ -110,7 +111,7 @@ function factory( options, indicator ) { f = options; } if ( !isFunction( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) ); } if ( opts.series ) { opts.limit = 1; @@ -131,10 +132,10 @@ function factory( options, indicator ) { */ function tabulateByAsync( collection, done ) { if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } return limit( collection, opts, f, clbk ); diff --git a/async/try-catch/lib/try_catch_async.js b/async/try-catch/lib/try_catch_async.js index b78f645e..98ddc90a 100644 --- a/async/try-catch/lib/try_catch_async.js +++ b/async/try-catch/lib/try_catch_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -58,10 +59,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function trycatchAsync( x, y, done ) { if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', x ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } x( clbk ); diff --git a/async/try-then/lib/try_then_async.js b/async/try-then/lib/try_then_async.js index 4e47f075..3ceb4e25 100644 --- a/async/try-then/lib/try_then_async.js +++ b/async/try-then/lib/try_then_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -66,13 +67,13 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function trythenAsync( x, y, done ) { if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', x ) ); } if ( !isFunction( y ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+y+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', y ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) ); } x( clbk1 ); diff --git a/async/until/lib/until_async.js b/async/until/lib/until_async.js index 1b480040..bc849497 100644 --- a/async/until/lib/until_async.js +++ b/async/until/lib/until_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function untilAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); } args = []; idx = 0; diff --git a/async/while/lib/while_async.js b/async/while/lib/while_async.js index 6d2a1627..6f8e1d8b 100644 --- a/async/while/lib/while_async.js +++ b/async/while/lib/while_async.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+done+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); } args = []; idx = 0; diff --git a/bifurcate-by/lib/bifurcate_by.js b/bifurcate-by/lib/bifurcate_by.js index f24897d9..d4beca9d 100644 --- a/bifurcate-by/lib/bifurcate_by.js +++ b/bifurcate-by/lib/bifurcate_by.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnIndices = require( './return_indices.js' ); @@ -82,7 +83,7 @@ function bifurcateBy( collection, options, predicate ) { var err; var cb; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = { 'returns': 'values' @@ -97,7 +98,7 @@ function bifurcateBy( collection, options, predicate ) { cb = predicate; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( collection, opts, cb ); diff --git a/bifurcate-in/lib/main.js b/bifurcate-in/lib/main.js index d95ed414..79d2e6cd 100644 --- a/bifurcate-in/lib/main.js +++ b/bifurcate-in/lib/main.js @@ -22,6 +22,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnKeys = require( './return_keys.js' ); @@ -115,7 +116,7 @@ function bifurcateIn( obj, options, predicate ) { var err; var cb; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } opts = { 'returns': 'values' @@ -130,7 +131,7 @@ function bifurcateIn( obj, options, predicate ) { cb = predicate; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( obj, opts, cb ); diff --git a/bifurcate-own/lib/main.js b/bifurcate-own/lib/main.js index 5e0d99c0..ced113ca 100644 --- a/bifurcate-own/lib/main.js +++ b/bifurcate-own/lib/main.js @@ -22,6 +22,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnKeys = require( './return_keys.js' ); @@ -94,7 +95,7 @@ function bifurcateOwn( obj, options, predicate ) { var err; var cb; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } opts = { 'returns': 'values' @@ -109,7 +110,7 @@ function bifurcateOwn( obj, options, predicate ) { cb = predicate; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( obj, opts, cb ); diff --git a/bifurcate/lib/bifurcate.js b/bifurcate/lib/bifurcate.js index dba535f3..dac3d7fd 100644 --- a/bifurcate/lib/bifurcate.js +++ b/bifurcate/lib/bifurcate.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnIndices = require( './return_indices.js' ); @@ -77,7 +78,7 @@ function bifurcate( collection, options, filter ) { var err; var f; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = { 'returns': 'values' @@ -92,7 +93,7 @@ function bifurcate( collection, options, filter ) { f = filter; } if ( !isCollection( f ) ) { - throw new TypeError( 'invalid argument. Last argument must be a collection. Value: `'+f+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a collection. Value: `%s`.', f ) ); } if ( collection.length !== f.length ) { throw new RangeError( 'invalid arguments. First and last arguments must be the same length.' ); diff --git a/capitalize-keys/lib/capitalize_keys.js b/capitalize-keys/lib/capitalize_keys.js index 23ed55e9..d8497461 100644 --- a/capitalize-keys/lib/capitalize_keys.js +++ b/capitalize-keys/lib/capitalize_keys.js @@ -21,6 +21,7 @@ // MODULES // var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -46,7 +47,7 @@ function capitalizeKeys( obj ) { var key; var k; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. Must provide an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); } out = {}; for ( key in obj ) { diff --git a/circular-buffer/lib/main.js b/circular-buffer/lib/main.js index 8862529e..587622d6 100644 --- a/circular-buffer/lib/main.js +++ b/circular-buffer/lib/main.js @@ -30,6 +30,7 @@ var setReadOnlyAccessor = require( './../../define-nonenumerable-read-only-acces var iteratorSymbol = require( '@stdlib/symbol/iterator' ); var MAX_ITERATIONS = require( '@stdlib/constants/float64/max' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -73,7 +74,7 @@ function CircularBuffer( buffer ) { } else if ( isCollection( buffer ) ) { buf = buffer; } else { - throw new TypeError( 'invalid argument. Must provide either a valid buffer size (positive integer) or an array-like object which can serve as the underlying buffer. Value: `' + buffer + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide either a valid buffer size (positive integer) or an array-like object which can serve as the underlying buffer. Value: `%s`.', buffer ) ); } this._buffer = arraylike2object( buf ); this._length = buf.length; @@ -221,7 +222,7 @@ setReadOnly( CircularBuffer.prototype, 'iterator', function iterator( niters ) { if ( arguments.length ) { if ( !isNonNegativeInteger( niters ) ) { - throw new TypeError( 'invalid argument. Must provide a nonnegative integer. Value: `' + niters + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', niters ) ); } N = niters; } else { diff --git a/compact-adjacency-matrix/lib/from_adjacency_list_iterator.js b/compact-adjacency-matrix/lib/from_adjacency_list_iterator.js index 65326cd7..f40bd197 100644 --- a/compact-adjacency-matrix/lib/from_adjacency_list_iterator.js +++ b/compact-adjacency-matrix/lib/from_adjacency_list_iterator.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -43,7 +44,7 @@ function fromIterator( it ) { z = v.value; if ( z ) { if ( !isCollection( z ) ) { - return new TypeError( 'invalid argument. An iterator must return an array-like object containing vertices. Value: `'+z+'`.' ); + return new TypeError( format( 'invalid argument. An iterator must return an array-like object containing vertices. Value: `%s`.', z ) ); } out.push( z ); } diff --git a/compact-adjacency-matrix/lib/from_adjacency_list_iterator_map.js b/compact-adjacency-matrix/lib/from_adjacency_list_iterator_map.js index 0ce30c28..35eeb357 100644 --- a/compact-adjacency-matrix/lib/from_adjacency_list_iterator_map.js +++ b/compact-adjacency-matrix/lib/from_adjacency_list_iterator_map.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -49,7 +50,7 @@ function fromIteratorMap( it, clbk, thisArg ) { if ( z ) { z = clbk.call( thisArg, z, i ); if ( !isCollection( z ) ) { - return new TypeError( 'invalid argument. Callback must return an array-like object containing vertices. Value: `'+z+'`.' ); + return new TypeError( format( 'invalid argument. Callback must return an array-like object containing vertices. Value: `%s`.', z ) ); } out.push( z ); } diff --git a/compact-adjacency-matrix/lib/from_edges_iterator.js b/compact-adjacency-matrix/lib/from_edges_iterator.js index a46ffb9f..58f73a44 100644 --- a/compact-adjacency-matrix/lib/from_edges_iterator.js +++ b/compact-adjacency-matrix/lib/from_edges_iterator.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -43,7 +44,7 @@ function fromIterator( it ) { z = v.value; if ( z ) { if ( !isCollection( z ) ) { - return new TypeError( 'invalid argument. An iterator must return an array-like object containing vertices. Value: `'+z+'`.' ); + return new TypeError( format( 'invalid argument. An iterator must return an array-like object containing vertices. Value: `%s`.', z ) ); } out.push( z[ 0 ], z[ 1 ] ); } diff --git a/compact-adjacency-matrix/lib/from_edges_iterator_map.js b/compact-adjacency-matrix/lib/from_edges_iterator_map.js index 315ae1ad..bf2abeb1 100644 --- a/compact-adjacency-matrix/lib/from_edges_iterator_map.js +++ b/compact-adjacency-matrix/lib/from_edges_iterator_map.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -49,7 +50,7 @@ function fromIteratorMap( it, clbk, thisArg ) { if ( z ) { z = clbk.call( thisArg, z, i ); if ( !isCollection( z ) ) { - return new TypeError( 'invalid argument. Callback must return an array-like object containing vertices. Value: `'+z+'`.' ); + return new TypeError( format( 'invalid argument. Callback must return an array-like object containing vertices. Value: `%s`.', z ) ); } out.push( z[ 0 ], z[ 1 ] ); } diff --git a/convert-path/lib/convert_path.js b/convert-path/lib/convert_path.js index 3ddd5664..47afa46e 100644 --- a/convert-path/lib/convert_path.js +++ b/convert-path/lib/convert_path.js @@ -24,6 +24,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var reExtendedLengthPath = require( '@stdlib/regexp/extended-length-path' ); var lowercase = require( '@stdlib/string/lowercase' ); var replace = require( '@stdlib/string/replace' ); +var format = require( '@stdlib/string/format' ); // VARIABLES // @@ -66,10 +67,10 @@ function convertPath( from, to ) { var parts; var out; if ( !isString( from ) ) { - throw new TypeError( 'invalid argument. First argument must be a string primitive. Value: `'+from+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%1`.', from ) ); } if ( !isString( to ) ) { - throw new TypeError( 'invalid argument. Second argument must be a string primitive. Value: `'+to+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a string primitive. Value: `%1`.', to ) ); } if ( to !== 'win32' && diff --git a/copy/lib/copy.js b/copy/lib/copy.js index f90752b2..5bb265cf 100644 --- a/copy/lib/copy.js +++ b/copy/lib/copy.js @@ -22,6 +22,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var deepCopy = require( './deep_copy.js' ); @@ -58,7 +59,7 @@ function copy( value, level ) { var out; if ( arguments.length > 1 ) { if ( !isNonNegativeInteger( level ) ) { - throw new TypeError( 'invalid argument. `level` must be a nonnegative integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. `level` must be a nonnegative integer. Value: `%s`.', level ) ); } if ( level === 0 ) { return value; diff --git a/count-by/lib/count_by.js b/count-by/lib/count_by.js index fb09f923..b241dbda 100644 --- a/count-by/lib/count_by.js +++ b/count-by/lib/count_by.js @@ -23,6 +23,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); @@ -60,7 +61,7 @@ function countBy( collection, options, indicator ) { var g; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = {}; if ( arguments.length === 2 ) { @@ -73,7 +74,7 @@ function countBy( collection, options, indicator ) { cb = indicator; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } thisArg = opts.thisArg; len = collection.length; diff --git a/curry-right/lib/curry_right.js b/curry-right/lib/curry_right.js index 78e6f36b..cc88c5ff 100644 --- a/curry-right/lib/curry_right.js +++ b/curry-right/lib/curry_right.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -50,7 +51,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -59,7 +60,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( 'invalid argument. Arity argument must be positive integer. Value: `' + len + '`.' ); + throw new TypeError( format( 'invalid argument. Arity argument must be positive integer. Value: `%s`.', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/curry/lib/curry.js b/curry/lib/curry.js index 688e46c5..f7eca77f 100644 --- a/curry/lib/curry.js +++ b/curry/lib/curry.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -50,7 +51,7 @@ function curry( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -59,7 +60,7 @@ function curry( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( 'invalid argument. Arity argument must be positive integer. Value: `' + len + '`.' ); + throw new TypeError( format( 'invalid argument. Arity argument must be positive integer. Value: `%s`.', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/deep-get/lib/deep_get.js b/deep-get/lib/deep_get.js index a580482e..4032f89d 100644 --- a/deep-get/lib/deep_get.js +++ b/deep-get/lib/deep_get.js @@ -23,6 +23,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isArray = require( '@stdlib/assert/is-array' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var validate = require( './validate.js' ); var defaults = require( './defaults.json' ); @@ -78,7 +79,7 @@ function deepGet( obj, path, options ) { } isStr = isString( path ); if ( !isStr && !isArray( path ) ) { - throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' ); + throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) ); } opts = copy( defaults ); if ( arguments.length > 2 ) { diff --git a/deep-get/lib/factory.js b/deep-get/lib/factory.js index 7b47869e..75d8f073 100644 --- a/deep-get/lib/factory.js +++ b/deep-get/lib/factory.js @@ -23,6 +23,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isArray = require( '@stdlib/assert/is-array' ); var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var validate = require( './validate.js' ); var defaults = require( './defaults.json' ); @@ -54,7 +55,7 @@ function factory( path, options ) { var err; isStr = isString( path ); if ( !isStr && !isArray( path ) ) { - throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' ); + throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) ); } opts = copy( defaults ); if ( arguments.length > 1 ) { diff --git a/deep-set/lib/deep_set.js b/deep-set/lib/deep_set.js index 5a813026..d4a8f2b7 100644 --- a/deep-set/lib/deep_set.js +++ b/deep-set/lib/deep_set.js @@ -23,6 +23,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isArray = require( '@stdlib/assert/is-array' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var validate = require( './validate.js' ); var defaults = require( './defaults.json' ); @@ -97,7 +98,7 @@ function deepSet( obj, path, value, options ) { } isStr = isString( path ); if ( !isStr && !isArray( path ) ) { - throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' ); + throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) ); } opts = copy( defaults ); if ( arguments.length > 3 ) { diff --git a/deep-set/lib/factory.js b/deep-set/lib/factory.js index b6fa970d..0cec3729 100644 --- a/deep-set/lib/factory.js +++ b/deep-set/lib/factory.js @@ -23,6 +23,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isArray = require( '@stdlib/assert/is-array' ); var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var validate = require( './validate.js' ); var defaults = require( './defaults.json' ); @@ -57,7 +58,7 @@ function factory( path, options ) { isStr = isString( path ); if ( !isStr && !isArray( path ) ) { - throw new TypeError( 'invalid argument. Key path must be a string primitive or a key array. Value: `' + path + '`.' ); + throw new TypeError( format( 'invalid argument. Key path must be a string primitive or a key array. Value: `%s`.', path ) ); } opts = copy( defaults ); if ( arguments.length > 1 ) { diff --git a/define-memoized-configurable-read-only-property/lib/main.js b/define-memoized-configurable-read-only-property/lib/main.js index ed7a4a11..0558f45f 100644 --- a/define-memoized-configurable-read-only-property/lib/main.js +++ b/define-memoized-configurable-read-only-property/lib/main.js @@ -23,6 +23,7 @@ var isObject = require( '@stdlib/assert/is-object' ); var isFunction = require( '@stdlib/assert/is-function' ); var defineMemoizedProperty = require( './../../define-memoized-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,10 +55,10 @@ var defineMemoizedProperty = require( './../../define-memoized-property' ); */ function setMemoizedConfigurableReadOnly( obj, prop, fcn ) { // eslint-disable-line id-length if ( !isObject( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } defineMemoizedProperty( obj, prop, { 'configurable': true, diff --git a/define-memoized-property/lib/main.js b/define-memoized-property/lib/main.js index 5ee87d3d..a9ee749c 100644 --- a/define-memoized-property/lib/main.js +++ b/define-memoized-property/lib/main.js @@ -23,6 +23,7 @@ var isObject = require( '@stdlib/assert/is-object' ); var isFunction = require( '@stdlib/assert/is-function' ); var defineProperty = require( './../../define-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,13 +61,13 @@ var defineProperty = require( './../../define-property' ); */ function defineMemoizedProperty( obj, prop, desc ) { if ( !isObject( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isObject( desc ) ) { - throw new TypeError( 'invalid argument. Property descriptor must be an object. Value: `' + desc + '`.' ); + throw new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', desc ) ); } if ( !isFunction( desc.value ) ) { - throw new TypeError( 'invalid argument. The `value` property of the property descriptor must be a function. Value: `' + desc.value + '`.' ); + throw new TypeError( format( 'invalid argument. The `value` property of the property descriptor must be a function. Value: `%s`.', desc.value ) ); } // Copy descriptor properties to a new data descriptor object: desc = { diff --git a/define-memoized-read-only-property/lib/main.js b/define-memoized-read-only-property/lib/main.js index 7d1455f5..cac84ab4 100644 --- a/define-memoized-read-only-property/lib/main.js +++ b/define-memoized-read-only-property/lib/main.js @@ -23,6 +23,7 @@ var isObject = require( '@stdlib/assert/is-object' ); var isFunction = require( '@stdlib/assert/is-function' ); var defineMemoizedProperty = require( './../../define-memoized-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,10 +55,10 @@ var defineMemoizedProperty = require( './../../define-memoized-property' ); */ function setMemoizedReadOnly( obj, prop, fcn ) { if ( !isObject( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } defineMemoizedProperty( obj, prop, { 'configurable': false, diff --git a/define-properties/lib/polyfill.js b/define-properties/lib/polyfill.js index ea0323f7..3dd5aca0 100644 --- a/define-properties/lib/polyfill.js +++ b/define-properties/lib/polyfill.js @@ -23,6 +23,7 @@ var isObject = require( '@stdlib/assert/is-object' ); var objectKeys = require( './../../keys' ); var defineProperty = require( './../../define-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -59,10 +60,10 @@ function defineProperties( obj, props ) { var i; if ( !isObject( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isObject( props ) ) { - throw new TypeError( 'invalid argument. Second argument must be an object of property descriptors. Value: `' + props + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an object of property descriptors. Value: `%s`.', props ) ); } keys = objectKeys( props ); for ( i = 0; i < keys.length; i++ ) { diff --git a/define-property/lib/polyfill.js b/define-property/lib/polyfill.js index f9cf6ddb..abd3686a 100644 --- a/define-property/lib/polyfill.js +++ b/define-property/lib/polyfill.js @@ -20,6 +20,11 @@ 'use strict'; +// MODULES // + +var format = require( '@stdlib/string/format' ); + + // VARIABLES // var objectProtoype = Object.prototype; @@ -70,10 +75,10 @@ function defineProperty( obj, prop, descriptor ) { var hasSet; if ( typeof obj !== 'object' || obj === null || toStr.call( obj ) === '[object Array]' ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( typeof descriptor !== 'object' || descriptor === null || toStr.call( descriptor ) === '[object Array]' ) { - throw new TypeError( 'invalid argument. Property descriptor must be an object. Value: `' + descriptor + '`.' ); + throw new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', descriptor ) ); } hasValue = ( 'value' in descriptor ); if ( hasValue ) { diff --git a/dirname/lib/dirname.js b/dirname/lib/dirname.js index e19de464..791fdf04 100644 --- a/dirname/lib/dirname.js +++ b/dirname/lib/dirname.js @@ -21,6 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var RE_DIRNAME = require( '@stdlib/regexp/dirname' ).REGEXP; @@ -39,7 +40,7 @@ var RE_DIRNAME = require( '@stdlib/regexp/dirname' ).REGEXP; */ function dirname( path ) { if ( !isString( path ) ) { - throw new TypeError( 'invalid argument. Path must be a primitive string. Value: `' + path + '`.' ); + throw new TypeError( format( 'invalid argument. Path must be a primitive string. Value: `%s`.', path ) ); } return RE_DIRNAME.exec( path )[ 1 ]; } diff --git a/do-until-each-right/lib/do_until_each_right.js b/do-until-each-right/lib/do_until_each_right.js index e3153a59..598ef578 100644 --- a/do-until-each-right/lib/do_until_each_right.js +++ b/do-until-each-right/lib/do_until_each_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -62,13 +63,13 @@ function doUntilEachRight( collection, fcn, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; if ( len === 0 ) { diff --git a/do-until-each/lib/do_until_each.js b/do-until-each/lib/do_until_each.js index 15155bb1..b6f5c966 100644 --- a/do-until-each/lib/do_until_each.js +++ b/do-until-each/lib/do_until_each.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function doUntilEach( collection, fcn, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; if ( len === 0 ) { diff --git a/do-until/lib/do_until.js b/do-until/lib/do_until.js index 9a4c41cd..a3a245b5 100644 --- a/do-until/lib/do_until.js +++ b/do-until/lib/do_until.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); function doUntil( fcn, predicate, thisArg ) { var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } i = 0; do { diff --git a/do-while-each-right/lib/do_while_each_right.js b/do-while-each-right/lib/do_while_each_right.js index 211e5a6a..126e0847 100644 --- a/do-while-each-right/lib/do_while_each_right.js +++ b/do-while-each-right/lib/do_while_each_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -62,13 +63,13 @@ function doWhileEachRight( collection, fcn, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; if ( len === 0 ) { diff --git a/do-while-each/lib/do_while_each.js b/do-while-each/lib/do_while_each.js index e6462197..e91650a5 100644 --- a/do-while-each/lib/do_while_each.js +++ b/do-while-each/lib/do_while_each.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -61,13 +62,13 @@ function doWhileEach( collection, fcn, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; if ( len === 0 ) { diff --git a/do-while/lib/do_while.js b/do-while/lib/do_while.js index d27cb41e..90042f6c 100644 --- a/do-while/lib/do_while.js +++ b/do-while/lib/do_while.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); function doWhile( fcn, predicate, thisArg ) { var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } i = 0; do { diff --git a/entries-in/lib/entries_in.js b/entries-in/lib/entries_in.js index eb382ae4..7125a176 100644 --- a/entries-in/lib/entries_in.js +++ b/entries-in/lib/entries_in.js @@ -21,6 +21,7 @@ // MODULES // var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -49,7 +50,7 @@ function objectEntriesIn( obj ) { var key; var out; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. Must provide an object-like value. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object-like value. Value: `%s`.', obj ) ); } out = []; for ( key in obj ) { // eslint-disable-line guard-for-in diff --git a/entries/lib/entries.js b/entries/lib/entries.js index 9dd77dbe..163fac95 100644 --- a/entries/lib/entries.js +++ b/entries/lib/entries.js @@ -22,6 +22,7 @@ var objectKeys = require( './../../keys' ); var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,7 +49,7 @@ function objectEntries( obj ) { var len; var i; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. Must provide an object-like value. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object-like value. Value: `%s`.', obj ) ); } keys = objectKeys( obj ); len = keys.length; diff --git a/escape-regexp-string/lib/main.js b/escape-regexp-string/lib/main.js index 992e8586..2d25d3bc 100644 --- a/escape-regexp-string/lib/main.js +++ b/escape-regexp-string/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // VARIABLES // @@ -47,7 +48,7 @@ function rescape( str ) { var i; if ( !isString( str ) ) { - throw new TypeError( 'invalid argument. Must provide a regular expression string. Value: `' + str + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide a regular expression string. Value: `%s`.', str ) ); } // Check if the string starts with a forward slash... if ( str[ 0 ] === '/' ) { diff --git a/every-by-right/lib/every_by_right.js b/every-by-right/lib/every_by_right.js index eb3b832f..10282db8 100644 --- a/every-by-right/lib/every_by_right.js +++ b/every-by-right/lib/every_by_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,10 +56,10 @@ function everyByRight( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = len-1; i >= 0; i-- ) { diff --git a/every-by/lib/every_by.js b/every-by/lib/every_by.js index 9b5f5113..a6b1a896 100644 --- a/every-by/lib/every_by.js +++ b/every-by/lib/every_by.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -51,10 +52,10 @@ function everyBy( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/every/lib/main.js b/every/lib/main.js index 82f9a562..2761cdcd 100644 --- a/every/lib/main.js +++ b/every/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -42,7 +43,7 @@ function every( collection ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. Must provide a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a collection. Value: `%s`.', collection ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/extname/lib/extname.js b/extname/lib/extname.js index 7d015b79..f2790729 100644 --- a/extname/lib/extname.js +++ b/extname/lib/extname.js @@ -22,6 +22,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var RE_EXTNAME = require( '@stdlib/regexp/extname' ).REGEXP; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -39,7 +40,7 @@ var RE_EXTNAME = require( '@stdlib/regexp/extname' ).REGEXP; */ function extname( filename ) { if ( !isString( filename ) ) { - throw new TypeError( 'invalid argument. Filename must be a primitive string. Value: `' + filename + '`.' ); + throw new TypeError( format( 'invalid argument. Filename must be a primitive string. Value: `%s`.', filename ) ); } return RE_EXTNAME.exec( filename )[ 1 ]; } diff --git a/filter-arguments/lib/main.js b/filter-arguments/lib/main.js index 501fe9aa..77bad1e1 100644 --- a/filter-arguments/lib/main.js +++ b/filter-arguments/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,10 +61,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function filterArguments( fcn, predicate, thisArg ) { if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } return wrap; diff --git a/find/lib/find.js b/find/lib/find.js index 366538d1..b9efc29c 100644 --- a/find/lib/find.js +++ b/find/lib/find.js @@ -26,6 +26,7 @@ var isObject = require( '@stdlib/assert/is-plain-object' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isCollection = require( '@stdlib/assert/is-collection' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -119,7 +120,7 @@ function find( arr, options, clbk ) { // eslint-disable-line stdlib/no-redeclare returns = [ 'values', 'indices', '*' ]; if ( !isCollection( arr ) && !isString( arr ) ) { - throw new TypeError( 'invalid argument. Must provide an array-like object. Value: `' + arr + '`' ); + throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); } len = arr.length; if ( arguments.length < 3 ) { @@ -130,15 +131,15 @@ function find( arr, options, clbk ) { // eslint-disable-line stdlib/no-redeclare cb = clbk; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`' ); + throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) ); } if ( !isObject( opts ) ) { - throw new TypeError( 'invalid argument. Options must be an object. Value: `' + opts + '`' ); + throw new TypeError( format( 'invalid argument. Options must be an object. Value: `%s`.', opts ) ); } if ( hasOwnProp( opts, 'k' ) ) { k = opts.k; if ( !isInteger( k ) ) { - throw new TypeError( 'invalid argument. `k` must be an integer. Value: `' + k + '`' ); + throw new TypeError( format( 'invalid argument. `k` must be an integer. Value: `%s`.', k ) ); } } else { k = len; @@ -146,7 +147,7 @@ function find( arr, options, clbk ) { // eslint-disable-line stdlib/no-redeclare if ( hasOwnProp( opts, 'returns' ) ) { ret = opts.returns; if ( !isString( ret ) || returns.indexOf( ret ) === -1 ) { - throw new TypeError( 'invalid argument. `returns` option must be a string and have one of the following values: `values`, `indices`, `all`. Value: `' + ret + '`' ); + throw new TypeError( format( 'invalid argument. `returns` option must be a string and have one of the following values: `values`, `indices`, `all`. Value: `%s`.', ret ) ); } if ( ret === 'values' ) { mode = 1; diff --git a/flatten-array/lib/factory.js b/flatten-array/lib/factory.js index 438a6a34..4baf6968 100644 --- a/flatten-array/lib/factory.js +++ b/flatten-array/lib/factory.js @@ -24,6 +24,7 @@ var isPositiveIntegerArray = require( '@stdlib/assert/is-positive-integer-array' var isObject = require( '@stdlib/assert/is-plain-object' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var defaults = require( './defaults.js' ); var genFcn = require( './gen_fcn.js' ); var wrapFlatten = require( './wrap_flatten.js' ); @@ -58,17 +59,17 @@ function factory( dims, options ) { var copyFLG; var flatten; if ( !isPositiveIntegerArray( dims ) ) { - throw new TypeError( 'invalid argument. First argument must be an array of positive integers. Value: `' + dims + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array of positive integers. Value: `%s`.', dims ) ); } copyFLG = defaults.copy; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' ); + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); } if ( hasOwnProp( options, 'copy' ) ) { copyFLG = options.copy; if ( !isBoolean( copyFLG ) ) { - throw new TypeError( 'invalid option. `copy` option must be a boolean primitive. Option: `' + copyFLG + '`.' ); + throw new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'copy', copyFLG ) ); } } } diff --git a/flatten-array/lib/main.js b/flatten-array/lib/main.js index e5939e61..1e068082 100644 --- a/flatten-array/lib/main.js +++ b/flatten-array/lib/main.js @@ -22,6 +22,7 @@ var copy = require( './../../copy' ); var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var format = require( '@stdlib/string/format' ); var defaults = require( './defaults.js' ); var validate = require( './validate.js' ); var recurse = require( './recurse.js' ); @@ -52,7 +53,7 @@ function flattenArray( arr, options ) { var err; var out; if ( !isArrayLikeObject( arr ) ) { - throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', arr ) ); } opts = { 'copy': defaults.copy, diff --git a/flatten-array/lib/wrap_flatten.js b/flatten-array/lib/wrap_flatten.js index 1e3e8416..cd55d5d2 100644 --- a/flatten-array/lib/wrap_flatten.js +++ b/flatten-array/lib/wrap_flatten.js @@ -21,6 +21,7 @@ // MODULES // var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -45,7 +46,7 @@ function wrap( flatten ) { */ function flattenArray( arr ) { if ( !isArrayLikeObject( arr ) ) { - throw new TypeError( 'invalid argument. Must provide an array-like object. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); } return flatten( arr ); } diff --git a/flatten-array/lib/wrap_flatten_copy.js b/flatten-array/lib/wrap_flatten_copy.js index 2a2b7789..76047c64 100644 --- a/flatten-array/lib/wrap_flatten_copy.js +++ b/flatten-array/lib/wrap_flatten_copy.js @@ -21,6 +21,7 @@ // MODULES // var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); @@ -46,7 +47,7 @@ function wrap( flatten ) { */ function flattenArray( arr ) { if ( !isArrayLikeObject( arr ) ) { - throw new TypeError( 'invalid argument. Must provide an array-like object. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); } return copy( flatten( arr ) ); } diff --git a/flatten-object/lib/factory.js b/flatten-object/lib/factory.js index 444546c4..da2d8c19 100644 --- a/flatten-object/lib/factory.js +++ b/flatten-object/lib/factory.js @@ -21,6 +21,7 @@ // MODULES // var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var defaults = require( './defaults.js' ); var validate = require( './validate.js' ); @@ -72,7 +73,7 @@ function factory( options ) { */ function flattenObject( obj ) { if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. Must provide an object-like value. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object-like value. Value: `%s`.', obj ) ); } return flatten( obj, opts ); } diff --git a/flatten-object/lib/flatten_object.js b/flatten-object/lib/flatten_object.js index e63192fa..d63d1aaf 100644 --- a/flatten-object/lib/flatten_object.js +++ b/flatten-object/lib/flatten_object.js @@ -21,6 +21,7 @@ // MODULES // var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); var copy = require( './../../copy' ); var defaults = require( './defaults.js' ); var validate = require( './validate.js' ); @@ -53,7 +54,7 @@ function flattenObject( obj, options ) { var opts; var err; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be object-like. Value: `' + obj + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be object-like. Value: `%s`.', obj ) ); } opts = copy( defaults ); if ( arguments.length > 1 ) { diff --git a/for-each-right/lib/for_each_right.js b/for-each-right/lib/for_each_right.js index eaf8ec2f..be6a702c 100644 --- a/for-each-right/lib/for_each_right.js +++ b/for-each-right/lib/for_each_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,10 +55,10 @@ function forEachRight( collection, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; for ( i = len-1; i >= 0; i-- ) { diff --git a/for-each/lib/for_each.js b/for-each/lib/for_each.js index ac0d5571..a0c42d98 100644 --- a/for-each/lib/for_each.js +++ b/for-each/lib/for_each.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -49,10 +50,10 @@ function forEach( collection, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/for-in/lib/for_in.js b/for-in/lib/for_in.js index f77d99d4..1e305290 100644 --- a/for-in/lib/for_in.js +++ b/for-in/lib/for_in.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -62,10 +63,10 @@ function forIn( obj, fcn, thisArg ) { var bool; var key; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } for ( key in obj ) { // eslint-disable-line guard-for-in bool = fcn.call( thisArg, obj[ key ], key, obj ); diff --git a/for-own/lib/for_own.js b/for-own/lib/for_own.js index a2a1088b..3e871697 100644 --- a/for-own/lib/for_own.js +++ b/for-own/lib/for_own.js @@ -22,6 +22,7 @@ var objectKeys = require( './../../keys' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -62,10 +63,10 @@ function forOwn( obj, fcn, thisArg ) { var k; var i; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } keys = objectKeys( obj ); len = keys.length; diff --git a/from-entries/lib/from_entries.js b/from-entries/lib/from_entries.js index aae15099..63822abe 100644 --- a/from-entries/lib/from_entries.js +++ b/from-entries/lib/from_entries.js @@ -21,6 +21,7 @@ // MODULES // var isArrayArray = require( '@stdlib/assert/is-array-array' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -42,7 +43,7 @@ function objectFromEntries( entries ) { var out; var i; if ( !isArrayArray( entries ) ) { - throw new TypeError( 'invalid argument. Must provide an array of arrays. Value: `'+entries+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an array of arrays. Value: `%s`.', entries ) ); } out = {}; for ( i = 0; i < entries.length; i++ ) { diff --git a/function-name/lib/function_name.js b/function-name/lib/function_name.js index e11008b5..5f8cabf3 100644 --- a/function-name/lib/function_name.js +++ b/function-name/lib/function_name.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var hasFunctionNameSupport = require( '@stdlib/assert/has-function-name-support' ); +var format = require( '@stdlib/string/format' ); var RE = require( '@stdlib/regexp/function-name' ).REGEXP; @@ -58,7 +59,7 @@ var isFunctionNameSupported = hasFunctionNameSupport(); function functionName( fcn ) { // TODO: add support for generator functions? if ( isFunction( fcn ) === false ) { - throw new TypeError( 'invalid argument. Must provide a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', fcn ) ); } if ( isFunctionNameSupported ) { return fcn.name; diff --git a/global/lib/main.js b/global/lib/main.js index 1bf11175..8c72c115 100644 --- a/global/lib/main.js +++ b/global/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var getThis = require( './codegen.js' ); var Self = require( './self.js' ); var Win = require( './window.js' ); @@ -48,7 +49,7 @@ var Global = require( './global.js' ); function getGlobal( codegen ) { if ( arguments.length ) { if ( !isBoolean( codegen ) ) { - throw new TypeError( 'invalid argument. Must provide a boolean primitive. Value: `'+codegen+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a boolean primitive. Value: `%s`.', codegen ) ); } if ( codegen ) { return getThis(); diff --git a/group-by/lib/group_by.js b/group-by/lib/group_by.js index 69fd6ab3..cc51a3ba 100644 --- a/group-by/lib/group_by.js +++ b/group-by/lib/group_by.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnIndices = require( './return_indices.js' ); @@ -82,7 +83,7 @@ function groupBy( collection, options, indicator ) { var err; var cb; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = { 'returns': 'values' @@ -97,7 +98,7 @@ function groupBy( collection, options, indicator ) { cb = indicator; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( collection, opts, cb ); diff --git a/group-in/lib/main.js b/group-in/lib/main.js index 39c6f981..9ee9f901 100644 --- a/group-in/lib/main.js +++ b/group-in/lib/main.js @@ -22,6 +22,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnKeys = require( './return_keys.js' ); @@ -115,7 +116,7 @@ function groupIn( obj, options, indicator ) { var err; var cb; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } opts = { 'returns': 'values' @@ -130,7 +131,7 @@ function groupIn( obj, options, indicator ) { cb = indicator; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( obj, opts, cb ); diff --git a/group-own/lib/main.js b/group-own/lib/main.js index c924ffbe..70f2ca2f 100644 --- a/group-own/lib/main.js +++ b/group-own/lib/main.js @@ -22,6 +22,7 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnKeys = require( './return_keys.js' ); @@ -94,7 +95,7 @@ function groupOwn( obj, options, indicator ) { var err; var cb; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } opts = { 'returns': 'values' @@ -109,7 +110,7 @@ function groupOwn( obj, options, indicator ) { cb = indicator; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } if ( opts.returns === 'values' ) { return returnValues( obj, opts, cb ); diff --git a/group/lib/group.js b/group/lib/group.js index 23018893..eb959bb0 100644 --- a/group/lib/group.js +++ b/group/lib/group.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var returnValues = require( './return_values.js' ); var returnIndices = require( './return_indices.js' ); @@ -77,7 +78,7 @@ function group( collection, options, groups ) { var err; var g; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = { 'returns': 'values' @@ -92,7 +93,7 @@ function group( collection, options, groups ) { g = groups; } if ( !isCollection( g ) ) { - throw new TypeError( 'invalid argument. Last argument must be a collection. Value: `'+g+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a collection. Value: `%s`.', g ) ); } if ( collection.length !== g.length ) { throw new RangeError( 'invalid arguments. First and last arguments must be the same length.' ); diff --git a/if-then/lib/if_then.js b/if-then/lib/if_then.js index 6b78fa44..d3f54467 100644 --- a/if-then/lib/if_then.js +++ b/if-then/lib/if_then.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -51,10 +52,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function ifthen( bool, x, y ) { if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', x ) ); } if ( !isFunction( y ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+y+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', y ) ); } if ( bool ) { return x(); diff --git a/index-of/lib/index_of.js b/index-of/lib/index_of.js index 6c76549e..21ccf3ec 100644 --- a/index-of/lib/index_of.js +++ b/index-of/lib/index_of.js @@ -24,6 +24,7 @@ var isnan = require( '@stdlib/assert/is-nan' ); var isCollection = require( '@stdlib/assert/is-collection' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -85,7 +86,7 @@ function indexOf( arr, searchElement, fromIndex ) { var len; var i; if ( !isCollection( arr ) && !isString( arr ) ) { - throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', arr ) ); } len = arr.length; if ( len === 0 ) { @@ -93,7 +94,7 @@ function indexOf( arr, searchElement, fromIndex ) { } if ( arguments.length === 3 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( 'invalid argument. `fromIndex` must be an integer. Value: `' + fromIndex + '`.' ); + throw new TypeError( format( 'invalid argument. `fromIndex` must be an integer. Value: `%s`.', fromIndex ) ); } if ( fromIndex >= 0 ) { if ( fromIndex >= len ) { diff --git a/inherit/lib/inherit.js b/inherit/lib/inherit.js index de339eff..9d0a7141 100644 --- a/inherit/lib/inherit.js +++ b/inherit/lib/inherit.js @@ -21,6 +21,7 @@ // MODULES // var defineProperty = require( './../../define-property' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); var createObject = require( './detect.js' ); @@ -71,7 +72,7 @@ function inherit( ctor, superCtor ) { throw err; } if ( typeof superCtor.prototype === 'undefined' ) { - throw new TypeError( 'invalid argument. Second argument must have a prototype from which another object can inherit. Value: `'+superCtor.prototype+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must have a prototype from which another object can inherit. Value: `%s`.', superCtor.prototype ) ); } // Create a prototype which inherits from the parent prototype: ctor.prototype = createObject( superCtor.prototype ); diff --git a/inherit/lib/validate.js b/inherit/lib/validate.js index b977b6f5..f65612a9 100644 --- a/inherit/lib/validate.js +++ b/inherit/lib/validate.js @@ -18,6 +18,13 @@ 'use strict'; +// MODULES // + +var format = require( '@stdlib/string/format' ); + + +// MAIN // + /** * Tests that a value is a valid constructor. * @@ -40,7 +47,7 @@ function validate( value ) { value === null || (type !== 'object' && type !== 'function') ) { - return new TypeError( 'invalid argument. A provided constructor must be either an object (except null) or a function. Value: `'+value+'`.' ); + return new TypeError( format( 'invalid argument. A provided constructor must be either an object (except null) or a function. Value: `%s`.', value ) ); } return null; } diff --git a/inherited-enumerable-properties/lib/main.js b/inherited-enumerable-properties/lib/main.js index b2b830de..657e77e6 100644 --- a/inherited-enumerable-properties/lib/main.js +++ b/inherited-enumerable-properties/lib/main.js @@ -27,6 +27,7 @@ var getOwnPropertyNames = require( './../../property-names' ); var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,7 +55,7 @@ function inheritedEnumerableProperties( value, level ) { // eslint-disable-line if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-enumerable-property-symbols/lib/main.js b/inherited-enumerable-property-symbols/lib/main.js index 725043ee..5652381d 100644 --- a/inherited-enumerable-property-symbols/lib/main.js +++ b/inherited-enumerable-property-symbols/lib/main.js @@ -26,6 +26,7 @@ var isEnumerableProperty = require( '@stdlib/assert/is-enumerable-property' ); var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedEnumerablePropertySymbols( value, level ) { // eslint-disable- if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-keys/lib/main.js b/inherited-keys/lib/main.js index 0ee8f610..89f4698d 100644 --- a/inherited-keys/lib/main.js +++ b/inherited-keys/lib/main.js @@ -26,6 +26,7 @@ var getOwnPropertyNames = require( './../../property-names' ); var getPrototypeOf = require( './../../get-prototype-of' ); var isEnumerable = require( '@stdlib/assert/is-enumerable-property' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedKeys( value, level ) { if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-nonenumerable-properties/lib/main.js b/inherited-nonenumerable-properties/lib/main.js index 190e036e..eba54876 100644 --- a/inherited-nonenumerable-properties/lib/main.js +++ b/inherited-nonenumerable-properties/lib/main.js @@ -27,6 +27,7 @@ var getOwnPropertyNames = require( './../../property-names' ); var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,7 +55,7 @@ function inheritedNonEnumerableProperties( value, level ) { // eslint-disable-li if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-nonenumerable-property-names/lib/main.js b/inherited-nonenumerable-property-names/lib/main.js index 4e49186c..2f4877e5 100644 --- a/inherited-nonenumerable-property-names/lib/main.js +++ b/inherited-nonenumerable-property-names/lib/main.js @@ -26,6 +26,7 @@ var isNonEnumerableProperty = require( '@stdlib/assert/is-nonenumerable-property var getOwnPropertyNames = require( './../../property-names' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedNonEnumerablePropertyNames( value, level ) { // eslint-disable if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-nonenumerable-property-symbols/lib/main.js b/inherited-nonenumerable-property-symbols/lib/main.js index 2b63ac64..eb7da12f 100644 --- a/inherited-nonenumerable-property-symbols/lib/main.js +++ b/inherited-nonenumerable-property-symbols/lib/main.js @@ -26,6 +26,7 @@ var isNonEnumerableProperty = require( '@stdlib/assert/is-nonenumerable-property var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedNonEnumerablePropertySymbols( value, level ) { // eslint-disab if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-properties/lib/main.js b/inherited-properties/lib/main.js index ca3a12f2..dbddd4b3 100644 --- a/inherited-properties/lib/main.js +++ b/inherited-properties/lib/main.js @@ -25,6 +25,7 @@ var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimit var propertySymbols = require( './../../property-symbols' ); var propertyNames = require( './../../property-names' ); var getPrototypeOf = require( './../../get-prototype-of' ); +var format = require( '@stdlib/string/format' ); // FUNCTIONS // @@ -72,7 +73,7 @@ function inheritedProperties( value, level ) { if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-property-descriptor/lib/main.js b/inherited-property-descriptor/lib/main.js index 7517aa56..e3af4131 100644 --- a/inherited-property-descriptor/lib/main.js +++ b/inherited-property-descriptor/lib/main.js @@ -24,6 +24,7 @@ var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var getOwnPropertyDescriptor = require( './../../property-descriptor' ); var getPrototypeOf = require( './../../get-prototype-of' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,7 +55,7 @@ function inheritedPropertyDescriptor( value, property, level ) { // eslint-disab var n; if ( arguments.length > 2 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Third argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-property-descriptors/lib/main.js b/inherited-property-descriptors/lib/main.js index f90edc51..f62a548f 100644 --- a/inherited-property-descriptors/lib/main.js +++ b/inherited-property-descriptors/lib/main.js @@ -28,6 +28,7 @@ var getPrototypeOf = require( './../../get-prototype-of' ); var objectKeys = require( './../../keys' ); var defineProperty = require( './../../define-property' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -59,7 +60,7 @@ function inheritedPropertyDescriptors( value, level ) { // eslint-disable-line i if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-property-names/lib/main.js b/inherited-property-names/lib/main.js index 99cb9b3b..ebd01714 100644 --- a/inherited-property-names/lib/main.js +++ b/inherited-property-names/lib/main.js @@ -24,6 +24,7 @@ var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var propertyNames = require( './../../property-names' ); var getPrototypeOf = require( './../../get-prototype-of' ); +var format = require( '@stdlib/string/format' ); // FUNCTIONS // @@ -70,7 +71,7 @@ function inheritedPropertyNames( value, level ) { if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-property-symbols/lib/main.js b/inherited-property-symbols/lib/main.js index 1fd1f44c..6d501f5c 100644 --- a/inherited-property-symbols/lib/main.js +++ b/inherited-property-symbols/lib/main.js @@ -24,6 +24,7 @@ var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var propertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); +var format = require( '@stdlib/string/format' ); // FUNCTIONS // @@ -70,7 +71,7 @@ function inheritedPropertySymbols( value, level ) { if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-writable-properties/lib/main.js b/inherited-writable-properties/lib/main.js index 3827fdb4..160f57b6 100644 --- a/inherited-writable-properties/lib/main.js +++ b/inherited-writable-properties/lib/main.js @@ -27,6 +27,7 @@ var getOwnPropertyNames = require( './../../property-names' ); var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,7 +55,7 @@ function inheritedWritableProperties( value, level ) { // eslint-disable-line id if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-writable-property-names/lib/main.js b/inherited-writable-property-names/lib/main.js index 27a6ad20..cd98065b 100644 --- a/inherited-writable-property-names/lib/main.js +++ b/inherited-writable-property-names/lib/main.js @@ -26,6 +26,7 @@ var isWritableProperty = require( '@stdlib/assert/is-writable-property' ); var getOwnPropertyNames = require( './../../property-names' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedWritablePropertyNames( value, level ) { // eslint-disable-line if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inherited-writable-property-symbols/lib/main.js b/inherited-writable-property-symbols/lib/main.js index 9feb4a06..9809f77e 100644 --- a/inherited-writable-property-symbols/lib/main.js +++ b/inherited-writable-property-symbols/lib/main.js @@ -26,6 +26,7 @@ var isWritableProperty = require( '@stdlib/assert/is-writable-property' ); var getOwnPropertySymbols = require( './../../property-symbols' ); var getPrototypeOf = require( './../../get-prototype-of' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,7 +54,7 @@ function inheritedWritablePropertySymbols( value, level ) { // eslint-disable-li if ( arguments.length > 1 ) { if ( !isPositiveInteger( level ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `' + level + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', level ) ); } N = level; } else { diff --git a/inmap-right/lib/inmap_right.js b/inmap-right/lib/inmap_right.js index aa91c9c7..7b3a7ce7 100644 --- a/inmap-right/lib/inmap_right.js +++ b/inmap-right/lib/inmap_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,10 +61,10 @@ function inmapRight( collection, fcn, thisArg ) { var v; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; for ( i = len-1; i >= 0; i-- ) { diff --git a/inmap/lib/inmap.js b/inmap/lib/inmap.js index 42d28ef1..48f53059 100644 --- a/inmap/lib/inmap.js +++ b/inmap/lib/inmap.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -59,10 +60,10 @@ function inmap( collection, fcn, thisArg ) { var v; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/key-by-right/lib/key_by_right.js b/key-by-right/lib/key_by_right.js index a0391a9a..d7013bdf 100644 --- a/key-by-right/lib/key_by_right.js +++ b/key-by-right/lib/key_by_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -56,10 +57,10 @@ function keyByRight( collection, fcn, thisArg ) { var key; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; out = {}; diff --git a/key-by/lib/key_by.js b/key-by/lib/key_by.js index 0b0ffb4e..9787e9d0 100644 --- a/key-by/lib/key_by.js +++ b/key-by/lib/key_by.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -56,10 +57,10 @@ function keyBy( collection, fcn, thisArg ) { var key; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; out = {}; diff --git a/lowercase-keys/lib/lowercase_keys.js b/lowercase-keys/lib/lowercase_keys.js index 9197045b..8725a1b3 100644 --- a/lowercase-keys/lib/lowercase_keys.js +++ b/lowercase-keys/lib/lowercase_keys.js @@ -21,6 +21,7 @@ // MODULES // var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -45,7 +46,7 @@ function lowercaseKeys( obj ) { var out; var key; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. Must provide an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); } out = {}; for ( key in obj ) { diff --git a/map-arguments/lib/main.js b/map-arguments/lib/main.js index 203d83ec..6ca662fc 100644 --- a/map-arguments/lib/main.js +++ b/map-arguments/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -58,10 +59,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function mapArguments( fcn, clbk, thisArg ) { if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( clbk ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+clbk+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); } return wrap; diff --git a/map-function/lib/map_function.js b/map-function/lib/map_function.js index 669859cb..ce65a88d 100644 --- a/map-function/lib/map_function.js +++ b/map-function/lib/map_function.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ function mapFun( fcn, n, thisArg ) { var out; var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a nonnegative integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) ); } // Note: we explicitly do not preallocate in order to ensure "fast" elements for large output arrays. out = []; diff --git a/map-keys/lib/map_keys.js b/map-keys/lib/map_keys.js index c6b78eb9..51923945 100644 --- a/map-keys/lib/map_keys.js +++ b/map-keys/lib/map_keys.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -59,10 +60,10 @@ function mapKeys( obj, transform ) { var key; var v; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( transform ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+transform+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', transform ) ); } out = {}; for ( key in obj ) { diff --git a/map-reduce/lib/main.js b/map-reduce/lib/main.js index 0f6c096e..1e401ad6 100644 --- a/map-reduce/lib/main.js +++ b/map-reduce/lib/main.js @@ -25,6 +25,7 @@ var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); var isFunction = require( '@stdlib/assert/is-function' ); var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -89,10 +90,10 @@ var arrayFcn = require( './array.js' ); */ function mapReduce( arr, initial, mapper, reducer, thisArg ) { if ( !isFunction( mapper ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value:`' + mapper + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', mapper ) ); } if ( !isFunction( reducer ) ) { - throw new TypeError( 'invalid argument. Fourth argument must be a function. Value:`' + reducer + '`.' ); + throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', reducer ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like return ndarrayFcn( ndarraylike2object( arr ), initial, mapper, reducer, thisArg ); // eslint-disable-line max-len @@ -100,7 +101,7 @@ function mapReduce( arr, initial, mapper, reducer, thisArg ) { if ( isArrayLikeObject( arr ) ) { return arrayFcn( arraylike2object( arr ), initial, mapper, reducer, thisArg ); // eslint-disable-line max-len } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/map-right/lib/assign.js b/map-right/lib/assign.js index a11392a1..9e6482b7 100644 --- a/map-right/lib/assign.js +++ b/map-right/lib/assign.js @@ -27,6 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var broadcast = require( '@stdlib/ndarray/base/maybe-broadcast-array' ); var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -90,11 +91,11 @@ function mapRight( arr, out, fcn, thisArg ) { var tmp; var sh; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like if ( !isndarrayLike( out ) ) { - throw new TypeError( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) ); } if ( isReadOnly( out ) ) { throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' ); @@ -111,7 +112,7 @@ function mapRight( arr, out, fcn, thisArg ) { } if ( isArrayLikeObject( arr ) ) { if ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) { - throw new TypeError( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) ); } if ( arr.length !== out.length ) { throw new RangeError( 'invalid arguments. Input and output arrays must have the same length.' ); @@ -119,7 +120,7 @@ function mapRight( arr, out, fcn, thisArg ) { arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len return out; } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/map-right/lib/main.js b/map-right/lib/main.js index 84c2765c..780b8f5f 100644 --- a/map-right/lib/main.js +++ b/map-right/lib/main.js @@ -27,6 +27,7 @@ var zeros = require( '@stdlib/array/base/zeros' ); var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var ndzeros = require( '@stdlib/ndarray/zeros' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -79,7 +80,7 @@ var arrayFcn = require( './array.js' ); function mapRight( arr, fcn, thisArg ) { var out; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like arr = ndarraylike2object( arr ); @@ -95,7 +96,7 @@ function mapRight( arr, fcn, thisArg ) { arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len return out; } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/map-values/lib/map_values.js b/map-values/lib/map_values.js index a071561b..54c0380a 100644 --- a/map-values/lib/map_values.js +++ b/map-values/lib/map_values.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -58,10 +59,10 @@ function mapValues( obj, transform ) { var out; var key; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( transform ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+transform+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', transform ) ); } out = {}; for ( key in obj ) { diff --git a/map/lib/assign.js b/map/lib/assign.js index 99e4a0c8..42a49e4d 100644 --- a/map/lib/assign.js +++ b/map/lib/assign.js @@ -27,6 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var broadcast = require( '@stdlib/ndarray/base/maybe-broadcast-array' ); var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -90,11 +91,11 @@ function map( arr, out, fcn, thisArg ) { var tmp; var sh; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like if ( !isndarrayLike( out ) ) { - throw new TypeError( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input array is an ndarray, the output array must also be an ndarray. Value: `%s`.', out ) ); } if ( isReadOnly( out ) ) { throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' ); @@ -111,7 +112,7 @@ function map( arr, out, fcn, thisArg ) { } if ( isArrayLikeObject( arr ) ) { if ( !isArrayLikeObject( out ) || isndarrayLike( out ) ) { - throw new TypeError( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input array is an array-like object, the output array must also be an array-like object. Value: `%s`.', out ) ); } if ( arr.length !== out.length ) { throw new RangeError( 'invalid arguments. Input and output arrays must have the same length.' ); @@ -119,7 +120,7 @@ function map( arr, out, fcn, thisArg ) { arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len return out; } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/map/lib/main.js b/map/lib/main.js index e9fe75e8..9374004f 100644 --- a/map/lib/main.js +++ b/map/lib/main.js @@ -27,6 +27,7 @@ var zeros = require( '@stdlib/array/base/zeros' ); var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var ndzeros = require( '@stdlib/ndarray/zeros' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -79,7 +80,7 @@ var arrayFcn = require( './array.js' ); function map( arr, fcn, thisArg ) { var out; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like arr = ndarraylike2object( arr ); @@ -95,7 +96,7 @@ function map( arr, fcn, thisArg ) { arrayFcn( arraylike2object( arr ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len return out; } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/map2-right/lib/assign.js b/map2-right/lib/assign.js index 03a1d014..0153ecaa 100644 --- a/map2-right/lib/assign.js +++ b/map2-right/lib/assign.js @@ -27,6 +27,7 @@ var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var broadcast = require( '@stdlib/ndarray/base/maybe-broadcast-array' ); var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -99,17 +100,17 @@ function map2Right( x, y, out, fcn, thisArg ) { var tmp; var sh; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Fourth argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) ); } isxnd = isndarrayLike( x ); isynd = isndarrayLike( y ); isznd = isndarrayLike( out ); if ( isxnd ) { // note: assertion order matters here, as an ndarray-like object is also array-like if ( !isynd ) { - throw new TypeError( 'invalid argument. If the first input array is an ndarray, the second input array must also be an ndarray. Value: `' + y + '`.' ); + throw new TypeError( format( 'invalid argument. If the first input array is an ndarray, the second input array must also be an ndarray. Value: `%s`.', y ) ); } if ( !isznd ) { - throw new TypeError( 'invalid argument. If the input arrays are ndarrays, the output array must also be an ndarray. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input arrays are ndarrays, the output array must also be an ndarray. Value: `%s`.', out ) ); } if ( isReadOnly( out ) ) { throw new Error( 'invalid argument. The output ndarray must be writable. Cannot write to a read-only ndarray.' ); @@ -131,10 +132,10 @@ function map2Right( x, y, out, fcn, thisArg ) { } if ( isArrayLikeObject( x ) ) { if ( isynd || !isArrayLikeObject( y ) ) { - throw new TypeError( 'invalid argument. If the first input array is an array-like object, the second input array must also be an array-like object. Value: `' + y + '`.' ); + throw new TypeError( format( 'invalid argument. If the first input array is an array-like object, the second input array must also be an array-like object. Value: `%s`.', y ) ); } if ( isznd || !isArrayLikeObject( out ) ) { - throw new TypeError( 'invalid argument. If the input arrays are array-like objects, the output array must also be an array-like object. Value: `' + out + '`.' ); + throw new TypeError( format( 'invalid argument. If the input arrays are array-like objects, the output array must also be an array-like object. Value: `%s`.', out ) ); } if ( x.length !== y.length || y.length !== out.length ) { throw new RangeError( 'invalid arguments. Input and output arrays must have the same number of elements ( i.e., length).' ); @@ -142,7 +143,7 @@ function map2Right( x, y, out, fcn, thisArg ) { arrayFcn( arraylike2object( x ), arraylike2object( y ), arraylike2object( out ), fcn, thisArg ); // eslint-disable-line max-len return out; } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + x + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', x ) ); } diff --git a/mask-arguments/lib/main.js b/mask-arguments/lib/main.js index 59a0ca01..102935b0 100644 --- a/mask-arguments/lib/main.js +++ b/mask-arguments/lib/main.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,10 +56,10 @@ function maskArguments( fcn, mask, thisArg ) { var idx; var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isCollection( mask ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object. Value: `'+mask+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) ); } idx = []; for ( i = 0; i < mask.length; i++ ) { diff --git a/memoize/lib/memoize.js b/memoize/lib/memoize.js index 25189f8c..bd510976 100644 --- a/memoize/lib/memoize.js +++ b/memoize/lib/memoize.js @@ -24,6 +24,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var setReadOnly = require( './../../define-nonenumerable-read-only-property' ); var identity = require( './../../identity-function' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,14 +61,14 @@ function memoize( fcn, hashFunction ) { var toKey; var cache; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( arguments.length < 2 ) { toKey = identity; } else { toKey = hashFunction; if ( !isFunction( toKey ) ) { - throw new TypeError( 'invalid argument. Hash function argument must be a function. Value: `' + toKey + '`.' ); + throw new TypeError( format( 'invalid argument. Hash function argument must be a function. Value: `%s`.', toKey ) ); } } cache = {}; diff --git a/merge/lib/mergefcn.js b/merge/lib/mergefcn.js index 07ef2978..edfb4ef8 100644 --- a/merge/lib/mergefcn.js +++ b/merge/lib/mergefcn.js @@ -21,6 +21,7 @@ // MODULES // var isObject = require( '@stdlib/assert/is-object' ); +var format = require( '@stdlib/string/format' ); var deepMerge = require( './deepmerge.js' ); @@ -83,7 +84,7 @@ function mergefcn( opts ) { throw new Error( 'insufficient input arguments. Must provide both a target object and one or more source objects.' ); } if ( !isObject( target ) ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `' + target + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', target ) ); } src = new Array( nargs ); for ( i = 0; i < nargs; i++ ) { @@ -91,7 +92,7 @@ function mergefcn( opts ) { // WARNING: this is a porous check. Buffers, Numbers, Booleans, Strings, Dates, RegExp, custom class instances,... will all pass. if ( !isObject( arg ) ) { - throw new TypeError( 'invalid argument. A merge source must be an object. Value: `' + arg + '`.' ); + throw new TypeError( format( 'invalid argument. A merge source must be an object. Value: `%s`.', arg ) ); } src[ i ] = arg; } diff --git a/merge/lib/validate.js b/merge/lib/validate.js index 7d00ae5a..84cb15c5 100644 --- a/merge/lib/validate.js +++ b/merge/lib/validate.js @@ -25,6 +25,7 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -43,18 +44,18 @@ var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimit */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' ); + return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); } if ( hasOwnProp( options, 'level' ) ) { opts.level = options.level; if ( !isPositiveInteger( opts.level ) ) { - return new TypeError( 'invalid option. `level` option must be a positive integer. Option: `' + opts.level + '`.' ); + return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'level', opts.level ) ); } } if ( hasOwnProp( options, 'copy' ) ) { opts.copy = options.copy; if ( !isBoolean( opts.copy ) ) { - return new TypeError( 'invalid option. `copy` option must be a boolean primitive. Option: `' + opts.copy + '`.' ); + return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'copy', opts.copy ) ); } } if ( hasOwnProp( options, 'override' ) ) { @@ -63,13 +64,13 @@ function validate( opts, options ) { !isBoolean( opts.override ) && !isFunction( opts.override ) ) { - return new TypeError( 'invalid option. `override` option must be either a boolean primitive or a function. Option: `' + opts.override + '`.' ); + return new TypeError( format( 'invalid option. `%s` option must be either a boolean primitive or a function. Option: `%s`.', 'override', opts.override ) ); } } if ( hasOwnProp( options, 'extend' ) ) { opts.extend = options.extend; if ( !isBoolean( opts.extend ) ) { - return new TypeError( 'invalid option. `extend` option must be a boolean primitive. Option: `' + opts.extend + '`.' ); + return new TypeError( format( 'invalid option. `%s` option must be a boolean primitive. Option: `%s`.', 'extend', opts.extend ) ); } } return null; diff --git a/move-property/lib/move_property.js b/move-property/lib/move_property.js index df0391cc..86147eee 100644 --- a/move-property/lib/move_property.js +++ b/move-property/lib/move_property.js @@ -21,6 +21,7 @@ // MODULES // var defineProperty = require( './../../define-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -52,10 +53,10 @@ var defineProperty = require( './../../define-property' ); function moveProperty( source, prop, target ) { var desc; if ( typeof source !== 'object' || source === null ) { - throw new TypeError( 'invalid argument. Source argument must be an object. Value: `' + source + '`.' ); + throw new TypeError( format( 'invalid argument. Source argument must be an object. Value: `%s`.', source ) ); } if ( typeof target !== 'object' || target === null ) { - throw new TypeError( 'invalid argument. Target argument must be an object. Value: `' + target + '`.' ); + throw new TypeError( format( 'invalid argument. Target argument must be an object. Value: `%s`.', target ) ); } // TODO: handle case where gOPD is not supported desc = Object.getOwnPropertyDescriptor( source, prop ); diff --git a/nary-function/lib/main.js b/nary-function/lib/main.js index 52b5f07a..bbb12a99 100644 --- a/nary-function/lib/main.js +++ b/nary-function/lib/main.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,10 +61,10 @@ var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).is function naryFunction( fcn, arity, thisArg ) { var fcns; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isNonNegativeInteger( arity ) ) { - throw new TypeError( 'invalid argument. Second argument must be a nonnegative integer. Value: `'+arity+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', arity ) ); } fcns = [ nullary, unary, binary, ternary, quaternary, quinary ]; return ( arity < fcns.length ) ? fcns[ arity ] : nary; diff --git a/none-by-right/lib/none_by_right.js b/none-by-right/lib/none_by_right.js index 442aea3e..6448233a 100644 --- a/none-by-right/lib/none_by_right.js +++ b/none-by-right/lib/none_by_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,10 +56,10 @@ function noneByRight( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = len-1; i >= 0; i-- ) { diff --git a/none-by/lib/none_by.js b/none-by/lib/none_by.js index 99ce8b9b..949ddfd0 100644 --- a/none-by/lib/none_by.js +++ b/none-by/lib/none_by.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -51,10 +52,10 @@ function noneBy( collection, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/none/lib/main.js b/none/lib/main.js index 9a6bc728..94112909 100644 --- a/none/lib/main.js +++ b/none/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -42,7 +43,7 @@ function none( collection ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. Must provide a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a collection. Value: `%s`.', collection ) ); } len = collection.length; for ( i = 0; i < len; i++ ) { diff --git a/omit-by/lib/omit_by.js b/omit-by/lib/omit_by.js index e3c80b25..4e8c29a9 100644 --- a/omit-by/lib/omit_by.js +++ b/omit-by/lib/omit_by.js @@ -22,6 +22,7 @@ var objectKeys = require( './../../keys' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,10 +55,10 @@ function omitBy( obj, predicate ) { var key; var i; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } out = {}; keys = objectKeys( obj ); diff --git a/omit/lib/omit.js b/omit/lib/omit.js index 1d05f3ac..8245bcb0 100644 --- a/omit/lib/omit.js +++ b/omit/lib/omit.js @@ -24,6 +24,7 @@ var objectKeys = require( './../../keys' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; var indexOf = require( './../../index-of' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -52,7 +53,7 @@ function omit( obj, keys ) { var key; var i; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } ownKeys = objectKeys( obj ); out = {}; @@ -74,7 +75,7 @@ function omit( obj, keys ) { } return out; } - throw new TypeError( 'invalid argument. Second argument must be either a string primitive or an array of string primitives. Value: `'+keys+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be either a string primitive or an array of string primitives. Value: `%s`.', keys ) ); } diff --git a/open-url/lib/browser.js b/open-url/lib/browser.js index 05043c1e..1399cea5 100644 --- a/open-url/lib/browser.js +++ b/open-url/lib/browser.js @@ -22,6 +22,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var isURI = require( '@stdlib/assert/is-uri' ); @@ -39,7 +40,7 @@ var isURI = require( '@stdlib/assert/is-uri' ); */ function openURL( url ) { if ( !isURI( url ) ) { - throw new TypeError( 'invalid input value. Must provide a valid URI. Value: `' + url + '`.' ); + throw new TypeError( format( 'invalid input value. Must provide a valid URI. Value: `%s`.', url ) ); } return window.open( url ); } diff --git a/open-url/lib/main.js b/open-url/lib/main.js index 6af903e8..c940b789 100644 --- a/open-url/lib/main.js +++ b/open-url/lib/main.js @@ -23,6 +23,7 @@ var spawn = require( 'child_process' ).spawn; var IS_WINDOWS = require( '@stdlib/assert/is-windows' ); var IS_DARWIN = require( '@stdlib/assert/is-darwin' ); +var format = require( '@stdlib/string/format' ); var isURI = require( '@stdlib/assert/is-uri' ); @@ -67,7 +68,7 @@ function openURL( url ) { var proc; var i; if ( !isURI( url ) ) { - throw new TypeError( 'invalid input value. Must provide a valid URI. Value: `' + url + '`.' ); + throw new TypeError( format( 'invalid input value. Must provide a valid URI. Value: `%s`.', url ) ); } args = new Array( ARGS.length ); for ( i = 0; i < ARGS.length; i++ ) { diff --git a/papply/lib/papply.js b/papply/lib/papply.js index b70a7409..d132c556 100644 --- a/papply/lib/papply.js +++ b/papply/lib/papply.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -47,7 +48,7 @@ function papply( fcn ) { var pargs; var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } pargs = new Array( arguments.length-1 ); for ( i = 1; i < arguments.length; i++ ) { diff --git a/parallel/lib/main.js b/parallel/lib/main.js index 5238dbb3..f8ed7aeb 100644 --- a/parallel/lib/main.js +++ b/parallel/lib/main.js @@ -23,6 +23,7 @@ var path = require( 'path' ); var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); var cwd = require( '@stdlib/process/cwd' ); var copy = require( './../../copy' ); var defaults = require( './defaults.js' ); @@ -77,7 +78,7 @@ function parallel() { files = arguments[ 0 ]; if ( !isStringArray( files ) ) { - throw new TypeError( 'invalid argument. First argument must be an array of string primitives. Value: `' + files + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array of string primitives. Value: `%s`.', files ) ); } files = files.slice(); opts = copy( defaults ); @@ -92,7 +93,7 @@ function parallel() { clbk = arguments[ 1 ]; } if ( !isFunction( clbk ) ) { - throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' ); + throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); } // Prevent the number of concurrent scripts exceeding the number of actual scripts to run. if ( opts.concurrency > files.length ) { diff --git a/parse-json/lib/parse_json.js b/parse-json/lib/parse_json.js index 9da5802a..18497af0 100644 --- a/parse-json/lib/parse_json.js +++ b/parse-json/lib/parse_json.js @@ -22,6 +22,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -41,11 +42,11 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function parseJSON( str, reviver ) { if ( !isString( str ) ) { - throw new TypeError( 'invalid argument. First argument must be a string. Value: `' + str + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a string primitive. Value: `%s`.', str ) ); } if ( arguments.length > 1 ) { if ( !isFunction( reviver ) ) { - throw new TypeError( 'invalid argument. Reviver argument must be a function. Value: `' + reviver + '`.' ); + throw new TypeError( format( 'invalid argument. Reviver argument must be a function. Value: `%s`.', reviver ) ); } } try { diff --git a/pick-arguments/lib/main.js b/pick-arguments/lib/main.js index 6c3d41ca..2d1fdd42 100644 --- a/pick-arguments/lib/main.js +++ b/pick-arguments/lib/main.js @@ -23,6 +23,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -53,16 +54,16 @@ function pickArguments( fcn, indices, thisArg ) { var v; var i; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isCollection( indices ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object containing nonnegative integers. Value: `'+indices+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object containing nonnegative integers. Value: `%s`.', indices ) ); } idx = []; for ( i = 0; i < indices.length; i++ ) { v = indices[ i ]; if ( !isNonNegativeInteger( v ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object containing nonnegative integers. Value: `'+indices+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object containing nonnegative integers. Value: `%s`.', indices ) ); } idx.push( v ); } diff --git a/pick-by/lib/pick_by.js b/pick-by/lib/pick_by.js index 8e920c15..c3984020 100644 --- a/pick-by/lib/pick_by.js +++ b/pick-by/lib/pick_by.js @@ -22,6 +22,7 @@ var objectKeys = require( './../../keys' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -54,10 +55,10 @@ function pickBy( obj, predicate ) { var key; var i; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } out = {}; keys = objectKeys( obj ); diff --git a/pick/lib/pick.js b/pick/lib/pick.js index eb910990..7a343a53 100644 --- a/pick/lib/pick.js +++ b/pick/lib/pick.js @@ -23,6 +23,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -50,7 +51,7 @@ function pick( obj, keys ) { var key; var i; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. First argument must be an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); } out = {}; if ( isString( keys ) ) { @@ -68,7 +69,7 @@ function pick( obj, keys ) { } return out; } - throw new TypeError( 'invalid argument. Second argument must be either a string primitive or an array of string primitives. Value: `'+keys+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be either a string primitive or an array of string primitives. Value: `%s`.', keys ) ); } diff --git a/pluck/lib/pluck.js b/pluck/lib/pluck.js index 4e0b5e54..80088482 100644 --- a/pluck/lib/pluck.js +++ b/pluck/lib/pluck.js @@ -23,6 +23,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var copy = require( './../../copy' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -70,7 +71,7 @@ function pluck( arr, prop, options ) { var i; if ( !isArray( arr ) ) { - throw new TypeError( 'invalid argument. First argument must be an array. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array. Value: `%s`.', arr ) ); } opts = copy( defaults ); if ( arguments.length > 2 ) { diff --git a/pop/lib/pop.js b/pop/lib/pop.js index 0f894541..ba13f962 100644 --- a/pop/lib/pop.js +++ b/pop/lib/pop.js @@ -23,6 +23,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var popObject = require( './pop_object.js' ); var popTypedArray = require( './pop_typed_array.js' ); @@ -69,7 +70,7 @@ function pop( collection ) { ) { return popObject( collection ); } - throw new TypeError( 'invalid argument. Must provide either an Array, Typed Array, or an array-like Object. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection ) ); } diff --git a/prepend/lib/prepend.js b/prepend/lib/prepend.js index 5a12afd2..23de3546 100644 --- a/prepend/lib/prepend.js +++ b/prepend/lib/prepend.js @@ -24,6 +24,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isCollection = require( '@stdlib/assert/is-collection' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var prependArray = require( './prepend_array.js' ); var prependObject = require( './prepend_object.js' ); var prependTypedArray = require( './prepend_typed_array.js' ); @@ -57,7 +58,7 @@ var prependTypedArray = require( './prepend_typed_array.js' ); */ function prepend( collection1, collection2 ) { if ( !isCollection( collection2 ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object. Value: `'+collection2+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', collection2 ) ); } if ( isArray( collection1 ) ) { return prependArray( collection1, collection2 ); @@ -76,7 +77,7 @@ function prepend( collection1, collection2 ) { ) { return prependObject( collection1, collection2 ); } - throw new TypeError( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `'+collection1+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection1 ) ); } diff --git a/push/lib/push.js b/push/lib/push.js index c135c535..a476cbf6 100644 --- a/push/lib/push.js +++ b/push/lib/push.js @@ -23,6 +23,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var pushArray = require( './push_array.js' ); var pushObject = require( './push_object.js' ); var pushTypedArray = require( './push_typed_array.js' ); @@ -77,7 +78,7 @@ function push( collection ) { ) { return pushObject( collection, items ); } - throw new TypeError( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection ) ); } diff --git a/real-max/lib/main.js b/real-max/lib/main.js index 140b40f3..fde1cb4a 100644 --- a/real-max/lib/main.js +++ b/real-max/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var FLOAT16 = require( '@stdlib/constants/float16/max' ); var FLOAT32 = require( '@stdlib/constants/float32/max' ); var FLOAT64 = require( '@stdlib/constants/float64/max' ); @@ -55,7 +56,7 @@ function realmax( dtype ) { case 'float16': return FLOAT16; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/real-min/lib/main.js b/real-min/lib/main.js index 6aaab9c0..416853fc 100644 --- a/real-min/lib/main.js +++ b/real-min/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var FLOAT16 = require( '@stdlib/constants/float16/smallest-normal' ); var FLOAT32 = require( '@stdlib/constants/float32/smallest-normal' ); var FLOAT64 = require( '@stdlib/constants/float64/smallest-normal' ); @@ -55,7 +56,7 @@ function realmin( dtype ) { case 'float16': return FLOAT16; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/reduce-right/lib/main.js b/reduce-right/lib/main.js index 25d32c40..acff2b8d 100644 --- a/reduce-right/lib/main.js +++ b/reduce-right/lib/main.js @@ -25,6 +25,7 @@ var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); var isFunction = require( '@stdlib/assert/is-function' ); var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -76,7 +77,7 @@ var arrayFcn = require( './array.js' ); */ function reduceRight( arr, initial, reducer, thisArg ) { if ( !isFunction( reducer ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value:`' + reducer + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', reducer ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like return ndarrayFcn( ndarraylike2object( arr ), initial, reducer, thisArg ); // eslint-disable-line max-len @@ -84,7 +85,7 @@ function reduceRight( arr, initial, reducer, thisArg ) { if ( isArrayLikeObject( arr ) ) { return arrayFcn( arraylike2object( arr ), initial, reducer, thisArg ); } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/reduce/lib/main.js b/reduce/lib/main.js index 15d82861..c1d1bd7d 100644 --- a/reduce/lib/main.js +++ b/reduce/lib/main.js @@ -25,6 +25,7 @@ var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); var isFunction = require( '@stdlib/assert/is-function' ); var ndarraylike2object = require( '@stdlib/ndarray/base/ndarraylike2object' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var format = require( '@stdlib/string/format' ); var ndarrayFcn = require( './ndarray.js' ); var arrayFcn = require( './array.js' ); @@ -76,7 +77,7 @@ var arrayFcn = require( './array.js' ); */ function reduce( arr, initial, reducer, thisArg ) { if ( !isFunction( reducer ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value:`' + reducer + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', reducer ) ); } if ( isndarrayLike( arr ) ) { // note: assertion order matters here, as an ndarray-like object is also array-like return ndarrayFcn( ndarraylike2object( arr ), initial, reducer, thisArg ); // eslint-disable-line max-len @@ -84,7 +85,7 @@ function reduce( arr, initial, reducer, thisArg ) { if ( isArrayLikeObject( arr ) ) { return arrayFcn( arraylike2object( arr ), initial, reducer, thisArg ); } - throw new TypeError( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', arr ) ); } diff --git a/reduce2d/lib/main.js b/reduce2d/lib/main.js index 269d7e7d..995a3b68 100644 --- a/reduce2d/lib/main.js +++ b/reduce2d/lib/main.js @@ -23,6 +23,7 @@ var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -72,16 +73,16 @@ function reduce2d( arr, initial, reducer, thisArg ) { var j; if ( !isArrayLikeObject( arr ) ) { - throw new TypeError( 'invalid argument. First argument must be an array-like object. Value: `' + arr + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', arr ) ); } if ( !isArrayLikeObject( initial ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array-like object. Value: `' + initial + '`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', initial ) ); } if ( initial.length !== arr.length ) { throw new RangeError( 'invalid argument. Second argument must have a length equal to the size of the outermost input array dimension.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `' + reducer + '`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', reducer ) ); } M = arr.length; out = []; diff --git a/regexp-from-string/lib/from_string.js b/regexp-from-string/lib/from_string.js index fb30b1e7..cce0a98d 100644 --- a/regexp-from-string/lib/from_string.js +++ b/regexp-from-string/lib/from_string.js @@ -22,6 +22,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var reRegExp = require( '@stdlib/regexp/regexp' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -39,7 +40,7 @@ var reRegExp = require( '@stdlib/regexp/regexp' ); */ function reFromString( str ) { if ( !isString( str ) ) { - throw new TypeError( 'invalid argument. Must provide a regular expression string. Value: `' + str + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide a regular expression string. Value: `%s`.', str ) ); } // Capture the regular expression pattern and any flags: str = reRegExp().exec( str ); diff --git a/reject-arguments/lib/main.js b/reject-arguments/lib/main.js index a0427377..b898b62b 100644 --- a/reject-arguments/lib/main.js +++ b/reject-arguments/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,10 +61,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function rejectArguments( fcn, predicate, thisArg ) { if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } return wrap; diff --git a/reorder-arguments/lib/main.js b/reorder-arguments/lib/main.js index ab36c182..1e397c61 100644 --- a/reorder-arguments/lib/main.js +++ b/reorder-arguments/lib/main.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer- */ function reorderArguments( fcn, indices, thisArg ) { if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } if ( !isNonNegativeIntegerArray( indices ) ) { - throw new TypeError( 'invalid argument. Second argument must be an array containing only nonnegative integers. Value: `'+indices+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be an array containing only nonnegative integers. Value: `%s`.', indices ) ); } return reordered; diff --git a/reverse-arguments/lib/main.js b/reverse-arguments/lib/main.js index cf471b0e..e5ef76ab 100644 --- a/reverse-arguments/lib/main.js +++ b/reverse-arguments/lib/main.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -45,7 +46,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function reverseArguments( fcn, thisArg ) { if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); } return reversed; diff --git a/safe-int-max/lib/main.js b/safe-int-max/lib/main.js index c4f178b7..51772411 100644 --- a/safe-int-max/lib/main.js +++ b/safe-int-max/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var FLOAT16 = require( '@stdlib/constants/float16/max-safe-integer' ); var FLOAT32 = require( '@stdlib/constants/float32/max-safe-integer' ); var FLOAT64 = require( '@stdlib/constants/float64/max-safe-integer' ); @@ -55,7 +56,7 @@ function safeintmax( dtype ) { case 'float16': return FLOAT16; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/safe-int-min/lib/main.js b/safe-int-min/lib/main.js index d7164b86..0a8f9d33 100644 --- a/safe-int-min/lib/main.js +++ b/safe-int-min/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var FLOAT16 = require( '@stdlib/constants/float16/min-safe-integer' ); var FLOAT32 = require( '@stdlib/constants/float32/min-safe-integer' ); var FLOAT64 = require( '@stdlib/constants/float64/min-safe-integer' ); @@ -55,7 +56,7 @@ function safeintmin( dtype ) { case 'float16': return FLOAT16; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/shift/lib/shift.js b/shift/lib/shift.js index a5366a4b..e4d4ac4b 100644 --- a/shift/lib/shift.js +++ b/shift/lib/shift.js @@ -23,6 +23,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var shiftObject = require( './shift_object.js' ); var shiftTypedArray = require( './shift_typed_array.js' ); @@ -71,7 +72,7 @@ function shift( collection ) { ) { return shiftObject( collection ); } - throw new TypeError( 'invalid argument. Must provide either an Array, Typed Array, or an array-like Object. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection ) ); } diff --git a/size-of/lib/main.js b/size-of/lib/main.js index b854e378..0ff601ad 100644 --- a/size-of/lib/main.js +++ b/size-of/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var INT8 = require( '@stdlib/constants/int8/num-bytes' ); var UINT8 = require( '@stdlib/constants/uint8/num-bytes' ); var INT16 = require( '@stdlib/constants/int16/num-bytes' ); @@ -81,7 +82,7 @@ function sizeOf( dtype ) { case 'complex64': return COMPLEX64; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/some-by-right/lib/some_by_right.js b/some-by-right/lib/some_by_right.js index 1c0e9994..b395e709 100644 --- a/some-by-right/lib/some_by_right.js +++ b/some-by-right/lib/some_by_right.js @@ -23,6 +23,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,13 +56,13 @@ function someByRight( collection, n, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isPositiveInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; count = 0; diff --git a/some-by/lib/some_by.js b/some-by/lib/some_by.js index 277c8fa8..3235875e 100644 --- a/some-by/lib/some_by.js +++ b/some-by/lib/some_by.js @@ -23,6 +23,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,13 +56,13 @@ function someBy( collection, n, predicate, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isPositiveInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', predicate ) ); } len = collection.length; count = 0; diff --git a/some/lib/main.js b/some/lib/main.js index 54e677fb..e8999a6f 100644 --- a/some/lib/main.js +++ b/some/lib/main.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); // MAIN // @@ -46,10 +47,10 @@ function some( collection, n ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isPositiveInteger( n ) ) { - throw new TypeError( 'invalid argument. Second argument must be a positive integer. Value: `'+n+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a positive integer. Value: `%s`.', n ) ); } len = collection.length; count = 0; diff --git a/tabulate-by/lib/tabulate_by.js b/tabulate-by/lib/tabulate_by.js index 0db85fcb..28d7306e 100644 --- a/tabulate-by/lib/tabulate_by.js +++ b/tabulate-by/lib/tabulate_by.js @@ -23,6 +23,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); var indexOf = require( './../../index-of' ); +var format = require( '@stdlib/string/format' ); var validate = require( './validate.js' ); @@ -73,7 +74,7 @@ function tabulateBy( collection, options, indicator ) { var i; var j; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } opts = {}; if ( arguments.length === 2 ) { @@ -86,7 +87,7 @@ function tabulateBy( collection, options, indicator ) { cb = indicator; } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+cb+'`.' ); + throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) ); } thisArg = opts.thisArg; count = 0; diff --git a/tabulate/lib/tabulate.js b/tabulate/lib/tabulate.js index ce6fcf23..9e135ec6 100644 --- a/tabulate/lib/tabulate.js +++ b/tabulate/lib/tabulate.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var indexOf = require( './../../index-of' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -57,7 +58,7 @@ function tabulate( collection ) { var i; var j; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } count = 0; tmp = []; diff --git a/timeit/lib/timeit.js b/timeit/lib/timeit.js index 4702fe7a..2a87c35a 100644 --- a/timeit/lib/timeit.js +++ b/timeit/lib/timeit.js @@ -25,6 +25,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isArray = require( '@stdlib/assert/is-array' ); var copy = require( './../../copy' ); var cwd = require( '@stdlib/process/cwd' ); +var format = require( '@stdlib/string/format' ); var nextTick = require( './../../next-tick' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -84,7 +85,7 @@ function timeit( code, options, clbk ) { var cb; if ( !isString( code ) ) { - throw new TypeError( 'invalid argument. First argument must be a primitive string. Value: `' + code + '`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a primitive string. Value: `%s`.', code ) ); } opts = copy( defaults ); if ( arguments.length === 2 ) { @@ -97,7 +98,7 @@ function timeit( code, options, clbk ) { } } if ( !isFunction( cb ) ) { - throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + cb + '`.' ); + throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) ); } results = new Array( opts.repeats ); dir = cwd(); diff --git a/try-catch/lib/try_catch.js b/try-catch/lib/try_catch.js index 62019e7e..ded92363 100644 --- a/try-catch/lib/try_catch.js +++ b/try-catch/lib/try_catch.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -47,7 +48,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function trycatch( x, y ) { if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', x ) ); } try { return x(); diff --git a/try-function/lib/wrap.js b/try-function/lib/wrap.js index 3cfeb36c..2d1a19ac 100644 --- a/try-function/lib/wrap.js +++ b/try-function/lib/wrap.js @@ -22,6 +22,7 @@ var isFunction = require( '@stdlib/assert/is-function' ); var isError = require( '@stdlib/assert/is-error' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -50,7 +51,7 @@ var isError = require( '@stdlib/assert/is-error' ); function wrap( fcn, thisArg ) { var ctx; if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Must provide a function. Value: `' + fcn + '`.' ); + throw new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', fcn ) ); } if ( arguments.length > 1 ) { ctx = thisArg; diff --git a/try-then/lib/try_then.js b/try-then/lib/try_then.js index cdb74908..d9d0ddb0 100644 --- a/try-then/lib/try_then.js +++ b/try-then/lib/try_then.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -52,10 +53,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); */ function trythen( x, y ) { if ( !isFunction( x ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+x+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', x ) ); } if ( !isFunction( y ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+y+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', y ) ); } try { return x(); diff --git a/type-max/lib/main.js b/type-max/lib/main.js index 92ab0c0c..6dba94d5 100644 --- a/type-max/lib/main.js +++ b/type-max/lib/main.js @@ -22,6 +22,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var INT8 = require( '@stdlib/constants/int8/max' ); var UINT8 = require( '@stdlib/constants/uint8/max' ); var INT16 = require( '@stdlib/constants/int16/max' ); @@ -77,7 +78,7 @@ function typemax( dtype ) { case 'float16': return FLOAT16; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/type-min/lib/main.js b/type-min/lib/main.js index deaca706..d7884e1b 100644 --- a/type-min/lib/main.js +++ b/type-min/lib/main.js @@ -22,6 +22,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var INT8 = require( '@stdlib/constants/int8/min' ); var INT16 = require( '@stdlib/constants/int16/min' ); var INT32 = require( '@stdlib/constants/int32/min' ); @@ -74,7 +75,7 @@ function typemin( dtype ) { case 'uint8c': // eslint-disable-line no-fallthrough return 0; default: - throw new TypeError( 'invalid argument. Must provide a recognized type. Value: `'+dtype+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide a recognized type. Value: `%s`.', dtype ) ); } } diff --git a/uncapitalize-keys/lib/uncapitalize_keys.js b/uncapitalize-keys/lib/uncapitalize_keys.js index 8c8eff2d..feb21d59 100644 --- a/uncapitalize-keys/lib/uncapitalize_keys.js +++ b/uncapitalize-keys/lib/uncapitalize_keys.js @@ -21,6 +21,7 @@ // MODULES // var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -46,7 +47,7 @@ function uncapitalizeKeys( obj ) { var key; var k; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. Must provide an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); } out = {}; for ( key in obj ) { diff --git a/unshift/lib/unshift.js b/unshift/lib/unshift.js index 6bc44b79..c1815dd0 100644 --- a/unshift/lib/unshift.js +++ b/unshift/lib/unshift.js @@ -23,6 +23,7 @@ var isArray = require( '@stdlib/assert/is-array' ); var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); var isInteger = require( '@stdlib/assert/is-integer' ); +var format = require( '@stdlib/string/format' ); var unshiftArray = require( './unshift_array.js' ); var unshiftObject = require( './unshift_object.js' ); var unshiftTypedArray = require( './unshift_typed_array.js' ); @@ -77,7 +78,7 @@ function unshift( collection ) { ) { return unshiftObject( collection, items ); } - throw new TypeError( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be either an Array, Typed Array, or an array-like Object. Value: `%s`.', collection ) ); } diff --git a/until-each-right/lib/until_each_right.js b/until-each-right/lib/until_each_right.js index d13f4a46..9fe91781 100644 --- a/until-each-right/lib/until_each_right.js +++ b/until-each-right/lib/until_each_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,13 +61,13 @@ function untilEachRight( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; i = len - 1; diff --git a/until-each/lib/until_each.js b/until-each/lib/until_each.js index dc779db0..01d2c3af 100644 --- a/until-each/lib/until_each.js +++ b/until-each/lib/until_each.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; i = 0; diff --git a/until/lib/until.js b/until/lib/until.js index 860456bc..ec4ccb4b 100644 --- a/until/lib/until.js +++ b/until/lib/until.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); function until( predicate, fcn, thisArg ) { var i; if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } i = 0; while ( !predicate( i ) ) { diff --git a/uppercase-keys/lib/uppercase_keys.js b/uppercase-keys/lib/uppercase_keys.js index f6867677..7c9db409 100644 --- a/uppercase-keys/lib/uppercase_keys.js +++ b/uppercase-keys/lib/uppercase_keys.js @@ -21,6 +21,7 @@ // MODULES // var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -45,7 +46,7 @@ function uppercaseKeys( obj ) { var out; var key; if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( 'invalid argument. Must provide an object. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); } out = {}; for ( key in obj ) { diff --git a/values-in/lib/values_in.js b/values-in/lib/values_in.js index 4edb2da2..7f873e87 100644 --- a/values-in/lib/values_in.js +++ b/values-in/lib/values_in.js @@ -21,6 +21,7 @@ // MODULES // var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -49,7 +50,7 @@ function objectValuesIn( obj ) { var out; var key; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. Must provide an object-like value. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object-like value. Value: `%s`.', obj ) ); } out = []; for ( key in obj ) { // eslint-disable-line guard-for-in diff --git a/values/lib/values.js b/values/lib/values.js index 3d49c398..1c27c1dd 100644 --- a/values/lib/values.js +++ b/values/lib/values.js @@ -22,6 +22,7 @@ var objectKeys = require( './../../keys' ); var isObjectLike = require( '@stdlib/assert/is-object-like' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,7 +49,7 @@ function objectValues( obj ) { var len; var i; if ( !isObjectLike( obj ) ) { - throw new TypeError( 'invalid argument. Must provide an object-like value. Value: `'+obj+'`.' ); + throw new TypeError( format( 'invalid argument. Must provide an object-like value. Value: `%s`.', obj ) ); } keys = objectKeys( obj ); len = keys.length; diff --git a/while-each-right/lib/while_each_right.js b/while-each-right/lib/while_each_right.js index 4572b01f..77bbc832 100644 --- a/while-each-right/lib/while_each_right.js +++ b/while-each-right/lib/while_each_right.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -60,13 +61,13 @@ function whileEachRight( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; i = len - 1; diff --git a/while-each/lib/while_each.js b/while-each/lib/while_each.js index 2d5f3e47..a6990edf 100644 --- a/while-each/lib/while_each.js +++ b/while-each/lib/while_each.js @@ -22,6 +22,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -55,13 +56,13 @@ function whileEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Third argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); } len = collection.length; i = 0; diff --git a/while/lib/while.js b/while/lib/while.js index 4e04cb2d..ad3fe526 100644 --- a/while/lib/while.js +++ b/while/lib/while.js @@ -21,6 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); // MAIN // @@ -48,10 +49,10 @@ var isFunction = require( '@stdlib/assert/is-function' ); function whilst( predicate, fcn, thisArg ) { var i; if ( !isFunction( predicate ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `'+predicate+'`.' ); + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. Second argument must be a function. Value: `'+fcn+'`.' ); + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); } i = 0; while ( predicate( i ) ) {