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

word-fabricator

v4.0.0

Published

Provide simple rules which determine the creation of fictional words

Downloads

9

Readme

Word Fabricator

Generate fictional words by specifying rules

const configure_word_fabricator = require('./path/to/word-fabricator');

const word_fabricator = configure_word_fabricator({
    blueprint: {
        dr: ['ago', 'e'],
        ago: ['n'],
        n: ['e', 'ago'],
        e: ['gg'],
        gg: [],
    },
    max_length: 6,
    initial_parts: ['dr', 'ago', 'n', 'e'],
});

const fictional_words = word_fabricator();

console.log(fictional_words.join(', '));

// dr, drago, dragon, dre, dregg, ago, agon, agone, n, ne, negg, nago, nagon, nagone, e, egg

code from demo/usage.js

Getting started

How to install

npm install word-fabricator

How to use


require('word-fabricator')

Returns a function to make configurations for how the words will be fabricated

const configure_word_fabricator = require('word-fabricator');

configure_word_fabricator

This function requires some initial rules and returns the actual word_fabricator

const word_fabricator = configure_word_fabricator(initial_rules); // specify required rules

initial_rules

This plain object may specify any rules, however it must specify the required rules; blueprint, max_length and initial_parts


word_fabricator

Returns the array of fictional words which are fabricated using the provided rules (initial rules and additional rules)

const words = word_fabricator(); // change nothing
// or
const words = word_fabricator(additional_rules); // override/append rules

additional_rules

This object may be undefined to change nothing or specify new rules and/or change predefined initial rules


console.log the list of fabricated words

const list_of_words = words.join(', ');

console.log(list_of_words);

The rules

* Required in initial_rules

blueprint*

An object where the values is an array of different letters, or rather segments, which are allowed to succeed after the letter segment which is its key. Segments are either one or multiple letters in a string

blueprint: {
    a: ['r', 'rr', 's'],
    e: ['r', 's', 'ss'],
    r: ['a', 'e'],
    rr: ['a', 'e'],
    s: ['r'],
    ss: ['a', 'e'],
}

max_length*

The maximum number of letters word-fabricator will try to build words

max_length: 4;

initial_parts*

An array of letter segments which every word will be built upon

initial_parts: ['a', 'e', 'r', 's', 'sa'];

Roadmap

  • Validate rules
  • Provide great error messages
  • Arrays and strings should kind of be seen as the same
  • Add some more rules
    • min_length
    • length (specified exact length)
    • Words to be excluded
      • Exact match
      • Substring
      • Regex
    • Something about the endings of the words (allowed, disallowed)
    • Limit the amount of words to be fabricated at a time

Maybe

  • All rules are allowed as snake_case as well as camelCase (other cases?)
  • Decide if standard should be max segments instead of max length

The user experience I would like to achieve

  1. install the package
  2. require the package
  3. provide some initial rules
    1. throws error if something is invalid
  4. run the function with some additional rules
  5. get the fabricated words