diff --git a/lib/node_modules/@stdlib/string/base/concat/README.md b/lib/node_modules/@stdlib/string/base/concat/README.md new file mode 100644 index 000000000000..b3132b2d8202 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/README.md @@ -0,0 +1,95 @@ + + +# concat + +> Concatenate two strings. + +
+ +
+ + + +
+ +## Usage + +```javascript +var concat = require( '@stdlib/string/base/concat' ); +``` + +#### concat( str1, str2 ) + +Concatenates two strings. + +```javascript +var out = concat( 'beep', 'boop' ); +// returns 'beepboop' +``` + +
+ + + +
+ +## Examples + + + +```javascript +var concat = require( '@stdlib/string/base/concat' ); + +var str = concat( 'beep', 'boop' ); +// returns 'beepboop' + +str = concat( 'foo', 'bar' ); +// returns 'foobar' + +str = concat( 'hello', 'world' ); +// returns 'helloworld' + +str = concat( '', 'abc' ); +// returns 'abc' + +str = concat( '123', '' ); +// returns '123' +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/string/base/concat/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/concat/benchmark/benchmark.js new file mode 100644 index 000000000000..1f73f939bb08 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/benchmark/benchmark.js @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var concat = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values1; + var values2; + var out; + var i; + + values1 = [ 'BEEP', 'FOO', 'HELLO' ]; + values2 = [ 'BOOP', 'BAR', 'WORLD' ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = concat( values1[ i%values1.length ], values2[ i%values2.length ] ); // eslint-disable-line max-len + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg + '::builtin', function benchmark( b ) { + var values1; + var values2; + var out; + var i; + + values1 = [ 'BEEP', 'FOO', 'HELLO' ]; + values2 = [ 'BOOP', 'BAR', 'WORLD' ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = values1[ i%values1.length ].concat( values2[ i%values2.length ] ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/string/base/concat/docs/repl.txt b/lib/node_modules/@stdlib/string/base/concat/docs/repl.txt new file mode 100644 index 000000000000..92bb45607c04 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( str1, str2 ) + Concatenates two strings. + + Parameters + ---------- + str1: string + First input string. + + str2: string + Second input string. + + Returns + ------- + out: string + Concatenated string. + + Examples + -------- + > var out = {{alias}}( 'beep', 'boop' ) + 'beepboop' + + See Also + -------- diff --git a/lib/node_modules/@stdlib/string/base/concat/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/concat/docs/types/index.d.ts new file mode 100644 index 000000000000..9e291dab1f8b --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/docs/types/index.d.ts @@ -0,0 +1,37 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 + +/** +* Concatenates two strings. +* +* @param str1 - first string +* @param str2 - second string +* @returns concatenated string +* +* @example +* var out = concat( 'beep', 'boop' ); +* // returns 'beepboop' +*/ +declare function concat( str1: S1, str2: S2 ): `${S1}${S2}`; + + +// EXPORTS // + +export = concat; diff --git a/lib/node_modules/@stdlib/string/base/concat/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/concat/docs/types/test.ts new file mode 100644 index 000000000000..d7beea4cb005 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/docs/types/test.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 concat = require( './index' ); + + +// TESTS // + +// The function returns a string... +{ + concat( 'beep', 'boop' ); // $ExpectType "beepboop" + concat( 'foo', 'bar' ); // $ExpectType "foobar" + concat( 'abc' as string, 'xyz' as string ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + concat( true, 'boop' ); // $ExpectError + concat( null, 'boop' ); // $ExpectError + concat( undefined, 'boop' ); // $ExpectError + concat( 123, 'boop' ); // $ExpectError + concat( {}, 'boop' ); // $ExpectError + concat( [], 'boop' ); // $ExpectError + concat( ( x: number ): number => x, 'boop' ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + concat( 'beep', true ); // $ExpectError + concat( 'beep', null ); // $ExpectError + concat( 'beep', undefined ); // $ExpectError + concat( 'beep', 123 ); // $ExpectError + concat( 'beep', {} ); // $ExpectError + concat( 'beep', [] ); // $ExpectError + concat( 'beep', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + concat(); // $ExpectError + concat( 'beep' ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/string/base/concat/examples/index.js b/lib/node_modules/@stdlib/string/base/concat/examples/index.js new file mode 100644 index 000000000000..96c9151daef2 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/examples/index.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 concat = require( './../lib' ); + +var str = concat( 'beep', 'boop' ); +console.log( str ); +// => 'beepboop' + +str = concat( 'foo', 'bar' ); +console.log( str ); +// => 'foobar' + +str = concat( 'Hello, ', 'world!' ); +console.log( str ); +// => 'Hello, world!' + +str = concat( '', 'empty' ); +console.log( str ); +// => 'empty' + +str = concat( 'test', '' ); +console.log( str ); +// => 'test' diff --git a/lib/node_modules/@stdlib/string/base/concat/lib/index.js b/lib/node_modules/@stdlib/string/base/concat/lib/index.js new file mode 100644 index 000000000000..6707d888e0e1 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/lib/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Concatenate two strings. +* +* @module @stdlib/string/base/concat +* +* @example +* var concat = require( '@stdlib/string/base/concat' ); +* +* var str = concat( 'beep', 'boop' ); +* // returns 'beepboop' +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/string/base/concat/lib/main.js b/lib/node_modules/@stdlib/string/base/concat/lib/main.js new file mode 100644 index 000000000000..1e4c9e305d9b --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/lib/main.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Concatenates two strings. +* +* @param {string} str1 - first string +* @param {string} str2 - second string +* @returns {string} concatenated string +* +* @example +* var str = concat( 'beep', 'boop' ); +* // returns 'beepboop' +*/ +function concat( str1, str2 ) { + return str1 + str2; +} + + +// EXPORTS // + +module.exports = concat; diff --git a/lib/node_modules/@stdlib/string/base/concat/package.json b/lib/node_modules/@stdlib/string/base/concat/package.json new file mode 100644 index 000000000000..f40f3955bd19 --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/string/base/concat", + "version": "0.0.0", + "description": "Concatenate two strings.", + "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", + "stdstring", + "utilities", + "utility", + "utils", + "util", + "base", + "concat", + "concatenate", + "join", + "combine", + "string", + "str" + ] +} diff --git a/lib/node_modules/@stdlib/string/base/concat/test/test.js b/lib/node_modules/@stdlib/string/base/concat/test/test.js new file mode 100644 index 000000000000..0a59ec7476cf --- /dev/null +++ b/lib/node_modules/@stdlib/string/base/concat/test/test.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 concat = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof concat, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function concatenates two strings', function test( t ) { + var expected; + var values; + var actual; + var i; + + values = [ + [ 'beep', 'boop' ], + [ 'foo', 'bar' ], + [ 'Hello, ', 'World!' ], + [ '', 'empty' ], + [ 'non-empty', '' ], + [ '', '' ] + ]; + expected = [ + 'beepboop', + 'foobar', + 'Hello, World!', + 'empty', + 'non-empty', + '' + ]; + for ( i = 0; i < values.length; i++ ) { + actual = concat( values[i][0], values[i][1] ); + t.strictEqual( actual, expected[i], 'returns expected value' ); + } + t.end(); +});