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

test-constructs

v1.0.0

Published

JavaScript objects and arrays for testing purposes.

Downloads

35

Readme

test-constructs

JavaScript objects and arrays for testing purposes.

Installing


npm install --save-dev test-constructs

Quick Start


const tc = require('test-constructs')

console.log(tc.rndObject()) // <= A random object
console.log(tc.rndString()) // <= A random string
console.log(tc.rndJson()) // <= A random JSON string
console.log(tc.arrays.strings) // <= An array of strings
console.log(tc.arrays.types) // <= An array of JavaScript types
console.log(tc.objects.asArray) // <= An array of objects
console.log(tc.objects.byName.foo) // <= The foo object
console.log(tc.objects.bySize.small) // <= A small object
console.log(tc.objects.special.circular) // <= A special object
console.log(tc.json.asArray) // <= An array of JSON strings
console.log(tc.json.byName.foo) // <= The foo object as a JSON string
console.log(tc.json.bySize.small) // <= A small JSON string
console.log(tc.objects.special.deep) // <= A special object as a JSON string

Rational

After writing test data for console-probe and perj I decided to modularise it.

API

The best option to understand what you get from test-constructs is to look through the source code.

rndObject()

Returns randomly one of the objects available under objects.asArray.

Does not include the special objects.

rndString()

Returns randomly one of the strings available under arrays.strings.

rndJson()

Returns randomly one of the JSON strings available under json.asArray.

arrays

Returns an object with the following properties:

  • strings - Returns an array of strings.
  • types - Returns an array containing a large number of different JavaScript types.

objects

Returns an object with the following properties:

  • asArray - Returns an array of objects not including the special objects.
  • bySize - Returns an object by a size name such as objects.bySize.large.
  • byName - Returns an object by a name such as objects.byName.tardis.
  • special - Returns special objects such as objects.special.circular.

json

Returns an object with the following properties:

  • asArray - Returns an array of stringified object strings.
  • bySize - Returns a JSON string by a size name such as json.bySize.small.
  • byName - Returns a JSON string by the object name such as json.byName.deathStar.
  • special - Returns a JSON string by the special object name such as json.special.deep.

Note: The circular object is not available under special because JSON.stringify will not convert circular objects.

About the Owner

I, Grant Carthew, am a technologist, trainer, and Dad from Queensland, Australia. I work on code in a number of personal projects and when the need arises I build my own packages.

This project exists because I needed testing data.

Everything I do in open source is done in my own time and as a contribution to the open source community.

If you are using my projects and would like to thank me or support me, please click the Patreon link below.

Patreon Donation

See my other projects on NPM.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Change Log

  • v1.0.0 [2018-07-06]: Initial release.