Giter Club home page Giter Club logo

shnayimmikrah's Introduction

Shnayim Mikrah

This project serves as a wrapper over the Sefaria api to enable presenting Shnayim Mikrah text by Aliyah.

On-line Support

Request

The following arguments can be set to control what data is returned:

interface Args {
  /**
   * Used to determine what date we need to look at in order to return the correct Aliyah
   * Must be a valid IANA time zone string, such as Asia/Jerusalem, America/New_York, Europe/Paris, etc.
   */
  timezone: string;
  /**
   * Used to specify if you want the parasha according to the diaspora calendar or according to the Israel calendar. 
   * Default is diaspora=1 to get the diaspora version.
   */
  diaspora?: number;
  /**
   * Used to control what ALiyah is returned. Default is the Aliyah for the day of the week.
   */
  aliyah?: 1 | 2 | 3 | 4 | 5 | 6 | 7; 

	/**
	 * What version should be used for the Hebrew text
	 */
	hebrewTextVersion: HebrewTextVersionOptions;
	
	/**
	 * What version should be used for the English text
	 */
	englishTextVersion: EnglishTextVersionOptions;
}
import getShnayimMikrah from '@orthodox-union/shnayimmikrah';

// This will return the Shnayim Mikrah for todays aliyah as would be leined in the America/New_York timezone.
await getShnayimMikrah({
  timezone: 'America/New_York'
});

Response

The data returned will have the following shape:

interface Aliyah {
    book: 'Genesis' | 'Exodus' | 'Leviticus' | 'Numbers' | 'Deuteronomy';
    aliyah: 1 | 2 | 3 | 4 | 5 | 6 | 7;
    verseRange: string; // Genesis 30:14-30:27
    verses: Array<{
      book: 'Genesis' | 'Exodus' | 'Leviticus' | 'Numbers' | 'Deuteronomy';
      chapter: number;
      verse: number;
      hebrewText: string;
      englishText: string;
      targum: string;
      rashi: string[];
    }>;
}

Off-line Support

Download

To download the data, you have the following options

interface DownloadArgs {
	/**
	 * Should the entire Chumash be download.
	 * Will take predence over `book`
	 */
	all: boolean;
	/**
	 * The Book you want to download.
	 */
	book: BookName;
	/**
	 * How the data should be stored
	 * @param {data} data The data being saved
	 */
	save: (data: OfflineStorage) => void;
	/**
	 * What version should be used for the Hebrew text
	 */
	hebrewTextVersion: HebrewTextVersionOptions;
	
	/**
	 * What version should be used for the English text
	 */
	englishTextVersion: EnglishTextVersionOptions;
}

Request

interface OfflineArgs {
	/**
   * Tells the package how to get the data.
   */
  getData: (book: BookName) => Promise<OfflineStorage>;
  /**
   * The book the Parsha is in.
   * Used in the getData function
   */
  book: BookName;
	/**
   * The Parsha to return.
   */
	parsha: ParshaName;
	/**
   * Used to control what ALiyah is returned. Default is the Aliyah for the day of the week.
   */
	aliyah?: AliyahNumber;
	/**
   * If true, the entire Parsha of the week will be returned.
   */
	wholeParsha?: boolean;
}

Response

If you request a single Aliyah, the response will be the same as offline support.

Otherwise you will get the entire Parsha:

interface Parsha {
	name: ParshaName;
	book: BookName;
	fullRef: string;
	aliyot: Aliyah[];
}

shnayimmikrah's People

Contributors

m-zuber avatar dependabot[bot] avatar shelomo avatar chaimpaneth avatar

Stargazers

 avatar Sevi avatar Michoel Samuels avatar Binyamin Aron Green avatar

Watchers

 avatar  avatar Benjamin avatar James Cloos avatar  avatar  avatar

shnayimmikrah's Issues

Tests

parseRange should be moved to utils file and tested
the main function should be tested as well

Query by Sefaria ref

We should accept a Sefaria ref (Genesis 30:14-30:27 for example).
If one is passed in, we can skip the call to the calendar endpoint.

Support asking for a specific parsha (+ aliyah)

We will need to have a hardcoded list that maps the Parsha name to either a ref or a known date.
If we are using a map to a ref, we need to then also have a map to refs for each Aliyah.

Side note - if they ask only for a Parsha, do we then return the entire Parsha, or just that days Aliyah?

Support instance with 3 Sifrei Torah

If there is a Shabbos with 3 Sifrei Torah, the responses can sometimes be incorrect as there is a flow-over in the response to Maftir

Per my recollection, this might only happen if it is also a double Parsha

Handle YomTov

The response from the calendar endpoint is shaped in a way such that the code will work, but we should either short circuit with a specific exception, or include an indication in the response

Query by date

The call to get the calendar supports sending in a day, month, year.
We should accept that and pass it through to give more control on the data that is returned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.