bizdays-toolkit 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.14.1] - 2026-10-20
8
+
9
+ ライブラリの結果は 0.14.0 と同じ(内部の改善と文書だけ)。
10
+
11
+ ### 開発
12
+
13
+ - `createCalendar`・`createSchedule` の作成が 0.13.0 で約 30% 遅くなっていた(CI の `bench` で 1.26 倍。手元では 14.0 → 18.5µs)のを直した。原因は、`createCalendarFromSchedule` のためにスケジュールの内部の判定を `WeakMap` に登録していたこと。`Object.freeze` 済みのオブジェクトに後から印(`WeakMap` のキーのハッシュや `defineProperty` の項目)を付けると、V8 がオブジェクトを遅い形に落とす。内部の判定を Symbol の項目としてオブジェクトリテラルに最初から含める形に変え、作成のコストは 0.12.0 の水準(手元で 14.9µs)に戻った。公開 API・結果は変わらない。Symbol の項目は `Object.keys`・`JSON.stringify` に出ない
14
+ - `docs/decisions.md`: 38 番にこの原因と「作ったあとに印を付けず、リテラルに含める」知見を追記した
15
+
7
16
  ## [0.14.0] - 2026-10-20
8
17
 
9
18
  ### 移行
@@ -373,7 +382,8 @@
373
382
 
374
383
  - 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
375
384
 
376
- [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.14.0...HEAD
385
+ [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.14.1...HEAD
386
+ [0.14.1]: https://github.com/inohan77/bizdays-toolkit/compare/v0.14.0...v0.14.1
377
387
  [0.14.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.13.0...v0.14.0
378
388
  [0.13.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.12.0...v0.13.0
379
389
  [0.12.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.11.1...v0.12.0
@@ -778,10 +778,10 @@ export function mapDays(from, to, fn) {
778
778
  * @internal スケジュールの内部の判定(暦日の文字列を直接受け取る)。createCalendarFromSchedule が、公開メソッド
779
779
  * (入力の解析を通る)を経由せずに 1 日分の結果を得るために使う。スケジュールごとに作成時に登録する
780
780
  */
781
- const internalInfo = new WeakMap();
781
+ const INTERNAL_INFO = Symbol("bizdays-toolkit.scheduleInfo");
782
782
  /** @internal スケジュールの内部の判定を取り出す(createSchedule が作ったものでなければ undefined) */
783
783
  export function infoOfSchedule(schedule) {
784
- return internalInfo.get(schedule);
784
+ return schedule[INTERNAL_INFO];
785
785
  }
786
786
  /** @internal 検証済みの規則からスケジュールを作る */
787
787
  export function buildSchedule(compiled) {
@@ -789,6 +789,9 @@ export function buildSchedule(compiled) {
789
789
  const resolve = createResolver(compiled, lookup);
790
790
  const info = (date) => resolve(date).day;
791
791
  const schedule = {
792
+ // 内部の判定(createCalendarFromSchedule が使う)。Symbol の項目なので列挙されず、JSON にも出ない。
793
+ // オブジェクトリテラルに含めるのは、あとから defineProperty や WeakMap で付けると作成が数 µs 遅くなるため
794
+ [INTERNAL_INFO]: info,
792
795
  timeZone: lookup.timeZone,
793
796
  providers: lookup.providers,
794
797
  outOfRange: lookup.outOfRange,
@@ -804,9 +807,7 @@ export function buildSchedule(compiled) {
804
807
  dayInfo: (input) => info(lookup.dateOf(input)),
805
808
  daysBetween: (from, to) => mapDays(lookup.dateOf(from), lookup.dateOf(to), info),
806
809
  };
807
- Object.freeze(schedule);
808
- internalInfo.set(schedule, info);
809
- return schedule;
810
+ return Object.freeze(schedule);
810
811
  }
811
812
  /**
812
813
  * 曜日・祝日・特定日の規則から、日ごとに値を返すスケジュールを作る。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bizdays-toolkit",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Holidays, business-day calendar and day-by-day schedules (e.g. store hours) with time zone support. Japanese holidays verified against the Cabinet Office data; UK bank holidays (England, Wales, Scotland, Northern Ireland) verified against GOV.UK. / 祝日と営業日のカレンダー(タイムゾーン対応・日本の祝日は内閣府、英国の bank holidays は GOV.UK のデータで全日照合)",
5
5
  "keywords": [
6
6
  "bank-holidays",