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

kontractions

v0.0.11

Published

Handle contractions with ease.

Downloads

20

Readme

    __                    __                           __     _                        
   / /__  ____    ____   / /_   _____  ____ _  _____  / /_   (_)  ____    ____    _____
  / //_/ / __ \  / __ \ / __/  / ___/ / __ `/ / ___/ / __/  / /  / __ \  / __ \  / ___/
 / ,<   / /_/ / / / / // /_   / /    / /_/ / / /__  / /_   / /  / /_/ / / / / / (__  )
/_/|_|  \____/ /_/ /_/ \__/  /_/     \__,_/  \___/  \__/  /_/   \____/ /_/ /_/ /____/  

A small javascript library for converting to and fro' contractions.

Install

npm i --save kontractions or yarn add kontractions

Basic Usage

ES6

import kontractions from 'kontractions'

Node Modules

const kontractions = require('kontractions')

API

  • kontractions.contract(string): Converts a string containing longforms to a string containing contractions.
  • kontractions.expand(string): Converts a string containing contractions to a string containing longforms, or the various possible longforms.
  • kontractions.updateContractions(object): Accepts an object and can be used for extending, modifying, or disabling the built-in default contractions.
  • kontractions.updateLongforms(object): Accepts an object and can be used for extending, modifying, or disabling the built-in default longforms.

Examples

  • kontractions.contract("I did not do it.") //=> i didn't do it.
  • kontractions.expand("I didn't do it.") //=> i did not do it.
  • kontractions.expand("I hope there's more food.") //=> i hope (( there has || there is )) more food.
  • kontractions.updateContractions({"they'd've": ['they would have']}) //=> The contraction they'd've will now be recognized when using the contract method.
  • kontractions.updateLongforms({"they would have": "they'd've"}) //=> The longform they would have will now be recognized when using the expand method.
  • kontractions.updateContractions({"they'd've": ['they would have']}) //=> Pass a falsy value to disable a contraction.
  • kontractions.updateLongforms({"they would have": false}) //=> Pass a falsy value to disable a longform.

Defaults

Philosophy

This library aims to one thing and do it well. With regards to the expand method, while it would be possible to examine the context in which contractions are used to determine the proper expansion, that will likely remain beyond the scope of this package. Therefore, consumers will need to implement their own logic to examine the output and pick the correct expansion.

Contributions

All contributors will receive proper attribution, as outlined in the awesome All-Contributors specification developed by open-source superstar Kent C. Dodds.

Development Setup

This project was bootstrapped with Babel Starter Kit. To get started with development, fork this repo and make edits to the src directory. Install dependencies with npm install or yarn. Run tests with npm test.

License

kontractions is available under MIT. See LICENSE for more details.

To-do

  • Add option to enable 3-word+ contractions