mirror of
https://github.com/acamarata/moment-hijri-plus.git
synced 2026-06-30 18:54:29 +00:00
chore: P1 polish and documentation updates
This commit is contained in:
parent
b96b21a861
commit
94d8b8f8c2
18 changed files with 1607 additions and 146 deletions
6
.github/wiki/_Sidebar.md
vendored
6
.github/wiki/_Sidebar.md
vendored
|
|
@ -10,6 +10,12 @@
|
|||
|
||||
**Reference**
|
||||
- [API Reference](API-Reference)
|
||||
- [installHijri](api/installHijri)
|
||||
- [toHijri](api/toHijri)
|
||||
- [fromHijri](api/fromHijri)
|
||||
- [formatHijri](api/formatHijri)
|
||||
- [hijriYear / hijriMonth / hijriDay](api/hijriYear-hijriMonth-hijriDay)
|
||||
- [isValidHijri](api/isValidHijri)
|
||||
- [Architecture](Architecture)
|
||||
- [Benchmarks](benchmarks/index)
|
||||
|
||||
|
|
|
|||
2
.github/wiki/api/functions/default.md
vendored
2
.github/wiki/api/functions/default.md
vendored
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
> **default**(`momentInstance`): `void`
|
||||
|
||||
Defined in: [src/index.ts:150](https://github.com/acamarata/moment-hijri-plus/blob/50b666503568cb2ef81d0a7fc2aeefa6cb395aa5/src/index.ts#L150)
|
||||
Defined in: [src/index.ts:150](https://github.com/acamarata/moment-hijri-plus/blob/b96b21a86195492a30c50860eaa4dcadad9946ab/src/index.ts#L150)
|
||||
|
||||
Install the Hijri plugin into the provided Moment.js instance.
|
||||
|
||||
|
|
|
|||
32
.github/wiki/examples/basic-usage.md
vendored
32
.github/wiki/examples/basic-usage.md
vendored
|
|
@ -1,10 +1,10 @@
|
|||
# Basic Usage Examples
|
||||
# Basic Usage
|
||||
|
||||
## Setup
|
||||
|
||||
```typescript
|
||||
import moment from 'moment';
|
||||
import { installHijri } from 'moment-hijri-plus';
|
||||
import installHijri from 'moment-hijri-plus';
|
||||
|
||||
installHijri(moment);
|
||||
```
|
||||
|
|
@ -14,7 +14,7 @@ installHijri(moment);
|
|||
```typescript
|
||||
const today = moment();
|
||||
const h = today.toHijri();
|
||||
// Returns null if date is outside UAQ range; guard before using
|
||||
// Returns null if date is outside the UAQ range; guard before use.
|
||||
|
||||
if (h !== null) {
|
||||
console.log(`${h.hd} / ${h.hm} / ${h.hy}`);
|
||||
|
|
@ -27,16 +27,16 @@ if (h !== null) {
|
|||
// 23 March 2023 = 1 Ramadan 1444 AH
|
||||
const m = moment('2023-03-23');
|
||||
|
||||
console.log(m.iYear()); // 1444
|
||||
console.log(m.iMonth()); // 9 (Ramadan is the 9th month)
|
||||
console.log(m.iDate()); // 1
|
||||
console.log(m.hijriYear()); // 1444
|
||||
console.log(m.hijriMonth()); // 9 (Ramadan is the 9th month)
|
||||
console.log(m.hijriDay()); // 1
|
||||
```
|
||||
|
||||
## Convert from Hijri to Gregorian
|
||||
|
||||
```typescript
|
||||
const gregorian = moment.fromHijri(1444, 9, 1);
|
||||
console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23'
|
||||
console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23'
|
||||
```
|
||||
|
||||
## Format with Hijri tokens
|
||||
|
|
@ -44,10 +44,10 @@ console.log(gregorian.format('YYYY-MM-DD')); // '2023-03-23'
|
|||
```typescript
|
||||
const m = moment('2023-03-23');
|
||||
|
||||
m.format('iD iMMMM iYYYY'); // '1 Ramadan 1444'
|
||||
m.format('iDD/iMM/iYYYY'); // '01/09/1444'
|
||||
m.format('YYYY-MM-DD'); // '2023-03-23' (Gregorian tokens still work)
|
||||
m.format('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)'
|
||||
m.formatHijri('iD iMMMM iYYYY'); // '1 Ramadan 1444'
|
||||
m.formatHijri('iDD/iMM/iYYYY'); // '01/09/1444'
|
||||
m.formatHijri('YYYY-MM-DD'); // no Hijri tokens; passes through to moment.format
|
||||
m.formatHijri('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)'
|
||||
```
|
||||
|
||||
## Use FCNA calendar
|
||||
|
|
@ -55,21 +55,21 @@ m.format('YYYY (iYYYY/iM/iD)'); // '2023 (1444/9/1)'
|
|||
```typescript
|
||||
const m = moment('2023-03-23');
|
||||
|
||||
const uaqYear = m.iYear(); // UAQ (default)
|
||||
const fcnaYear = m.iYear({ calendar: 'fcna' }); // FCNA
|
||||
const uaqYear = m.hijriYear(); // UAQ (default)
|
||||
const fcnaYear = m.hijriYear({ calendar: 'fcna' }); // FCNA
|
||||
|
||||
console.log(uaqYear, fcnaYear);
|
||||
// Near month boundaries, UAQ and FCNA may differ by one day
|
||||
// Near month boundaries, UAQ and FCNA may differ by one day.
|
||||
```
|
||||
|
||||
## CJS usage
|
||||
|
||||
```javascript
|
||||
const moment = require('moment');
|
||||
const { installHijri } = require('moment-hijri-plus');
|
||||
const installHijri = require('moment-hijri-plus').default;
|
||||
|
||||
installHijri(moment);
|
||||
|
||||
const m = moment('2023-03-23');
|
||||
console.log(m.iYear()); // 1444
|
||||
console.log(m.hijriYear()); // 1444
|
||||
```
|
||||
|
|
|
|||
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
|
|
@ -78,3 +78,25 @@ jobs:
|
|||
grep "README.md" pack-output.txt
|
||||
grep "CHANGELOG.md" pack-output.txt
|
||||
grep "LICENSE" pack-output.txt
|
||||
|
||||
coverage:
|
||||
name: Coverage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm run build
|
||||
- name: Coverage
|
||||
run: pnpm run coverage
|
||||
- name: Upload to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
files: ./coverage/lcov.info
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
fail_ci_if_error: false
|
||||
|
|
|
|||
145
README.md
145
README.md
|
|
@ -4,7 +4,9 @@
|
|||
[](https://github.com/acamarata/moment-hijri-plus/actions/workflows/ci.yml)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
Moment.js plugin for Hijri calendar conversion and formatting. Delegates all calendar logic to [hijri-core](https://github.com/acamarata/hijri-core), a zero-dependency Hijri engine with pluggable calendar support.
|
||||
Moment.js plugin for Hijri calendar conversion and formatting. Delegates all calendar
|
||||
logic to [hijri-core](https://github.com/acamarata/hijri-core), a zero-dependency Hijri
|
||||
engine with pluggable calendar support (Umm al-Qura and FCNA/ISNA).
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
@ -12,148 +14,55 @@ Moment.js plugin for Hijri calendar conversion and formatting. Delegates all cal
|
|||
pnpm add moment moment-hijri-plus hijri-core
|
||||
```
|
||||
|
||||
Both `moment` and `hijri-core` are peer dependencies and must be installed alongside this package.
|
||||
Both `moment` and `hijri-core` are peer dependencies.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
import moment from 'moment';
|
||||
import installHijri from 'moment-hijri-plus';
|
||||
|
||||
// Install the plugin once at startup.
|
||||
installHijri(moment);
|
||||
|
||||
// Convert a Gregorian date to Hijri.
|
||||
const m = moment(new Date(2023, 2, 23)); // 23 March 2023
|
||||
const hijri = m.toHijri();
|
||||
// => { hy: 1444, hm: 9, hd: 1 } (1 Ramadan 1444 AH)
|
||||
m.toHijri(); // { hy: 1444, hm: 9, hd: 1 } (1 Ramadan 1444 AH)
|
||||
m.formatHijri('iD iMMMM iYYYY AH'); // '1 Ramadan 1444 AH'
|
||||
|
||||
// Format using Hijri tokens.
|
||||
m.formatHijri('iD iMMMM iYYYY AH');
|
||||
// => '1 Ramadan 1444 AH'
|
||||
|
||||
// Construct a moment from a Hijri date.
|
||||
const start = moment.fromHijri(1446, 1, 1);
|
||||
// => moment representing 7 July 2024 (1 Muharram 1446 AH)
|
||||
moment.fromHijri(1446, 1, 1); // moment for 7 July 2024
|
||||
```
|
||||
|
||||
## API
|
||||
## API Summary
|
||||
|
||||
### Instance methods
|
||||
Call `installHijri(moment)` once at startup to add these methods.
|
||||
|
||||
All methods are added to `moment.Moment` by calling `installHijri(moment)` once.
|
||||
|
||||
| Method | Signature | Description |
|
||||
| Method | Returns | Description |
|
||||
| --- | --- | --- |
|
||||
| `toHijri` | `(options?) => HijriDate \| null` | Convert to Hijri. Returns `null` if the date is outside the calendar range. |
|
||||
| `hijriYear` | `(options?) => number \| null` | Hijri year, or `null` if out of range. |
|
||||
| `hijriMonth` | `(options?) => number \| null` | Hijri month (1-12), or `null` if out of range. |
|
||||
| `hijriDay` | `(options?) => number \| null` | Hijri day, or `null` if out of range. |
|
||||
| `isValidHijri` | `(options?) => boolean` | `true` if the date falls within the supported Hijri range. |
|
||||
| `formatHijri` | `(formatStr, options?) => string` | Format using Hijri tokens. Returns `''` if out of range. Non-Hijri tokens pass through to `moment.format()`. |
|
||||
| `toHijri(options?)` | `HijriDate \| null` | Convert to Hijri date object |
|
||||
| `hijriYear(options?)` | `number \| null` | Hijri year |
|
||||
| `hijriMonth(options?)` | `number \| null` | Hijri month (1-12) |
|
||||
| `hijriDay(options?)` | `number \| null` | Hijri day |
|
||||
| `isValidHijri(options?)` | `boolean` | True if date is within calendar range |
|
||||
| `formatHijri(fmt, options?)` | `string` | Format with Hijri tokens; non-Hijri tokens pass through |
|
||||
| `moment.fromHijri(hy, hm, hd, options?)` | `Moment` | Construct moment from Hijri date |
|
||||
|
||||
### Static factory
|
||||
Pass `{ calendar: 'fcna' }` to switch from the default Umm al-Qura calendar to FCNA/ISNA.
|
||||
|
||||
| Method | Signature | Description |
|
||||
| --- | --- | --- |
|
||||
| `moment.fromHijri` | `(hy, hm, hd, options?) => Moment` | Create a moment from a Hijri date. Throws if the date is invalid or out of range. |
|
||||
|
||||
### Options
|
||||
|
||||
```typescript
|
||||
interface ConversionOptions {
|
||||
calendar?: string; // 'uaq' (default) | 'fcna'
|
||||
}
|
||||
```
|
||||
|
||||
## Calendar Systems
|
||||
|
||||
| ID | Name | Description |
|
||||
| --- | --- | --- |
|
||||
| `uaq` | Umm al-Qura | Official calendar of Saudi Arabia. Tabular, covers AH 1318-1500 (1900-2076 CE). Default. |
|
||||
| `fcna` | FCNA/ISNA | Fiqh Council of North America calculated calendar. |
|
||||
|
||||
Pass the calendar ID via `options`:
|
||||
|
||||
```javascript
|
||||
m.toHijri({ calendar: 'fcna' });
|
||||
moment.fromHijri(1444, 9, 1, { calendar: 'fcna' });
|
||||
```
|
||||
|
||||
## Format Tokens
|
||||
|
||||
`formatHijri()` recognises the following tokens. All other tokens are passed through to `moment.format()`, so you can mix Hijri and Gregorian tokens freely.
|
||||
|
||||
| Token | Example | Description |
|
||||
| --- | --- | --- |
|
||||
| `iYYYY` | `1444` | Hijri year, 4 digits |
|
||||
| `iYY` | `44` | Hijri year, 2 digits |
|
||||
| `iMMMM` | `Ramadan` | Month long name |
|
||||
| `iMMM` | `Ramadan` | Month medium name |
|
||||
| `iMM` | `09` | Month, zero-padded |
|
||||
| `iM` | `9` | Month, no padding |
|
||||
| `iDD` | `01` | Day, zero-padded |
|
||||
| `iD` | `1` | Day, no padding |
|
||||
| `iEEEE` | `Yawm al-Khamis` | Weekday long name |
|
||||
| `iEEE` | `Kham` | Weekday short name |
|
||||
| `iE` | `5` | Weekday numeric (1=Sun, 7=Sat) |
|
||||
| `ioooo` | `AH` | Era, long |
|
||||
| `iooo` | `AH` | Era, short |
|
||||
|
||||
### Mixed format example
|
||||
|
||||
```javascript
|
||||
m.formatHijri('iD iMMMM iYYYY [CE:] MMMM YYYY');
|
||||
// => '1 Ramadan 1444 CE: March 2023'
|
||||
```
|
||||
|
||||
Bracket escaping (`[...]`) is handled by moment's own formatter for the Gregorian portion.
|
||||
|
||||
## TypeScript
|
||||
|
||||
The plugin augments `moment.Moment` and `moment.MomentStatic` via module declaration merging, so type safety applies after the plugin is installed. No extra imports are needed for the types.
|
||||
|
||||
```typescript
|
||||
import moment from 'moment';
|
||||
import installHijri from 'moment-hijri-plus';
|
||||
import type { HijriDate, ConversionOptions } from 'moment-hijri-plus';
|
||||
|
||||
installHijri(moment);
|
||||
|
||||
const hijri: HijriDate | null = moment().toHijri();
|
||||
```
|
||||
Full API reference, format token table, and examples are in the
|
||||
[project wiki](https://github.com/acamarata/moment-hijri-plus/wiki).
|
||||
|
||||
## Note on Moment.js
|
||||
|
||||
Moment.js is in maintenance mode. The authors recommend Luxon, Day.js, or date-fns for new projects. This package targets existing codebases already using Moment.js. If you are starting a new project, [dayjs-hijri-plus](https://github.com/acamarata/dayjs-hijri-plus) is a compatible alternative that works with Day.js.
|
||||
|
||||
## Architecture
|
||||
|
||||
A thin plugin wrapper over [hijri-core](https://github.com/acamarata/hijri-core). The plugin augments the Moment.js prototype with Hijri methods, each delegating to the registered calendar engine. Zero global state.
|
||||
|
||||
For more detail see the [Architecture wiki page](https://github.com/acamarata/moment-hijri-plus/wiki/Architecture).
|
||||
|
||||
## Documentation
|
||||
|
||||
Full API reference, architecture notes, and calendar algorithm details are in the [project wiki](https://github.com/acamarata/moment-hijri-plus/wiki).
|
||||
Moment.js is in maintenance mode. For new projects,
|
||||
[dayjs-hijri-plus](https://github.com/acamarata/dayjs-hijri-plus) offers the same Hijri
|
||||
support on Day.js. This package targets existing codebases already using Moment.js.
|
||||
|
||||
## Related
|
||||
|
||||
- [hijri-core](https://github.com/acamarata/hijri-core): zero-dependency Hijri calendar engine used by this plugin
|
||||
- [luxon-hijri](https://github.com/acamarata/luxon-hijri): same Hijri support for Luxon
|
||||
- [hijri-core](https://github.com/acamarata/hijri-core): Hijri calendar engine used internally
|
||||
- [dayjs-hijri-plus](https://github.com/acamarata/dayjs-hijri-plus): same API for Day.js
|
||||
- [luxon-hijri](https://github.com/acamarata/luxon-hijri): same API for Luxon
|
||||
- [pray-calc](https://github.com/acamarata/pray-calc): Islamic prayer time calculation
|
||||
|
||||
## Compatibility
|
||||
|
||||
- Node.js 20, 22, 24
|
||||
- Moment.js 2.x (peer dependency)
|
||||
- ESM and CJS builds included
|
||||
- TypeScript definitions bundled
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
Calendar data and algorithms provided by [hijri-core](https://github.com/acamarata/hijri-core). The Umm al-Qura table is derived from data published by the King Abdulaziz City for Science and Technology (KACST). FCNA new moon calculations follow Jean Meeus, "Astronomical Algorithms," 2nd ed., Chapter 49.
|
||||
|
||||
## License
|
||||
|
||||
MIT. Copyright (c) 2026 Aric Camarata.
|
||||
|
|
|
|||
224
coverage/lcov-report/base.css
Normal file
224
coverage/lcov-report/base.css
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
body, html {
|
||||
margin:0; padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
font-family: Helvetica Neue, Helvetica, Arial;
|
||||
font-size: 14px;
|
||||
color:#333;
|
||||
}
|
||||
.small { font-size: 12px; }
|
||||
*, *:after, *:before {
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
box-sizing:border-box;
|
||||
}
|
||||
h1 { font-size: 20px; margin: 0;}
|
||||
h2 { font-size: 14px; }
|
||||
pre {
|
||||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-moz-tab-size: 2;
|
||||
-o-tab-size: 2;
|
||||
tab-size: 2;
|
||||
}
|
||||
a { color:#0074D9; text-decoration:none; }
|
||||
a:hover { text-decoration:underline; }
|
||||
.strong { font-weight: bold; }
|
||||
.space-top1 { padding: 10px 0 0 0; }
|
||||
.pad2y { padding: 20px 0; }
|
||||
.pad1y { padding: 10px 0; }
|
||||
.pad2x { padding: 0 20px; }
|
||||
.pad2 { padding: 20px; }
|
||||
.pad1 { padding: 10px; }
|
||||
.space-left2 { padding-left:55px; }
|
||||
.space-right2 { padding-right:20px; }
|
||||
.center { text-align:center; }
|
||||
.clearfix { display:block; }
|
||||
.clearfix:after {
|
||||
content:'';
|
||||
display:block;
|
||||
height:0;
|
||||
clear:both;
|
||||
visibility:hidden;
|
||||
}
|
||||
.fl { float: left; }
|
||||
@media only screen and (max-width:640px) {
|
||||
.col3 { width:100%; max-width:100%; }
|
||||
.hide-mobile { display:none!important; }
|
||||
}
|
||||
|
||||
.quiet {
|
||||
color: #7f7f7f;
|
||||
color: rgba(0,0,0,0.5);
|
||||
}
|
||||
.quiet a { opacity: 0.7; }
|
||||
|
||||
.fraction {
|
||||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
||||
font-size: 10px;
|
||||
color: #555;
|
||||
background: #E8E8E8;
|
||||
padding: 4px 5px;
|
||||
border-radius: 3px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.path a:link, div.path a:visited { color: #333; }
|
||||
table.coverage {
|
||||
border-collapse: collapse;
|
||||
margin: 10px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.coverage td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
table.coverage td.line-count {
|
||||
text-align: right;
|
||||
padding: 0 5px 0 20px;
|
||||
}
|
||||
table.coverage td.line-coverage {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
min-width:20px;
|
||||
}
|
||||
|
||||
table.coverage td span.cline-any {
|
||||
display: inline-block;
|
||||
padding: 0 5px;
|
||||
width: 100%;
|
||||
}
|
||||
.missing-if-branch {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #333;
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
.skip-if-branch {
|
||||
display: none;
|
||||
margin-right: 10px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #ccc;
|
||||
color: white;
|
||||
}
|
||||
.missing-if-branch .typ, .skip-if-branch .typ {
|
||||
color: inherit !important;
|
||||
}
|
||||
.coverage-summary {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
||||
.keyline-all { border: 1px solid #ddd; }
|
||||
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
||||
.coverage-summary tbody { border: 1px solid #bbb; }
|
||||
.coverage-summary td { border-right: 1px solid #bbb; }
|
||||
.coverage-summary td:last-child { border-right: none; }
|
||||
.coverage-summary th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.coverage-summary th.file { border-right: none !important; }
|
||||
.coverage-summary th.pct { }
|
||||
.coverage-summary th.pic,
|
||||
.coverage-summary th.abs,
|
||||
.coverage-summary td.pct,
|
||||
.coverage-summary td.abs { text-align: right; }
|
||||
.coverage-summary td.file { white-space: nowrap; }
|
||||
.coverage-summary td.pic { min-width: 120px !important; }
|
||||
.coverage-summary tfoot td { }
|
||||
|
||||
.coverage-summary .sorter {
|
||||
height: 10px;
|
||||
width: 7px;
|
||||
display: inline-block;
|
||||
margin-left: 0.5em;
|
||||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
||||
}
|
||||
.coverage-summary .sorted .sorter {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
.coverage-summary .sorted-desc .sorter {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
.status-line { height: 10px; }
|
||||
/* yellow */
|
||||
.cbranch-no { background: yellow !important; color: #111; }
|
||||
/* dark red */
|
||||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
||||
.low .chart { border:1px solid #C21F39 }
|
||||
.highlighted,
|
||||
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
||||
background: #C21F39 !important;
|
||||
}
|
||||
/* medium red */
|
||||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
||||
/* light red */
|
||||
.low, .cline-no { background:#FCE1E5 }
|
||||
/* light green */
|
||||
.high, .cline-yes { background:rgb(230,245,208) }
|
||||
/* medium green */
|
||||
.cstat-yes { background:rgb(161,215,106) }
|
||||
/* dark green */
|
||||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
||||
.high .chart { border:1px solid rgb(77,146,33) }
|
||||
/* dark yellow (gold) */
|
||||
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
||||
.medium .chart { border:1px solid #f9cd0b; }
|
||||
/* light yellow */
|
||||
.medium { background: #fff4c2; }
|
||||
|
||||
.cstat-skip { background: #ddd; color: #111; }
|
||||
.fstat-skip { background: #ddd; color: #111 !important; }
|
||||
.cbranch-skip { background: #ddd !important; color: #111; }
|
||||
|
||||
span.cline-neutral { background: #eaeaea; }
|
||||
|
||||
.coverage-summary td.empty {
|
||||
opacity: .5;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
line-height: 1;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.cover-fill, .cover-empty {
|
||||
display:inline-block;
|
||||
height: 12px;
|
||||
}
|
||||
.chart {
|
||||
line-height: 0;
|
||||
}
|
||||
.cover-empty {
|
||||
background: white;
|
||||
}
|
||||
.cover-full {
|
||||
border-right: none !important;
|
||||
}
|
||||
pre.prettyprint {
|
||||
border: none !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.com { color: #999 !important; }
|
||||
.ignore-none { color: #999; font-weight: normal; }
|
||||
|
||||
.wrapper {
|
||||
min-height: 100%;
|
||||
height: auto !important;
|
||||
height: 100%;
|
||||
margin: 0 auto -48px;
|
||||
}
|
||||
.footer, .push {
|
||||
height: 48px;
|
||||
}
|
||||
87
coverage/lcov-report/block-navigation.js
Normal file
87
coverage/lcov-report/block-navigation.js
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/* eslint-disable */
|
||||
var jumpToCode = (function init() {
|
||||
// Classes of code we would like to highlight in the file view
|
||||
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
||||
|
||||
// Elements to highlight in the file listing view
|
||||
var fileListingElements = ['td.pct.low'];
|
||||
|
||||
// We don't want to select elements that are direct descendants of another match
|
||||
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
||||
|
||||
// Selector that finds elements on the page to which we can jump
|
||||
var selector =
|
||||
fileListingElements.join(', ') +
|
||||
', ' +
|
||||
notSelector +
|
||||
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
||||
|
||||
// The NodeList of matching elements
|
||||
var missingCoverageElements = document.querySelectorAll(selector);
|
||||
|
||||
var currentIndex;
|
||||
|
||||
function toggleClass(index) {
|
||||
missingCoverageElements
|
||||
.item(currentIndex)
|
||||
.classList.remove('highlighted');
|
||||
missingCoverageElements.item(index).classList.add('highlighted');
|
||||
}
|
||||
|
||||
function makeCurrent(index) {
|
||||
toggleClass(index);
|
||||
currentIndex = index;
|
||||
missingCoverageElements.item(index).scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
inline: 'center'
|
||||
});
|
||||
}
|
||||
|
||||
function goToPrevious() {
|
||||
var nextIndex = 0;
|
||||
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
||||
nextIndex = missingCoverageElements.length - 1;
|
||||
} else if (missingCoverageElements.length > 1) {
|
||||
nextIndex = currentIndex - 1;
|
||||
}
|
||||
|
||||
makeCurrent(nextIndex);
|
||||
}
|
||||
|
||||
function goToNext() {
|
||||
var nextIndex = 0;
|
||||
|
||||
if (
|
||||
typeof currentIndex === 'number' &&
|
||||
currentIndex < missingCoverageElements.length - 1
|
||||
) {
|
||||
nextIndex = currentIndex + 1;
|
||||
}
|
||||
|
||||
makeCurrent(nextIndex);
|
||||
}
|
||||
|
||||
return function jump(event) {
|
||||
if (
|
||||
document.getElementById('fileSearch') === document.activeElement &&
|
||||
document.activeElement != null
|
||||
) {
|
||||
// if we're currently focused on the search input, we don't want to navigate
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
case 78: // n
|
||||
case 74: // j
|
||||
goToNext();
|
||||
break;
|
||||
case 66: // b
|
||||
case 75: // k
|
||||
case 80: // p
|
||||
goToPrevious();
|
||||
break;
|
||||
}
|
||||
};
|
||||
})();
|
||||
window.addEventListener('keydown', jumpToCode);
|
||||
BIN
coverage/lcov-report/favicon.png
Normal file
BIN
coverage/lcov-report/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 445 B |
116
coverage/lcov-report/index.html
Normal file
116
coverage/lcov-report/index.html
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Code coverage report for All files</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="prettify.css" />
|
||||
<link rel="stylesheet" href="base.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>All files</h1>
|
||||
<div class='clearfix'>
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">92.68% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>152/164</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">58.06% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>18/31</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>9/9</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">92.68% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>152/164</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
<template id="filterTemplate">
|
||||
<div class="quiet">
|
||||
Filter:
|
||||
<input type="search" id="fileSearch">
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<div class="pad1">
|
||||
<table class="coverage-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr>
|
||||
<td class="file high" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
|
||||
<td data-value="92.68" class="pic high">
|
||||
<div class="chart"><div class="cover-fill" style="width: 92%"></div><div class="cover-empty" style="width: 8%"></div></div>
|
||||
</td>
|
||||
<td data-value="92.68" class="pct high">92.68%</td>
|
||||
<td data-value="164" class="abs high">152/164</td>
|
||||
<td data-value="58.06" class="pct medium">58.06%</td>
|
||||
<td data-value="31" class="abs medium">18/31</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="9" class="abs high">9/9</td>
|
||||
<td data-value="92.68" class="pct high">92.68%</td>
|
||||
<td data-value="164" class="abs high">152/164</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||
at 2026-05-30T19:44:07.776Z
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
prettyPrint();
|
||||
};
|
||||
</script>
|
||||
<script src="sorter.js"></script>
|
||||
<script src="block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
577
coverage/lcov-report/index.ts.html
Normal file
577
coverage/lcov-report/index.ts.html
Normal file
|
|
@ -0,0 +1,577 @@
|
|||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Code coverage report for index.ts</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="prettify.css" />
|
||||
<link rel="stylesheet" href="base.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1><a href="index.html">All files</a> index.ts</h1>
|
||||
<div class='clearfix'>
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">92.68% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>152/164</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">58.06% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>18/31</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>9/9</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">92.68% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>152/164</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<p class="quiet">
|
||||
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||
</p>
|
||||
<template id="filterTemplate">
|
||||
<div class="quiet">
|
||||
Filter:
|
||||
<input type="search" id="fileSearch">
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||
<a name='L2'></a><a href='#L2'>2</a>
|
||||
<a name='L3'></a><a href='#L3'>3</a>
|
||||
<a name='L4'></a><a href='#L4'>4</a>
|
||||
<a name='L5'></a><a href='#L5'>5</a>
|
||||
<a name='L6'></a><a href='#L6'>6</a>
|
||||
<a name='L7'></a><a href='#L7'>7</a>
|
||||
<a name='L8'></a><a href='#L8'>8</a>
|
||||
<a name='L9'></a><a href='#L9'>9</a>
|
||||
<a name='L10'></a><a href='#L10'>10</a>
|
||||
<a name='L11'></a><a href='#L11'>11</a>
|
||||
<a name='L12'></a><a href='#L12'>12</a>
|
||||
<a name='L13'></a><a href='#L13'>13</a>
|
||||
<a name='L14'></a><a href='#L14'>14</a>
|
||||
<a name='L15'></a><a href='#L15'>15</a>
|
||||
<a name='L16'></a><a href='#L16'>16</a>
|
||||
<a name='L17'></a><a href='#L17'>17</a>
|
||||
<a name='L18'></a><a href='#L18'>18</a>
|
||||
<a name='L19'></a><a href='#L19'>19</a>
|
||||
<a name='L20'></a><a href='#L20'>20</a>
|
||||
<a name='L21'></a><a href='#L21'>21</a>
|
||||
<a name='L22'></a><a href='#L22'>22</a>
|
||||
<a name='L23'></a><a href='#L23'>23</a>
|
||||
<a name='L24'></a><a href='#L24'>24</a>
|
||||
<a name='L25'></a><a href='#L25'>25</a>
|
||||
<a name='L26'></a><a href='#L26'>26</a>
|
||||
<a name='L27'></a><a href='#L27'>27</a>
|
||||
<a name='L28'></a><a href='#L28'>28</a>
|
||||
<a name='L29'></a><a href='#L29'>29</a>
|
||||
<a name='L30'></a><a href='#L30'>30</a>
|
||||
<a name='L31'></a><a href='#L31'>31</a>
|
||||
<a name='L32'></a><a href='#L32'>32</a>
|
||||
<a name='L33'></a><a href='#L33'>33</a>
|
||||
<a name='L34'></a><a href='#L34'>34</a>
|
||||
<a name='L35'></a><a href='#L35'>35</a>
|
||||
<a name='L36'></a><a href='#L36'>36</a>
|
||||
<a name='L37'></a><a href='#L37'>37</a>
|
||||
<a name='L38'></a><a href='#L38'>38</a>
|
||||
<a name='L39'></a><a href='#L39'>39</a>
|
||||
<a name='L40'></a><a href='#L40'>40</a>
|
||||
<a name='L41'></a><a href='#L41'>41</a>
|
||||
<a name='L42'></a><a href='#L42'>42</a>
|
||||
<a name='L43'></a><a href='#L43'>43</a>
|
||||
<a name='L44'></a><a href='#L44'>44</a>
|
||||
<a name='L45'></a><a href='#L45'>45</a>
|
||||
<a name='L46'></a><a href='#L46'>46</a>
|
||||
<a name='L47'></a><a href='#L47'>47</a>
|
||||
<a name='L48'></a><a href='#L48'>48</a>
|
||||
<a name='L49'></a><a href='#L49'>49</a>
|
||||
<a name='L50'></a><a href='#L50'>50</a>
|
||||
<a name='L51'></a><a href='#L51'>51</a>
|
||||
<a name='L52'></a><a href='#L52'>52</a>
|
||||
<a name='L53'></a><a href='#L53'>53</a>
|
||||
<a name='L54'></a><a href='#L54'>54</a>
|
||||
<a name='L55'></a><a href='#L55'>55</a>
|
||||
<a name='L56'></a><a href='#L56'>56</a>
|
||||
<a name='L57'></a><a href='#L57'>57</a>
|
||||
<a name='L58'></a><a href='#L58'>58</a>
|
||||
<a name='L59'></a><a href='#L59'>59</a>
|
||||
<a name='L60'></a><a href='#L60'>60</a>
|
||||
<a name='L61'></a><a href='#L61'>61</a>
|
||||
<a name='L62'></a><a href='#L62'>62</a>
|
||||
<a name='L63'></a><a href='#L63'>63</a>
|
||||
<a name='L64'></a><a href='#L64'>64</a>
|
||||
<a name='L65'></a><a href='#L65'>65</a>
|
||||
<a name='L66'></a><a href='#L66'>66</a>
|
||||
<a name='L67'></a><a href='#L67'>67</a>
|
||||
<a name='L68'></a><a href='#L68'>68</a>
|
||||
<a name='L69'></a><a href='#L69'>69</a>
|
||||
<a name='L70'></a><a href='#L70'>70</a>
|
||||
<a name='L71'></a><a href='#L71'>71</a>
|
||||
<a name='L72'></a><a href='#L72'>72</a>
|
||||
<a name='L73'></a><a href='#L73'>73</a>
|
||||
<a name='L74'></a><a href='#L74'>74</a>
|
||||
<a name='L75'></a><a href='#L75'>75</a>
|
||||
<a name='L76'></a><a href='#L76'>76</a>
|
||||
<a name='L77'></a><a href='#L77'>77</a>
|
||||
<a name='L78'></a><a href='#L78'>78</a>
|
||||
<a name='L79'></a><a href='#L79'>79</a>
|
||||
<a name='L80'></a><a href='#L80'>80</a>
|
||||
<a name='L81'></a><a href='#L81'>81</a>
|
||||
<a name='L82'></a><a href='#L82'>82</a>
|
||||
<a name='L83'></a><a href='#L83'>83</a>
|
||||
<a name='L84'></a><a href='#L84'>84</a>
|
||||
<a name='L85'></a><a href='#L85'>85</a>
|
||||
<a name='L86'></a><a href='#L86'>86</a>
|
||||
<a name='L87'></a><a href='#L87'>87</a>
|
||||
<a name='L88'></a><a href='#L88'>88</a>
|
||||
<a name='L89'></a><a href='#L89'>89</a>
|
||||
<a name='L90'></a><a href='#L90'>90</a>
|
||||
<a name='L91'></a><a href='#L91'>91</a>
|
||||
<a name='L92'></a><a href='#L92'>92</a>
|
||||
<a name='L93'></a><a href='#L93'>93</a>
|
||||
<a name='L94'></a><a href='#L94'>94</a>
|
||||
<a name='L95'></a><a href='#L95'>95</a>
|
||||
<a name='L96'></a><a href='#L96'>96</a>
|
||||
<a name='L97'></a><a href='#L97'>97</a>
|
||||
<a name='L98'></a><a href='#L98'>98</a>
|
||||
<a name='L99'></a><a href='#L99'>99</a>
|
||||
<a name='L100'></a><a href='#L100'>100</a>
|
||||
<a name='L101'></a><a href='#L101'>101</a>
|
||||
<a name='L102'></a><a href='#L102'>102</a>
|
||||
<a name='L103'></a><a href='#L103'>103</a>
|
||||
<a name='L104'></a><a href='#L104'>104</a>
|
||||
<a name='L105'></a><a href='#L105'>105</a>
|
||||
<a name='L106'></a><a href='#L106'>106</a>
|
||||
<a name='L107'></a><a href='#L107'>107</a>
|
||||
<a name='L108'></a><a href='#L108'>108</a>
|
||||
<a name='L109'></a><a href='#L109'>109</a>
|
||||
<a name='L110'></a><a href='#L110'>110</a>
|
||||
<a name='L111'></a><a href='#L111'>111</a>
|
||||
<a name='L112'></a><a href='#L112'>112</a>
|
||||
<a name='L113'></a><a href='#L113'>113</a>
|
||||
<a name='L114'></a><a href='#L114'>114</a>
|
||||
<a name='L115'></a><a href='#L115'>115</a>
|
||||
<a name='L116'></a><a href='#L116'>116</a>
|
||||
<a name='L117'></a><a href='#L117'>117</a>
|
||||
<a name='L118'></a><a href='#L118'>118</a>
|
||||
<a name='L119'></a><a href='#L119'>119</a>
|
||||
<a name='L120'></a><a href='#L120'>120</a>
|
||||
<a name='L121'></a><a href='#L121'>121</a>
|
||||
<a name='L122'></a><a href='#L122'>122</a>
|
||||
<a name='L123'></a><a href='#L123'>123</a>
|
||||
<a name='L124'></a><a href='#L124'>124</a>
|
||||
<a name='L125'></a><a href='#L125'>125</a>
|
||||
<a name='L126'></a><a href='#L126'>126</a>
|
||||
<a name='L127'></a><a href='#L127'>127</a>
|
||||
<a name='L128'></a><a href='#L128'>128</a>
|
||||
<a name='L129'></a><a href='#L129'>129</a>
|
||||
<a name='L130'></a><a href='#L130'>130</a>
|
||||
<a name='L131'></a><a href='#L131'>131</a>
|
||||
<a name='L132'></a><a href='#L132'>132</a>
|
||||
<a name='L133'></a><a href='#L133'>133</a>
|
||||
<a name='L134'></a><a href='#L134'>134</a>
|
||||
<a name='L135'></a><a href='#L135'>135</a>
|
||||
<a name='L136'></a><a href='#L136'>136</a>
|
||||
<a name='L137'></a><a href='#L137'>137</a>
|
||||
<a name='L138'></a><a href='#L138'>138</a>
|
||||
<a name='L139'></a><a href='#L139'>139</a>
|
||||
<a name='L140'></a><a href='#L140'>140</a>
|
||||
<a name='L141'></a><a href='#L141'>141</a>
|
||||
<a name='L142'></a><a href='#L142'>142</a>
|
||||
<a name='L143'></a><a href='#L143'>143</a>
|
||||
<a name='L144'></a><a href='#L144'>144</a>
|
||||
<a name='L145'></a><a href='#L145'>145</a>
|
||||
<a name='L146'></a><a href='#L146'>146</a>
|
||||
<a name='L147'></a><a href='#L147'>147</a>
|
||||
<a name='L148'></a><a href='#L148'>148</a>
|
||||
<a name='L149'></a><a href='#L149'>149</a>
|
||||
<a name='L150'></a><a href='#L150'>150</a>
|
||||
<a name='L151'></a><a href='#L151'>151</a>
|
||||
<a name='L152'></a><a href='#L152'>152</a>
|
||||
<a name='L153'></a><a href='#L153'>153</a>
|
||||
<a name='L154'></a><a href='#L154'>154</a>
|
||||
<a name='L155'></a><a href='#L155'>155</a>
|
||||
<a name='L156'></a><a href='#L156'>156</a>
|
||||
<a name='L157'></a><a href='#L157'>157</a>
|
||||
<a name='L158'></a><a href='#L158'>158</a>
|
||||
<a name='L159'></a><a href='#L159'>159</a>
|
||||
<a name='L160'></a><a href='#L160'>160</a>
|
||||
<a name='L161'></a><a href='#L161'>161</a>
|
||||
<a name='L162'></a><a href='#L162'>162</a>
|
||||
<a name='L163'></a><a href='#L163'>163</a>
|
||||
<a name='L164'></a><a href='#L164'>164</a>
|
||||
<a name='L165'></a><a href='#L165'>165</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">12x</span>
|
||||
<span class="cline-any cline-yes">12x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">5x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import moment from 'moment';
|
||||
import type { Moment as MomentInstance } from 'moment';
|
||||
import { toHijri, toGregorian, hmLong, hmMedium, hwLong, hwShort, hwNumeric } from 'hijri-core';
|
||||
import type { HijriDate, ConversionOptions } from './types';
|
||||
|
||||
declare module 'moment' {
|
||||
interface MomentStatic {
|
||||
/**
|
||||
* Construct a moment from a Hijri date.
|
||||
* Throws if the date is invalid or outside the supported range.
|
||||
* Call installHijri(moment) before use.
|
||||
*/
|
||||
fromHijri(hy: number, hm: number, hd: number, options?: ConversionOptions): MomentInstance;
|
||||
}
|
||||
|
||||
interface Moment {
|
||||
/**
|
||||
* Convert this moment to a Hijri date.
|
||||
* Returns null if the date falls outside the supported calendar range.
|
||||
*/
|
||||
toHijri(options?: ConversionOptions): HijriDate | null;
|
||||
|
||||
/** Return the Hijri year, or null if out of range. */
|
||||
hijriYear(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return the Hijri month (1-12), or null if out of range. */
|
||||
hijriMonth(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return the Hijri day, or null if out of range. */
|
||||
hijriDay(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return true if this moment falls within the supported Hijri range. */
|
||||
isValidHijri(options?: ConversionOptions): boolean;
|
||||
|
||||
/**
|
||||
* Format this moment using Hijri-aware format tokens.
|
||||
*
|
||||
* Hijri tokens: iYYYY iYY iMMMM iMMM iMM iM iDD iD iEEEE iEEE iE ioooo iooo
|
||||
* All other tokens are passed through to moment's own format().
|
||||
*
|
||||
* Returns an empty string if the date is outside the Hijri range.
|
||||
*/
|
||||
formatHijri(formatStr: string, options?: ConversionOptions): string;
|
||||
}
|
||||
}
|
||||
|
||||
// Regex matching all Hijri format tokens. Ordered longest-first so iYYYY is
|
||||
// matched before iYY, iMMMM before iMMM, iDD before iD, iEEEE before iEEE.
|
||||
const HIJRI_TOKEN_RE = /iYYYY|iYY|iMMMM|iMMM|iMM|iM|iDD|iD|iEEEE|iEEE|iE|ioooo|iooo/g;
|
||||
|
||||
/**
|
||||
* Escape a literal string so moment.format() treats it as literal text.
|
||||
* Wraps the value in square brackets, escaping any ] characters within.
|
||||
*/
|
||||
function escapeLiteral(value: string): string {
|
||||
return '[' + value.replace(/]/g, '][]') + ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the Hijri plugin into the provided moment instance.
|
||||
*
|
||||
* @example
|
||||
* import moment from 'moment';
|
||||
* import installHijri from 'moment-hijri-plus';
|
||||
* installHijri(moment);
|
||||
*/
|
||||
function install(momentInstance: typeof moment): void {
|
||||
momentInstance.fn.toHijri = function (opts?: ConversionOptions): HijriDate | null {
|
||||
return toHijri(this.toDate(), opts);
|
||||
};
|
||||
|
||||
momentInstance.fn.hijriYear = function (opts?: ConversionOptions): number | null {
|
||||
return this.toHijri(opts)?.<span class="branch-0 cbranch-no" title="branch not covered" >hy ?? null;</span>
|
||||
};
|
||||
|
||||
momentInstance.fn.hijriMonth = function (opts?: ConversionOptions): number | null {
|
||||
return this.toHijri(opts)?.<span class="branch-0 cbranch-no" title="branch not covered" >hm ?? null;</span>
|
||||
};
|
||||
|
||||
momentInstance.fn.hijriDay = function (opts?: ConversionOptions): number | null {
|
||||
return this.toHijri(opts)?.<span class="branch-0 cbranch-no" title="branch not covered" >hd ?? null;</span>
|
||||
};
|
||||
|
||||
momentInstance.fn.isValidHijri = function (opts?: ConversionOptions): boolean {
|
||||
return this.toHijri(opts) !== null;
|
||||
};
|
||||
|
||||
momentInstance.fn.formatHijri = function (formatStr: string, opts?: ConversionOptions): string {
|
||||
const hijri = this.toHijri(opts);
|
||||
if (!hijri) <span class="branch-0 cbranch-no" title="branch not covered" >return '';</span>
|
||||
const dow = this.day();
|
||||
// Replace Hijri tokens with escaped literals, then pass the residual string
|
||||
// to moment.format() so all standard tokens (YYYY, MMM, etc.) resolve correctly.
|
||||
// Escaping is required because values like "Ramadan" would otherwise be
|
||||
// interpreted by moment as format tokens (R, a, m, etc.).
|
||||
const residual = formatStr.replace(HIJRI_TOKEN_RE, (token: string): string => {
|
||||
switch (token) {
|
||||
case 'iYYYY':
|
||||
return escapeLiteral(String(hijri.hy).padStart(4, '0'));
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iYY':</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(String(hijri.hy % 100).padStart(2, '0'));</span>
|
||||
case 'iMMMM':
|
||||
// Non-null: hijri.hm is 1-12; hm-1 is always 0-11, within hmLong bounds.
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
return escapeLiteral(hmLong[hijri.hm - 1]!);
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iMMM':</span>
|
||||
<span class="cstat-no" title="statement not covered" > // eslint-disable-next-line @typescript-eslint/no-non-null-assertion</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(hmMedium[hijri.hm - 1]!);</span>
|
||||
case 'iMM':
|
||||
return escapeLiteral(String(hijri.hm).padStart(2, '0'));
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iM':</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(String(hijri.hm));</span>
|
||||
case 'iDD':
|
||||
return escapeLiteral(String(hijri.hd).padStart(2, '0'));
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iD':</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(String(hijri.hd));</span>
|
||||
case 'iEEEE':
|
||||
// Non-null: dow is always 0-6 (day of week), within hwLong bounds.
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
return escapeLiteral(hwLong[dow]!);
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iEEE':</span>
|
||||
<span class="cstat-no" title="statement not covered" > // eslint-disable-next-line @typescript-eslint/no-non-null-assertion</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(hwShort[dow]!);</span>
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iE':</span>
|
||||
<span class="cstat-no" title="statement not covered" > // eslint-disable-next-line @typescript-eslint/no-non-null-assertion</span>
|
||||
<span class="cstat-no" title="statement not covered" > return escapeLiteral(String(hwNumeric[dow]!));</span>
|
||||
// Era tokens: both iooo and ioooo map to the common abbreviation.
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > case 'iooo':</span>
|
||||
case 'ioooo':
|
||||
return escapeLiteral('AH');
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > default:</span>
|
||||
<span class="cstat-no" title="statement not covered" > return token;</span>
|
||||
}
|
||||
});
|
||||
return this.format(residual);
|
||||
};
|
||||
|
||||
// Attach fromHijri as a property on the constructor. We use bracket notation and a type
|
||||
// assertion because MomentStatic augmentation produces a DTS visibility error with some
|
||||
// TypeScript configurations; attaching at runtime is equivalent and safe.
|
||||
(momentInstance as unknown as Record<string, unknown>)['fromHijri'] = function (
|
||||
hy: number,
|
||||
hm: number,
|
||||
hd: number,
|
||||
opts?: ConversionOptions,
|
||||
): moment.Moment {
|
||||
let greg: Date | null;
|
||||
try {
|
||||
greg = toGregorian(hy, hm, hd, opts);
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > } catch {</span>
|
||||
<span class="cstat-no" title="statement not covered" > throw new Error(`Invalid or out-of-range Hijri date: ${hy}/${hm}/${hd}`);</span>
|
||||
<span class="cstat-no" title="statement not covered" > }</span>
|
||||
if (!greg) {
|
||||
throw new Error(`Invalid or out-of-range Hijri date: ${hy}/${hm}/${hd}`);
|
||||
}
|
||||
// Construct from explicit year/month/day to avoid UTC-to-local timezone
|
||||
// shift when the Date object represents midnight UTC.
|
||||
return momentInstance([greg.getUTCFullYear(), greg.getUTCMonth(), greg.getUTCDate()]);
|
||||
};
|
||||
}
|
||||
|
||||
export default install;
|
||||
export type { HijriDate, ConversionOptions, CalendarEngine } from 'hijri-core';
|
||||
export { registerCalendar, getCalendar, listCalendars } from 'hijri-core';
|
||||
</pre></td></tr></table></pre>
|
||||
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage generated by
|
||||
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||
at 2026-05-30T19:44:07.776Z
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
prettyPrint();
|
||||
};
|
||||
</script>
|
||||
<script src="sorter.js"></script>
|
||||
<script src="block-navigation.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
coverage/lcov-report/prettify.css
Normal file
1
coverage/lcov-report/prettify.css
Normal file
|
|
@ -0,0 +1 @@
|
|||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
||||
2
coverage/lcov-report/prettify.js
Normal file
2
coverage/lcov-report/prettify.js
Normal file
File diff suppressed because one or more lines are too long
BIN
coverage/lcov-report/sort-arrow-sprite.png
Normal file
BIN
coverage/lcov-report/sort-arrow-sprite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
210
coverage/lcov-report/sorter.js
Normal file
210
coverage/lcov-report/sorter.js
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/* eslint-disable */
|
||||
var addSorting = (function() {
|
||||
'use strict';
|
||||
var cols,
|
||||
currentSort = {
|
||||
index: 0,
|
||||
desc: false
|
||||
};
|
||||
|
||||
// returns the summary table element
|
||||
function getTable() {
|
||||
return document.querySelector('.coverage-summary');
|
||||
}
|
||||
// returns the thead element of the summary table
|
||||
function getTableHeader() {
|
||||
return getTable().querySelector('thead tr');
|
||||
}
|
||||
// returns the tbody element of the summary table
|
||||
function getTableBody() {
|
||||
return getTable().querySelector('tbody');
|
||||
}
|
||||
// returns the th element for nth column
|
||||
function getNthColumn(n) {
|
||||
return getTableHeader().querySelectorAll('th')[n];
|
||||
}
|
||||
|
||||
function onFilterInput() {
|
||||
const searchValue = document.getElementById('fileSearch').value;
|
||||
const rows = document.getElementsByTagName('tbody')[0].children;
|
||||
|
||||
// Try to create a RegExp from the searchValue. If it fails (invalid regex),
|
||||
// it will be treated as a plain text search
|
||||
let searchRegex;
|
||||
try {
|
||||
searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
|
||||
} catch (error) {
|
||||
searchRegex = null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
let isMatch = false;
|
||||
|
||||
if (searchRegex) {
|
||||
// If a valid regex was created, use it for matching
|
||||
isMatch = searchRegex.test(row.textContent);
|
||||
} else {
|
||||
// Otherwise, fall back to the original plain text search
|
||||
isMatch = row.textContent
|
||||
.toLowerCase()
|
||||
.includes(searchValue.toLowerCase());
|
||||
}
|
||||
|
||||
row.style.display = isMatch ? '' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// loads the search box
|
||||
function addSearchBox() {
|
||||
var template = document.getElementById('filterTemplate');
|
||||
var templateClone = template.content.cloneNode(true);
|
||||
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
||||
template.parentElement.appendChild(templateClone);
|
||||
}
|
||||
|
||||
// loads all columns
|
||||
function loadColumns() {
|
||||
var colNodes = getTableHeader().querySelectorAll('th'),
|
||||
colNode,
|
||||
cols = [],
|
||||
col,
|
||||
i;
|
||||
|
||||
for (i = 0; i < colNodes.length; i += 1) {
|
||||
colNode = colNodes[i];
|
||||
col = {
|
||||
key: colNode.getAttribute('data-col'),
|
||||
sortable: !colNode.getAttribute('data-nosort'),
|
||||
type: colNode.getAttribute('data-type') || 'string'
|
||||
};
|
||||
cols.push(col);
|
||||
if (col.sortable) {
|
||||
col.defaultDescSort = col.type === 'number';
|
||||
colNode.innerHTML =
|
||||
colNode.innerHTML + '<span class="sorter"></span>';
|
||||
}
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
// attaches a data attribute to every tr element with an object
|
||||
// of data values keyed by column name
|
||||
function loadRowData(tableRow) {
|
||||
var tableCols = tableRow.querySelectorAll('td'),
|
||||
colNode,
|
||||
col,
|
||||
data = {},
|
||||
i,
|
||||
val;
|
||||
for (i = 0; i < tableCols.length; i += 1) {
|
||||
colNode = tableCols[i];
|
||||
col = cols[i];
|
||||
val = colNode.getAttribute('data-value');
|
||||
if (col.type === 'number') {
|
||||
val = Number(val);
|
||||
}
|
||||
data[col.key] = val;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// loads all row data
|
||||
function loadData() {
|
||||
var rows = getTableBody().querySelectorAll('tr'),
|
||||
i;
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
rows[i].data = loadRowData(rows[i]);
|
||||
}
|
||||
}
|
||||
// sorts the table using the data for the ith column
|
||||
function sortByIndex(index, desc) {
|
||||
var key = cols[index].key,
|
||||
sorter = function(a, b) {
|
||||
a = a.data[key];
|
||||
b = b.data[key];
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
},
|
||||
finalSorter = sorter,
|
||||
tableBody = document.querySelector('.coverage-summary tbody'),
|
||||
rowNodes = tableBody.querySelectorAll('tr'),
|
||||
rows = [],
|
||||
i;
|
||||
|
||||
if (desc) {
|
||||
finalSorter = function(a, b) {
|
||||
return -1 * sorter(a, b);
|
||||
};
|
||||
}
|
||||
|
||||
for (i = 0; i < rowNodes.length; i += 1) {
|
||||
rows.push(rowNodes[i]);
|
||||
tableBody.removeChild(rowNodes[i]);
|
||||
}
|
||||
|
||||
rows.sort(finalSorter);
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
tableBody.appendChild(rows[i]);
|
||||
}
|
||||
}
|
||||
// removes sort indicators for current column being sorted
|
||||
function removeSortIndicators() {
|
||||
var col = getNthColumn(currentSort.index),
|
||||
cls = col.className;
|
||||
|
||||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
||||
col.className = cls;
|
||||
}
|
||||
// adds sort indicators for current column being sorted
|
||||
function addSortIndicators() {
|
||||
getNthColumn(currentSort.index).className += currentSort.desc
|
||||
? ' sorted-desc'
|
||||
: ' sorted';
|
||||
}
|
||||
// adds event listeners for all sorter widgets
|
||||
function enableUI() {
|
||||
var i,
|
||||
el,
|
||||
ithSorter = function ithSorter(i) {
|
||||
var col = cols[i];
|
||||
|
||||
return function() {
|
||||
var desc = col.defaultDescSort;
|
||||
|
||||
if (currentSort.index === i) {
|
||||
desc = !currentSort.desc;
|
||||
}
|
||||
sortByIndex(i, desc);
|
||||
removeSortIndicators();
|
||||
currentSort.index = i;
|
||||
currentSort.desc = desc;
|
||||
addSortIndicators();
|
||||
};
|
||||
};
|
||||
for (i = 0; i < cols.length; i += 1) {
|
||||
if (cols[i].sortable) {
|
||||
// add the click event handler on the th so users
|
||||
// dont have to click on those tiny arrows
|
||||
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener('click', ithSorter(i));
|
||||
} else {
|
||||
el.attachEvent('onclick', ithSorter(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// adds sorting functionality to the UI
|
||||
return function() {
|
||||
if (!getTable()) {
|
||||
return;
|
||||
}
|
||||
cols = loadColumns();
|
||||
loadData();
|
||||
addSearchBox();
|
||||
addSortIndicators();
|
||||
enableUI();
|
||||
};
|
||||
})();
|
||||
|
||||
window.addEventListener('load', addSorting);
|
||||
222
coverage/lcov.info
Normal file
222
coverage/lcov.info
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
TN:
|
||||
SF:src/index.ts
|
||||
FN:55,escapeLiteral
|
||||
FN:67,install
|
||||
FN:68,momentInstance.fn.toHijri
|
||||
FN:72,momentInstance.fn.hijriYear
|
||||
FN:76,momentInstance.fn.hijriMonth
|
||||
FN:80,momentInstance.fn.hijriDay
|
||||
FN:84,momentInstance.fn.isValidHijri
|
||||
FN:88,momentInstance.fn.formatHijri
|
||||
FN:141,momentInstance.fromHijri
|
||||
FNF:9
|
||||
FNH:9
|
||||
FNDA:7,escapeLiteral
|
||||
FNDA:1,install
|
||||
FNDA:12,momentInstance.fn.toHijri
|
||||
FNDA:1,momentInstance.fn.hijriYear
|
||||
FNDA:1,momentInstance.fn.hijriMonth
|
||||
FNDA:1,momentInstance.fn.hijriDay
|
||||
FNDA:1,momentInstance.fn.isValidHijri
|
||||
FNDA:5,momentInstance.fn.formatHijri
|
||||
FNDA:3,momentInstance.fromHijri
|
||||
DA:1,1
|
||||
DA:2,1
|
||||
DA:3,1
|
||||
DA:4,1
|
||||
DA:5,1
|
||||
DA:6,1
|
||||
DA:7,1
|
||||
DA:8,1
|
||||
DA:9,1
|
||||
DA:10,1
|
||||
DA:11,1
|
||||
DA:12,1
|
||||
DA:13,1
|
||||
DA:14,1
|
||||
DA:15,1
|
||||
DA:16,1
|
||||
DA:17,1
|
||||
DA:18,1
|
||||
DA:19,1
|
||||
DA:20,1
|
||||
DA:21,1
|
||||
DA:22,1
|
||||
DA:23,1
|
||||
DA:24,1
|
||||
DA:25,1
|
||||
DA:26,1
|
||||
DA:27,1
|
||||
DA:28,1
|
||||
DA:29,1
|
||||
DA:30,1
|
||||
DA:31,1
|
||||
DA:32,1
|
||||
DA:33,1
|
||||
DA:34,1
|
||||
DA:35,1
|
||||
DA:36,1
|
||||
DA:37,1
|
||||
DA:38,1
|
||||
DA:39,1
|
||||
DA:40,1
|
||||
DA:41,1
|
||||
DA:42,1
|
||||
DA:43,1
|
||||
DA:44,1
|
||||
DA:45,1
|
||||
DA:46,1
|
||||
DA:47,1
|
||||
DA:48,1
|
||||
DA:49,1
|
||||
DA:50,1
|
||||
DA:51,1
|
||||
DA:52,1
|
||||
DA:53,1
|
||||
DA:54,1
|
||||
DA:55,7
|
||||
DA:56,7
|
||||
DA:57,7
|
||||
DA:58,1
|
||||
DA:59,1
|
||||
DA:60,1
|
||||
DA:61,1
|
||||
DA:62,1
|
||||
DA:63,1
|
||||
DA:64,1
|
||||
DA:65,1
|
||||
DA:66,1
|
||||
DA:67,1
|
||||
DA:68,1
|
||||
DA:69,12
|
||||
DA:70,12
|
||||
DA:71,1
|
||||
DA:72,1
|
||||
DA:73,1
|
||||
DA:74,1
|
||||
DA:75,1
|
||||
DA:76,1
|
||||
DA:77,1
|
||||
DA:78,1
|
||||
DA:79,1
|
||||
DA:80,1
|
||||
DA:81,1
|
||||
DA:82,1
|
||||
DA:83,1
|
||||
DA:84,1
|
||||
DA:85,1
|
||||
DA:86,1
|
||||
DA:87,1
|
||||
DA:88,1
|
||||
DA:89,5
|
||||
DA:90,5
|
||||
DA:91,5
|
||||
DA:92,5
|
||||
DA:93,5
|
||||
DA:94,5
|
||||
DA:95,5
|
||||
DA:96,5
|
||||
DA:97,7
|
||||
DA:98,7
|
||||
DA:99,2
|
||||
DA:100,7
|
||||
DA:101,0
|
||||
DA:102,7
|
||||
DA:103,1
|
||||
DA:104,1
|
||||
DA:105,1
|
||||
DA:106,7
|
||||
DA:107,0
|
||||
DA:108,0
|
||||
DA:109,7
|
||||
DA:110,1
|
||||
DA:111,7
|
||||
DA:112,0
|
||||
DA:113,7
|
||||
DA:114,1
|
||||
DA:115,7
|
||||
DA:116,0
|
||||
DA:117,7
|
||||
DA:118,1
|
||||
DA:119,1
|
||||
DA:120,1
|
||||
DA:121,7
|
||||
DA:122,0
|
||||
DA:123,0
|
||||
DA:124,7
|
||||
DA:125,0
|
||||
DA:126,0
|
||||
DA:127,7
|
||||
DA:128,7
|
||||
DA:129,7
|
||||
DA:130,1
|
||||
DA:131,7
|
||||
DA:132,0
|
||||
DA:133,7
|
||||
DA:134,5
|
||||
DA:135,5
|
||||
DA:136,5
|
||||
DA:137,1
|
||||
DA:138,1
|
||||
DA:139,1
|
||||
DA:140,1
|
||||
DA:141,1
|
||||
DA:142,3
|
||||
DA:143,3
|
||||
DA:144,3
|
||||
DA:145,3
|
||||
DA:146,3
|
||||
DA:147,3
|
||||
DA:148,3
|
||||
DA:149,3
|
||||
DA:150,3
|
||||
DA:151,0
|
||||
DA:152,0
|
||||
DA:153,3
|
||||
DA:154,1
|
||||
DA:155,1
|
||||
DA:156,2
|
||||
DA:157,2
|
||||
DA:158,2
|
||||
DA:159,3
|
||||
DA:160,1
|
||||
DA:161,1
|
||||
DA:162,1
|
||||
DA:163,1
|
||||
DA:164,1
|
||||
LF:164
|
||||
LH:152
|
||||
BRDA:55,0,0,7
|
||||
BRDA:67,1,0,1
|
||||
BRDA:68,2,0,12
|
||||
BRDA:72,3,0,1
|
||||
BRDA:73,4,0,0
|
||||
BRDA:76,5,0,1
|
||||
BRDA:77,6,0,0
|
||||
BRDA:80,7,0,1
|
||||
BRDA:81,8,0,0
|
||||
BRDA:84,9,0,1
|
||||
BRDA:88,10,0,5
|
||||
BRDA:90,11,0,0
|
||||
BRDA:96,12,0,7
|
||||
BRDA:98,13,0,2
|
||||
BRDA:100,14,0,0
|
||||
BRDA:102,15,0,1
|
||||
BRDA:106,16,0,0
|
||||
BRDA:109,17,0,1
|
||||
BRDA:111,18,0,0
|
||||
BRDA:113,19,0,1
|
||||
BRDA:115,20,0,0
|
||||
BRDA:117,21,0,1
|
||||
BRDA:121,22,0,0
|
||||
BRDA:124,23,0,0
|
||||
BRDA:128,24,0,0
|
||||
BRDA:129,25,0,1
|
||||
BRDA:131,26,0,0
|
||||
BRDA:141,27,0,3
|
||||
BRDA:150,28,0,0
|
||||
BRDA:153,29,0,1
|
||||
BRDA:155,30,0,2
|
||||
BRF:31
|
||||
BRH:18
|
||||
end_of_record
|
||||
1
coverage/tmp/coverage-51344-1780170247749-0.json
Normal file
1
coverage/tmp/coverage-51344-1780170247749-0.json
Normal file
File diff suppressed because one or more lines are too long
1
coverage/tmp/coverage-51345-1780170247743-0.json
Normal file
1
coverage/tmp/coverage-51345-1780170247743-0.json
Normal file
File diff suppressed because one or more lines are too long
105
src/index.ts
105
src/index.ts
|
|
@ -7,8 +7,19 @@ declare module 'moment' {
|
|||
interface MomentStatic {
|
||||
/**
|
||||
* Construct a moment from a Hijri date.
|
||||
* Throws if the date is invalid or outside the supported range.
|
||||
* Call installHijri(moment) before use.
|
||||
*
|
||||
* Delegates to hijri-core's `toGregorian()` to resolve the Gregorian equivalent,
|
||||
* then constructs the moment from the explicit UTC year/month/day to avoid timezone
|
||||
* drift when the Date object represents midnight UTC.
|
||||
*
|
||||
* @param hy - Hijri year.
|
||||
* @param hm - Hijri month (1 = Muharram, 12 = Dhul Hijjah).
|
||||
* @param hd - Hijri day (1-30).
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns A moment positioned at the Gregorian equivalent of the given Hijri date.
|
||||
* @throws {Error} If the date is invalid or outside the chosen calendar's range.
|
||||
* @example
|
||||
* moment.fromHijri(1444, 9, 1).format('YYYY-MM-DD'); // '2023-03-23'
|
||||
*/
|
||||
fromHijri(hy: number, hm: number, hd: number, options?: ConversionOptions): MomentInstance;
|
||||
}
|
||||
|
|
@ -16,29 +27,88 @@ declare module 'moment' {
|
|||
interface Moment {
|
||||
/**
|
||||
* Convert this moment to a Hijri date.
|
||||
* Returns null if the date falls outside the supported calendar range.
|
||||
*
|
||||
* Passes the underlying `Date` to hijri-core's `toHijri()`. The calendar engine
|
||||
* performs a table lookup (UAQ) or astronomical calculation (FCNA).
|
||||
*
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns A `HijriDate` object `{ hy, hm, hd }`, or `null` if the date is outside
|
||||
* the supported range (UAQ covers approximately CE 1900-2076).
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).toHijri();
|
||||
* // => { hy: 1444, hm: 9, hd: 1 }
|
||||
*/
|
||||
toHijri(options?: ConversionOptions): HijriDate | null;
|
||||
|
||||
/** Return the Hijri year, or null if out of range. */
|
||||
/**
|
||||
* Return the Hijri year.
|
||||
*
|
||||
* Convenience wrapper around `toHijri()`. Use `toHijri()` when you need all three
|
||||
* fields to avoid redundant calendar lookups.
|
||||
*
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns The Hijri year, or `null` if the date is outside the calendar range.
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).hijriYear(); // => 1444
|
||||
*/
|
||||
hijriYear(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return the Hijri month (1-12), or null if out of range. */
|
||||
/**
|
||||
* Return the Hijri month (1-12).
|
||||
*
|
||||
* 1 = Muharram, 9 = Ramadan, 12 = Dhul Hijjah.
|
||||
*
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns The Hijri month number, or `null` if out of range.
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).hijriMonth(); // => 9 (Ramadan)
|
||||
*/
|
||||
hijriMonth(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return the Hijri day, or null if out of range. */
|
||||
/**
|
||||
* Return the Hijri day (1-30).
|
||||
*
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns The Hijri day number, or `null` if out of range.
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).hijriDay(); // => 1
|
||||
*/
|
||||
hijriDay(options?: ConversionOptions): number | null;
|
||||
|
||||
/** Return true if this moment falls within the supported Hijri range. */
|
||||
/**
|
||||
* Return `true` if this moment falls within the supported Hijri range.
|
||||
*
|
||||
* Equivalent to `moment.toHijri(opts) !== null`. Use as a guard before
|
||||
* calling `toHijri()` on user-supplied dates that may predate CE 1900.
|
||||
*
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns `true` if the date is within range, `false` otherwise.
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).isValidHijri(); // => true
|
||||
* moment(new Date(1800, 0, 1)).isValidHijri(); // => false
|
||||
*/
|
||||
isValidHijri(options?: ConversionOptions): boolean;
|
||||
|
||||
/**
|
||||
* Format this moment using Hijri-aware format tokens.
|
||||
*
|
||||
* Hijri tokens: iYYYY iYY iMMMM iMMM iMM iM iDD iD iEEEE iEEE iE ioooo iooo
|
||||
* All other tokens are passed through to moment's own format().
|
||||
* Hijri tokens (prefix `i`) are resolved to their Arabic calendar equivalents
|
||||
* via a single regex pass. The residual format string is passed to `moment.format()`
|
||||
* so all standard Gregorian tokens resolve normally. This allows mixing Hijri and
|
||||
* Gregorian tokens in a single format string.
|
||||
*
|
||||
* Returns an empty string if the date is outside the Hijri range.
|
||||
* Supported Hijri tokens: `iYYYY`, `iYY`, `iMMMM`, `iMMM`, `iMM`, `iM`,
|
||||
* `iDD`, `iD`, `iEEEE`, `iEEE`, `iE`, `ioooo`, `iooo`.
|
||||
*
|
||||
* @param formatStr - Format string. Hijri tokens and Moment.js tokens may be mixed freely.
|
||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||
* @returns The formatted string, or `''` if the date is outside the Hijri range.
|
||||
* @example
|
||||
* moment(new Date(2023, 2, 23)).formatHijri('iD iMMMM iYYYY AH');
|
||||
* // => '1 Ramadan 1444 AH'
|
||||
*
|
||||
* moment(new Date(2023, 2, 23)).formatHijri('iD iMMMM iYYYY [CE:] MMMM D, YYYY');
|
||||
* // => '1 Ramadan 1444 CE: March 23, 2023'
|
||||
*/
|
||||
formatHijri(formatStr: string, options?: ConversionOptions): string;
|
||||
}
|
||||
|
|
@ -57,12 +127,25 @@ function escapeLiteral(value: string): string {
|
|||
}
|
||||
|
||||
/**
|
||||
* Install the Hijri plugin into the provided moment instance.
|
||||
* Install the Hijri plugin into the provided Moment.js instance.
|
||||
*
|
||||
* Mutates `momentInstance.fn` to add instance methods (`toHijri`, `hijriYear`,
|
||||
* `hijriMonth`, `hijriDay`, `isValidHijri`, `formatHijri`) and attaches
|
||||
* `momentInstance.fromHijri` as a static factory. Call once at application startup.
|
||||
*
|
||||
* The call is idempotent: calling it a second time overwrites the methods with
|
||||
* identical implementations.
|
||||
*
|
||||
* @param momentInstance - The Moment.js constructor to augment. Pass your imported
|
||||
* `moment` directly. Works with any moment instance, including locale-scoped ones.
|
||||
* @example
|
||||
* import moment from 'moment';
|
||||
* import installHijri from 'moment-hijri-plus';
|
||||
*
|
||||
* installHijri(moment);
|
||||
*
|
||||
* moment(new Date(2023, 2, 23)).toHijri();
|
||||
* // => { hy: 1444, hm: 9, hd: 1 }
|
||||
*/
|
||||
function install(momentInstance: typeof moment): void {
|
||||
momentInstance.fn.toHijri = function (opts?: ConversionOptions): HijriDate | null {
|
||||
|
|
|
|||
Loading…
Reference in a new issue