@@ -28,6 +28,7 @@ var isCollection = require( '@stdlib/assert/is-collection' );
28
28
var isArrayBuffer = require ( '@stdlib/assert/is-arraybuffer' ) ;
29
29
var isObject = require ( '@stdlib/assert/is-object' ) ;
30
30
var isArray = require ( '@stdlib/assert/is-array' ) ;
31
+ var isString = require ( '@stdlib/assert/is-string' ) ;
31
32
var isFunction = require ( '@stdlib/assert/is-function' ) ;
32
33
var isComplexLike = require ( '@stdlib/assert/is-complex-like' ) ;
33
34
var isEven = require ( '@stdlib/math/base/assert/is-even' ) ;
@@ -1537,6 +1538,52 @@ setReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchEleme
1537
1538
return - 1 ;
1538
1539
} ) ;
1539
1540
1541
+ /**
1542
+ * Returns a new string by concatenating all array elements.
1543
+ *
1544
+ * @name join
1545
+ * @memberof Complex128Array.prototype
1546
+ * @type {Function }
1547
+ * @param {string } [separator=','] - element separator
1548
+ * @throws {TypeError } `this` must be a complex number array
1549
+ * @throws {TypeError } first argument must be a string
1550
+ * @returns {string } string representation
1551
+ *
1552
+ * @example
1553
+ * var arr = new Complex128Array( 2 );
1554
+ *
1555
+ * arr.set( [ 1.0, 1.0 ], 0 );
1556
+ * arr.set( [ 2.0, 2.0 ], 1 );
1557
+ *
1558
+ * var str = arr.join();
1559
+ * // returns '1 + 1i,2 + 2i'
1560
+ *
1561
+ * str = arr.join( '/' );
1562
+ * // returns '1 + 1i/2 + 2i'
1563
+ */
1564
+ setReadOnly ( Complex128Array . prototype , 'join' , function join ( separator ) {
1565
+ var out ;
1566
+ var buf ;
1567
+ var sep ;
1568
+ var i ;
1569
+ if ( ! isComplexArray ( this ) ) {
1570
+ throw new TypeError ( 'invalid invocation. `this` is not a complex number array.' ) ;
1571
+ }
1572
+ if ( arguments . length === 0 ) {
1573
+ sep = ',' ;
1574
+ } else if ( isString ( separator ) ) {
1575
+ sep = separator ;
1576
+ } else {
1577
+ throw new TypeError ( format ( 'invalid argument. First argument must be a string. Value: `%s`.' , separator ) ) ;
1578
+ }
1579
+ out = [ ] ;
1580
+ buf = this . _buffer ;
1581
+ for ( i = 0 ; i < this . _length ; i ++ ) {
1582
+ out . push ( getComplex128 ( buf , i ) . toString ( ) ) ;
1583
+ }
1584
+ return out . join ( sep ) ;
1585
+ } ) ;
1586
+
1540
1587
/**
1541
1588
* Returns the last index at which a given element can be found.
1542
1589
*
0 commit comments