Skip to content

Commit

Permalink
📚 deepFreeze に JSDoc 書く
Browse files Browse the repository at this point in the history
  • Loading branch information
SSlime-s committed Nov 4, 2023
1 parent 63ef27f commit 3a8762c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/deepFreeze.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* オブジェクトや配列の全てのプロパティを再帰的にfreezeする
*
* 自己参照など閉路が存在する場合は無限ループに陥るので注意
*
* @see https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
*/
export const deepFreeze = <const T extends object>(obj: T): T => {
const propNames = Object.getOwnPropertyNames(obj)

Expand Down

0 comments on commit 3a8762c

Please sign in to comment.