Skip to content

A JavaScript library for handling singular possessive apostrophes with support for international names.

License

Notifications You must be signed in to change notification settings

sunanmau5/possessive-js

Repository files navigation

possessive-js

npm version npm downloads License: MIT Test Status JavaScript Style Guide

A JavaScript library for handling singular possessive apostrophes with support for international names.

Features

  • Handles English possessive rules correctly
  • Supports international names (German, French, Nordic)
  • Case preservation
  • Configurable styles
  • Zero dependencies
  • Supports both CommonJS and ES Modules
  • Tiny bundle size (~8KB)

Installation

npm install possessive-js

Usage

// ESM
import Possessive from "possessive-js";

// CommonJS
const Possessive = require("possessive-js");

// Basic usage
const possessive = new Possessive();
possessive.makePossessive("John"); // => "John's"
possessive.makePossessive("Chris"); // => "Chris'"

// International names
possessive.makePossessive("François"); // => "François'"
possessive.makePossessive("Strauß"); // => "Strauß'"
possessive.makePossessive("Müller"); // => "Müller's"

// Alternative style
const altPossessive = new Possessive({ style: "alternative" });
altPossessive.makePossessive("Chris"); // => "Chris's"

Configuration

const possessive = new Possessive({
  // Use 'alternative' for names ending in 's' to add 's (Chris's)
  // Use 'standard' for just apostrophe (Chris')
  style: "standard",

  // Language-specific rules
  enableFrenchRules: true,
  enableGermanRules: true,
  enableNordicRules: true
});

Special Cases

German Names

  • Names ending in 'ß': Strauß → Strauß'
  • Names with umlauts: Müller → Müller's

French Names

  • Names ending in silent letters: François → François'
  • Names with accents: René → René's

Nordic Names

  • Names with special characters: Åberg → Åberg's

Contributing

Pull requests are welcome! For major changes, please open an issue first.

License

MIT © Sunan Regi Maunakea

About

A JavaScript library for handling singular possessive apostrophes with support for international names.

Resources

License

Stars

Watchers

Forks

Packages

No packages published