string-transform
    TypeScript icon, indicating that this package has built-in type declarations

    21.9.19 • Public • Published

    String Transform Tweet

    Build Status License NPM version Website NPM downloads

    String transform module from Glize library.

    Usage

    npm install string-transform --save
    import {
      capitalize,
      hash,
      toCamelCase,
      toKebabCase,
      toPascalCase,
      toSnakeCase,
    } from 'string-transform';
    
    /**
     * Transforms the first character of each word to uppercase; other
     * characters are unaffected.
     * @param {string} str The string to be transformed.
     * @return {string} Returns transformed string.
     */
    console.log(capitalize('test string')); // Test String
    
    /**
     * Converts <code>str</code> to hashed string.
     * @param {string} str The input string.
     * @return {string} Returns hashed string.
     */
    console.log(hash('https://glize.js.org/')); // 4Q69R
    
    /**
     * Converts the passed string into a string with the separator denoted by the 
     * next word capitalized (aka lower camel case).
     * @param {string} str The input string.
     * @return {string} A string convered into a string with the separator 
     * denoted by the next word capitalized.
     * @see https://en.wikipedia.org/wiki/Camel_case
     */
    console.log(toCamelCase('to-camel-case')); // toCamelCase
    
    /**
     * Converts the passed string into a string of capitalized words without 
     * separators (aka upper camel case).
     * @param {string} str The input string.
     * @return {string} A string convered into a string of capitalized words 
     * without separators.
     * @see https://en.wikipedia.org/wiki/PascalCase
     */
    console.log(toPascalCase('to-pascal-case')); // ToPascalCase
    
    /**
     * Converts the given string into a string with a single underscore as a separator.
     * @param {string} str The input string.
     * @return {string} A convered string.
     * @see https://en.wikipedia.org/wiki/Snake_case
     */
    console.log(toSnakeCase('toSnakeCase')); // to_snake_case
    
    /**
     * Converts the given string into a string with a single dash as a separator.
     * @param {string} str The input string.
     * @return {string} A convered string.
     */
    console.log(toKebabCase('toKebabCase')); // to-kebab-case

    For more information please visit Glize project page.

    Install

    npm i string-transform

    Homepage

    glize.js.org

    DownloadsWeekly Downloads

    31,497

    Version

    21.9.19

    License

    Apache-2.0

    Unpacked Size

    21.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • vpodk
    • lizapodk