The ASPAVA
is a versatile JavaScript library designed to manipulate and
generate sequences of words or phrases. It is a flexible and easy-to-use tool
that can be particularly useful for various applications, such as text
processing, generative art, and educational purposes.
This library is built around a simple yet powerful class, AspavaGenerator
,
which provides various methods for manipulating a list of words or phrases. By
default, it comes with a predefined list of words, but it can be easily
customized to suit your needs.
- Customizable Word List: Start with a default set of words or input your own list.
- Various Manipulation Methods: Includes methods for shuffling, sorting (ascending and descending), changing case, and more.
- Generator Function: Utilize a generator function for iterative word generation.
- Easy to Integrate: Designed as an ES6 module, making it straightforward to include in modern JavaScript projects.
To use the ASPAVA
in your project, simply include it as a module. Ensure that
you have a JavaScript environment that supports ES6 modules.
import aspava from "npm:aspava";
Create an instance of AspavaGenerator
with the default word list, or provide
your own array of words.
import { AspavaGenerator } from "npm:aspava";
const customWords = ["Word1", "Word2", "Word3"];
const aspava = new AspavaGenerator(customWords);
-
Get a specific word:
const word = aspava.get(2); // Returns the 3rd word in the list
-
Get all words:
const words = aspava.getAll(); // Returns all words in the list
-
Get words as a string:
const str = aspava.getAsString(); // Returns all words joined by a space
-
Get first letters of each word:
const initials = aspava.getFirstLetters(); // Returns a string of initials
-
Shuffle the words:
aspava.shuffle(); // Randomly shuffles the words
-
Sort words in ascending order:
aspava.ascending(); // Sorts the words alphabetically
-
Sort words in descending order:
aspava.descending(); // Sorts the words in reverse alphabetical order
-
Convert words to uppercase:
aspava.upper(); // Converts all words to uppercase
-
Convert words to lowercase:
aspava.lower(); // Converts all words to lowercase
The generator()
method yields a sequence of words up to a specified maximum
generation count (default is 6).
for (const word of aspava.generator(6)) {
console.log(word);
}
Here is a complete example demonstrating various functionalities of the
ASPAVA
:
import aspava from "npm:aspava";
// Generate 100 words, shuffle them and print each word in uppercase
for (const word of aspava.shuffle().upper().generator(100)) {
console.log(word);
}
The ASPAVA
is a powerful and flexible tool that can be a valuable addition to
various JavaScript projects. With its easy-to-use interface and a wide range of
functionalities, it opens up many possibilities for creative and practical
applications.
Note: This README.md covers the basic functionalities and usage of the
ASPAVA
library. For more advanced use cases and customization, please ask for
detailed information on GitHub.