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

tibetan-sort-js

v2.1.4

Published

Tibetan string sorting according to customary native order

Downloads

20

Readme

JS Library to sort Tibetan

After exploring different options for tibetan collation in JavaScript, there seems to be no viable option to sort Unicode Tibetan strings. This library hopes to fullfill this purpose in an elegant, modern and efficient manner.

State of the art

The most logical option to sort Tibetan would by using Intl.Collator. The problem is that all browsers seems to use ICU to implement this object, and ICU has a bug on Tibetan collation, which won't be fixed in the short term. It will take even more time for the fix to appear in mainstream browsers, so it's not even a middle term solution. Bugs have been filled for Firefox, ChakraCore, Chrome and Safari.

Pure Javascript implementations of Intl.Collator don't seem to exist, as the only Intl polyfill doesn't support it.

The only library we found that would be of possible use is lasca, but it proved very buggy and extremely inefficient.

This implementation

This implementation aims at being very efficient, at the cost of difficult corner cases in Tibetan. As a consequence:

  • it does not normalize strings (\u0F77 is not treated like \u0FB2\u0F71\u0F80)
  • it does not handle Sanskrit stacks very precisely (the ICU rule &ཀར<ཀརྐ is too difficult to handle)

Installation

yarn add tibetan-sort-js --save

API

compare

Compares two strings in Tibetan Unicode, can be used as argument of Array.compare(). The behavior is undefined if the arguments are not strings. Doesn't workswell with non-Tibetan strings.

Parameters

  • a string first string to be compared.
  • b string second string to be compared.

Returns number 0 if equivalent, 1 if a > b, -1 if a < b

compareEwts

Compares two strings in EWTS, has the same argument and return value as compare. The function only works on customary EWTS and doesn't handle oddly encoded cases such as b.r+g+ya (instead of brgya).

TODO

  • add an option to normalize strings?

Release history

See change log.

License

The code is Copyright 2017-2019 Buddhist Digital Resource Center, and is provided under the MIT License.