Skip to content

RostiMelk/is-kris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

is-kris

A lightweight, zero-dependency TypeScript utility for detecting variations of the name Chris/Kris in strings.

npm version License: MIT

Supported Name Variations

Recognizes these patterns (case-insensitive):

  • Chris: Chris, Chriss
  • Kris: Kris, Kriss, Khris
  • Christopher: Christopher, Christoph
  • Kristopher: Kristopher, Kristoph
  • Other variants: Christofer, Cristofer, Christoffer, Kristoffer

Installation

npm install is-kris

Usage

import { isKris, isExactlyKris, findKris, countKris, REGEX } from "is-kris";

// Check if string contains any Chris/Kris variation
isKris("Hello Chris"); // true
isKris("John"); // false

// Check if string is exactly a Chris/Kris variation
isExactlyKris("Chris"); // true
isExactlyKris("Hello Chris"); // false

// Find all variations in a string
findKris("Chris and Kris are friends"); // ['Chris', 'Kris']

// Count variations in a string
countKris("Chris, Kris, and Christopher"); // 3

// Access the underlying regex
console.log(REGEX); // /\b(?:c|ch|k|kh)ri(?:s|ss|st(?:o(?:ph(?:er)?|fer|ffer)))\b/i

// You can also use Chris aliases
import { isChris, findChris, countChris, isExactlyChris } from "is-kris";

isChris("Hello Christopher"); // true
findChris("Chris and Kris"); // ['Chris', 'Kris']

API Reference

isKris(input: string): boolean

Checks if a string contains any variation of Chris/Kris.

isExactlyKris(input: string): boolean

Checks if a string is exactly a variation of Chris/Kris.

findKris(input: string): string[]

Returns array of all Chris/Kris variations found in the string.

countKris(input: string): number

Returns the number of Chris/Kris variations found.

REGEX: RegExp

The underlying regular expression pattern.

Error Handling

All functions handle invalid inputs gracefully:

isKris(null); // false
findKris(undefined); // []
countKris(123); // 0

Performance & Compatibility

  • Optimized regex for fast matching
  • Lightweight bundle (~2KB)
  • Works in Node.js 18+, all modern browsers, Bun, and Deno

Development

git clone https://github.com/RostiMelk/is-kris.git
cd is-kris
bun install
bun test
bun run build

About

We got a lot of Kris/Chris' at the office πŸ˜΅β€πŸ’«

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published