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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lc_call_number_compare

v0.0.1

Published

Provides functions to compare and sort Library of Congress Classification (LC) call numbers.

Downloads

21

Readme

LC Call Number Compare

LC Call Number Compare is a simple ES6 module that provides functions to compare and sort Library of Congress Classification (LC) call numbers.

Usage

Installation

$ npm install --save lc_call_number_compare

Example

var lc = require('lc_call_number_compare');

var x = 'HF5381 .S5145 2008',
    y = 'PE1479 .B87 O93 1993',
    z = 'AM101 .S3533 L58 1987b',
    result;

result = lc.cmp(x, y);  /* a negative value */
result = lc.cmp(y, x);  /* a positive value */
result = lc.cmp(x, x);  /* 0 */

result = lc.eq(x, y);   /* false */
result = lc.gt(x, y);   /* false */
result = lc.gte(x, y);  /* false */
result = lc.lt(x, y);   /* true */
result = lc.lte(x, y);  /* true */

result = [x, y, z].sort(lc.cmp);  /* [z, x, y] */

result = [x, y, z].sort((x, y) => {
  return lc.cmp(x, y, { case_sensitive: true });
});

Common options

Options can passed to the functions as an additional argument:

result = lc.cmp(a, b, { case_sensitive: true });

case_sensitive: boolean

Indicates whether comparisons should be case-sensitive. Defaults to false.

Functions

cmp

Compares two strings that are LC call numbers.

Returns a positive value if the first call number is greater than the second call number.

Returns a negative value if the first call number is less than the second call number.

Return 0 if the first call number is equal to the second call number.

eq, gt, gte, lt, lte

Compares two strings that are LC call numbers.

eq returns true if the first call number is equal to the second call number, false if otherwise.

gt returns true if the first call number is greater than the second call number, false if otherwise.

gte returns true if the first call number is greater than or equal to the second call number, false if otherwise.

lt returns true if the first call number is less than the second call number, false if otherwise.

lte returns true if the first call number is less than or equal to the second call number, false if otherwise.

Expected call number format

The library expects the LC call number to look like:

|Part|Description |---|--- |QH91.75|Class number |.C2|First cutter |C38|Second cutter |2005b|Date of publication |Suppl.|Supplementary information

The call number should be written as a single string with no newlines e.g. 'QH91.75.C2 C38 2005b Suppl.'.

Whitespace between the class number and the first cutter is optional.

Whitespace between the first and second cutters and the supplement information is mandatory.

The cutter numbers and the date of publication can have work letters appended.

The code does its best to match as long a sequence as possible. In the case of a partial match (e.g. only the class number is matched) the remainder of the call number will be regarded as supplementary information, which is sorted in simple alphabetical order.

License

Except where otherwise stated, this project is released under the MIT License.