string iterator - nberlette/is GitHub Wiki
function isStringIterator<T extends string = string>(
it: unknown,
): it is StringIterator<T>;
Check if the given value is a string iterator, which is an iterable iterator
that yields individual characters from a string literal or String object. This
is the type of object returned by String.prototype[Symbol.iterator]
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a string iterator, false
otherwise.
Iterables
import { isStringIterator } from "jsr:@nick/is/string-iterator";
const str = "foo";
const iter = str[Symbol.iterator]();
console.log(isStringIterator(iterator)); // true
console.log(isStringIterator(str)); // false
Represents a string iterator.
-
T
extendsstring
(default:string
)
readonly [Symbol.toStringTag]: "String Iterator";