string

Checks if the given string contains whitespace.

Type signature

(x: string) => boolean

Examples

containsWhitespace("test string");
// ⇒ true
Try in REPL
containsWhitespace("test");
// ⇒ false
Try in REPL

Questions

  • How to check if a string contains whitespace?

TypeScript sourceJavaScript source

Empty string.

Type signature

""

Examples

empty();
// ⇒ ""
Try in REPL

Questions

  • How to get an empty string?

TypeScript sourceJavaScript source

Transforms the first character to lowercase.

Type signature

(text: string) => string

Examples

firstToLower("TeSt");
// ⇒ "teSt"
Try in REPL

Questions

  • How to make the first letter of a string lowercase?

TypeScript sourceJavaScript source

Transforms the first character to uppercase.

Type signature

(text: string) => string

Examples

firstToUpper("teSt");
// ⇒ "TeSt"
Try in REPL

Questions

  • How to make the first letter of a string uppercase?

TypeScript sourceJavaScript source

Checks if the given substring is present in the source string.

Type signature

(search: string) => (text: string) => boolean

Examples

includes("brown fox")(
  "The quick brown fox jumps over the lazy dog",
);
// ⇒ true
Try in REPL
includes("brown dog")(
  "The quick brown fox jumps over the lazy dog",
);
// ⇒ false
Try in REPL

Questions

  • How to check if a string contains a given substring?

TypeScript sourceJavaScript source

Non-breaking space.

Type signature

" "

Examples

nbsp;
// ⇒ " "
Try in REPL

Questions

  • How to get a non-breaking space?

TypeScript sourceJavaScript source

Checks if the given string is present and is not empty or all whitespace.

Type signature

(x?: string) => boolean

Examples

nonEmpty("test with spaces");
// ⇒ true
Try in REPL
nonEmpty("   ");
// ⇒ false
Try in REPL
nonEmpty(null);
// ⇒ false
Try in REPL

Questions

  • How to check if a string is non-empty?
  • How to check if a string is not all whitespace?
  • How to check if a string is not null or undefined?

TypeScript sourceJavaScript source

Checks if the given string starts with the given substring.

Type signature

(prefix: string) => (xs: string) => boolean

Examples

startsWith("The")(
  "The quick brown fox jumps over the lazy dog",
);
// ⇒ true
Try in REPL
startsWith("Quick")(
  "The quick brown fox jumps over the lazy dog",
);
// ⇒ false
Try in REPL

Questions

  • How to check if a string starts with a given substring?

TypeScript sourceJavaScript source