nodejs / nodejs/node

Add `partialDeepEqual()` in strict assertion mode

オープン
#62,327 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request never-stale
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

What is the problem this feature will solve?

I use strict assertion mode in my tests:

import assert from "node:assert/strict";

assert.equal("...", "...");
assert.deepEqual({ "..." }, { "..." });
assert.partialDeepEqual({ "..." }, { "..." });

But the partialDeepEqual() doesn't exist. You have to use partialDeepStrictEqual() that has the word Strict in its name, whereas the other methods do not.

What is the feature you are proposing to solve the problem?

The "node:assert/strict" module should re-export partialDeepStrictEqual() with the name partialDeepEqual() so that function names are consistent in strict assertion mode.

Additional information

The partialDeepStrictEqual() function was added with https://github.com/nodejs/node/pull/54630. I couldn't find any references to the terms strict assertion mode.

"Re-export" takes place in two locations:

I don't think adding the following two lines is enough?

// if (options.strict) { 
this.partialDeepEqual = this.partialDeepStrictEqual; 

// assert.strict = ObjectAssign(strict, assert, { 
partialDeepEqual: assert.partialDeepStrictEqual, 

Because partialDeepEqual() doesn't exist in legacy assertion mode. So we need to manage the fact that the Assert type will be different between the two modes.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

lib/assert.js の 126-131 行付近と 894-899 行付近にある、リンクされた 2 つの export 箇所から始め、strict と legacy の assertion モードが Assert 型をどのように公開しているかを確認してください。strict モードのエイリアスを追加しますが、legacy モードには追加せず、その後、両方の import 形式で partialDeepEqual が公開され、partialDeepStrictEqual は引き続き利用可能であることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
api
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。