Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions lib/node_modules/@stdlib/assert/is-palindrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!--

@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.

-->

# isPalindrome

> Test if a value is a palindrome.

<section class="usage">

## 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
```

</section>

<!-- /.usage -->

<section class="examples">

## 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
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

* * *

## See Also

- <span class="package-name">[`@stdlib/assert/is-string`][@stdlib/assert/is-string]</span><span class="delimiter">: </span><span class="description">test if a value is a string.</span>

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

<!-- <related-links> -->

[@stdlib/assert/is-string]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-string

<!-- </related-links> -->

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -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 ) {

Check warning on line 50 in lib/node_modules/@stdlib/assert/is-palindrome/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions
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();
});
30 changes: 30 additions & 0 deletions lib/node_modules/@stdlib/assert/is-palindrome/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -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
--------

Original file line number Diff line number Diff line change
@@ -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;

Check warning on line 31 in lib/node_modules/@stdlib/assert/is-palindrome/docs/types/index.d.ts

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected any. Specify a different type


// EXPORTS //

export = isPalindrome;
34 changes: 34 additions & 0 deletions lib/node_modules/@stdlib/assert/is-palindrome/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions lib/node_modules/@stdlib/assert/is-palindrome/examples/index.js
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/assert/is-palindrome/lib/index.js
Original file line number Diff line number Diff line change
@@ -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;
Loading