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

bible-abbreviation

v1.0.7

Published

Easily obtain the universal identifiers and full names of the books of the Bible in a variety of formats and languages.

Downloads

40

Readme

bible-abbreviation

npm version

Easily obtain the universal identifiers and full names of the books of the Bible in a variety of formats and languages.

Table of Contents

⚙️ Installation

npm install bible-abbreviation

📑 Usage

const { Abbreviator } = require('bible-abbreviation');
const abbrv = new Abbreviator();

1️⃣ Get universal tag for a given abbreviation

The first feature of the Abbreviator is the getTag method, which provides a universal code for a Bible book based on an abbreviation you give it:

const abbrv = new Abbreviator();
const matthewTag = abbrv.getTag('Matthew');
console.log(matthewTag); // output : 'MT'

This method supports a very wide variety of abbreviations, for example MT will be returned for the following values: matthieu, mt, matt, mat, matthew. You can view all the supported abbreviations per book in the file canonAbbrv.json.

2️⃣ Generate a title for a given book

The second feature of this module is the getTitle method, which generates a title in a given language and format, for a book given as a parameter:

const abbrv = new Abbreviator();
const matthewTitle = abbrv.getTitle('Matt');
console.log(matthewTitle); // output : 'Matthew'

By default, the Abbreviator is set to English, but you can also directly instantiate the object with the language of your choice from among those available (see Internationalization section) by giving the constructor the identifier of the desired language.

// abbreviator in french
const abbrv = new Abbreviator('fr');
const matthewTitle = abbrv.getTitle('Matt');
console.log(matthewTitle); // output : 'Matthieu'

You can of course change the language at any time by using the setLang method on the instantiated object.

const abbrv = new Abbreviator(); // abbrv in english
abbrv.setLang('fr'); // abbrv is now in french

By default, the title format is set to short, but you can set the default format to long, short or tiny at any time according to your preference using the setSize method:

const abbrv = new Abbreviator();
abbrv.setSize('long'); // abbrv's title size are now set to 'long'
const matthewTitle = abbrv.getTitle('Matt');
console.log(matthewTitle) // output : Gospel according to Matthew

Here's the different available formats

  • long — Detailed title (ex: Mt → Gospel according to Matthew)
  • short — Short book title (ex: 2 Thess → 2 Thessalonians)
  • tiny — Abbréviation standard (ex: Genesis → Gn)

You can also access a particular format without having to change the default value by providing the desired size as the second parameter of the getTitle function:

const abbrv = new Abbreviator();
abbrv.setSize('long'); // abbrv's title size are now set to 'long'

let matthewTitle = abbrv.getTitle('Matt', 'short'); // return a short title even if you set size to long because you explicitly asked for a short size here
console.log(matthewTitle) // output : "Matthew"

matthewTitle = abbrv.getTitle('Matthew'); // no explicit format here so the method return the title with the default size
console.log(matthewTitle) // output : Gospel according to Matthew

⚡ Error handling

For a better user experience, the Abbreviator class methods don't throw any exceptions. The getTag and getTitle methods will return null if the book provided as a parameter does not exist. For getTitle, if the given format is unknown, the default parameter previously defined (by the constructor or by you) will be used. In the same way, for setSize and setLang, if the respective parameters provided are not supported, the default parameters will be reset to their initial values, short and en_US respectively. Finally, to optimize loading of i18n data, if you try to set the language to the same value as the current one, the class will detect it and will not make any changes.

🌍 Internationalization

English and French are the only two languages supported at the moment. We'll be working on integrating other languages in the future, but if you'd like to see a language available on the module quickly, please open a PR on our Github.

❓ Notes

As the class is designed so that parameters can be modified at any time, it is theoretically unnecessary to instantiate multiple Abbreviator objects. As each instance of Abbreviator loads a JSON file in the corresponding language, it is strongly recommended not to instantiate multiple objects of the Abbreviator class for performance optimization reasons.

We're working on a new structure for the i18n internationalization folder to optimize data loading. This improvement is not a high priority, since the module currently supports only two languages, but the release of this optimization will be backward-compatible.

💻 Contribute

Want to improve the module? submit a pull-request on github or open an issue.

📜 License

Copyright © 2023 RyanHmd This project is MIT licensed.