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

testob

v0.1.1

Published

testob (a test object library)

Downloads

13

Readme

testob Build Status Coverage Status

A small test object library, lets you instantiate a stateful object with methods that will return certain values or values conforming to certain criteria.

Example

let testob_basic = require('testob').basic;

let to = new testob_basic({
    attribs: {
        foo: 'foobar1',
        bar: 'barbaz2',
        baz: 'bazbat3',
        },
    throw_unknown_attribs: true,
    throw_set_undefined:   true,
    });

Setting throw_unknown_attribs to true (default is false) causes an exception to be thrown when calling get or getset on an attribute that does not exist.

Setting throw_set_undefined to true (default is false) causes an exception to be thrown when calling set or getset with an undefined new value.

Once instantiated, various methods exist:

to.return_first_arg('foobat');      // returns 'foobat'
to.return_args('bazfoo', 4, {});    // returns ['bazfoo', 4, {}]
to.return_true();                   // returns true
to.return_false();                  // returns false
to.return_bool();                   // returns a boolean value
to.return_int();                    // returns an integer value
to.return_float();                  // returns a floating point value
to.return_fun();                    // returns a function

NodeJS and browser usage

Works in node, just require it, like so:

let basic_obj = require('testob').basic;

Works client side in at least most browsers as well, either incorporate it with webpack or similar, or just load it, something like this:

<script src="lib/testob/dist/testob.js"></script>

This imports testob_basic.

Dist files

The dist folder has the following files available:

File | Description :-- | :-- testob.js | Limited ES6 features (works with Node.js v4+ and most browsers) testob_es5.js | ES5 translation (should work with anything) testob_es5.min.js | Minified ES5 translation

Build

run npm install to install the dev/build dependencies, and grunt build to build.

This will create ES5 dist/testob.js and dist/testob.min.js files, and run the unit tests against them.

Running grunt watch_dev will invoke an ES6 NodeJS only continuous file watch build test cycle, and generate coverage reports. Running grunt watch_full will watch for file changes and do a full build.