JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q34931F
  • License Apache-2.0

Test if a value is a string in snake case.

Package Exports

  • @stdlib/assert-is-snakecase
  • @stdlib/assert-is-snakecase/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/assert-is-snakecase) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

isSnakecase

NPM version Build Status Coverage Status

Test if a value is a string in snake case.

Installation

npm install @stdlib/assert-is-snakecase

Usage

var isSnakecase = require( '@stdlib/assert-is-snakecase' );

isSnakecase( value )

Tests if a value is a string in snake case.

var bool = isSnakecase( 'hello_world' );
// returns true

bool = isSnakecase( 'Hello World' );
// returns false

Notes

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

Examples

var isSnakecase = require( '@stdlib/assert-is-snakecase' );

var bool = isSnakecase( 'foo_bar_baz' );
// returns true

bool = isSnakecase( 'FOO_BAR' );
// returns false

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

bool = isSnakecase( 'beep-boop' );
// returns false

bool = isSnakecase( null );
// returns false

CLI

Installation

To use the module as a general utility, install the module globally

npm install -g @stdlib/assert-is-snakecase

Usage

Usage: is-snakecase [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-snakecase --split /\r?\n/
    # Escaped...
    $ echo -n $'beEp booP\nfoo_bar' | is-snakecase --split /\\r?\\n/
  • The implementation ignores trailing delimiters.

Examples

$ is-snakecase foo_bar
true

To use as a standard stream,

$ echo -n 'fooBar' | is-snakecase
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 'fooBar\tbeep_boop' | is-snakecase --split '\t'
false
true

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright © 2016-2022. The Stdlib Authors.