@hudabook/qur
v0.0.4
Published
A web decoder for Quran File Format.
Downloads
15
Readme
Quran File Format Decoder
A web decoder for Quran File Format.
Table of Contents
Prerequisites
This implementation is intended for web browsers, esm and cjs builds are available.
Installation
npm install @hudabook/qur --save
Usage
import { QuranFileFormat } from '@hudabook/qur';
// make sure your server can respond to the following GET request
const response = await fetch('uthmani.qur');
const buffer = await response.arrayBuffer();
const qur = new QuranFileFormat(buffer);
const suraAlFatiha = qur.sura(1); // Sura Reference Starts at 1
if (suraAlFatiha.status === 'success') {
const { value } = suraAlFatiha;
const content = value.toString();
console.log(content); // logs sura Al Fatiha content to console
}
API
interface QuranFileFormat {
new(buffer: ArrayBuffer): QuranFileFormat;
sura(sura_ref: number): Result<QuranSura>;
}
interface QuranSura {
toString(): string
}
interface Result<Value> {
status: 'success' | 'error'
value?: Value
error?: string
}
Contributing
Contributions are welcome, Feel free to raise a PR here
Specifications
Quran File format specifications can be found here
License
This package is distributed under MIT license.