JSPM

doc-chomp

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 950
    • Score
      100M100P100Q126201F
    • License MIT

    Doc Chomp chomps on your document literals

    Package Exports

    • doc-chomp

    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 (doc-chomp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    🍴 Doc Chomp

    Doc Chomp chomps on your document literals

    Usage

    Doc Chomp is useful for keeping nice indentation outside ES6 template literals, while making them internally clean and consistent.

    const DocChomp = require('doc-chomp');
    
    let chompedString = DocChomp`
      This string will be trimmed such that all indentation matches this line
    
      * Extra indentation is supported just fine
        * No problem! 👌🏼
    
      The line after the DocChomp call shouldn't be used, or Doc Chomp will complain!
      `
    
    function compareStrings() {
      if (chompedString) {
        return chompedString === DocChomp`
          This string will be trimmed such that all indentation matches this line
    
          * Extra indentation is supported just fine
            * No problem! 👌🏼
    
          The line after the DocChomp call shouldn't be used, or Doc Chomp will complain!
          `;
      }
    }
    
    compareStrings(); // true!

    In this example, chompedString will have two space characters trimmed from each line.

    No text should be added on the same line as DocChomp, as if text was accepted here, Doc Chomp couldn't make a good choice about spacing!