diff --git a/lib/node_modules/@stdlib/array/base/join/README.md b/lib/node_modules/@stdlib/array/base/join/README.md new file mode 100644 index 000000000000..fa364e599940 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/README.md @@ -0,0 +1,141 @@ + + +# join + +> Return a string created by joining array elements using a specified separator. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var join = require( '@stdlib/array/base/join' ); +``` + +#### join( x, separator ) + +Returns a string created by joining array elements using a specified separator. + +```javascript +var x = [ 1, 2, 3, 4, 5, 6 ]; + +var out = join( x, ',' ); +// returns '1,2,3,4,5,6' +``` + +
+ + + + + +
+ +## Notes + +- 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: + + ```text + x.join( separator ) + ``` + +- If an array element is either `null` or `undefined`, the function will serialize the element as an empty string. + +
+ + + + + +
+ +## Examples + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var AccessorArray = require( '@stdlib/array/base/accessor' ); +var Float64Array = require( '@stdlib/array/float64' ); +var join = require( '@stdlib/array/base/join' ); + +var x = [ 0, 1, 2, 3, 4, 5 ]; +var s = join( x, ',' ); +// returns '0,1,2,3,4,5' + +x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +s = join( x, ',' ); +// returns '0,1,2,3,4,5' + +s = join( x, '-' ); +// returns '0-1-2-3-4-5' + +s = new AccessorArray( [ 1, 2, 3, 4 ] ); +s = join( s, ',' ); +// returns '1,2,3,4' + +x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +s = join( x, ',' ); +// returns '1 + 2i,3 + 4i,5 + 6i' + +x = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); +s = join( x, ',' ); +// returns '1 - 1i,2 - 2i' +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/base/join/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/join/benchmark/benchmark.length.js new file mode 100644 index 000000000000..60ed2fc96ac2 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isString = require( '@stdlib/assert/is-string' ); +var ones = require( '@stdlib/array/base/ones' ); +var pkg = require( './../package.json' ).name; +var join = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var s; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + s = join( x, ',' ); + if ( !isString( s ) ) { + b.fail( 'should return a string' ); + } + } + if ( !isString( s ) ) { + b.fail( 'should return a string' ); + } + b.toc(); + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( pkg+':dtype=generic,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/base/join/docs/repl.txt b/lib/node_modules/@stdlib/array/base/join/docs/repl.txt new file mode 100644 index 000000000000..431b9dd83c20 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/docs/repl.txt @@ -0,0 +1,35 @@ + +{{alias}}( x, separator ) + Return a string created by joining array elements using a + specified separator. + + If provided an array-like object having a `join` method, the function + defers execution to that method and assumes that the method has the + following signature: + + x.join( separator ) + + If provided an array-like object without a `join` method, the function + manually constructs the output string. + + Parameters + ---------- + x: ArrayLikeObject + Input array. + + separator: string + Separator to be used. + + Returns + ------- + out: string + Joined string. + + Examples + -------- + > var out = {{alias}}( [ 1, 2, 3, 4 ], ',' ) + '1,2,3,4' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/array/base/join/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/join/docs/types/index.d.ts new file mode 100644 index 000000000000..5f2d05372181 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/docs/types/index.d.ts @@ -0,0 +1,74 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; + +/** +* Returns a string created by joining array elements using a specified separator. +* +* @param x - input array +* @param separator - separator element +* @returns string +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* var out = join( x, ',' ); +* // returns '1,2,3' +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* var out = join( x, ',' ); +* // returns '1 + 2i,3 + 4i,5 + 6i' +*/ +declare function join( x: T, separator: string ): string; + +/** +* Returns a string created by joining array elements using a specified separator. +* +* @param x - input array +* @param separator - separator element +* @returns string +* +* @example +* var x = [ 1, 2, 3 ]; +* +* var out = join( x, ',' ); +* // returns '1,2,3' +* +* @example +* var x = [ 1, 2, 3, 4, 5, 6 ]; +* +* var out = join( x, '-' ); +* // returns '1-2-3-4-5-6' +*/ +declare function join( x: Collection, separator: string ): string; + + +// EXPORTS // + +export = join; diff --git a/lib/node_modules/@stdlib/array/base/join/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/join/docs/types/test.ts new file mode 100644 index 000000000000..7ff06fc321f7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/docs/types/test.ts @@ -0,0 +1,68 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex128Array = require( '@stdlib/array/complex128' ); +import Complex64Array = require( '@stdlib/array/complex64' ); +import join = require( './index' ); + + +// TESTS // + +// The function returns a string... +{ + join( [ 1, 2, 3 ], ',' ); // $ExpectType string + join( new Float64Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Float32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Int32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Int16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Int8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Uint32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Uint16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Uint8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Uint8ClampedArray( [ 1, 2, 3 ] ), ',' ); // $ExpectType string + join( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string + join( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not a collection... +{ + join( 5, ',' ); // $ExpectError + join( true, ',' ); // $ExpectError + join( false, ',' ); // $ExpectError + join( null, ',' ); // $ExpectError + join( void 0, ',' ); // $ExpectError + join( {}, ',' ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = [ 1, 2, 3 ]; + + join( x, true ); // $ExpectError + join( x, false ); // $ExpectError + join( x, null ); // $ExpectError + join( x, {} ); // $ExpectError + join( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + join(); // $ExpectError + join( [ 1, 2, 3 ] ); // $ExpectError + join( [ 1, 2, 3 ], ',', {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/base/join/examples/index.js b/lib/node_modules/@stdlib/array/base/join/examples/index.js new file mode 100644 index 000000000000..3588b02cf3f7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/examples/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var zeroTo = require( '@stdlib/array/base/zero-to' ); +var AccessorArray = require( '@stdlib/array/base/accessor' ); +var join = require( './../lib' ); + +var x = [ 0, 1, 2, 3, 4, 5 ]; + +var s = join( x, ',' ); +console.log( s ); +// => '0,1,2,3,4,5' + +x = new Float64Array( zeroTo( 6 ) ); + +s = join( x, ',' ); +console.log( s ); +// => '0,1,2,3,4,5' + +s = join( x, '-' ); +console.log( s ); +// => '0-1-2-3-4-5' + +s = new AccessorArray( [ 1, 2, 3, 4 ] ); + +s = join( s, ',' ); +console.log( s ); +// => '1,2,3,4' + +x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +s = join( x, ',' ); +console.log( s ); +// => '1 + 2i,3 + 4i,5 + 6i' + +x = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + +s = join( x, ',' ); +console.log( s ); +// => '1 - 1i,2 - 2i' diff --git a/lib/node_modules/@stdlib/array/base/join/lib/index.js b/lib/node_modules/@stdlib/array/base/join/lib/index.js new file mode 100644 index 000000000000..7480632b571e --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return a string created by joining array elements using a specified separator. +* +* @module @stdlib/array/base/join +* +* @example +* var join = require( '@stdlib/array/base/join' ); +* +* var x = [ 1, 2, 3, 4 ]; +* +* var out = join( x, ',' ); +* // returns '1,2,3,4' +*/ + + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/base/join/lib/main.js b/lib/node_modules/@stdlib/array/base/join/lib/main.js new file mode 100644 index 000000000000..d4b9f6594d13 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/lib/main.js @@ -0,0 +1,158 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); + + +// FUNCTIONS // + +/** +* Tests whether an object has a specified method. +* +* @private +* @param {Object} obj - input object +* @param {string} method - method name +* @returns {boolean} boolean indicating whether an object has a specified method +* +* @example +* var bool = hasMethod( [], 'join' ); +* // returns true +* +* @example +* var bool = hasMethod( [], 'beep' ); +* // returns false +*/ +function hasMethod( obj, method ) { + return ( typeof obj[ method ] === 'function' ); +} + +/** +* Returns a string created by joining array elements using a specified separator when input is an accessor array. +* +* @private +* @param {Object} x - input array object +* @param {integer} separator - separator +* @returns {string} joined string +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); +* +* var out = accessors( x, ',' ); +* // returns '1,2,3,4' +*/ +function accessors( x, separator ) { + var output; + var data; + var get; + var i; + var v; + data = x.data; + get = x.accessors[ 0 ]; + output = ''; + for ( i = 0; i < data.length; i++ ) { + v = get( data, i ); + if ( typeof v === 'undefined' || v === null ) { + v = ''; + } + output += v; + if ( i < data.length - 1 ) { + output += separator; + } + } + return output; +} + +/** +* Returns a string created by manually joining array elements using a specified separator. +* +* @private +* @param {Object} x - input array object +* @param {integer} separator - separator +* @returns {string} joined string +* +* @example +* var x = [ 1, 2, 3, 4 ]; +* var out = constructString( x, ',' ); +* // returns '1,2,3,4' +*/ +function constructString( x, separator ) { + var i; + var s; + var v; + s = ''; + for ( i = 0; i < x.length; i++ ) { + v = x[ i ]; + if ( typeof v === 'undefined' || v === null ) { + v = ''; + } + s += v; + if ( i < x.length - 1 ) { + s += separator; + } + } + return s; +} + + +// MAIN // + +/** +* Returns a string created by joining array elements using a specified separator. +* +* @param {Collection} x - input array +* @param {integer} separator - separator to be used in string +* @returns {string} joined string +* +* @example +* var x = [ 1, 2, 3, 4 ]; +* +* var out = join( x, ',' ); +* // returns '1,2,3,4' +* +* @example +* var x = [ 1, 2, 3, null, undefined, 4 ]; +* +* var out = join( x, '-' ); +* // returns '1-2-3---4' +*/ +function join( x, separator ) { + var obj; + if ( hasMethod( x, 'join' ) ) { + return x.join( separator ); + } + obj = arraylike2object( x ); + if ( obj.accessorProtocol ) { + return accessors( obj, separator ); + } + if ( obj.dtype === 'generic' || obj.dtype === null ) { + return constructString( x, separator ); + } + return x.join( separator ); +} + + +// EXPORTS // + +module.exports = join; diff --git a/lib/node_modules/@stdlib/array/base/join/package.json b/lib/node_modules/@stdlib/array/base/join/package.json new file mode 100644 index 000000000000..829703a669a3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/array/base/join", + "version": "0.0.0", + "description": "Return a string created by joining array elements using a specified separator.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "array", + "generic", + "join", + "concat", + "concatenate", + "serialize", + "tostring" + ] +} diff --git a/lib/node_modules/@stdlib/array/base/join/test/test.js b/lib/node_modules/@stdlib/array/base/join/test/test.js new file mode 100644 index 000000000000..5849b5002834 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/join/test/test.js @@ -0,0 +1,222 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var AccessorArray = require( '@stdlib/array/base/accessor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var join = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof join, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function joins an array-like object (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ 1, 2, 3, null ]; + + expected = '1,2,3,'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + expected = '1-2-3-'; + actual = join( x, '-' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = []; + + expected = ''; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = [ 'hello', '', undefined, null, NaN, undefined ]; + + expected = 'hello,,,,NaN,'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = [ null, undefined, null, undefined ]; + + expected = ',,,'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = [ null, 1, 2, 'testString', undefined ]; + + expected = ',1,2,testString,'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = [ null, 1, 2, NaN, undefined ]; + + expected = ',1,2,NaN,'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = [ 1 ]; + + expected = '1'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function joins an array-like object (float64)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + expected = '1,2,3'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Float64Array( [ 1.0 ] ); + + expected = '1'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Float64Array( [] ); + + expected = ''; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function joins an array-like object (int32)', function test( t ) { + var expected; + var actual; + var x; + + x = new Int32Array( [ 1, 2, 3 ] ); + + expected = '1,2,3'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Int32Array( [] ); + + expected = ''; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Int32Array( [ 1 ] ); + + expected = '1'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function joins an array-like object (complex128)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); + + expected = '1 - 1i,2 - 2i'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Complex128Array( [] ); + + expected = ''; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function joins an array-like object (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = new AccessorArray( [ 1, 2, 3, 4 ] ); + + expected = '1,2,3,4'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new AccessorArray( [ 1, 2, 3, null, undefined, 4 ] ); + + expected = '1,2,3,,,4'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new AccessorArray( [ 1 ] ); + + expected = '1'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new AccessorArray( [ null, undefined, NaN ] ); + + expected = ',,NaN'; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new AccessorArray( [] ); + + expected = ''; + actual = join( x, ',' ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +});