npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chooie/preformatted

v1.0.1

Published

Template strings, without the superfluous whitespace.

Downloads

6

Readme

Preformatted

Template strings, without the superfluous whitespace.

The indenation is readjusted to be level with whatever the first line's indentation is. Leading and trailing whitespace is also removed (blanks and newlines).

Example

const preformatted = require("./preformatted.js");

describe("SHARED: Preformatted", function() {
  it("demonstration", function() {
    const animal = "cat";
    const sound = "meow";
    const normalTemplateString = `
      The ${animal} goes

      '${sound}'
    `;
    console.log();
    console.log("Normal template string:");
    console.log(normalTemplateString);

    const preformattedTemplateString = preformatted`
      The ${animal} goes

      '${sound}'
    `;
    console.log("Preformatted template string:");
    console.log(preformattedTemplateString);
  });
});

gives:

Normal template string:

      The cat goes

      'meow'

Preformatted template string:
The cat goes

'meow'

Install the library

NodeJS

npm install --save-exact @chooie/preformatted

Client

  • Copy generated/dist/client/bundle.js to your project and include it in a script tag on the desired page
  • If using Browserify, you can include the source at src/application/shared/preformatted.js

Development

View the available tasks to run

Run on your local machine

./tasks.sh

Run within Docker

./docker-tasks.sh

Quickstart

  • Install docker (I'm running 18.03.0-ce-mac60)

  • Start the Karma server

    ./docker-tasks.sh karma
  • Capture the browsers you want to test by visiting http://localhost:9876

  • Run all the checks

    ./docker-tasks.sh test:all
  • Start the application

    ./docker-tasks.sh run

Setup

Frontend testing requirements

In order to perform cross-browser testing professionally, we must test our application in real browsers. The testing infrastructure checks that the expected browsers are tested. You will need to install the necessary browsers and run the necessary emulators(or test loosely - see the error message).

I recommend that you test all browsers/platforms that you intend to serve as part of the automated testing.

With this in place, make sure to start the karma server and capture each of the browsers you would like to test by visiting http://localhost:9876 (may differ if you are in an emulator - read the docs for that environment).

Gotchas

When limiting the mocha tests that you want to run with .skip() or .only(), make sure to use the test:quick task first to get a passing suite (WITH NO LIMITS SPECIFIED YET). Then limit your tests and run test:quick again.

There is something weird going on with our jake test tasks, mocha, and/or karma that is stopping this from working properly (like with test:all).

Credits

Much of the inspiration and implementation is borrowed from James Shore (https://github.com/jamesshore). I highly recommend his webseries Let's Code Test Driven Javascript (http://www.letscodejavascript.com/).