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

@kingjs/assert-theory

v1.0.20

Published

Calls a theory with every combination of elements from an array set.

Downloads

9

Readme

@kingjs/assert-theory

Assert that a theory is true for a combination of observations.

Usage

Assert that addition and multiplication are commutative operations for a combination of 3 whole numbers and 3 fractions like this:

var testTheory = require('@kingjs/assert-theory');
var assert = require('@kingjs/assert');

var id = 0;

testTheory(function(o, i) {
  assert(id++ == i);

  var naturalFirst = eval(o.natural + o.op + o.fraction);
  var fractionFirst = eval(o.fraction + o.op + o.natural);

  assert(naturalFirst == fractionFirst); 
}, {
  op: [ '+', '*' ],
  natural: [1, 2, 3],
  fraction: [.1, .2, .3],
});

assert(id == 3 * 3 * 2); // = 18

API

declare function testTheory(
  theory: (
    this, 
    observation, 
    i
  ) => void,
  observations: { [index: string]: any },
  runId?: number
);

Parameters

  • theory: A function that tests a set of observations.
    • this: The observations.
    • observation: The observation generated from data.
    • id: The number identifying observation.
  • observations: A descriptor whose every property contains either an array, primitive, or object from which a sequence of similar descriptors is generated where each property is replaced with an array element, the primitive, or a property value respectively.
  • runId: If present, runs only the observation with the given id.

Remarks

If an observation fails then it can be easily debugged by supplying runId. If runId is specified an exception is still thrown after the test pass to ensure that the runId is removed.

Install

With npm installed, run

$ npm install @kingjs/assert-theory

Acknowledgments

Like nUnit TheoryAttribute.

License

MIT

Analytics