2019-12-01から1ヶ月間の記事一覧
ファイル index.js から require されている全モジュールの個数を知るには、require してみて require.cache を見ればよい。なので、 $ node -p 'require("./index.js") && Object.keys(require.cache).length' これで数えられる。
小技。 #!/bin/bash ssh <user>@<hostname> 'bash -s' << EOS # ここにシェルスクリプトを書く echo hello echo world EOS CLI からも実行できる。 $ ssh <user>@<hostname> 'bash -s' << EOS > echo hello > echo world > EOS</hostname></user></hostname></user>
(TypeScript のバージョンは 3.7 である) Object.keys() は文字列の配列型を返す。 const SomeObject = { FOO: 'foo', BAR: 'bar', BAZ: 'baz', } // string[] 型 const keys = Object.keys(SomeObject) for (const key of keys) { // key は string 型な…