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

@coffeeio/hypher

v1.0.0

Published

A fast and small hyphenation engine

Downloads

46

Readme

Hypher

Fork of hyphenation library to remove jQuery and delete unused code.

A small and fast JavaScript hyphenation engine. Can be used in Node.js and as a jQuery plugin.

Node.js

Hypher can be installed from NPM:

npm install hypher hyphenation.en-us

You can then use it in your program by creating an instance of Hypher and giving it a language object:

var Hypher = require('hypher'),
    english = require('hyphenation.en-us'),
    h = new Hypher(english);

// returns ['hy', 'phen', 'ation']
h.hyphenate('hyphenation');

See examples/node/ for a full example on how to use Hypher. The hyphenate method does not support hyphenated compound words. These should be split into individual words before being passed to the hyphenation engine and reassembled afterwards by the caller. You can also use the hyphenateText method to hyphenate a string of text. The hyphenateText method does support compound words and returns a string with inserted soft hyphens (\u00AD.)

// returns 'Hy|phen|ation is use|ful when cen|ter jus|ti|fy|ing a text.' where `|` is a soft hyphen
h.hyphenateText('Hyphenation is useful when center justifying a text.');

The hyphenateText method takes an optional second parameter minLength which is the minimum length a word should have to be considered for hyphenation (defaults to 4.) Note that an instance of the Hypher class should only be created once for each language object.

The language object should contain:

{
  // The minimum number of unhyphenated characters at the left of each word. (required)
  leftmin: <number>,

  // The minimum number of unhyphenated characters at the right of each word. (required)
  rightmin: <number>,

  // A comma separated list of hyphenation exceptions. Custom hyphenations
  // can be specified using '\u2027' (hyphenation point) as hyphenation
  // character. List items are case-insensitive. (Optional)
  exceptions: <string>,

  // A patterns object (required)
  patterns: {}
}

Language patterns can be found in the patterns repository.

License

Hypher is licensed under the three clause BSD license (see BSD.txt.)

See also

Contributors

  • Laurens Meurs - improvements to the exception list