or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash--isstring

Standalone utility function for checking whether a value is classified as a String primitive or String object.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.isstring@3.0.x

To install, run

npx @tessl/cli install tessl/npm-lodash--isstring@3.0.0

index.mddocs/

Lodash IsString

Lodash IsString provides a standalone utility function for checking whether a value is classified as a String primitive or String object. This is the modern build of lodash's _.isString exported as a standalone Node.js module, enabling string type checking without importing the entire lodash library.

Package Information

  • Package Name: lodash.isstring
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.isstring

Core Imports

const isString = require('lodash.isstring');

For ES modules:

import isString from 'lodash.isstring';

For TypeScript:

import isString from 'lodash.isstring';

// Type guard usage
function processValue(value: unknown): string | null {
  if (isString(value)) {
    // TypeScript now knows value is string
    return value.toUpperCase();
  }
  return null;
}

Basic Usage

const isString = require('lodash.isstring');

// Check string primitives
isString('hello');        // => true
isString('');            // => true

// Check String objects
isString(new String('hello')); // => true

// Check non-strings
isString(123);           // => false
isString(true);          // => false
isString(null);          // => false
isString(undefined);     // => false
isString([]);            // => false
isString({});            // => false

Capabilities

String Type Checking

Checks if a value is classified as a String primitive or String object. This function handles both JavaScript string primitives and String constructor objects correctly.

/**
 * Checks if `value` is classified as a `String` primitive or object.
 * @param {*} value The value to check
 * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`
 */
function isString(value);

Implementation Details:

  • Uses typeof value == 'string' to detect string primitives
  • Uses Object.prototype.toString.call(value) == '[object String]' to detect String objects
  • Handles both primitive strings and String constructor instances
  • Returns false for null, undefined, numbers, booleans, arrays, objects, and other non-string types

Usage Examples:

const isString = require('lodash.isstring');

// String primitives
isString('abc');               // => true
isString('');                  // => true
isString('123');               // => true

// String objects
isString(new String('abc'));   // => true
isString(new String(''));      // => true

// Non-string values
isString(123);                 // => false
isString(true);                // => false
isString(false);               // => false
isString(null);                // => false
isString(undefined);           // => false
isString([]);                  // => false
isString({});                  // => false
isString(new Date());          // => false
isString(/regex/);             // => false
isString(function() {});       // => false

// Edge cases
isString(String(123));         // => true (converts to primitive string)
isString(Object('abc'));       // => true (creates String object)