Skip to content

Commit e0f6be8

Browse files
committed
Update benchmarks and examples
1 parent 29557a4 commit e0f6be8

File tree

8 files changed

+55
-55
lines changed

8 files changed

+55
-55
lines changed

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

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

21-
# toJSON
21+
# typedarray2json
2222

2323
> Return a [JSON][json] representation of a typed array.
2424
@@ -37,10 +37,10 @@ limitations under the License.
3737
## Usage
3838

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

43-
#### toJSON( typedarray )
43+
#### typedarray2json( typedarray )
4444

4545
Returns a [JSON][json] representation of a typed array.
4646

@@ -49,7 +49,7 @@ var Float64Array = require( '@stdlib/array/float64' );
4949

5050
var arr = new Float64Array( [ 5.0, 3.0 ] );
5151

52-
var json = toJSON( arr );
52+
var json = typedarray2json( arr );
5353
/* returns
5454
{
5555
'type': 'Float64Array',
@@ -97,7 +97,7 @@ For guidance on reviving a JSON-serialized typed array, see [`reviver()`][@stdli
9797

9898
var arr = new CustomArray( [ 5.0, 3.0 ] );
9999

100-
var json = toJSON( arr );
100+
var json = typedarray2json( arr );
101101
/* returns
102102
{
103103
'type': 'Float64Array',
@@ -130,10 +130,10 @@ var Uint8Array = require( '@stdlib/array/uint8' );
130130
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
131131
var Complex64Array = require( '@stdlib/array/complex64' );
132132
var Complex128Array = require( '@stdlib/array/complex128' );
133-
var toJSON = require( '@stdlib/array/to-json' );
133+
var typedarray2json = require( '@stdlib/array/to-json' );
134134
135135
var arr = new Float64Array( [ 5.0, 3.0 ] );
136-
var json = toJSON( arr );
136+
var json = typedarray2json( arr );
137137
/* returns
138138
{
139139
'type': 'Float64Array',
@@ -142,7 +142,7 @@ var json = toJSON( arr );
142142
*/
143143
144144
arr = new Float32Array( [ 5.0, -3.0 ] );
145-
json = toJSON( arr );
145+
json = typedarray2json( arr );
146146
/* returns
147147
{
148148
'type': 'Float32Array',
@@ -151,7 +151,7 @@ json = toJSON( arr );
151151
*/
152152
153153
arr = new Complex128Array( [ 5.0, 3.0 ] );
154-
json = toJSON( arr );
154+
json = typedarray2json( arr );
155155
/* returns
156156
{
157157
'type': 'Complex128Array',
@@ -160,7 +160,7 @@ json = toJSON( arr );
160160
*/
161161
162162
arr = new Complex64Array( [ 5.0, 3.0 ] );
163-
json = toJSON( arr );
163+
json = typedarray2json( arr );
164164
/* returns
165165
{
166166
'type': 'Complex64Array',
@@ -169,7 +169,7 @@ json = toJSON( arr );
169169
*/
170170
171171
arr = new Int32Array( [ -5, 3 ] );
172-
json = toJSON( arr );
172+
json = typedarray2json( arr );
173173
/* returns
174174
{
175175
'type': 'Int32Array',
@@ -178,7 +178,7 @@ json = toJSON( arr );
178178
*/
179179
180180
arr = new Uint32Array( [ 5, 3 ] );
181-
json = toJSON( arr );
181+
json = typedarray2json( arr );
182182
/* returns
183183
{
184184
'type': 'Uint32Array',
@@ -187,7 +187,7 @@ json = toJSON( arr );
187187
*/
188188
189189
arr = new Int16Array( [ -5, 3 ] );
190-
json = toJSON( arr );
190+
json = typedarray2json( arr );
191191
/* returns
192192
{
193193
'type': 'Int16Array',
@@ -196,7 +196,7 @@ json = toJSON( arr );
196196
*/
197197
198198
arr = new Uint16Array( [ 5, 3 ] );
199-
json = toJSON( arr );
199+
json = typedarray2json( arr );
200200
/* returns
201201
{
202202
'type': 'Uint16Array',
@@ -205,7 +205,7 @@ json = toJSON( arr );
205205
*/
206206
207207
arr = new Int8Array( [ -5, 3 ] );
208-
json = toJSON( arr );
208+
json = typedarray2json( arr );
209209
/* returns
210210
{
211211
'type': 'Int8Array',
@@ -214,7 +214,7 @@ json = toJSON( arr );
214214
*/
215215
216216
arr = new Uint8Array( [ 5, 3 ] );
217-
json = toJSON( arr );
217+
json = typedarray2json( arr );
218218
/* returns
219219
{
220220
'type': 'Uint8Array',
@@ -223,7 +223,7 @@ json = toJSON( arr );
223223
*/
224224
225225
arr = new Uint8ClampedArray( [ 5, 3 ] );
226-
json = toJSON( arr );
226+
json = typedarray2json( arr );
227227
/* returns
228228
{
229229
'type': 'Uint8ClampedArray',

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
2525
var randu = require( '@stdlib/random/base/randu' );
2626
var pkg = require( './../package.json' ).name;
27-
var toJSON = require( './../lib' );
27+
var typedarray2json = require( './../lib' );
2828

2929

3030
// MAIN //
@@ -38,8 +38,8 @@ bench( pkg, function benchmark( b ) {
3838

3939
b.tic();
4040
for ( i = 0; i < b.iterations; i++ ) {
41-
arr[ 0 ] = randu();
42-
o = toJSON( arr );
41+
arr[ 0 ] = i;
42+
o = typedarray2json( arr );
4343
if ( typeof o !== 'object' ) {
4444
b.fail( 'should return an object' );
4545
}

lib/node_modules/@stdlib/array/to-json/benchmark/benchmark.length.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var pow = require( '@stdlib/math/base/special/pow' );
2525
var randu = require( '@stdlib/random/base/randu' );
2626
var Float64Array = require( '@stdlib/array/float64' );
2727
var pkg = require( './../package.json' ).name;
28-
var toJSON = require( './../lib' );
28+
var typedarray2json = require( './../lib' );
2929

3030

3131
// FUNCTIONS //
@@ -59,8 +59,8 @@ function createBenchmark( len ) {
5959

6060
b.tic();
6161
for ( i = 0; i < b.iterations; i++ ) {
62-
arr[ 0 ] = randu();
63-
o = toJSON( arr );
62+
arr[ 0 ] = i;
63+
o = typedarray2json( arr );
6464
if ( typeof o !== 'object' ) {
6565
b.fail( 'should return an object' );
6666
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ interface JSONRepresentation {
5858
* var Float64Array = require( `@stdlib/array/float64` );
5959
*
6060
* var arr = new Float64Array( [ 5.0, 3.0 ] );
61-
* var json = toJSON( arr );
61+
* var json = typedarray2json( arr );
6262
* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] }
6363
*/
64-
declare function toJSON( arr: RealOrComplexTypedArray ): JSONRepresentation;
64+
declare function typedarray2json( arr: RealOrComplexTypedArray ): JSONRepresentation; // tslint:disable-line:max-line-length
6565

6666

6767
// EXPORTS //
6868

69-
export = toJSON;
69+
export = typedarray2json;

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

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

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

2121

2222
// TESTS //
@@ -25,25 +25,25 @@ import toJSON = require( './index' );
2525
{
2626
const x = new Float64Array( 10 );
2727

28-
toJSON( x ); // $ExpectType JSONRepresentation
28+
typedarray2json( x ); // $ExpectType JSONRepresentation
2929
}
3030

3131
// The compiler throws an error if the function is provided a first argument which is not array-like...
3232
{
33-
toJSON( 'abc' ); // $ExpectError
34-
toJSON( 123 ); // $ExpectError
35-
toJSON( true ); // $ExpectError
36-
toJSON( false ); // $ExpectError
37-
toJSON( {} ); // $ExpectError
38-
toJSON( [] ); // $ExpectError
39-
toJSON( null ); // $ExpectError
40-
toJSON( undefined ); // $ExpectError
33+
typedarray2json( 'abc' ); // $ExpectError
34+
typedarray2json( 123 ); // $ExpectError
35+
typedarray2json( true ); // $ExpectError
36+
typedarray2json( false ); // $ExpectError
37+
typedarray2json( {} ); // $ExpectError
38+
typedarray2json( [] ); // $ExpectError
39+
typedarray2json( null ); // $ExpectError
40+
typedarray2json( undefined ); // $ExpectError
4141
}
4242

4343
// The compiler throws an error if the function is provided an unsupported number of arguments...
4444
{
4545
const x = new Float64Array( 10 );
4646

47-
toJSON(); // $ExpectError
48-
toJSON( x, 3 ); // $ExpectError
47+
typedarray2json(); // $ExpectError
48+
typedarray2json( x, 3 ); // $ExpectError
4949
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ var Uint8Array = require( '@stdlib/array/uint8' );
2929
var Uint8ClampedArray = require( '@stdlib/array/uint8c' );
3030
var Complex64Array = require( '@stdlib/array/complex64' );
3131
var Complex128Array = require( '@stdlib/array/complex128' );
32-
var toJSON = require( './../lib' );
32+
var typedarray2json = require( './../lib' );
3333

3434
var arr = new Float64Array( [ 5.0, 3.0 ] );
35-
console.log( toJSON( arr ) );
35+
console.log( typedarray2json( arr ) );
3636
/* =>
3737
{
3838
'type': 'Float64Array',
@@ -41,7 +41,7 @@ console.log( toJSON( arr ) );
4141
*/
4242

4343
arr = new Float32Array( [ 5.0, -3.0 ] );
44-
console.log( toJSON( arr ) );
44+
console.log( typedarray2json( arr ) );
4545
/* =>
4646
{
4747
'type': 'Float32Array',
@@ -50,7 +50,7 @@ console.log( toJSON( arr ) );
5050
*/
5151

5252
arr = new Complex128Array( [ 5.0, -3.0 ] );
53-
console.log( toJSON( arr ) );
53+
console.log( typedarray2json( arr ) );
5454
/* =>
5555
{
5656
'type': 'Complex128Array',
@@ -59,7 +59,7 @@ console.log( toJSON( arr ) );
5959
*/
6060

6161
arr = new Complex64Array( [ 5.0, -3.0 ] );
62-
console.log( toJSON( arr ) );
62+
console.log( typedarray2json( arr ) );
6363
/* =>
6464
{
6565
'type': 'Complex64Array',
@@ -68,7 +68,7 @@ console.log( toJSON( arr ) );
6868
*/
6969

7070
arr = new Int32Array( [ -5, 3 ] );
71-
console.log( toJSON( arr ) );
71+
console.log( typedarray2json( arr ) );
7272
/* =>
7373
{
7474
'type': 'Int32Array',
@@ -77,7 +77,7 @@ console.log( toJSON( arr ) );
7777
*/
7878

7979
arr = new Uint32Array( [ 5, 3 ] );
80-
console.log( toJSON( arr ) );
80+
console.log( typedarray2json( arr ) );
8181
/* =>
8282
{
8383
'type': 'Uint32Array',
@@ -86,7 +86,7 @@ console.log( toJSON( arr ) );
8686
*/
8787

8888
arr = new Int16Array( [ -5, 3 ] );
89-
console.log( toJSON( arr ) );
89+
console.log( typedarray2json( arr ) );
9090
/* =>
9191
{
9292
'type': 'Int16Array',
@@ -95,7 +95,7 @@ console.log( toJSON( arr ) );
9595
*/
9696

9797
arr = new Uint16Array( [ 5, 3 ] );
98-
console.log( toJSON( arr ) );
98+
console.log( typedarray2json( arr ) );
9999
/* =>
100100
{
101101
'type': 'Uint16Array',
@@ -104,7 +104,7 @@ console.log( toJSON( arr ) );
104104
*/
105105

106106
arr = new Int8Array( [ -5, 3 ] );
107-
console.log( toJSON( arr ) );
107+
console.log( typedarray2json( arr ) );
108108
/* =>
109109
{
110110
'type': 'Int8Array',
@@ -113,7 +113,7 @@ console.log( toJSON( arr ) );
113113
*/
114114

115115
arr = new Uint8Array( [ 5, 3 ] );
116-
console.log( toJSON( arr ) );
116+
console.log( typedarray2json( arr ) );
117117
/* =>
118118
{
119119
'type': 'Uint8Array',
@@ -122,7 +122,7 @@ console.log( toJSON( arr ) );
122122
*/
123123

124124
arr = new Uint8ClampedArray( [ 5, 3 ] );
125-
console.log( toJSON( arr ) );
125+
console.log( typedarray2json( arr ) );
126126
/* =>
127127
{
128128
'type': 'Uint8ClampedArray',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
*
2626
* @example
2727
* var Float64Array = require( '@stdlib/array/float64' );
28-
* var toJSON = require( '@stdlib/array/to-json' );
28+
* var typedarray2json = require( '@stdlib/array/to-json' );
2929
*
3030
* var arr = new Float64Array( [ 5.0, 3.0 ] );
31-
* var json = toJSON( arr );
31+
* var json = typedarray2json( arr );
3232
* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] }
3333
*/
3434

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ var typeName = require( './type.js' );
4747
* var Float64Array = require( '@stdlib/array/float64' );
4848
*
4949
* var arr = new Float64Array( [ 5.0, 3.0 ] );
50-
* var json = toJSON( arr );
50+
* var json = typedarray2json( arr );
5151
* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] }
5252
*/
53-
function toJSON( arr ) {
53+
function typedarray2json( arr ) {
5454
var data;
5555
var out;
5656
var i;
@@ -79,4 +79,4 @@ function toJSON( arr ) {
7979

8080
// EXPORTS //
8181

82-
module.exports = toJSON;
82+
module.exports = typedarray2json;

0 commit comments

Comments
 (0)