本文整理匯總了TypeScript中@ember/debug.debug函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug函數的具體用法?TypeScript debug怎麽用?TypeScript debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了debug函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
Libraries.prototype.logVersions = function(): void {
let libs = this._registry;
let nameLengths = libs.map(item => get(item, 'name.length'));
let maxNameLength = Math.max.apply(null, nameLengths);
debug('-------------------------------');
for (let i = 0; i < libs.length; i++) {
let lib = libs[i];
let spaces = new Array(maxNameLength - lib.name.length + 1).join(' ');
debug([lib.name, spaces, ' : ', lib.version].join(''));
}
debug('-------------------------------');
};
示例2: runInDebug
/**
* @ember/debug tests
*/
runInDebug(); // $ExpectError
runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void
// Log a warning if we have more than 3 tomsters
const tomsterCount = 2;
warn('Too many tomsters!'); // $ExpectType void
warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void
warn('Too many tomsters!', tomsterCount <= 3, { // $ExpectType void
id: 'ember-debug.too-many-tomsters'
});
debug(); // $ExpectError
debug('Too many tomsters!'); // $ExpectType void
debug('Too many tomsters!', 'foo'); // $ExpectError
// Test for truthiness
const str = 'hello';
assert('Must pass a string', typeof str === 'string'); // $ExpectType void
// Fail unconditionally
assert('This code path should never be run'); // $ExpectType void
// next is not called, so no warnings get the default behavior
registerWarnHandler(); // $ExpectError
registerWarnHandler(() => {}); // $ExpectType void
registerWarnHandler((message, { id }, next) => { // $ExpectType void
message; // $ExpectType string
示例3: logErrorMessage
logErrorMessage(subject: string, message: string) {
this.errorToast(subject, message);
debug(message);
}