Skip to content

Commit a937d83

Browse files
committed
Auto-generated commit
1 parent 9b8f3f1 commit a937d83

File tree

6 files changed

+393
-4
lines changed

6 files changed

+393
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ This release closes the following issue:
481481

482482
##### Features
483483

484+
- [`6ddda90`](https://github.com/stdlib-js/stdlib/commit/6ddda90477b17bb06353e539d6d6dbf9207e6b8f) - add `join` method to `array/fixed-endian-factory` [(#3287)](https://github.com/stdlib-js/stdlib/pull/3287)
484485
- [`c8143c4`](https://github.com/stdlib-js/stdlib/commit/c8143c4f1f5254c67916bb1548aa5443d282e263) - add `lastIndexOf` method to `array/fixed-endian-factory` [(#3281)](https://github.com/stdlib-js/stdlib/pull/3281)
485486
- [`9db1815`](https://github.com/stdlib-js/stdlib/commit/9db181520dc74f28aab70a73aac64202cf7560ce) - add `indexOf` method to `array/fixed-endian-factory` [(#3279)](https://github.com/stdlib-js/stdlib/pull/3279)
486487
- [`1d217ba`](https://github.com/stdlib-js/stdlib/commit/1d217bad1d35210a57d65c8be67c596815589082) - add `map` method to `array/fixed-endian-factory` [(#3270)](https://github.com/stdlib-js/stdlib/pull/3270)
@@ -497,9 +498,9 @@ This release closes the following issue:
497498

498499
##### Closed Issues
499500

500-
A total of 6 issues were closed in this release:
501+
A total of 7 issues were closed in this release:
501502

502-
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3155](https://github.com/stdlib-js/stdlib/issues/3155)
503+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3147](https://github.com/stdlib-js/stdlib/issues/3147), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3155](https://github.com/stdlib-js/stdlib/issues/3155)
503504

504505
</section>
505506

@@ -553,9 +554,9 @@ A total of 6 issues were closed in this release:
553554

554555
### Closed Issues
555556

556-
A total of 13 issues were closed in this release:
557+
A total of 14 issues were closed in this release:
557558

558-
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3155](https://github.com/stdlib-js/stdlib/issues/3155), [#3164](https://github.com/stdlib-js/stdlib/issues/3164), [#3165](https://github.com/stdlib-js/stdlib/issues/3165), [#3176](https://github.com/stdlib-js/stdlib/issues/3176), [#3177](https://github.com/stdlib-js/stdlib/issues/3177), [#3178](https://github.com/stdlib-js/stdlib/issues/3178), [#3179](https://github.com/stdlib-js/stdlib/issues/3179), [#3180](https://github.com/stdlib-js/stdlib/issues/3180)
559+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135), [#3138](https://github.com/stdlib-js/stdlib/issues/3138), [#3146](https://github.com/stdlib-js/stdlib/issues/3146), [#3147](https://github.com/stdlib-js/stdlib/issues/3147), [#3149](https://github.com/stdlib-js/stdlib/issues/3149), [#3150](https://github.com/stdlib-js/stdlib/issues/3150), [#3155](https://github.com/stdlib-js/stdlib/issues/3155), [#3164](https://github.com/stdlib-js/stdlib/issues/3164), [#3165](https://github.com/stdlib-js/stdlib/issues/3165), [#3176](https://github.com/stdlib-js/stdlib/issues/3176), [#3177](https://github.com/stdlib-js/stdlib/issues/3177), [#3178](https://github.com/stdlib-js/stdlib/issues/3178), [#3179](https://github.com/stdlib-js/stdlib/issues/3179), [#3180](https://github.com/stdlib-js/stdlib/issues/3180)
559560

560561
</section>
561562

@@ -586,6 +587,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
586587

587588
<details>
588589

590+
- [`6ddda90`](https://github.com/stdlib-js/stdlib/commit/6ddda90477b17bb06353e539d6d6dbf9207e6b8f) - **feat:** add `join` method to `array/fixed-endian-factory` [(#3287)](https://github.com/stdlib-js/stdlib/pull/3287) _(by Aditya Sapra, Philipp Burckhardt)_
589591
- [`c8143c4`](https://github.com/stdlib-js/stdlib/commit/c8143c4f1f5254c67916bb1548aa5443d282e263) - **feat:** add `lastIndexOf` method to `array/fixed-endian-factory` [(#3281)](https://github.com/stdlib-js/stdlib/pull/3281) _(by Aditya Sapra, Philipp Burckhardt)_
590592
- [`9818fa6`](https://github.com/stdlib-js/stdlib/commit/9818fa6dd8c90e045a147bfd1ba83cb1f693d17b) - **feat:** update namespace TypeScript declarations [(#3259)](https://github.com/stdlib-js/stdlib/pull/3259) _(by stdlib-bot, Philipp Burckhardt)_
591593
- [`9db1815`](https://github.com/stdlib-js/stdlib/commit/9db181520dc74f28aab70a73aac64202cf7560ce) - **feat:** add `indexOf` method to `array/fixed-endian-factory` [(#3279)](https://github.com/stdlib-js/stdlib/pull/3279) _(by Aditya Sapra, Athan Reines)_

fixed-endian-factory/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,35 @@ var str = arr.toString();
727727
// returns '1,2,3'
728728
```
729729

730+
<a name="method-join"></a>
731+
732+
#### TypedArrayFE.prototype.join( \[separator] )
733+
734+
Serializes the array elements into a string, with elements separated by the specified `separator`. If no `separator` is provided, a comma (`,`) is used as the default.
735+
736+
```javascript
737+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
738+
739+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
740+
741+
var str = arr.join();
742+
// returns '1,2,3'
743+
744+
str = arr.join( ' - ' );
745+
// returns '1 - 2 - 3'
746+
```
747+
748+
If the provided `separator` is not a string, it is coerced to a string.
749+
750+
```javascript
751+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
752+
753+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
754+
755+
var str = arr.join( 0 );
756+
// returns '10203'
757+
```
758+
730759
</section>
731760

732761
<!-- /.usage -->
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var factory = require( './../lib' );
25+
var pkg = require( './../package.json' ).name;
26+
27+
28+
// VARIABLES //
29+
30+
var Float64ArrayFE = factory( 'float64' );
31+
32+
33+
// MAIN //
34+
35+
bench( pkg+':join', function benchmark( b ) {
36+
var out;
37+
var arr;
38+
var i;
39+
40+
arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
41+
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
out = arr.join();
45+
if ( typeof out !== 'string' ) {
46+
b.fail( 'should return a string' );
47+
}
48+
}
49+
b.toc();
50+
if ( typeof out !== 'string' ) {
51+
b.fail( 'should return a string' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var zeroTo = require( './../../zero-to' );
26+
var factory = require( './../lib' );
27+
var pkg = require( './../package.json' ).name;
28+
29+
30+
// VARIABLES //
31+
32+
var Float64ArrayFE = factory( 'float64' );
33+
34+
35+
// FUNCTIONS //
36+
37+
/**
38+
* Creates a benchmark function.
39+
*
40+
* @private
41+
* @param {PositiveInteger} len - array length
42+
* @returns {Function} benchmark function
43+
*/
44+
function createBenchmark( len ) {
45+
var arr;
46+
arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
47+
return benchmark;
48+
49+
/**
50+
* Benchmark function.
51+
*
52+
* @private
53+
* @param {Benchmark} b - benchmark instance
54+
*/
55+
function benchmark( b ) {
56+
var out;
57+
var i;
58+
59+
b.tic();
60+
for ( i = 0; i < b.iterations; i++ ) {
61+
out = arr.join( '/' );
62+
if ( typeof out !== 'string' ) {
63+
b.fail( 'should return a string' );
64+
}
65+
}
66+
b.toc();
67+
if ( typeof out !== 'string' ) {
68+
b.fail( 'should return a string' );
69+
}
70+
b.pass( 'benchmark finished' );
71+
b.end();
72+
}
73+
}
74+
75+
76+
// MAIN //
77+
78+
/**
79+
* Main execution sequence.
80+
*
81+
* @private
82+
*/
83+
function main() {
84+
var len;
85+
var min;
86+
var max;
87+
var f;
88+
var i;
89+
90+
min = 1; // 10^min
91+
max = 6; // 10^max
92+
93+
for ( i = min; i <= max; i++ ) {
94+
len = pow( 10, i );
95+
f = createBenchmark( len );
96+
bench( pkg+':join:len='+len, f );
97+
}
98+
}
99+
100+
main();

fixed-endian-factory/lib/main.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,42 @@ function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdli
920920
return out.join( ',' );
921921
});
922922

923+
/**
924+
* Serializes the array elements into a string, with elements separated by the specified `separator`.
925+
*
926+
* @private
927+
* @name join
928+
* @memberof TypedArray.prototype
929+
* @type {Function}
930+
* @param {string} [separator=','] - string used to separate consecutive elements
931+
* @throws {TypeError} `this` must be a typed array instance
932+
* @returns {string} joined string
933+
*/
934+
setReadOnly( TypedArray.prototype, 'join', function join( separator ) {
935+
var out;
936+
var buf;
937+
var sep;
938+
var i;
939+
940+
if ( !isTypedArray( this ) ) {
941+
throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );
942+
}
943+
944+
if ( arguments.length > 0 ) {
945+
sep = String( separator );
946+
} else {
947+
sep = ',';
948+
}
949+
950+
out = [];
951+
buf = this._buffer;
952+
for ( i = 0; i < this._length; i++ ) {
953+
out.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) );
954+
}
955+
956+
return out.join( sep );
957+
});
958+
923959
return TypedArray;
924960

925961
/**

0 commit comments

Comments
 (0)