https://nodejs.org/api/util.html を読んでいたらutil.isXxx
系のメソッドがdeprecatedになっていてびっくりした。
経緯
@yosuke_furukawa さんに経緯を教えてもらった。
@sasaplus1 経緯を説明すると、 util.isObject が functionに対してtrueと判定されない => functionはobjectとして仕様に明記されてるし、underscoreもそう判定する=>そもそもisXxxいらなくない?=>deprecated
— Yosuke FURUKAWA (@yosuke_furukawa) 2015, 10月 8
調べたらちゃんとCHANGELOG.mdに書いてあった。
util: The util.is*() functions have been deprecated, beginning with deprecation warnings in the documentation for this release, users are encouraged to seek more robust alternatives in the npm registry, (Sakthipriyan Vairamani) #2447.
- https://github.com/nodejs/node/blob/master/CHANGELOG.md#2015-09-08-version-400-stable-rvagg
- https://github.com/nodejs/node/pull/2715
- https://github.com/nodejs/node/pull/2447
- https://github.com/nodejs/node/pull/1301
util.isXxxを使いたいとき
https://github.com/nodejs/node/pull/1301#issuecomment-88178570 には
core-util-is package is a suitable replacement in user-land IMO
とあるのでcore-util-is
を使えば良いっぽい。このライブラリにはisXxx
系のメソッドだけが入っている。
何も考えずに「あ、新しいの出てる」とnodebrew install-binary
するのもいいけど、ちゃんと変更点も読もうと思いました( ˘ω˘)