CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-is-js

Micro check library providing comprehensive type checking and validation operations across different JavaScript environments

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

configuration.mddocs/

Configuration

Library configuration and utility functions for customization and namespace management.

Capabilities

Namespace Management

Set Namespace

Changes the namespace of the library to prevent name collisions with other libraries that might use the global is variable.

/**
 * Change namespace of library to prevent name collisions
 * @returns New reference to the is object, while restoring previous global 'is'
 */
function setNamespace(): typeof is;

Usage Example:

// Save reference before other libraries override 'is'
const customName = is.setNamespace();

// Now 'is' refers to whatever was there before, 
// and customName refers to is.js
customName.odd(3);      // true
customName.string('test'); // true

// The global 'is' has been restored to its previous value

Regular Expression Customization

Set RegExp

Override built-in regular expressions with custom patterns for specific validation needs.

/**
 * Override RegExps if you think they suck
 * @param regexp - New regular expression pattern
 * @param name - Name of the regexp to override
 */
function setRegexp(regexp: RegExp, name: string): void;

Usage Example:

// Original URL validation
is.url('https://www.duckduckgo.com'); // true

// Override the URL regex with a custom pattern
is.setRegexp(/quack/, 'url');

// Now the URL function uses the new pattern
is.url('quack');        // true
is.url('https://www.duckduckgo.com'); // false (no longer matches)

Available RegExp Names:

The following built-in regular expressions can be overridden:

  • 'affirmative' - Affirmative responses (yes, true, ok, etc.)
  • 'alphaNumeric' - Alphanumeric characters
  • 'caPostalCode' - Canadian postal codes
  • 'creditCard' - Credit card numbers
  • 'dateString' - Date string formats
  • 'email' - Email addresses
  • 'eppPhone' - EPP phone numbers
  • 'hexadecimal' - Hexadecimal values
  • 'hexColor' - Hex color codes
  • 'ipv4' - IPv4 addresses
  • 'ipv6' - IPv6 addresses
  • 'nanpPhone' - North American phone numbers
  • 'socialSecurityNumber' - US Social Security Numbers
  • 'timeString' - Time string formats
  • 'ukPostCode' - UK postal codes
  • 'url' - URL formats
  • 'usZipCode' - US ZIP codes

docs

collection-validation.md

configuration.md

date-time.md

environment-detection.md

index.md

numeric-operations.md

pattern-matching.md

presence-checking.md

string-checking.md

type-checking.md

tile.json