UNPKG

@kmaslesa/tajweed

Version:

Qur'an ayahs tajweed

48 lines (47 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAyahByIndexAsync = exports.getAllAyahsAsync = exports.getAyahByIndex = exports.getAllAyahs = void 0; const tajweed_ts_1 = require("tajweed-ts"); const ayahs = require('./data.json'); // Synchronous version const getAllAyahs = () => { return ayahs; }; exports.getAllAyahs = getAllAyahs; const getAyahByIndex = (index, withParsedTajweed) => { if (index >= 1 && index <= 6236) { const ayah = ayahs[index - 1]; if (withParsedTajweed) { const tajweedParser = new tajweed_ts_1.Tajweed(); return tajweedParser.parse(ayah, true); } else { return ayah; } } else { throw new Error('Invalid page number, valid range 1-6236'); } }; exports.getAyahByIndex = getAyahByIndex; // Asynchronous version const getAllAyahsAsync = async () => { return ayahs; }; exports.getAllAyahsAsync = getAllAyahsAsync; const getAyahByIndexAsync = async (index, withParsedTajweed) => { if (index >= 1 && index <= 6236) { const ayah = ayahs[index - 1]; if (withParsedTajweed) { const tajweedParser = new tajweed_ts_1.Tajweed(); return tajweedParser.parse(ayah, true); } else { return ayah; } } else { throw new Error('Invalid page number, valid range 1-6236'); } }; exports.getAyahByIndexAsync = getAyahByIndexAsync;