gnome-shell の拡張機能を作成しています。JavaScript 拡張機能は、SQL クエリを生成し、標準出力で出力をキャプチャします。SQL クエリが 0 のタプル/レコードと評価される場合、拡張機能がクラッシュします。
以下はコードスニペットです。
let [success, out, err, error] = GLib.spawn_sync(null, ["sqlite3", "-line", places, sqlQuery], null, 4, null);
let result = out.toString(); // Crashing here for 0 tuples. I was expecting 'result = ""'
私はJavaScriptの初心者です。out
このシナリオでのオブジェクトの処理方法がわかりません。オブジェクトが null ではありません。未定義でもありません。
typeof out == null // false
typeof out == undefined // false
typeof out == "object" // true
編集
typeof out == "null" // false
typeof out == "undefined" // false
typeof out == "object" // true