Skip to content

Commit d0062fd

Browse files
committed
Auto-generated commit
1 parent 55bf887 commit d0062fd

File tree

11 files changed

+968
-0
lines changed

11 files changed

+968
-0
lines changed

CONTRIBUTORS

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# Contributors listed in alphabetical order.
44

5+
Adarsh Palaskar <[email protected]>
56
Aditya Sapra <[email protected]>
67
AgPriyanshu18 <[email protected]>
78
Ali Salesi <[email protected]>
@@ -29,6 +30,7 @@ Joris Labie <[email protected]>
2930
Justin Dennison <[email protected]>
3031
Karthik Prakash <[email protected]>
3132
33+
3234
Marcus Fantham <[email protected]>
3335
Matt Cochrane <[email protected]>
3436
Mihir Pandit <[email protected]>
@@ -37,11 +39,14 @@ Momtchil Momtchev <[email protected]>
3739
Naresh Jagadeesan <[email protected]>
3840
Nithin Katta <[email protected]>
3941
Ognjen Jevremović <[email protected]>
42+
Oneday12323 <[email protected]>
4043
Philipp Burckhardt <[email protected]>
4144
Prajwal Kulkarni <[email protected]>
4245
Pranav Goswami <[email protected]>
4346
4447
48+
49+
Rejoan Sardar <[email protected]>
4550
Ricky Reusser <[email protected]>
4651
Robert Gislason <[email protected]>
4752
Roman Stetsyk <[email protected]>
@@ -54,6 +59,7 @@ Shubham <[email protected]>
5459
Snehil Shah <[email protected]>
5560
Spandan Barve <[email protected]>
5661
Stephannie Jiménez Gacha <[email protected]>
62+
5763
Yernar Yergaziyev <[email protected]>
5864
orimiles5 <[email protected]>
5965

base/join/README.md

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# join
22+
23+
> Return a string created by joining array elements using a specified separator.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var join = require( '@stdlib/array/base/join' );
41+
```
42+
43+
#### join( x, separator )
44+
45+
Returns a string created by joining array elements using a specified separator.
46+
47+
```javascript
48+
var x = [ 1, 2, 3, 4, 5, 6 ];
49+
50+
var out = join( x, ',' );
51+
// returns '1,2,3,4,5,6'
52+
```
53+
54+
</section>
55+
56+
<!-- /.usage -->
57+
58+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
59+
60+
<section class="notes">
61+
62+
## Notes
63+
64+
- If provided an array-like object having a `join` method, the function defers execution to that method and assumes that the method API has the following signature:
65+
66+
```text
67+
x.join( separator )
68+
```
69+
70+
- If an array element is either `null` or `undefined`, the function will serialize the element as an empty string.
71+
72+
</section>
73+
74+
<!-- /.notes -->
75+
76+
<!-- Package usage examples. -->
77+
78+
<section class="examples">
79+
80+
## Examples
81+
82+
<!-- eslint no-undef: "error" -->
83+
84+
```javascript
85+
var Complex128Array = require( '@stdlib/array/complex128' );
86+
var Complex64Array = require( '@stdlib/array/complex64' );
87+
var AccessorArray = require( '@stdlib/array/base/accessor' );
88+
var Float64Array = require( '@stdlib/array/float64' );
89+
var join = require( '@stdlib/array/base/join' );
90+
91+
var x = [ 0, 1, 2, 3, 4, 5 ];
92+
var s = join( x, ',' );
93+
// returns '0,1,2,3,4,5'
94+
95+
x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] );
96+
s = join( x, ',' );
97+
// returns '0,1,2,3,4,5'
98+
99+
s = join( x, '-' );
100+
// returns '0-1-2-3-4-5'
101+
102+
s = new AccessorArray( [ 1, 2, 3, 4 ] );
103+
s = join( s, ',' );
104+
// returns '1,2,3,4'
105+
106+
x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
107+
s = join( x, ',' );
108+
// returns '1 + 2i,3 + 4i,5 + 6i'
109+
110+
x = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] );
111+
s = join( x, ',' );
112+
// returns '1 - 1i,2 - 2i'
113+
```
114+
115+
</section>
116+
117+
<!-- /.examples -->
118+
119+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
120+
121+
<section class="references">
122+
123+
</section>
124+
125+
<!-- /.references -->
126+
127+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
128+
129+
<section class="related">
130+
131+
</section>
132+
133+
<!-- /.related -->
134+
135+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
136+
137+
<section class="links">
138+
139+
</section>
140+
141+
<!-- /.links -->
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 isString = require( '@stdlib/assert/is-string' );
26+
var ones = require( './../../../base/ones' );
27+
var pkg = require( './../package.json' ).name;
28+
var join = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
var x = ones( len );
42+
return benchmark;
43+
44+
/**
45+
* Benchmark function.
46+
*
47+
* @private
48+
* @param {Benchmark} b - benchmark instance
49+
*/
50+
function benchmark( b ) {
51+
var s;
52+
var i;
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
s = join( x, ',' );
57+
if ( !isString( s ) ) {
58+
b.fail( 'should return a string' );
59+
}
60+
}
61+
if ( !isString( s ) ) {
62+
b.fail( 'should return a string' );
63+
}
64+
b.toc();
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
}
68+
}
69+
70+
71+
// MAIN //
72+
73+
/**
74+
* Main execution sequence.
75+
*
76+
* @private
77+
*/
78+
function main() {
79+
var len;
80+
var min;
81+
var max;
82+
var f;
83+
var i;
84+
85+
min = 1; // 10^min
86+
max = 6; // 10^max
87+
88+
for ( i = min; i <= max; i++ ) {
89+
len = pow( 10, i );
90+
91+
f = createBenchmark( len );
92+
bench( pkg+':dtype=generic,len='+len, f );
93+
}
94+
}
95+
96+
main();

base/join/docs/repl.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
{{alias}}( x, separator )
3+
Return a string created by joining array elements using a
4+
specified separator.
5+
6+
If provided an array-like object having a `join` method, the function
7+
defers execution to that method and assumes that the method has the
8+
following signature:
9+
10+
x.join( separator )
11+
12+
If provided an array-like object without a `join` method, the function
13+
manually constructs the output string.
14+
15+
Parameters
16+
----------
17+
x: ArrayLikeObject
18+
Input array.
19+
20+
separator: string
21+
Separator to be used.
22+
23+
Returns
24+
-------
25+
out: string
26+
Joined string.
27+
28+
Examples
29+
--------
30+
> var out = {{alias}}( [ 1, 2, 3, 4 ], ',' )
31+
'1,2,3,4'
32+
33+
See Also
34+
--------
35+

base/join/docs/types/index.d.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Collection, TypedArray, ComplexTypedArray } from '@stdlib/types/array';
24+
25+
/**
26+
* Returns a string created by joining array elements using a specified separator.
27+
*
28+
* @param x - input array
29+
* @param separator - separator element
30+
* @returns string
31+
*
32+
* @example
33+
* var Float64Array = require( '@stdlib/array/float64' );
34+
*
35+
* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] );
36+
*
37+
* var out = join( x, ',' );
38+
* // returns '1,2,3'
39+
*
40+
* @example
41+
* var Complex128Array = require( '@stdlib/array/complex128' );
42+
*
43+
* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
44+
*
45+
* var out = join( x, ',' );
46+
* // returns '1 + 2i,3 + 4i,5 + 6i'
47+
*/
48+
declare function join<T extends TypedArray | ComplexTypedArray>( x: T, separator: string ): string;
49+
50+
/**
51+
* Returns a string created by joining array elements using a specified separator.
52+
*
53+
* @param x - input array
54+
* @param separator - separator element
55+
* @returns string
56+
*
57+
* @example
58+
* var x = [ 1, 2, 3 ];
59+
*
60+
* var out = join( x, ',' );
61+
* // returns '1,2,3'
62+
*
63+
* @example
64+
* var x = [ 1, 2, 3, 4, 5, 6 ];
65+
*
66+
* var out = join( x, '-' );
67+
* // returns '1-2-3-4-5-6'
68+
*/
69+
declare function join<T = unknown>( x: Collection<T>, separator: string ): string;
70+
71+
72+
// EXPORTS //
73+
74+
export = join;

0 commit comments

Comments
 (0)