isKebabcase

Test if a value is a string in kebab case.

Usage

var isKebabcase = require( '@stdlib/assert/is-kebabcase' );

isKebabcase( value )

Tests if a value is a string in kebab case.

var bool = isKebabcase( 'beep-boop' );
// returns true

bool = isKebabcase( 'BEEP_BOOP' );
// returns false

Notes

  • The function validates that a value is a string. For all other types, the function returns false.

Examples

var isKebabcase = require( '@stdlib/assert/is-kebabcase' );

var bool = isKebabcase( 'beep-boop' );
// returns true

bool = isKebabcase( 'BEEP_BOOP' );
// returns false

bool = isKebabcase( 'fooBar' );
// returns false

bool = isKebabcase( 'foo_bar' );
// returns false

bool = isKebabcase( 'BeepBoop' );
// returns false

bool = isKebabcase( null );
// returns false

CLI

Usage

Usage: is-kebabcase [options] [<string>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --split sep           Delimiter for stdin data. Default: '/\\r?\\n/'.

Notes

  • If the split separator is a regular expression, ensure that the split option is either properly escaped or enclosed in quotes.

    # Not escaped...
    $ echo -n $'beEp booP\nfoo-bar' | is-kebabcase --split /\r?\n/
    # Escaped...
    $ echo -n $'beEp booP\nfoo-bar' | is-kebabcase --split /\\r?\\n/
    
  • The implementation ignores trailing delimiters.

Examples

$ is-kebabcase beep-boop
true

To use as a standard stream,

$ echo -n 'beep Boop' | is-kebabcase
false

By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.

$ echo -n 'beepBoop\tfoo-bar' | is-kebabcase --split '\t'
false
true
Did you find this page helpful?