Skip to content

Latest commit

 

History

History
293 lines (129 loc) · 6.33 KB

README.md

File metadata and controls

293 lines (129 loc) · 6.33 KB

bible.js

Support me on Patreon Buy me a book PayPal Ask me anything Version Downloads Get help on Codementor

Buy Me A Coffee

The Bible as a NPM module.

☁️ Installation

# Using npm
npm install --save bible.js

# Using yarn
yarn add bible.js

📋 Example

const Bible = require("bible.js");

// Init Bible
Bible.init({
    versions: {
        en: {
            source: "https://github.com/BibleJS/bible-english"
          , version: "master"
          , language: "en"
        },
        ro: {
            source: "https://github.com/BibleJS/bible-romanian"
          , version: "master"
          , language: "ro"
        }
    }
}, err => {
    if (err) { throw err; }

    // Create Bible instances
    const displayVerses = lang => {
        return (err, data) => {
            if (err) { throw err; }

            console.log("-------------");

            (data || []).forEach(c => {
                console.log(c.verse + " | " + c.text);
            })

            console.log("-------------\n");
        }
    }

    // Get a specific Bible verse in English
    const enBible = new Bible({ language: "en" })
    enBible.get("Psalm 1:1-6", displayVerses("en"));

    // Get a specific Bible verse in Romanian
    const roBible = new Bible({ language: "ro" })
    roBible.get("Psalmii 1:1-6", displayVerses("ro"));

    // Search
    roBible.search("/meroza/gi", displayVerses("ro"));
});

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. 🐛
  3. For direct and quick help, you can use Codementor. 🚀

📝 Documentation

init(config, cb)

Inits BibleJS submodules by downloading them as set in the config object This method should be called before initializing the BibleJS instance.

Params

  • Object config: The configuration object containing the following field:
  • versions (Object)
    • <version_name> (Object)
      • source (String): The git url of the BibleJS submodule.
      • version (String): The git tag or branch of the submodule.
      • language (String): The submodule language.
  • Function cb: The cb function.

Return

  • BibleJS The BibleJS constructor.

BibleJS(options)

Creates a new BibleJS instance.

Params

  • Object options: An object containing the following fields:
  • language: the langauge of the BibleJS instance (default: "en").

Return

  • BibleJS The BibleJS instance.

get(reference, cb)

This function gets the response providing the BibleJS reference.

Params

  • String reference: The verse reference. It can be in the following formats:
e.g. Genesis 1:1  - returns one verse
or Genesis 1:1,2  - returns two verses (1 and 2)
or Genesis 1:1-10 - returns the verses 1 - 10
or Genesis 1      - returns the whole chapter
  • Function cb: The cb function.

Return

  • BibleJS The BibleJS instance (this).

search(query, cb)

This function gets the verses that match to the regular expression provided.

Params

  • String|RegExp query: The string/regular expression that matches the searched verses.
  • Function cb: The cb function

Return

  • BibleJS The BibleJS instance (this)

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💖 Support my projects

I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like 🚀

  • Buy me a book—I love books! I will remember you after years if you buy me one. 😁 📖

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! ❤️

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • bible-sample-config
  • bible

📜 License

MIT © Ionică Bizău