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

mudderjs

v0.1.5

Published

Generate lexicographically-spaced strings between two strings from pre-defined alphabets.

Downloads

15

Readme

Mudder

Generate lexicographically-spaced strings between two strings from pre-defined alphabets.

This package is a rewrite of Mudder.js with a Rust core that is used to generate bindings to Python (via PyO3) and JS/TS (via wasm-pack).

Quickstart

  • Rust: cargo add mudder
  • Python: pip install mudderpy or poetry add mudderpy
  • JS/TS: npm install mudderjs or yarn add mudderjs

API

The API is the same for all three languages. Note that there are a few differences in usage compared to the original:

  • The SymbolTable constructor takes in a str/string instead of a char[]/string[]. Each member of the symbol table is assumed to be a character.
  • When calling mudder, optional values for the start and end parameters use None or undefined instead of empty strings.
  • No method overloads.

Constructor

Create a new SymbolTable by passing in a string. The characters in the string will be used as the alphabet for the SymbolTable, with the first character being the "zero" character and, the second being the "one" character, and so on.

In Rust, the new method takes in a Vector of chars. The from_str method takes in a &str. In Python and JS/TS, the constructor takes in a str/string.

use mudder::SymbolTable;

let table = SymbolTable::from_str("abc");
from mudderpy import SymbolTable

table = SymbolTable("abc")
import { SymbolTable } from "mudderjs";

const table = new SymbolTable("abc");

Default SymbolTables

For convenience, there are a few default SymbolTables that can be used.

  • SymbolTable::decimal: 0123456789
  • SymbolTable::alphabetic: abcdefghijklmnopqrstuvwxyz
  • SymbolTable::base36: 0123456789abcdefghijklmnopqrstuvwxyz
  • SymbolTable::base62: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  • SymbolTable::hex: 0123456789abcdef

SymbolTable methods

A SymbolTable has the following methods:

  • SymbolTable::mudder(n: usize, start: Option<&str>, end: Option<&str>) -> Result<Vec<String>, &'static str>: Generate n strings between start and end. If start is None, the first string will be the first string in the SymbolTable. If end is None, the last string will be the last string in the SymbolTable, repeated k+6 times where k=len(start).

  • SymbolTable::mudder_one(start: Option<&str>, end: Option<&str>) -> Result<String, &'static str>: Convenience method for calling mudder with n=1 and returning the first element of the resulting vector.

Note that for Python and JS, the return type is just a list of strings or a single string.

Examples

use mudder::SymbolTable;

let table = SymbolTable::from_str("abc");
// let table = SymbolTable::new(vec!['a', 'b', 'c']);

let strings = table.mudder(5, None, None).unwrap();
assert_eq!(strings, vec!["ab", "ac", "b", "bc", "c"]);
from mudderpy import SymbolTable

table = SymbolTable("abc")
strings = table.mudder(5)
assert strings == ['ab', 'ac', 'b', 'bc', 'c']
import { SymbolTable } from "mudderjs";

const table = new SymbolTable("abc");
const strings = table.mudder(5);
assert(strings == ["ab", "ac", "b", "bc", "c"]);