possessive-js
v0.1.0
Published
A JavaScript library for handling singular possessive apostrophes with support for international names
Downloads
83
Maintainers
Readme
possessive-js
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