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-snippets

v1.0.2

Published

An npm package to get Bible verses, random verses, Psalms, and promises.

Downloads

175

Readme

Bible-Snippets

Bible-Snippets is an npm package that allows you to fetch specific Bible verses, random verses, Psalms, and Bible promises. This package is perfect for developers looking to integrate Bible verses into their applications, websites, or spiritual projects.

Features

  • Retrieve any Bible verse given the book, chapter, and verse number.
  • Get a random Bible verse.
  • Retrieve a range of verses from a specified book and chapter.
  • Get a random Psalm.
  • Get a random Bible promise.

Installation

You can install the package via npm. Open your terminal and run:

npm install bible-snippets

Usage

Importing the Package

To use the package in your project, first import it:

const BibleVerse = require("bible-snippets");

Creating an Instance

You can create an instance of the BibleVerse class:

const bibleVerse = new BibleVerse();

1. Fetching a Specific Bible Verse

To retrieve a specific Bible verse, provide the book name, chapter, and verse number:

bibleVerse
  .getVerse("John", 3, 16)
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

Example Output:

{
  "reference": "John 3:16",
  "verses": [
    {
      "book_id": "JHN",
      "book_name": "John",
      "chapter": 3,
      "verse": 16,
      "text": "For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life."
    }
  ],
  "text": "For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life.",
  "translation_id": "web",
  "translation_name": "World English Bible",
  "translation_note": "Public Domain"
}

2. Getting a Random Bible Verse

You can easily fetch a random Bible verse with the following method:

bibleVerse
  .getRandomVerse()
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

Example Output:

{
  "reference": "Luke 19:32",
  "verses": [
    {
      "book_id": "LUK",
      "book_name": "Luke",
      "chapter": 19,
      "verse": 32,
      "text": "Those who were sent went away, and found things just as he had told them."
    }
  ],
  "text": "Those who were sent went away, and found things just as he had told them.",
  "translation_id": "web",
  "translation_name": "World English Bible",
  "translation_note": "Public Domain"
}

3. Fetching a Range of Verses

To get a range of verses, you can specify the book, chapter, starting verse, and ending verse:

bibleVerse
  .getVerseRange("Psalms", 23, 1, 3)
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

Example Output:

{
  "reference": "Psalms 23:1-3",
  "verses": [
    {
      "book_id": "PSA",
      "book_name": "Psalms",
      "chapter": 23,
      "verse": 1,
      "text": "Yahweh is my shepherd:\nI shall lack nothing."
    },
    {
      "book_id": "PSA",
      "book_name": "Psalms",
      "chapter": 23,
      "verse": 2,
      "text": "He makes me lie down in green pastures.\nHe leads me beside still waters."
    },
    {
      "book_id": "PSA",
      "book_name": "Psalms",
      "chapter": 23,
      "verse": 3,
      "text": "He restores my soul.\nHe guides me in the paths of righteousness for his name’s sake."
    }
  ],
  "text": "Yahweh is my shepherd:\nI shall lack nothing.\nHe makes me lie down in green pastures.\nHe leads me beside still waters.\nHe restores my soul.\nHe guides me in the paths of righteousness for his name’s sake.",
  "translation_id": "web",
  "translation_name": "World English Bible",
  "translation_note": "Public Domain"
}

4. Getting a Random Psalm

To retrieve a random Psalm, use the following method:

bibleVerse
  .getRandomPsalm()
  .then((randomPsalm) => console.log(randomPsalm))
  .catch((error) => console.error(error));

Example Output:

{
  "book": "Psalm",
  "chapter": 28,
  "verse": 7,
  "text": "The Lord is my strength and my shield; in him my heart trusts."
}

5. Getting a Random Bible Promise

You can fetch a random Bible promise like this:

bibleVerse
  .getRandomPromise()
  .then((randomPromise) => console.log(randomPromise))
  .catch((error) => console.error(error));

Example Output:

{
  "book": "2 Corinthians",
  "chapter": 12,
  "verse": 9,
  "text": "But he said to me, 'My grace is sufficient for you, for my power is made perfect in weakness.'"
}

Error Handling

The methods will throw errors if the provided parameters are invalid. Make sure to handle these exceptions appropriately.

Example of Error Handling

try {
  await bibleVerse.getVerse("InvalidBook", 1, 1);
} catch (error) {
  console.error(error.message);
}

Acknowledgments

Special thanks to the creators and maintainers of Bible API for providing a valuable resource for accessing Bible verses and scriptures. Your hard work makes it easier for developers to integrate spiritual content into their applications.

Contribution

Contributions are welcome! If you want to contribute to this package, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit them (git commit -am 'Add a new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.