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

cientista

v0.1.0

Published

Cientista is a versatile library designed to facilitate the smooth update of critical software paths.

Downloads

7

Readme

Cientista

Table of Contents

Introduction

Cientista is a versatile library designed to facilitate the smooth update of critical software paths. It provides a structured approach to managing and executing experiments, including synchronous, asynchronous, and promise-returning tests. With configurable options for verbosity, logging, and behavior on cyclomatic complexity and performance changes, Cientista ensures robust and reliable experimentation processes. Ideal for developers and organizations aiming to streamline their testing workflows and enhance the quality of their software through rigorous experimentation.

Features

  • Test Management: Add, manage, and execute various types of tests including synchronous, asynchronous, and promise-returning tests.
  • Configurable Options: Customize verbosity, logging, and behavior on cyclomatic complexity and performance changes.
  • Error Handling: Robust error handling with support for custom error types and continuation chains.
  • Validation Methods: Add custom validation methods for your tests.
  • Cleanup Methods: Define cleanup methods to ensure resources are properly released after tests.

Getting Started

Installation

To install Cientista, run:

npm install cientista

Usage

To use Cientista, import the library and create a new instance of the Cientista class. You can then add tests using the with* methods and execute them using the run method.

import { Cientista } from 'cientista';

function fibonacciBase(n: number): number {
  if (n <= 1) return n;
  return fibonacciBase(n - 1) + fibonacciBase(n - 2);
}

function fibonacciWithoutRecursion(n: number): number {
  let a = 0, b = 1, f = 1;
  for (let i = 2; i <= n; i++) {
    f = a + b;
    [a, b] = [b, f];
  }
  return f;
}

const cientista = new Cientista(fibonacciBase, "Fibonacci");
cientista.withTest('withoutRecursion', fibonacciWithoutRecursion);

cientista.onError((key, result, experiment) => console.log({ key, result, experiment }));

cientista.onSuccess((key, result, experiment) => console.log({ key, result, experiment }));
await cientista.run(10);

To skip test, you can use the skipTests method:

const cientista = new Cientista(fibonacciBase, "Fibonacci");

// Skip all tests based on a condition
cientista.skipTests(() => true);

// Skip all tests that match a specific regular expression
cientista.skipTests(/test/);

// Skip all tests based in the array of test names
cientista.skipTests(["test"]);

// Skip multiple tests based on different conditions
cientista.skipTests([
  ["test", () => true],
  [/otherTest/, () => true],
]);

You can also execute cleanup methods after the tests are executed:

const cientista = new Cientista(fibonacciBase, "Fibonacci");

const method = () => console.log("method");
const cleanupMethod = () => console.log("cleanupMethod");
cientista.withTest("withoutRecursion", method, cleanupMethod);

await cientista.run(10);

Or

const cientista = new Cientista(baseMethod, "Fibonacci");

const method = () => console.log("method");
const cleanupMethod = () => console.log("cleanupMethod");

cientista.withTest("withoutRecursion", method);
cientista.withCleanup("withoutRecursion", cleanupMethod);

await cientista.run(10);

You can also add custom validation methods for your tests:

const cientista = new Cientista(baseMethod, "Fibonacci");

const method = () => console.log("method");
const cleanupMethod = () => console.log("cleanupMethod");
const validationMethod = (result) => result === 55;

cientista.withTest("withoutRecursion", method, cleanupMethod, validationMethod);

await cientista.run(10);

Cyclomatic complexity and performance changes can be configured using the options method:

const cientista = new Cientista(baseMethod, "Fibonacci", {
    failOnIncreasedCyclomaticComplexity: true,
    failOnDecreasedPerformance: true,
});

...

await cientista.run(10);

You can also add custom verbosity and logging options:

const cientista = new Cientista(baseMethod, "Fibonacci", {
    verbosity: 1, // 0 - Silent, 1 - Verbose
    log: console.log,
});

...

await cientista.run(10);

Contributors

Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue if you have any questions, suggestions, or bug reports.