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

pronouny

v0.5.0

Published

a small, typed utility library to determine the correct pronoun from a string and several utility functions.

Downloads

13

Readme

Pronouny

Pronouny is a typed library intended to make programmatically resolving English pronouns easier.

Installation

To install, simply run npm install pronouny.

Usage

// Single import
import Pronouny from "pronouny";

// Create a new instance of Pronouny. All config is optional.
// Below are defaults.
const p = new Pronouny({
	// Will default to failing quietly into "they".
	failQuietly: true,

	// Will default to only querying the first subject
	// pronoun to limit scope. Set to "true" to force
	// recursive search.
	deepSearch: false,

	// Will default to using random pronouns in arrays.
	// Set to false to force using 0 index.
	useRandom: true,

	// Will default to using "they" as a fallback pronoun.
	fallbackPronoun: "they",
});

// Create a new Pronoun object using Pronouny.new()
const pronounZe: Pronoun = p.new(
	{
		subject: "ze",
		object: "hir",
		possessive: "hirs",
		psAdjective: "hir",
		reflexive: "hirself",
	},
	false
);

// .new() will automatically add new Pronouns to its
// validation map. however, if you want to do so manually,
// you can do it with Pronouny.add().
p.add(pronounZe);

// .remove() also works;
p.remove(p.resolve("I"));
// this deletes the "I" pronoun from the map.

// Methods are chainable so you can reach the Pronoun class.
p.add(pronounZe).set("he/they").use().subject();
//   ^Pronouny      ^PronounSet    ^Pronoun  ^string

// Instantiate a set of pronouns using Pronouny.set().
const vayne = {
	username: "vaynegarden",
	pronouns: p.set("she/ze/they"),
};
// from there, you can use `[PronounSet].use()` to get a random `Pronoun`.

// Resolve the pronouns in your app by referencing the form
// that you need. There's `subject`, `object`, `possessive`,
// `psAdjective`, and `reflexive`.
console.log(
	`${vayne.username} has updated ${vayne.pronouns.psAdjective()} status.`
);
// This returns "vaynegarden updated her status", "vaynegarden
// updated hir status", or "vaynegarden updated their status",
// selected randomly among the three.

// Alternatively, you can use the `parse()` template string method
// to parse a string with pronouns and write in reasonably natural syntax.
// This functionality will be updated more in the future.
console.log(
	vayne.pronouns.parse`${vayne.username} has updated ${"her"} status.`
);
// Returns the same as above.

Changelog

v0.5.0

  • Added parse() method to Pronoun and PronounSet to allow for parsing of strings into their correct pronoun forms.
  • Added optional resolver property to Pronouns to allow retracing to related Pronouny instance.
  • Added identify() method to Pronouny to allow for identification for type of pronouns.

v0.4.0

  • Optimized forEach() calls to use for loops instead.
  • Added fallbackPronoun option to allow for configuration of pronoun to use in case of quiet failure states.
  • Removed redundant set parameter from [PronounSet].remove() calls.

v0.3.1

  • Added documentation.
  • Reordered failQuietly and useRandom on Pronoun.
  • Tested and fixed examples.

v0.3.0

  • Rewritten to consolidate functionality into a single default export Pronouny.
  • Includes "we", "you", and "I" pronouns by default.
  • Added a config object so you can decide on error handling globally.
  • All methods are now chainable for ease of use.

v0.2.0

  • Now fails silently when trying to resolve pronouns that don't exist or indexing out of bounds.
  • Implementation of PronounSet class changed to Set from Array to prevent duplicate pronouns.
  • added get() method to PronounSet class to retrieve a random Pronoun object.
  • Added add() and remove() on PronounSet

v0.1.2

  • Initial release.

TODO

  • [x] Consolidate implementation into one general-use class.
  • [x] Add global configuration for pronoun use.
  • [ ] Use more performant data structures.
  • [ ] Cleaner error handling.
  • [ ] Unique pronoun identifiers to allow for pronouns with the same first subject pronoun to have multiple forms.