process.throwDeprecation 屬性是 process 模塊的內置應用程序編程接口,用於指示當前 Node.js 進程是否設置了 -throw-deprecation 標誌。 process.throwDeprecation 是可變的,因此可能會在運行時更改棄用警告是否導致錯誤。
用法:
process.throwDeprecation
返回值:此屬性指示是否在當前 Node.js 進程上設置了 -throw-deprecation 標誌。
下麵的例子說明了 Node.js 中 process.throwDeprecation 屬性的使用:
範例1:
Javascript
// Node.js program to demonstrate the
// process.throwDeprecation Property
// Include process module
const process = require('process');
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
運行命令:node -throw-deprecation hello.js
輸出 1:
true
運行命令:節點 hello.js
輸出 2:
undefined
範例2:
Javascript
// Node.js program to demonstrate the
// process.throwDeprecation Property
// Include process module
const process = require('process');
// Instance Properties
process.throwDeprecation = false;
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
// Instance Properties
process.throwDeprecation = true;
// Printing process.throwDeprecation
// property value
console.log(process.throwDeprecation);
運行命令:node -throw-deprecation hello.js
輸出 1:
true true
運行命令:節點 hello.js
輸出 2:
false true
參考:https://nodejs.org/api/process.html#process_process_throwdeprecation
相關用法
- Node.js GM charcoal()用法及代碼示例
- Node.js GM blur()用法及代碼示例
- Node.js GM sharpen()用法及代碼示例
- Node.js GM drawLine()用法及代碼示例
- Node.js GM drawArc()用法及代碼示例
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Node.js process.throwDeprecation Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。