mirror of
https://github.com/acamarata/moment-hijri-plus.git
synced 2026-07-04 04:30:42 +00:00
Compare commits
No commits in common. "main" and "v1.0.2" have entirely different histories.
24 changed files with 1488 additions and 305 deletions
|
|
@ -1,140 +0,0 @@
|
||||||
# Forgejo CI mirror — git.ariccamarata.com
|
|
||||||
# Mirrors .github/workflows/ci.yml for the self-hosted Forgejo Actions runner.
|
|
||||||
# Keep in sync with the GitHub workflow; only addition is the nSentry failure step.
|
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: Test (Node ${{ matrix.node }})
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node: [20, 22, 24]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Enable corepack
|
|
||||||
run: corepack enable
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node }}
|
|
||||||
cache: pnpm
|
|
||||||
- run: pnpm install --frozen-lockfile
|
|
||||||
- run: pnpm run build
|
|
||||||
- run: node --test test.mjs
|
|
||||||
- run: node --test test-cjs.cjs
|
|
||||||
- name: Report failure to nSentry
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
# nself sentry ci enable <repo> must be run on the CamClaw server first.
|
|
||||||
# Once registered, the runner's nself-sentry-sync hook delivers this report
|
|
||||||
# to ~/Sites/acamarata/.claude/inbox via root@sentry-errors.ariccamarata.com.
|
|
||||||
echo "CI_FAILURE repo=${{ github.repository }} job=${{ github.job }} run=${{ github.run_id }}" >&2
|
|
||||||
|
|
||||||
lint:
|
|
||||||
name: Lint
|
|
||||||
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 lint
|
|
||||||
- run: pnpm run format:check
|
|
||||||
- name: Report failure to nSentry
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
# nself sentry ci enable <repo> must be run on the CamClaw server first.
|
|
||||||
# Once registered, the runner's nself-sentry-sync hook delivers this report
|
|
||||||
# to ~/Sites/acamarata/.claude/inbox via root@sentry-errors.ariccamarata.com.
|
|
||||||
echo "CI_FAILURE repo=${{ github.repository }} job=${{ github.job }} run=${{ github.run_id }}" >&2
|
|
||||||
|
|
||||||
typecheck:
|
|
||||||
name: Typecheck
|
|
||||||
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 typecheck
|
|
||||||
- name: Report failure to nSentry
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
# nself sentry ci enable <repo> must be run on the CamClaw server first.
|
|
||||||
# Once registered, the runner's nself-sentry-sync hook delivers this report
|
|
||||||
# to ~/Sites/acamarata/.claude/inbox via root@sentry-errors.ariccamarata.com.
|
|
||||||
echo "CI_FAILURE repo=${{ github.repository }} job=${{ github.job }} run=${{ github.run_id }}" >&2
|
|
||||||
|
|
||||||
pack-check:
|
|
||||||
name: Pack check
|
|
||||||
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: Verify pack contents
|
|
||||||
run: |
|
|
||||||
npm pack --dry-run 2>&1 | tee pack-output.txt
|
|
||||||
grep "dist/index.cjs" pack-output.txt
|
|
||||||
grep "dist/index.mjs" pack-output.txt
|
|
||||||
grep "dist/index.d.ts" pack-output.txt
|
|
||||||
grep "dist/index.d.mts" pack-output.txt
|
|
||||||
grep "README.md" pack-output.txt
|
|
||||||
grep "CHANGELOG.md" pack-output.txt
|
|
||||||
grep "LICENSE" pack-output.txt
|
|
||||||
- name: Report failure to nSentry
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
# nself sentry ci enable <repo> must be run on the CamClaw server first.
|
|
||||||
# Once registered, the runner's nself-sentry-sync hook delivers this report
|
|
||||||
# to ~/Sites/acamarata/.claude/inbox via root@sentry-errors.ariccamarata.com.
|
|
||||||
echo "CI_FAILURE repo=${{ github.repository }} job=${{ github.job }} run=${{ github.run_id }}" >&2
|
|
||||||
|
|
||||||
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
|
|
||||||
- name: Report failure to nSentry
|
|
||||||
if: failure()
|
|
||||||
run: |
|
|
||||||
# nself sentry ci enable <repo> must be run on the CamClaw server first.
|
|
||||||
# Once registered, the runner's nself-sentry-sync hook delivers this report
|
|
||||||
# to ~/Sites/acamarata/.claude/inbox via root@sentry-errors.ariccamarata.com.
|
|
||||||
echo "CI_FAILURE repo=${{ github.repository }} job=${{ github.job }} run=${{ github.run_id }}" >&2
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,5 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
coverage/
|
|
||||||
*.tgz
|
*.tgz
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -5,18 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [1.0.4] - 2026-06-13
|
## [Unreleased]
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Published package now includes `dist/index.d.mts` so ESM type resolution under `node16`/`nodenext` resolves the import condition.
|
|
||||||
|
|
||||||
## [1.0.3] - 2026-06-10
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- `.toHijri()` now converts the calendar date the moment instance displays (year/month/day
|
|
||||||
components, respecting `.utc()` mode) rather than passing the raw instant to hijri-core.
|
|
||||||
This eliminates wrong-Hijri-day results around UTC-midnight for hosts east or west of UTC.
|
|
||||||
Requires hijri-core 1.0.3.
|
|
||||||
|
|
||||||
## [1.0.2] - 2026-05-30
|
## [1.0.2] - 2026-05-30
|
||||||
|
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -50,15 +50,6 @@ Pass `{ calendar: 'fcna' }` to switch from the default Umm al-Qura calendar to F
|
||||||
Full API reference, format token table, and examples are in the
|
Full API reference, format token table, and examples are in the
|
||||||
[project wiki](https://github.com/acamarata/moment-hijri-plus/wiki).
|
[project wiki](https://github.com/acamarata/moment-hijri-plus/wiki).
|
||||||
|
|
||||||
## Day boundaries and time zones
|
|
||||||
|
|
||||||
Conversions use the calendar date the moment instance displays, not the underlying UTC
|
|
||||||
instant. A `moment("2025-03-01")` parsed in any local timezone returns the Hijri date
|
|
||||||
for March 1st, 2025. A moment created with `.utc()` uses its UTC components.
|
|
||||||
|
|
||||||
Religious day-start at sunset is outside the scope of this package; it depends on
|
|
||||||
location and madhab, and must be handled at the application layer.
|
|
||||||
|
|
||||||
## Note on Moment.js
|
## Note on Moment.js
|
||||||
|
|
||||||
Moment.js is in maintenance mode. For new projects,
|
Moment.js is in maintenance mode. For new projects,
|
||||||
|
|
@ -75,7 +66,3 @@ support on Day.js. This package targets existing codebases already using Moment.
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT. Copyright (c) 2026 Aric Camarata.
|
MIT. Copyright (c) 2026 Aric Camarata.
|
||||||
|
|
||||||
## Telemetry
|
|
||||||
|
|
||||||
This package supports optional, anonymous usage telemetry via [`@acamarata/telemetry`](https://github.com/acamarata/telemetry). It is **off by default**. See [TELEMETRY.md](https://github.com/acamarata/telemetry/blob/main/TELEMETRY.md) for what is collected and how to enable or disable it.
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
# Telemetry Disclosure
|
|
||||||
|
|
||||||
This package supports opt-in anonymous usage telemetry via [`@acamarata/telemetry`](https://github.com/acamarata/telemetry).
|
|
||||||
|
|
||||||
Telemetry is **off by default**. No data is sent unless you set `ACAMARATA_TELEMETRY=1`.
|
|
||||||
|
|
||||||
Full disclosure (what is sent, where it goes, how to disable):
|
|
||||||
[github.com/acamarata/telemetry/blob/main/TELEMETRY.md](https://github.com/acamarata/telemetry/blob/main/TELEMETRY.md)
|
|
||||||
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
|
|
@ -5,17 +5,10 @@ import { typescript } from '@acamarata/eslint-config';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
files: ['src/**/*.ts'],
|
|
||||||
plugins: { '@typescript-eslint': tsPlugin },
|
plugins: { '@typescript-eslint': tsPlugin },
|
||||||
languageOptions: {
|
languageOptions: { parser: tsParser },
|
||||||
parser: tsParser,
|
|
||||||
parserOptions: {
|
|
||||||
project: './tsconfig.json',
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
},
|
||||||
},
|
...typescript,
|
||||||
},
|
|
||||||
...typescript.map((cfg) => ({ ...cfg, files: ['src/**/*.ts'] })),
|
|
||||||
eslintConfigPrettier,
|
eslintConfigPrettier,
|
||||||
{
|
{
|
||||||
ignores: ['dist/', 'node_modules/', 'test.mjs', 'test-cjs.cjs'],
|
ignores: ['dist/', 'node_modules/', 'test.mjs', 'test-cjs.cjs'],
|
||||||
|
|
|
||||||
13
package.json
13
package.json
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "moment-hijri-plus",
|
"name": "moment-hijri-plus",
|
||||||
"version": "1.0.4",
|
"version": "1.0.2",
|
||||||
"description": "Moment.js plugin for Hijri calendar conversion and formatting. Supports Umm al-Qura and FCNA calendars via hijri-core.",
|
"description": "Moment.js plugin for Hijri calendar conversion and formatting. Supports Umm al-Qura and FCNA calendars via hijri-core.",
|
||||||
"author": "Aric Camarata",
|
"author": "Aric Camarata",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
"lint": "eslint src/",
|
"lint": "eslint src/",
|
||||||
"format": "prettier --write src/",
|
"format": "prettier --write src/",
|
||||||
"format:check": "prettier --check src/",
|
"format:check": "prettier --check src/",
|
||||||
"prepack": "pnpm run build",
|
"prepublishOnly": "tsup",
|
||||||
"coverage": "c8 --reporter=lcov --reporter=text node test.mjs",
|
"coverage": "c8 --reporter=lcov --reporter=text node test.mjs",
|
||||||
"docs": "typedoc --out .github/wiki/api src/index.ts",
|
"docs": "typedoc --out .github/wiki/api src/index.ts",
|
||||||
"postbuild": "cp dist/index.d.ts dist/index.d.mts"
|
"postbuild": "cp dist/index.d.ts dist/index.d.mts"
|
||||||
|
|
@ -61,24 +61,21 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@acamarata/eslint-config": "^0.1.0",
|
"@acamarata/eslint-config": "^0.1.0",
|
||||||
|
"c8": "^10.1.3",
|
||||||
"@acamarata/prettier-config": "^0.1.0",
|
"@acamarata/prettier-config": "^0.1.0",
|
||||||
"@acamarata/tsconfig": "^0.1.0",
|
"@acamarata/tsconfig": "^0.1.0",
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/js": "^10.0.1",
|
||||||
"@types/node": "^25.3.5",
|
"@types/node": "^25.3.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
||||||
"@typescript-eslint/parser": "^8.56.1",
|
|
||||||
"c8": "^10.1.3",
|
|
||||||
"eslint": "^10.0.3",
|
"eslint": "^10.0.3",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"hijri-core": "^1.0.3",
|
"hijri-core": "^1.0.0",
|
||||||
"moment": "^2.30.0",
|
"moment": "^2.30.0",
|
||||||
"prettier": "^3.8.1",
|
"prettier": "^3.8.1",
|
||||||
"tsup": "^8.0.0",
|
"tsup": "^8.0.0",
|
||||||
"typedoc": "^0.28.19",
|
"typedoc": "^0.28.19",
|
||||||
"typedoc-plugin-markdown": "^4.11.0",
|
"typedoc-plugin-markdown": "^4.11.0",
|
||||||
"typescript": "^5.5.0",
|
"typescript": "^5.5.0",
|
||||||
"typescript-eslint": "^8.56.1",
|
"typescript-eslint": "^8.56.1"
|
||||||
"@acamarata/telemetry": "^0.1.0"
|
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ importers:
|
||||||
'@acamarata/prettier-config':
|
'@acamarata/prettier-config':
|
||||||
specifier: ^0.1.0
|
specifier: ^0.1.0
|
||||||
version: 0.1.0(prettier@3.8.1)
|
version: 0.1.0(prettier@3.8.1)
|
||||||
'@acamarata/telemetry':
|
|
||||||
specifier: ^0.1.0
|
|
||||||
version: 0.1.0
|
|
||||||
'@acamarata/tsconfig':
|
'@acamarata/tsconfig':
|
||||||
specifier: ^0.1.0
|
specifier: ^0.1.0
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
|
|
@ -26,12 +23,6 @@ importers:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^25.3.5
|
specifier: ^25.3.5
|
||||||
version: 25.3.5
|
version: 25.3.5
|
||||||
'@typescript-eslint/eslint-plugin':
|
|
||||||
specifier: ^8.56.1
|
|
||||||
version: 8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.0.3)(typescript@5.9.3))(eslint@10.0.3)(typescript@5.9.3)
|
|
||||||
'@typescript-eslint/parser':
|
|
||||||
specifier: ^8.56.1
|
|
||||||
version: 8.56.1(eslint@10.0.3)(typescript@5.9.3)
|
|
||||||
c8:
|
c8:
|
||||||
specifier: ^10.1.3
|
specifier: ^10.1.3
|
||||||
version: 10.1.3
|
version: 10.1.3
|
||||||
|
|
@ -42,8 +33,8 @@ importers:
|
||||||
specifier: ^10.1.8
|
specifier: ^10.1.8
|
||||||
version: 10.1.8(eslint@10.0.3)
|
version: 10.1.8(eslint@10.0.3)
|
||||||
hijri-core:
|
hijri-core:
|
||||||
specifier: ^1.0.3
|
specifier: ^1.0.0
|
||||||
version: 1.0.3
|
version: 1.0.0
|
||||||
moment:
|
moment:
|
||||||
specifier: ^2.30.0
|
specifier: ^2.30.0
|
||||||
version: 2.30.1
|
version: 2.30.1
|
||||||
|
|
@ -90,10 +81,6 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
prettier: '>=3.0.0'
|
prettier: '>=3.0.0'
|
||||||
|
|
||||||
'@acamarata/telemetry@0.1.0':
|
|
||||||
resolution: {integrity: sha512-iP09ZD0bHencHLbv6kQZDgwN9crLCWGKxmiMrfJjhBCoWTgv4koSgg0Li/LFKwCCFluua6orj9fVeQ8eqcJXSQ==}
|
|
||||||
engines: {node: '>=20'}
|
|
||||||
|
|
||||||
'@acamarata/tsconfig@0.1.0':
|
'@acamarata/tsconfig@0.1.0':
|
||||||
resolution: {integrity: sha512-bgzyBak43mE+0HhduZX3cvaPjKcggtGGZZMjr35qtYWolsIWgZ9nx7OOswbVYoU35qoUv6rZ0mTK6GbZ8QTYjw==}
|
resolution: {integrity: sha512-bgzyBak43mE+0HhduZX3cvaPjKcggtGGZZMjr35qtYWolsIWgZ9nx7OOswbVYoU35qoUv6rZ0mTK6GbZ8QTYjw==}
|
||||||
engines: {node: '>=20'}
|
engines: {node: '>=20'}
|
||||||
|
|
@ -828,8 +815,8 @@ packages:
|
||||||
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
hijri-core@1.0.3:
|
hijri-core@1.0.0:
|
||||||
resolution: {integrity: sha512-ONT5gp+Z/lzT/BbWKS0F8lcKK9T/H6jc95NLQE4Angdt7Uimo4KkmSt/qn9odaQRp1pX0RjA65QRcR4miF7XxA==}
|
resolution: {integrity: sha512-wImBZLBKbEWEEUE1nrc1CFY/uvx4XjGNWYChImJZlswXIVhrBCzSVaj6DP1AU2gUMJ6KDh2ygXo/u/Qx232CXA==}
|
||||||
engines: {node: '>=20'}
|
engines: {node: '>=20'}
|
||||||
|
|
||||||
html-escaper@2.0.2:
|
html-escaper@2.0.2:
|
||||||
|
|
@ -1258,8 +1245,6 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
prettier: 3.8.1
|
prettier: 3.8.1
|
||||||
|
|
||||||
'@acamarata/telemetry@0.1.0': {}
|
|
||||||
|
|
||||||
'@acamarata/tsconfig@0.1.0': {}
|
'@acamarata/tsconfig@0.1.0': {}
|
||||||
|
|
||||||
'@bcoe/v8-coverage@1.0.2': {}
|
'@bcoe/v8-coverage@1.0.2': {}
|
||||||
|
|
@ -1893,7 +1878,7 @@ snapshots:
|
||||||
|
|
||||||
has-flag@4.0.0: {}
|
has-flag@4.0.0: {}
|
||||||
|
|
||||||
hijri-core@1.0.3: {}
|
hijri-core@1.0.0: {}
|
||||||
|
|
||||||
html-escaper@2.0.2: {}
|
html-escaper@2.0.2: {}
|
||||||
|
|
||||||
|
|
|
||||||
84
src/index.ts
84
src/index.ts
|
|
@ -1,9 +1,9 @@
|
||||||
import moment from "moment";
|
import moment from 'moment';
|
||||||
import type { Moment as MomentInstance } from "moment";
|
import type { Moment as MomentInstance } from 'moment';
|
||||||
import { toHijri, toGregorian, hmLong, hmMedium, hwLong, hwShort, hwNumeric } from "hijri-core";
|
import { toHijri, toGregorian, hmLong, hmMedium, hwLong, hwShort, hwNumeric } from 'hijri-core';
|
||||||
import type { HijriDate, ConversionOptions } from "./types";
|
import type { HijriDate, ConversionOptions } from './types';
|
||||||
|
|
||||||
declare module "moment" {
|
declare module 'moment' {
|
||||||
interface MomentStatic {
|
interface MomentStatic {
|
||||||
/**
|
/**
|
||||||
* Construct a moment from a Hijri date.
|
* Construct a moment from a Hijri date.
|
||||||
|
|
@ -28,13 +28,8 @@ declare module "moment" {
|
||||||
/**
|
/**
|
||||||
* Convert this moment to a Hijri date.
|
* Convert this moment to a Hijri date.
|
||||||
*
|
*
|
||||||
* Converts the calendar date this moment instance displays (year/month/day) to a
|
* Passes the underlying `Date` to hijri-core's `toHijri()`. The calendar engine
|
||||||
* Hijri date via hijri-core's `toHijri()`. The conversion is independent of the
|
* performs a table lookup (UAQ) or astronomical calculation (FCNA).
|
||||||
* host machine's timezone: a moment in UTC mode uses its UTC components, and a
|
|
||||||
* moment in local mode uses its local components. The raw instant (milliseconds
|
|
||||||
* since epoch) is never passed directly to the calendar engine.
|
|
||||||
*
|
|
||||||
* The calendar engine performs a table lookup (UAQ) or astronomical calculation (FCNA).
|
|
||||||
*
|
*
|
||||||
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
* @param options - Calendar selection. Default: `{ calendar: 'uaq' }`.
|
||||||
* @returns A `HijriDate` object `{ hy, hm, hd }`, or `null` if the date is outside
|
* @returns A `HijriDate` object `{ hy, hm, hd }`, or `null` if the date is outside
|
||||||
|
|
@ -128,7 +123,7 @@ const HIJRI_TOKEN_RE = /iYYYY|iYY|iMMMM|iMMM|iMM|iM|iDD|iD|iEEEE|iEEE|iE|ioooo|i
|
||||||
* Wraps the value in square brackets, escaping any ] characters within.
|
* Wraps the value in square brackets, escaping any ] characters within.
|
||||||
*/
|
*/
|
||||||
function escapeLiteral(value: string): string {
|
function escapeLiteral(value: string): string {
|
||||||
return "[" + value.replace(/]/g, "][]") + "]";
|
return '[' + value.replace(/]/g, '][]') + ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -154,11 +149,7 @@ function escapeLiteral(value: string): string {
|
||||||
*/
|
*/
|
||||||
function install(momentInstance: typeof moment): void {
|
function install(momentInstance: typeof moment): void {
|
||||||
momentInstance.fn.toHijri = function (opts?: ConversionOptions): HijriDate | null {
|
momentInstance.fn.toHijri = function (opts?: ConversionOptions): HijriDate | null {
|
||||||
// Use the calendar date this instance displays rather than the raw instant.
|
return toHijri(this.toDate(), opts);
|
||||||
// this.year()/.month()/.date() respect utc mode automatically, so a moment
|
|
||||||
// created with .utc() uses UTC components and a local moment uses local components.
|
|
||||||
// moment.month() is 0-based, matching Date.UTC's month parameter exactly.
|
|
||||||
return toHijri(new Date(Date.UTC(this.year(), this.month(), this.date())), opts);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
momentInstance.fn.hijriYear = function (opts?: ConversionOptions): number | null {
|
momentInstance.fn.hijriYear = function (opts?: ConversionOptions): number | null {
|
||||||
|
|
@ -179,7 +170,7 @@ function install(momentInstance: typeof moment): void {
|
||||||
|
|
||||||
momentInstance.fn.formatHijri = function (formatStr: string, opts?: ConversionOptions): string {
|
momentInstance.fn.formatHijri = function (formatStr: string, opts?: ConversionOptions): string {
|
||||||
const hijri = this.toHijri(opts);
|
const hijri = this.toHijri(opts);
|
||||||
if (!hijri) return "";
|
if (!hijri) return '';
|
||||||
const dow = this.day();
|
const dow = this.day();
|
||||||
// Replace Hijri tokens with escaped literals, then pass the residual string
|
// Replace Hijri tokens with escaped literals, then pass the residual string
|
||||||
// to moment.format() so all standard tokens (YYYY, MMM, etc.) resolve correctly.
|
// to moment.format() so all standard tokens (YYYY, MMM, etc.) resolve correctly.
|
||||||
|
|
@ -187,39 +178,39 @@ function install(momentInstance: typeof moment): void {
|
||||||
// interpreted by moment as format tokens (R, a, m, etc.).
|
// interpreted by moment as format tokens (R, a, m, etc.).
|
||||||
const residual = formatStr.replace(HIJRI_TOKEN_RE, (token: string): string => {
|
const residual = formatStr.replace(HIJRI_TOKEN_RE, (token: string): string => {
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case "iYYYY":
|
case 'iYYYY':
|
||||||
return escapeLiteral(String(hijri.hy).padStart(4, "0"));
|
return escapeLiteral(String(hijri.hy).padStart(4, '0'));
|
||||||
case "iYY":
|
case 'iYY':
|
||||||
return escapeLiteral(String(hijri.hy % 100).padStart(2, "0"));
|
return escapeLiteral(String(hijri.hy % 100).padStart(2, '0'));
|
||||||
case "iMMMM":
|
case 'iMMMM':
|
||||||
// Non-null: hijri.hm is 1-12; hm-1 is always 0-11, within hmLong bounds.
|
// 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
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return escapeLiteral(hmLong[hijri.hm - 1]!);
|
return escapeLiteral(hmLong[hijri.hm - 1]!);
|
||||||
case "iMMM":
|
case 'iMMM':
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return escapeLiteral(hmMedium[hijri.hm - 1]!);
|
return escapeLiteral(hmMedium[hijri.hm - 1]!);
|
||||||
case "iMM":
|
case 'iMM':
|
||||||
return escapeLiteral(String(hijri.hm).padStart(2, "0"));
|
return escapeLiteral(String(hijri.hm).padStart(2, '0'));
|
||||||
case "iM":
|
case 'iM':
|
||||||
return escapeLiteral(String(hijri.hm));
|
return escapeLiteral(String(hijri.hm));
|
||||||
case "iDD":
|
case 'iDD':
|
||||||
return escapeLiteral(String(hijri.hd).padStart(2, "0"));
|
return escapeLiteral(String(hijri.hd).padStart(2, '0'));
|
||||||
case "iD":
|
case 'iD':
|
||||||
return escapeLiteral(String(hijri.hd));
|
return escapeLiteral(String(hijri.hd));
|
||||||
case "iEEEE":
|
case 'iEEEE':
|
||||||
// Non-null: dow is always 0-6 (day of week), within hwLong bounds.
|
// Non-null: dow is always 0-6 (day of week), within hwLong bounds.
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return escapeLiteral(hwLong[dow]!);
|
return escapeLiteral(hwLong[dow]!);
|
||||||
case "iEEE":
|
case 'iEEE':
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return escapeLiteral(hwShort[dow]!);
|
return escapeLiteral(hwShort[dow]!);
|
||||||
case "iE":
|
case 'iE':
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
return escapeLiteral(String(hwNumeric[dow]!));
|
return escapeLiteral(String(hwNumeric[dow]!));
|
||||||
// Era tokens: both iooo and ioooo map to the common abbreviation.
|
// Era tokens: both iooo and ioooo map to the common abbreviation.
|
||||||
case "iooo":
|
case 'iooo':
|
||||||
case "ioooo":
|
case 'ioooo':
|
||||||
return escapeLiteral("AH");
|
return escapeLiteral('AH');
|
||||||
default:
|
default:
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +221,7 @@ function install(momentInstance: typeof moment): void {
|
||||||
// Attach fromHijri as a property on the constructor. We use bracket notation and a type
|
// 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
|
// assertion because MomentStatic augmentation produces a DTS visibility error with some
|
||||||
// TypeScript configurations; attaching at runtime is equivalent and safe.
|
// TypeScript configurations; attaching at runtime is equivalent and safe.
|
||||||
(momentInstance as unknown as Record<string, unknown>)["fromHijri"] = function (
|
(momentInstance as unknown as Record<string, unknown>)['fromHijri'] = function (
|
||||||
hy: number,
|
hy: number,
|
||||||
hm: number,
|
hm: number,
|
||||||
hd: number,
|
hd: number,
|
||||||
|
|
@ -245,21 +236,12 @@ function install(momentInstance: typeof moment): void {
|
||||||
if (!greg) {
|
if (!greg) {
|
||||||
throw new Error(`Invalid or out-of-range Hijri date: ${hy}/${hm}/${hd}`);
|
throw new Error(`Invalid or out-of-range Hijri date: ${hy}/${hm}/${hd}`);
|
||||||
}
|
}
|
||||||
// Construct from explicit year/month/day components so the moment displays
|
// Construct from explicit year/month/day to avoid UTC-to-local timezone
|
||||||
// the correct calendar date regardless of the host timezone offset.
|
// shift when the Date object represents midnight UTC.
|
||||||
return momentInstance([greg.getUTCFullYear(), greg.getUTCMonth(), greg.getUTCDate()]);
|
return momentInstance([greg.getUTCFullYear(), greg.getUTCMonth(), greg.getUTCDate()]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default install;
|
export default install;
|
||||||
export type { HijriDate, ConversionOptions, CalendarEngine } from "hijri-core";
|
export type { HijriDate, ConversionOptions, CalendarEngine } from 'hijri-core';
|
||||||
export { registerCalendar, getCalendar, listCalendars } from "hijri-core";
|
export { registerCalendar, getCalendar, listCalendars } from 'hijri-core';
|
||||||
|
|
||||||
// ── Opt-in anonymous telemetry ────────────────────────────────────────────────
|
|
||||||
// Off by default. Enable: ACAMARATA_TELEMETRY=1
|
|
||||||
// What is sent + how to disable: https://github.com/acamarata/telemetry/blob/main/TELEMETRY.md
|
|
||||||
import("@acamarata/telemetry")
|
|
||||||
.then(({ track }) => track("load", { package: "moment-hijri-plus", version: "1.0.4" }))
|
|
||||||
.catch(() => {
|
|
||||||
// telemetry not installed or disabled — that's fine
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export type { HijriDate, ConversionOptions } from "hijri-core";
|
export type { HijriDate, ConversionOptions } from 'hijri-core';
|
||||||
|
|
|
||||||
19
test-cjs.cjs
19
test-cjs.cjs
|
|
@ -61,22 +61,3 @@ describe('CJS: isValidHijri', () => {
|
||||||
assert.equal(moment(new Date(2023, 2, 23, 12)).isValidHijri(), true);
|
assert.equal(moment(new Date(2023, 2, 23, 12)).isValidHijri(), true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('CJS: UTC-day boundary (regression)', () => {
|
|
||||||
it('fromHijri → toHijri round-trip: 1446/9/1', () => {
|
|
||||||
const m = moment.fromHijri(1446, 9, 1);
|
|
||||||
const h = m.toHijri();
|
|
||||||
assert.notEqual(h, null);
|
|
||||||
assert.equal(h.hy, 1446);
|
|
||||||
assert.equal(h.hm, 9);
|
|
||||||
assert.equal(h.hd, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('moment("2025-03-01") toHijri => 1446/9/1 (timezone-invariant)', () => {
|
|
||||||
const h = moment('2025-03-01').toHijri();
|
|
||||||
assert.notEqual(h, null);
|
|
||||||
assert.equal(h.hy, 1446);
|
|
||||||
assert.equal(h.hm, 9);
|
|
||||||
assert.equal(h.hd, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
23
test.mjs
23
test.mjs
|
|
@ -110,26 +110,3 @@ describe('FCNA calendar', () => {
|
||||||
assert.equal(typeof h.hd, 'number');
|
assert.equal(typeof h.hd, 'number');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('UTC-day boundary (regression)', () => {
|
|
||||||
it('fromHijri → toHijri round-trip: 1446/9/1', () => {
|
|
||||||
// Construct from Hijri, convert back — must be exact regardless of host TZ.
|
|
||||||
const m = moment.fromHijri(1446, 9, 1);
|
|
||||||
const h = m.toHijri();
|
|
||||||
assert.notEqual(h, null);
|
|
||||||
assert.equal(h.hy, 1446);
|
|
||||||
assert.equal(h.hm, 9);
|
|
||||||
assert.equal(h.hd, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('moment("2025-03-01") toHijri => 1446/9/1 (timezone-invariant)', () => {
|
|
||||||
// moment parses date-only ISO strings as LOCAL midnight.
|
|
||||||
// toHijri must convert the displayed calendar date (2025-03-01), not the raw
|
|
||||||
// instant, so the result is the same regardless of the host timezone offset.
|
|
||||||
const h = moment('2025-03-01').toHijri();
|
|
||||||
assert.notEqual(h, null);
|
|
||||||
assert.equal(h.hy, 1446);
|
|
||||||
assert.equal(h.hm, 9);
|
|
||||||
assert.equal(h.hd, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue