Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6156c2

Browse files
committed
Transform error messages
1 parentab7c24a commitf6156c2

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

‎lib/factory.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
varisObject=require('@stdlib/assert-is-plain-object');
24-
varformat=require('@stdlib/string-format');
24+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2525
varassign=require('@stdlib/object-assign');
2626
varArrayStream=require('./main.js');
2727

@@ -70,7 +70,7 @@ function factory( options ) {
7070
varopts;
7171
if(arguments.length){
7272
if(!isObject(options)){
73-
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',options));
73+
thrownewTypeError(format('1M92V',options));
7474
}
7575
opts=assign({},options);
7676
}else{

‎lib/main.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var Readable = require( 'readable-stream' ).Readable;
2424
varisCollection=require('@stdlib/assert-is-collection');
2525
varisError=require('@stdlib/assert-is-error');
2626
varisBuffer=require('@stdlib/assert-is-buffer');
27-
varformat=require('@stdlib/string-format');
27+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2828
varassign=require('@stdlib/object-assign');
2929
varinherit=require('@stdlib/utils-inherit');
3030
varsetNonEnumerable=require('@stdlib/utils-define-nonenumerable-property');
@@ -81,7 +81,7 @@ function read() {
8181
v=Buffer.concat([string2buffer(this._sep),v]);
8282
}
8383
}else{
84-
err=newError(format('invalid operation. Serialization function must return a string or Buffer. Value: `%s`.',v));
84+
err=newError(format('1M9A9',v));
8585
}
8686
}
8787
if(err){
@@ -181,7 +181,7 @@ function ArrayStream( src, options ) {
181181
returnnewArrayStream(src);
182182
}
183183
if(!isCollection(src)){
184-
thrownewTypeError(format('invalid argument. First argument must be an array-like object. Value: `%s`.',src));
184+
thrownewTypeError(format('1M92O',src));
185185
}
186186
opts=assign({},DEFAULTS);
187187
if(arguments.length>1){

‎lib/object_mode.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
varisObject=require('@stdlib/assert-is-plain-object');
24-
varformat=require('@stdlib/string-format');
24+
varformat=require('@stdlib/error-tools-fmtprodmsg');
2525
varassign=require('@stdlib/object-assign');
2626
varArrayStream=require('./main.js');
2727

@@ -65,7 +65,7 @@ function objectMode( src, options ) {
6565
if(arguments.length>1){
6666
opts=options;
6767
if(!isObject(opts)){
68-
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',opts));
68+
thrownewTypeError(format('1M92V',opts));
6969
}
7070
opts=assign({},options);
7171
}else{

‎lib/validate.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
2626
varisNonNegative=require('@stdlib/assert-is-nonnegative-number').isPrimitive;
2727
varisString=require('@stdlib/assert-is-string').isPrimitive;
2828
varisFunction=require('@stdlib/assert-is-function');
29-
varformat=require('@stdlib/string-format');
29+
varformat=require('@stdlib/error-tools-fmtprodmsg');
3030

3131

3232
// MAIN //
@@ -57,42 +57,42 @@ var format = require( '@stdlib/string-format' );
5757
*/
5858
functionvalidate(opts,options){
5959
if(!isObject(options)){
60-
returnnewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',options));
60+
returnnewTypeError(format('1M92V',options));
6161
}
6262
if(hasOwnProp(options,'sep')){
6363
opts.sep=options.sep;
6464
if(!isString(opts.sep)){
65-
returnnewTypeError(format('invalid option. `%s` option must be a string. Option: `%s`.','sep',opts.sep));
65+
returnnewTypeError(format('1M92W','sep',opts.sep));
6666
}
6767
}
6868
if(hasOwnProp(options,'objectMode')){
6969
opts.objectMode=options.objectMode;
7070
if(!isBoolean(opts.objectMode)){
71-
returnnewTypeError(format('invalid option. `%s` option must be a boolean. Option: `%s`.','objectMode',opts.objectMode));
71+
returnnewTypeError(format('1M92o','objectMode',opts.objectMode));
7272
}
7373
}
7474
if(hasOwnProp(options,'encoding')){
7575
opts.encoding=options.encoding;
7676
if(!isString(opts.encoding)&&opts.encoding!==null){
77-
returnnewTypeError(format('invalid option. `%s` option must be a string or null. Option: `%s`.','encoding',opts.encoding));
77+
returnnewTypeError(format('1M97n','encoding',opts.encoding));
7878
}
7979
}
8080
if(hasOwnProp(options,'highWaterMark')){
8181
opts.highWaterMark=options.highWaterMark;
8282
if(!isNonNegative(opts.highWaterMark)){
83-
returnnewTypeError(format('invalid option. `%s` option must be a nonnegative number. Option: `%s`.','highWaterMark',opts.highWaterMark));
83+
returnnewTypeError(format('1M94k','highWaterMark',opts.highWaterMark));
8484
}
8585
}
8686
if(hasOwnProp(options,'serialize')){
8787
opts.serialize=options.serialize;
8888
if(!isFunction(opts.serialize)){
89-
returnnewTypeError(format('invalid option. `%s` option must be a function. Option: `%s`.','serialize',opts.serialize));
89+
returnnewTypeError(format('1M96p','serialize',opts.serialize));
9090
}
9191
}
9292
if(hasOwnProp(options,'dir')){
9393
opts.dir=options.dir;
9494
if(opts.dir!==1&&opts.dir!==-1){
95-
returnnewTypeError(format('invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.','dir',opts.dir));
95+
returnnewTypeError(format('1M92v','dir',opts.dir));
9696
}
9797
}
9898
returnnull;

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@stdlib/buffer-ctor":"^0.2.2",
5050
"@stdlib/buffer-from-string":"^0.2.2",
5151
"@stdlib/object-assign":"^0.2.2",
52-
"@stdlib/string-format":"^0.2.2",
52+
"@stdlib/error-tools-fmtprodmsg":"^0.2.2",
5353
"@stdlib/types":"^0.4.1",
5454
"@stdlib/utils-define-nonenumerable-property":"^0.2.2",
5555
"@stdlib/utils-define-nonenumerable-read-only-property":"^0.2.2",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp