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

sequence-maker

v0.0.9

Published

Professional tool for generating random sequences

Downloads

9

Readme

Sequence Maker

Professional tool for generating random sequences.

Use in your project tests.


alt text alt text

Getting Started

$ npm i sequence-maker --save-dev

Creating sequence maker


const sequenceMaker = require('sequence-maker');

//create sequenceMaker
const sequence = new sequenceMaker();

Simple example


//simple: generates Random level
const simpleExample = sequence.make(
	{
		head: "Level of Unit", // constant phrase
		level: { // set type
			type: Number, // random Number
			min: 0, // min value (not required)
			max: 999, // max value (not required)
		}
	}, 
	3 // SIZE OF SEQUENCE
);

console.log(simpleExample);

/* console something like this:

[ 
	{ 
		head: "Level of Unit",
		level: 968 
	}, 
	{ 
		head: "Level of Unit",
		level: 941 
	}, 
	{ 
		head: "Level of Unit",
		level: 736 
	} 
]

*/

Commonly example

//medium: Object from object
const mediumExample = sequence.make(
	{
		parent: { // parent
			name: String, // set type without opts
			child: { // child
				name: { // set type with custom opts
					type: String, 
					len: 5, // length of random string
				}
			}
		}
	},
	2
);

console.log(mediumExample);

/* console something like this:

[
  {
    parent: { 
    	name: 'a5039030e01c54ef48f411bda6e0661d', 
    	child: {
    		name: 'f45e1'
    	} 
    }
  },
  {
    parent: { 
    	name: '0bb040de3523d9e621e26631d42c9851', 
    	child: {
    		name: 'bc012'
    	}
    }
  }
]

*/

Array

//create array from object
const createArray = sequence.make(
	{
		todo: [{
			text: "don't call your ex!!!",
			faled: {
				type: Boolean,
				prob: 0.99 // the probability of value: "true"
			}
		}]
	},
	2
);

console.log(createArray);

/* console something like this:

[
	{
		todo: [
			{ text: "don't call your ex!!!", failed: true },
			{ text: "don't call your ex!!!", failed: true },
			{ text: "don't call your ex!!!", failed: false },
			{ text: "don't call your ex!!!", failed: true },
		]
	},
	{
		todo: [
			{ text: "don't call your ex!!!", failed: true },
			{ text: "don't call your ex!!!", failed: true },
		]
	}
]

*/

Extremely example

//extreme: Using: 'Linker', 'List', 'UniqueList'
const Linker = sequenceMaker.Linker; // copy value from object
const List = sequenceMaker.List; // random value taken from list (MATCHES IS POSSIBLE)
const UniqueList = sequenceMaker.UniqueList; // random value taken from list (MATCHES EXCLUDED)

const extremeExample = sequence.make(
	{
		unit: {
			name: UniqueList(["Theodor", "Immanuil", "Pheodor", "Sophia"]), // set type
			race: List(["Human", "Orc", "Elf", "Dwarf", "Unicorn"]), // set type
		},
		copy_name: Linker("unit.name"), // copy value from <this-obj>.unit.name
	},
	2
);

console.log(extremeExample);

/* console something like this:

[
  { unit: { name: 'Theodor', race: 'Unicorn' }, copy_name: 'Theodor' },
  { unit: { name: 'Pheodor', race: 'Dwarf' }, copy_name: 'Pheodor' }
]

*/

You can create custom types!

//bonus: Create custom type
const MyCustomType = (opts) => { // opts: required
	const string = opts.string() // opts.<value> - is getter!!!
	
	return "This is a bad password: " + string;
}

const customTypesObjs = sequence.make(
	{
		log: {
			type: MyCustomType, // set your custom type
			string: {
				type: String,
				len: 3,
			}
		}
	},
	13
)

console.log(customTypesObjs);

//WOW!
/* console something like this:
[
  { log: 'This is a bad password: 077' },
  { log: 'This is a bad password: 7a8' },
  { log: 'This is a bad password: f45' },
  { log: 'This is a bad password: a4c' },
  { log: 'This is a bad password: c3d' },
  { log: 'This is a bad password: cf9' },
  { log: 'This is a bad password: 7d0' },
  { log: 'This is a bad password: 930' },
  { log: 'This is a bad password: e28' },
  { log: 'This is a bad password: 351' },
  { log: 'This is a bad password: 115' },
  { log: 'This is a bad password: 101' },
  { log: 'This is a bad password: 5d5' }
]

*/

Write data to file

//write schema to file by write method
sequence.write(
	{
		/* schema ... */
	},
	555, /* size of sequence */
	'myFile.json' /* file name */
)

Changing default config

sequence-maker/config.json


More Examples ...

docs