Skip to content

angelabenavente/is-string-checker

Repository files navigation

is-string-checker NPM version License: MIT NPM total downloads

A lightweight utility to check if a given value is a string.


🚀 Features

  • Zero dependencies: Lightweight and easy to integrate.
  • Reliable type-checking: Handles edge cases such as Object.create(null) or string objects (new String()).
  • Cross-platform: Works in Node.js, browsers, and other JavaScript environments.
  • ESM and CJS support: Fully compatible with modern module systems.

📦 Installation

You can install is-string-checker using your favorite package manager:

# Using pnpm
pnpm add is-string-checker

# Using npm
npm install is-string-checker

# Using yarn
yarn add is-string-checker

🌟 Usage

Here's how to use the library in your project:

Import the library

// CommonJS
const isString = require('is-string-checker');

// ES Modules
import isString from 'is-string-checker';

Basic example

console.log(isString("hello")); // true
console.log(isString(new String("hello"))); // true
console.log(isString(123)); // false
console.log(isString(null)); // false
console.log(isString(undefined)); // false

🔧 API

isString(value)

Checks if the given value is a string.

Parameters

  • value (any): The value to check.

Returns

  • boolean: Returns true if value is a string; otherwise, false.

🛠️ Development

If you want to contribute or run the project locally, follow these steps:

Clone the repository

git clone https://github.com/angelabenavente/is-string-checker.git
cd is-string-checker

Install dependencies

npm install

Run tests

npm run test

Lint the code

npm run eslint

🧪 Testing

This project uses Jest for testing. To run the test suite, simply use:

npm run test

Example output:

PASS  ./isString.test.js
✓ should return true for valid strings (10 ms)
✓ should return false for non-strings
...

Feel free to add more test cases in the test file.

🔄 Changelog

See CHANGELOG.md for a detailed history of changes.


💡 Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a clear description of the changes.

See CONTRIBUTING.md for more details.


📜 License

This project is licensed under the MIT License. Created with ❤️ by Ángela Benavente.


🌍 Links