Skip to content

Commit 4fce040

Browse files
committed
Update variable names and doctest values
1 parent 18fef57 commit 4fce040

File tree

8 files changed

+72
-72
lines changed

8 files changed

+72
-72
lines changed

lib/node_modules/@stdlib/error/to-json/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
1919
-->
2020

21-
# toJSON
21+
# error2json
2222

2323
> Return a [JSON][json] representation of an [error][mdn-error] object.
2424
@@ -37,18 +37,18 @@ limitations under the License.
3737
## Usage
3838

3939
```javascript
40-
var toJSON = require( '@stdlib/error/to-json' );
40+
var error2json = require( '@stdlib/error/to-json' );
4141
```
4242

43-
#### toJSON( error )
43+
#### error2json( error )
4444

4545
Returns a [JSON][json] representation of an [`error`][mdn-error] object.
4646

4747
```javascript
4848
var err = new Error( 'beep' );
4949

50-
var json = toJSON( err );
51-
/* returns
50+
var json = error2json( err );
51+
/* e.g., returns
5252
{
5353
'type': 'Error',
5454
'name': 'Error', // if present
@@ -80,8 +80,8 @@ var err = new Error( 'beep' );
8080
err.a = 'b';
8181
err.c = { 'd': 'e' };
8282

83-
var json = toJSON( err );
84-
/* returns
83+
var json = error2json( err );
84+
/* e.g., returns
8585
{
8686
'type': 'Error',
8787
'name': 'Error', // if present
@@ -129,8 +129,8 @@ var json = toJSON( err );
129129

130130
var err = new CustomError( 'boop' );
131131

132-
var json = toJSON( err );
133-
/*
132+
var json = error2json( err );
133+
/* e.g., returns
134134
{
135135
'type': 'TypeError',
136136
'name': 'CustomError',
@@ -153,11 +153,11 @@ var json = toJSON( err );
153153
<!-- eslint no-undef: "error" -->
154154

155155
```javascript
156-
var toJSON = require( '@stdlib/error/to-json' );
156+
var error2json = require( '@stdlib/error/to-json' );
157157
158158
var err = new Error( 'beep' );
159-
var out = toJSON( err );
160-
/* returns
159+
var out = error2json( err );
160+
/* e.g., returns
161161
{
162162
'type': 'Error',
163163
'name': 'Error',
@@ -167,8 +167,8 @@ var out = toJSON( err );
167167
*/
168168
169169
err = new TypeError( 'invalid type' );
170-
out = toJSON( err );
171-
/* returns
170+
out = error2json( err );
171+
/* e.g., returns
172172
{
173173
'type': 'TypeError',
174174
'name': 'TypeError',
@@ -178,8 +178,8 @@ out = toJSON( err );
178178
*/
179179
180180
err = new SyntaxError( 'bad syntax' );
181-
out = toJSON( err );
182-
/* returns
181+
out = error2json( err );
182+
/* e.g., returns
183183
{
184184
'type': 'SyntaxError',
185185
'name': 'SyntaxError',
@@ -189,8 +189,8 @@ out = toJSON( err );
189189
*/
190190
191191
err = new ReferenceError( 'unknown variable' );
192-
out = toJSON( err );
193-
/* returns
192+
out = error2json( err );
193+
/* e.g., returns
194194
{
195195
'type': 'ReferenceError',
196196
'name': 'ReferenceError',
@@ -200,8 +200,8 @@ out = toJSON( err );
200200
*/
201201
202202
err = new URIError( 'bad URI' );
203-
out = toJSON( err );
204-
/* returns
203+
out = error2json( err );
204+
/* e.g., returns
205205
{
206206
'type': 'URIError',
207207
'name': 'URIError',
@@ -211,8 +211,8 @@ out = toJSON( err );
211211
*/
212212
213213
err = new RangeError( 'value out-of-range' );
214-
out = toJSON( err );
215-
/* returns
214+
out = error2json( err );
215+
/* e.g., returns
216216
{
217217
'type': 'RangeError',
218218
'name': 'RangeError',
@@ -222,8 +222,8 @@ out = toJSON( err );
222222
*/
223223
224224
err = new EvalError( 'eval error' );
225-
out = toJSON( err );
226-
/* returns
225+
out = error2json( err );
226+
/* e.g., returns
227227
{
228228
'type': 'EvalError',
229229
'name': 'EvalError',

lib/node_modules/@stdlib/error/to-json/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var fromCodePoint = require( '@stdlib/string/from-code-point' );
2524
var pkg = require( './../package.json' ).name;
2625
var toJSON = require( './../lib' );
2726

@@ -37,7 +36,7 @@ bench( pkg, function benchmark( b ) {
3736

3837
b.tic();
3938
for ( i = 0; i < b.iterations; i++ ) {
40-
err.message = 'be-'+fromCodePoint( (i%25)+97 )+' -ep';
39+
err.message = 'beep' + i;
4140
o = toJSON( err );
4241
if ( typeof o !== 'object' ) {
4342
b.fail( 'should return an object' );

lib/node_modules/@stdlib/error/to-json/docs/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
*
2727
* @example
2828
* var err = new Error( 'beep' );
29-
* var json = toJSON( err );
29+
* var json = error2json( err );
3030
* // returns {...}
3131
*/
32-
declare function toJSON( err: Error|TypeError|SyntaxError|URIError|ReferenceError|RangeError|EvalError ): any; // tslint-disable-line max-line-length
32+
declare function error2json( err: Error|TypeError|SyntaxError|URIError|ReferenceError|RangeError|EvalError ): any; // tslint-disable-line max-line-length
3333

3434

3535
// EXPORTS //
3636

37-
export = toJSON;
37+
export = error2json;

lib/node_modules/@stdlib/error/to-json/docs/types/test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,36 @@
1616
* limitations under the License.
1717
*/
1818

19-
import toJSON = require( './index' );
19+
import error2json = require( './index' );
2020

2121

2222
// TESTS //
2323

2424
// The function returns an object...
2525
{
26-
toJSON( new Error( 'beep' ) ); // $ExpectType any
27-
toJSON( new TypeError( 'beep' ) ); // $ExpectType any
28-
toJSON( new SyntaxError( 'beep' ) ); // $ExpectType any
29-
toJSON( new URIError( 'beep' ) ); // $ExpectType any
30-
toJSON( new ReferenceError( 'beep' ) ); // $ExpectType any
31-
toJSON( new RangeError( 'beep' ) ); // $ExpectType any
32-
toJSON( new EvalError( 'beep' ) ); // $ExpectType any
26+
error2json( new Error( 'beep' ) ); // $ExpectType any
27+
error2json( new TypeError( 'beep' ) ); // $ExpectType any
28+
error2json( new SyntaxError( 'beep' ) ); // $ExpectType any
29+
error2json( new URIError( 'beep' ) ); // $ExpectType any
30+
error2json( new ReferenceError( 'beep' ) ); // $ExpectType any
31+
error2json( new RangeError( 'beep' ) ); // $ExpectType any
32+
error2json( new EvalError( 'beep' ) ); // $ExpectType any
3333
}
3434

3535
// The function does not compile if provided a value other than an error object...
3636
{
37-
toJSON( 'abc' ); // $ExpectError
38-
toJSON( true ); // $ExpectError
39-
toJSON( false ); // $ExpectError
40-
toJSON( null ); // $ExpectError
41-
toJSON( undefined ); // $ExpectError
42-
toJSON( 5 ); // $ExpectError
43-
toJSON( [] ); // $ExpectError
44-
toJSON( {} ); // $ExpectError
45-
toJSON( ( x: number ): number => x ); // $ExpectError
37+
error2json( 'abc' ); // $ExpectError
38+
error2json( true ); // $ExpectError
39+
error2json( false ); // $ExpectError
40+
error2json( null ); // $ExpectError
41+
error2json( undefined ); // $ExpectError
42+
error2json( 5 ); // $ExpectError
43+
error2json( [] ); // $ExpectError
44+
error2json( {} ); // $ExpectError
45+
error2json( ( x: number ): number => x ); // $ExpectError
4646
}
4747

4848
// The function does not compile if provided insufficient arguments...
4949
{
50-
toJSON(); // $ExpectError
50+
error2json(); // $ExpectError
5151
}

lib/node_modules/@stdlib/error/to-json/examples/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
'use strict';
2020

21-
var toJSON = require( './../lib' );
21+
var error2json = require( './../lib' );
2222

2323
var err = new Error( 'beep' );
24-
console.log( toJSON( err ) );
25-
/* =>
24+
console.log( error2json( err ) );
25+
/* e.g., =>
2626
{
2727
'type': 'Error',
2828
'name': 'Error',
@@ -32,8 +32,8 @@ console.log( toJSON( err ) );
3232
*/
3333

3434
err = new TypeError( 'invalid type' );
35-
console.log( toJSON( err ) );
36-
/* =>
35+
console.log( error2json( err ) );
36+
/* e.g., =>
3737
{
3838
'type': 'TypeError',
3939
'name': 'TypeError',
@@ -43,8 +43,8 @@ console.log( toJSON( err ) );
4343
*/
4444

4545
err = new SyntaxError( 'bad syntax' );
46-
console.log( toJSON( err ) );
47-
/* =>
46+
console.log( error2json( err ) );
47+
/* e.g., =>
4848
{
4949
'type': 'SyntaxError',
5050
'name': 'SyntaxError',
@@ -54,8 +54,8 @@ console.log( toJSON( err ) );
5454
*/
5555

5656
err = new ReferenceError( 'unknown variable' );
57-
console.log( toJSON( err ) );
58-
/* =>
57+
console.log( error2json( err ) );
58+
/* e.g., =>
5959
{
6060
'type': 'ReferenceError',
6161
'name': 'ReferenceError',
@@ -65,8 +65,8 @@ console.log( toJSON( err ) );
6565
*/
6666

6767
err = new URIError( 'bad URI' );
68-
console.log( toJSON( err ) );
69-
/* =>
68+
console.log( error2json( err ) );
69+
/* e.g., =>
7070
{
7171
'type': 'URIError',
7272
'name': 'URIError',
@@ -76,8 +76,8 @@ console.log( toJSON( err ) );
7676
*/
7777

7878
err = new RangeError( 'value out-of-range' );
79-
console.log( toJSON( err ) );
80-
/* =>
79+
console.log( error2json( err ) );
80+
/* e.g., =>
8181
{
8282
'type': 'RangeError',
8383
'name': 'RangeError',
@@ -87,8 +87,8 @@ console.log( toJSON( err ) );
8787
*/
8888

8989
err = new EvalError( 'eval error' );
90-
console.log( toJSON( err ) );
91-
/* =>
90+
console.log( error2json( err ) );
91+
/* e.g., =>
9292
{
9393
'type': 'EvalError',
9494
'name': 'EvalError',

lib/node_modules/@stdlib/error/to-json/lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
* @module @stdlib/error/to-json
2525
*
2626
* @example
27-
* var toJSON = require( '@stdlib/error/to-json' );
27+
* var error2json = require( '@stdlib/error/to-json' );
2828
*
2929
* var err = new Error( 'beep' );
30-
* var json = toJSON( err );
30+
* var json = error2json( err );
3131
* // returns <Object>
3232
*/
3333

3434
// MODULES //
3535

36-
var toJSON = require( './main.js' );
36+
var main = require( './main.js' );
3737

3838

3939
// EXPORTS //
4040

41-
module.exports = toJSON;
41+
module.exports = main;

lib/node_modules/@stdlib/error/to-json/lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ var typeName = require( './type.js' );
3333
* Returns a JSON representation of an error object.
3434
*
3535
* @param {(Error|TypeError|SyntaxError|URIError|ReferenceError|RangeError|EvalError)} err - error to serialize
36-
* @throws {TypeError} first argument must be an error object
36+
* @throws {TypeError} must provide an error object
3737
* @returns {Object} JSON representation
3838
*
3939
* @example
4040
* var err = new Error( 'beep' );
41-
* var json = toJSON( err );
41+
* var json = error2json( err );
4242
* // returns {...}
4343
*/
44-
function toJSON( err ) {
44+
function error2json( err ) {
4545
var keys;
4646
var out;
4747
var i;
@@ -82,4 +82,4 @@ function toJSON( err ) {
8282

8383
// EXPORTS //
8484

85-
module.exports = toJSON;
85+
module.exports = error2json;

lib/node_modules/@stdlib/error/to-json/test/test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tape( 'main export is a function', function test( t ) {
5151
t.end();
5252
});
5353

54-
tape( 'if provided anything other than an error instance, the function will throw an error', function test( t ) {
54+
tape( 'if provided anything other than an error instance, the function throws an error', function test( t ) {
5555
var values;
5656
var i;
5757

@@ -62,6 +62,7 @@ tape( 'if provided anything other than an error instance, the function will thro
6262
null,
6363
void 0,
6464
true,
65+
false,
6566
[],
6667
{},
6768
function noop() {}
@@ -85,7 +86,7 @@ tape( 'the function returns a JSON object', function test( t ) {
8586

8687
err = new Error( 'beep' );
8788
json = toJSON( err );
88-
t.strictEqual( isPlainObject( json ), true, 'returns an object' );
89+
t.strictEqual( isPlainObject( json ), true, 'returns expected value' );
8990
t.end();
9091
});
9192

0 commit comments

Comments
 (0)