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

@koalati/result-builder

v1.4.0

Published

A helper library for Koalati tool developers that helps generate and format results.

Downloads

1

Readme

Result Builder library for Koalati tools

npm (scoped) GitHub CI Workflow status Libraries.io dependency status for latest release, scoped npm package

A library that allows tool developers to easily build and format result sets in Koalati tools, using the validation format defined in Koalati's contributor documentation.

Installation

  • Make sure NodeJs is installed
  • Install the package using the npm install command
npm i result-builder

Usage

Then, you can include it in your project and use like this

const { ResultBuilder, priorities } = require('@koalati/result-builder')
//...
const resultsBuilder = new ResultBuilder(); 
const test = resultsBuilder.newTest('test-unique-name');
test.setTitle("my-title")
    .setDescription("my-description")
    .setWeight(0.5)
    .setScore(0.5)
    .addRecommendation("Optimize your images to reduce your page's weight by %savings%.", { "%savings%": "6%" }, priorities.OPTIMIZATION)
    .addSnippet(["my-snippet"])
    .addTableRow([
        [
            "Table heading 1",
            "Table heading 2"
        ],
        [
            "Table value 1",
            "Table value 2"
        ]
    ])
// ... 
return resultsBuilder.getResultsTests(); 

Classes and methods

ResultBuilder (main class)

| Methods | Descriptions | | :---------------- | :--------------------------------------------------------- | | newTest(string) | Allow to set up a new test by providing a test unique name | | getResultsTests() | Allow to get all the list of all the recorded tests | | toJson() | Convert the result to a JSON format | | toArray() | Convert all the results into an array |

Test (utility class)

| Methods | Descriptions | | :--------------------------------- | :------------------------------- | | addRecommendation(string, object = {}, priority = null) | Adds a recommendation indicating to the user improvements to be made. The first parameter is the recommendation's template message. The second argument is an object literal containing any dynamic values that should be substituted in the template (where the object's keys correspond to the placeholder it will replace). The third argument indicates the level of priority of the recommendation, which should be either null or one of the priority constants exported by the package. | | addSnippet(string|ElementHandle) | Allows you to add code snippets from the results obtained.| | addSnippets(string[]|ElementHandle[]) | Allows you to add multiple code snippets from the results obtained.| | addTableRow(array) | Adds a row to a data table. The first row will act as the table's header. Every row must have the same number of columns. | | setTitle(string) | Defines a user-friendly title for the test. | | setDescription(string) | Defines a user-friendly description for the test. | | setWeight(number) | Defines the weight of this test relative to others in the same tool. Only numbers between 0.0 and 1.0. | | setScore(float) | Defines the score of this test. Only numbers between 0.0 and 1.0. | | getTitle() | Returns the title of the test. | | getDescription() | Returns the description of the test. | | getWeight() | Returns the weight of the test. | | getScore() | Returns the score of the test. | | getSnippets() | Returns the list of snippets. |

Authors

This was originally developed by Papa Alioune FALL in the Spring of 2021. This fork has been made to keep the library up-to-date, as Papa's has since completed his internship.

Maintained by Émile Perron and Koalati.