or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# Lodash IsString

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: lodash.isstring

7

- **Package Type**: npm

8

- **Language**: JavaScript

9

- **Installation**: `npm install lodash.isstring`

10

11

## Core Imports

12

13

```javascript

14

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

15

```

16

17

For ES modules:

18

19

```javascript

20

import isString from 'lodash.isstring';

21

```

22

23

For TypeScript:

24

25

```typescript

26

import isString from 'lodash.isstring';

27

28

// Type guard usage

29

function processValue(value: unknown): string | null {

30

if (isString(value)) {

31

// TypeScript now knows value is string

32

return value.toUpperCase();

33

}

34

return null;

35

}

36

```

37

38

## Basic Usage

39

40

```javascript

41

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

42

43

// Check string primitives

44

isString('hello'); // => true

45

isString(''); // => true

46

47

// Check String objects

48

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

49

50

// Check non-strings

51

isString(123); // => false

52

isString(true); // => false

53

isString(null); // => false

54

isString(undefined); // => false

55

isString([]); // => false

56

isString({}); // => false

57

```

58

59

## Capabilities

60

61

### String Type Checking

62

63

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.

64

65

```javascript { .api }

66

/**

67

* Checks if `value` is classified as a `String` primitive or object.

68

* @param {*} value The value to check

69

* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`

70

*/

71

function isString(value);

72

```

73

74

**Implementation Details:**

75

- Uses `typeof value == 'string'` to detect string primitives

76

- Uses `Object.prototype.toString.call(value) == '[object String]'` to detect String objects

77

- Handles both primitive strings and String constructor instances

78

- Returns `false` for null, undefined, numbers, booleans, arrays, objects, and other non-string types

79

80

**Usage Examples:**

81

82

```javascript

83

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

84

85

// String primitives

86

isString('abc'); // => true

87

isString(''); // => true

88

isString('123'); // => true

89

90

// String objects

91

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

92

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

93

94

// Non-string values

95

isString(123); // => false

96

isString(true); // => false

97

isString(false); // => false

98

isString(null); // => false

99

isString(undefined); // => false

100

isString([]); // => false

101

isString({}); // => false

102

isString(new Date()); // => false

103

isString(/regex/); // => false

104

isString(function() {}); // => false

105

106

// Edge cases

107

isString(String(123)); // => true (converts to primitive string)

108

isString(Object('abc')); // => true (creates String object)

109

```