diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/README.md b/lib/node_modules/@stdlib/assert/is-palindrome/README.md new file mode 100644 index 000000000000..ecc714142a6b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/README.md @@ -0,0 +1,105 @@ + + +# isPalindrome + +> Test if a value is a palindrome. + +
+ +## Usage + +```javascript +var isPalindrome = require( '@stdlib/assert/is-palindrome' ); +``` + +#### isPalindrome( value ) + +Tests if a `value` is a palindrome `string`. + +```javascript +var bool = isPalindrome( 'racecar' ); +// returns true + +bool = isPalindrome( 'level' ); +// returns true + +bool = isPalindrome( 'abc' ); +// returns false + +bool = isPalindrome( null ); +// returns false +``` + +
+ + + +
+ +## Examples + +```javascript +var isPalindrome = require( '@stdlib/assert/is-palindrome' ); + +var bool = isPalindrome( 'racecar' ); +// returns true + +bool = isPalindrome( 'ada' ); +// returns true + +bool = isPalindrome( 'website' ); +// returns false + +bool = isPalindrome( null ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-palindrome/benchmark/benchmark.js new file mode 100644 index 000000000000..1b02617a8458 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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' ); +var pkg = require( './../package.json' ).name; +var isPalindrome = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPalindrome( 'racecar' ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isString( pkg ) ) { + b.fail( 'should be a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg + ':long_string', function benchmark( b ) { + var bool; + var str; + var i; + + str = 'tattarrattat'; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPalindrome( str ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !bool ) { + b.fail( 'should return true' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-palindrome/docs/repl.txt new file mode 100644 index 000000000000..fe8876b38725 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( value ) + Tests if a value is a palindrome. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if a value is a palindrome. + + Examples + -------- + > var bool = {{alias}}( 'racecar' ) + true + > bool = {{alias}}( 'level' ) + true + > bool = {{alias}}( 'noon' ) + true + > bool = {{alias}}( 'stdlib' ) + false + > bool = {{alias}}( null ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/index.d.ts new file mode 100644 index 000000000000..9c5907f04448 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/index.d.ts @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 + +/** +* Tests if a value is a palindrome. +* +* @param v - value to test +* @returns boolean indicating if a value is a palindrome +* +* @example +* var bool = isPalindrome( 'racecar' ); +* // returns true +*/ +declare function isPalindrome( v: any ): boolean; + + +// EXPORTS // + +export = isPalindrome; diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/test.ts new file mode 100644 index 000000000000..2c434ad5ae82 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/docs/types/test.ts @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isPalindrome = require( '@stdlib/assert/is-palindrome' ); + + +// TESTS // + +// The function returns a boolean... +{ + isPalindrome( 'racecar' ); // $ExpectType boolean + isPalindrome( '' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + isPalindrome(); // $ExpectError + isPalindrome( 'racecar', {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/examples/index.js b/lib/node_modules/@stdlib/assert/is-palindrome/examples/index.js new file mode 100644 index 000000000000..16bb3e1a7976 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/examples/index.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isPalindrome = require( './../lib' ); + +console.log( isPalindrome( 'racecar' ) ); +// => true + +console.log( isPalindrome( 'ada' ) ); +// => true + +console.log( isPalindrome( 'website' ) ); +// => false + +console.log( isPalindrome( null ) ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/lib/index.js b/lib/node_modules/@stdlib/assert/is-palindrome/lib/index.js new file mode 100644 index 000000000000..a5f87d0a244b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/lib/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Assert if a value is a palindrome. +* +* @module @stdlib/assert/is-palindrome +* +* @example +* var isPalindrome = require( '@stdlib/assert/is-palindrome' ); +* +* var bool = isPalindrome( 'level' ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/lib/main.js b/lib/node_modules/@stdlib/assert/is-palindrome/lib/main.js new file mode 100644 index 000000000000..d8efc047939d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/lib/main.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isString = require( '@stdlib/assert/is-string' ); + + +// MAIN // + +/** +* Tests if a value is a palindrome. +* +* @param {*} v - value to test +* @returns {boolean} boolean indicating if a value is a palindrome +* +* @example +* var bool = isPalindrome( 'racecar' ); +* // returns true +* +* @example +* var bool = isPalindrome( 'abc' ); +* // returns false +*/ +function isPalindrome( v ) { + var len; + var i; + var j; + + if ( !isString( v ) ) { + return false; + } + len = v.length; + if ( len <= 1 ) { + return true; + } + + i = 0; + j = len - 1; + while ( i < j ) { + if ( v.charAt( i ) !== v.charAt( j ) ) { + return false; + } + i += 1; + j -= 1; + } + return true; +} + + +// EXPORTS // + +module.exports = isPalindrome; diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/package.json b/lib/node_modules/@stdlib/assert/is-palindrome/package.json new file mode 100644 index 000000000000..99d780be4e6a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/assert/is-palindrome", + "version": "0.0.0", + "description": "Test if a value is a palindrome.", + "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", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "string", + "palindrome", + "is", + "ispalindrome", + "type", + "check", + "validate", + "valid", + "test" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-palindrome/test/test.js b/lib/node_modules/@stdlib/assert/is-palindrome/test/test.js new file mode 100644 index 000000000000..c9815738f4f4 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-palindrome/test/test.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isPalindrome = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isPalindrome, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns true if a value is a palindrome', function test( t ) { + var values; + var i; + + values = [ + 'racecar', + 'level', + 'a', + '', + 'step on no pets', + 'deleveled' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isPalindrome( values[ i ] ), true, 'returns true for ' + values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns false if a value is not a palindrome', function test( t ) { + var values; + var i; + + values = [ + 'abc', + 'stdlib', + null, + undefined, + 121, + NaN, + {}, + [] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isPalindrome( values[ i ] ), false, 'returns false for ' + values[ i ] ); + } + t.end(); +});