You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/ndarray/zeros-like/lib/main.js
+5-4
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ var strides2offset = require( '@stdlib/ndarray/base/strides2offset' );
29
29
varbuffer=require('@stdlib/ndarray/base/buffer');
30
30
varnumel=require('@stdlib/ndarray/base/numel');
31
31
varndarray=require('@stdlib/ndarray/ctor');
32
+
varformat=require('@stdlib/string/format');
32
33
33
34
34
35
// MAIN //
@@ -72,13 +73,13 @@ function zerosLike( x ) {
72
73
varst;
73
74
74
75
if(!isndarrayLike(x)){
75
-
thrownewTypeError('invalid argument. First argument must be an ndarray-like object. Value: `'+x+'`.');
76
+
thrownewTypeError(format('invalid argument. First argument must be an ndarray-like object. Value: `%s`.',x));
76
77
}
77
78
opts={};
78
79
if(arguments.length>1){
79
80
options=arguments[1];
80
81
if(!isPlainObject(options)){
81
-
thrownewTypeError('invalid argument. Options argument must be an object. Value: `'+options+'`.');
82
+
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',options));
82
83
}
83
84
if(hasOwnProp(options,'dtype')){
84
85
opts.dtype=options.dtype;
@@ -91,7 +92,7 @@ function zerosLike( x ) {
91
92
opts.shape=[opts.shape];
92
93
}
93
94
if(!isNonNegativeIntegerArray(opts.shape)){
94
-
thrownewTypeError('invalid option. `shape` option must either be a nonnegative integer or an array of nonnegative integers. Option: `'+opts.shape+'`.');
95
+
thrownewTypeError(format('invalid option. `%s` option must either be a nonnegative integer or an array of nonnegative integers. Option: `%s`.','shape',opts.shape));
95
96
}
96
97
}else{
97
98
opts.shape=x.shape;
@@ -120,7 +121,7 @@ function zerosLike( x ) {
120
121
}
121
122
buf=buffer(opts.dtype,len);
122
123
if(buf===null){
123
-
thrownewTypeError('invalid argument. First argument must have a recognized data type. Value: `'+opts.dtype+'`.');
124
+
thrownewTypeError(format('invalid argument. First argument must have a recognized data type. Value: `%s`.',opts.dtype));
0 commit comments