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

@working-sloth/data-matrix

v2.0.0

Published

Data matrix for NodeJS

Downloads

65

Readme

Data Matrix

npm version Build Status Codacy Badge codecov MIT License

DataMatrix

日本語

Diligent developer, is it your work to crete many lengthy code for unit tests? Let's be lazy.

What?

Data list creator for JavaScript and TypeScript.

Why?

  • Less code: you don't have to write lengthy code any more for unit test
  • Readable: less code helps you to understand test cases and find mistake
  • Learning cost: basic takes only 1 step, full function takes 5 only steps to learn

Quick start

import { buildDataMatrix } from '@working-sloth/data-matrix';

// define test param
type Test = { time: string, isMale: boolean; age: number, expect: number, label: string };
// buildDataMatrix<T> convert the matrix to test list
const tests = buildDataMatrix<Test>(
    [
        ['time',        'isMale',   'age',  'expect',   'label'] // Header
    ], [//-------------------------------------------------------
        // Lacking values will be filled from LEFT to RIGHT with previous value
        ['morning',     true,       10,     -0.5,   '[morning] boy (max): discount 50%'],
        [/*morning*/    /*true*/    11,     0.0,    '[morning] boy (above): no discount'],
        [                           64,     0.0,    '[morning] senior man (under): no discount'],
        [                           65,     -0.5,   '[morning] senior man (min): discount 50%'],
        [               false,      10,     -0.5,   '[morning] girl (max): discount 50%'],
        [               /*false*/   11,     0.0,    '[morning] girl (above): no discount'],
        ...
    ]
);

// Test loop
for (const test of tests) {
    it(test.label, () => {
        // Given
        const service = new FooService();
        // When
        const discount = service.calcDiscount(test.time, test.isMale, test.age);
        // Then
        expect(discount).toEqual(test.expect);
    });
}

Other samples

I have a truly marvelous sample of this case which this margin is too narrow to contain. See samples

Schedule

  • Crate docs: someday
  • Extension for VS Code (matrix formatter & header generator): someday
  • Rest: every day
  • Sleep: every day
  • Be clever and lazy: soon
  • Be stupid and diligent: never

If you aren't satisfied