亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

首頁(yè) web前端 js教程 JsTraceToIX - 調(diào)試 React、Vue 和 Node.js 變得更容易! – 無(wú)需用「console.log」弄亂您的程式碼庫(kù)!

JsTraceToIX - 調(diào)試 React、Vue 和 Node.js 變得更容易! – 無(wú)需用「console.log」弄亂您的程式碼庫(kù)!

Oct 17, 2024 am 06:20 AM

JsTraceToIX - Debugging React, Vue, and Node.js just got easier! – no need to clutter your codebase with `console.log`!

If you've ever had to debug React or Vue components, arrow functions, or complex expressions on Node or the Web Browser, you know the pain of adding multiple console.log statements and making unnecessary code changes. That's where JsTraceToIX comes in!

Project Link

Key Features:

  • Simplifies debugging with minimal code changes.
  • Supports debugging of React, Vue, and Node.js environments, as well as regular browsers.
  • Handles single-line expressions and arrow functions with ease.
  • Easily define names, filter results, and override inputs and outputs for better traceability.
  • Simple function names, like c__ and d__, make it easy to spot and remove traces after catching the bug.
  • Works seamlessly with multithreaded environments.

Bonus: If you're working with Python, check out PyTraceToIX, which offers the same powerful debugging tools for your Python projects.

Say goodbye to complex and messy debugging – with JsTraceToIX, you can capture inputs and display results all in one step, making debugging cleaner and faster!

Check out JsTraceToIX and see how it can simplify your debugging process.

Installation

Environment Require Installation
Browser No
Node.js Yes
React Optional
Vue Yes
npm install jstracetoix --save-dev

React Usage

In this example:

  • cityTax arrow function captures the input price and names it 'Price'.
  • On ShoppingList function:
    • c__ captures the title in the first .
    • c__ captures the output of the cityTax and names it CityTax in the 2nd .
    • d__ displays the aggregated information in a single line: title, price, cityTax, total Price.

The d__ will generate this output:

i0:`Rice` | Price:`10` | CityTax:`5` | _:`15`
i0:`Coffee` | Price:`30` | CityTax:`15` | _:`45`
i0:`Shoes` | Price:`100` | CityTax:`15` | _:`115`
import './App.css';
// Without local installation
import { c__, d__ } from 'https://cdn.jsdelivr.net/gh/a-bentofreire/jstracetoix@1.1.0/component/jstracetoix.mjs';

// If it's installed locally via "npm install jstracetoix --save-dev"
// import { c__, d__ } from 'jstracetoix/component/jstracetoix.mjs';

const cityTax = (price) => c__(price, {name: 'Price'}) > 20 ? 15 : 5;
const products = [
    { title: 'Rice', price: 10, id: 1 },
    { title: 'Coffee', price: 30, id: 2 },
    { title: 'Shoes', price: 100, id: 3 },
];

function ShoppingList() {
    const listItems = products.map(product =>
        <tr key={product.id}>
            <td>{c__(product.title)}</td>
            <td>{d__(product.price + c__(cityTax(product.price), { name: 'CityTax' }))}</td>
        </tr>
    );

    return (
        <table><tbody>{listItems}</tbody></table>
    );
}

function App() {
    return (
        <div className="App">
            <header className="App-header">
                <ShoppingList />
            </header>
        </div>
    );
}

export default App;

Node.js Usage

In this example:

  • c__.allow() - overrides the input value being debugged when value > 40.00, for other values it doesn't captures the input.
  • d__.allow() - overrides the result value being debugged.
  • d__.after() - stops the program after displaying the result and the captured fields.
import { c__, d__ } from 'jstracetoix';

const products = [
    { "name": "Smartphone 128GB", "price": 699.00 },
    { "name": "Coffee Maker", "price": 49.99 },
    { "name": "Electric Toothbrush", "price": 39.95 },
    { "name": "4K Ultra HD TV", "price": 999.99 },
    { "name": "Gaming Laptop", "price": 1299.00 }];

const factor = (price) => price < 1000 ? 1.10 : 1;

const prices = d__(products.map(product => c__(product.price,
    {
        allow: (index, name, value) => value > 40.00 ?
            Math.floor(value * factor(value)) : false,
        name: product.name.substring(0, 10)
    })), {
    allow: (data) => data._.map((v, i) => `${i}:${v}`),
    after: (data) => process.exit() // exits after displaying the results
});
// Smartphone:`768` | Coffee Mak:`54` | 4K Ultra H:`1099` | Gaming Lap:`1299` | _:`["0:699","1:49.99","2:39.95","3:999.99","4:1299"]`

// this code is unreachable
for (const price in prices) {
    let value = price;
}

Output

Environment Default Output Function
Browser console.debug
Node.js process.stdout
React console.debug
Vue console.debug

Except for Node.js environment, the output is displayed in the browser's developer tools under the "Console Tab".
Since the output is generated using console.debug, it can easily be filtered out from regular console.log messages.

The default output function can be override using init__({'stream': new_stream.log })

Metadata

The d__ function callbacks allow, before and after will receive a parameter data with the allowed inputs plus the following meta items:

  • meta__: list of meta keys including the name key.
  • thread_id__: thread_id being executed
  • allow_input_count__: total number of inputs that are allowed.
  • input_count__: total number of inputs being captured.
  • allow__: If false it was allowed. Use this for after callback.
  • output__: Text passed to before without new_line.
  • name: name parameter

Documentation

Package Documentation

以上是JsTraceToIX - 調(diào)試 React、Vue 和 Node.js 變得更容易! – 無(wú)需用「console.log」弄亂您的程式碼庫(kù)!的詳細(xì)內(nèi)容。更多資訊請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願(yuàn)投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請(qǐng)聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動(dòng)的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線(xiàn)上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強(qiáng)大的PHP整合開(kāi)發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)程式碼編輯軟體(SublimeText3)

熱門(mén)話(huà)題

Laravel 教程
1597
29
PHP教程
1488
72
如何在node.js中提出HTTP請(qǐng)求? 如何在node.js中提出HTTP請(qǐng)求? Jul 13, 2025 am 02:18 AM

在Node.js中發(fā)起HTTP請(qǐng)求有三種常用方式:使用內(nèi)置模塊、axios和node-fetch。 1.使用內(nèi)置的http/https模塊無(wú)需依賴(lài),適合基礎(chǔ)場(chǎng)景,但需手動(dòng)處理數(shù)據(jù)拼接和錯(cuò)誤監(jiān)聽(tīng),例如用https.get()獲取數(shù)據(jù)或通過(guò).write()發(fā)送POST請(qǐng)求;2.axios是基於Promise的第三方庫(kù),語(yǔ)法簡(jiǎn)潔且功能強(qiáng)大,支持async/await、自動(dòng)JSON轉(zhuǎn)換、攔截器等,推薦用於簡(jiǎn)化異步請(qǐng)求操作;3.node-fetch提供類(lèi)似瀏覽器fetch的風(fēng)格,基於Promise且語(yǔ)法簡(jiǎn)單

JavaScript數(shù)據(jù)類(lèi)型:原始與參考 JavaScript數(shù)據(jù)類(lèi)型:原始與參考 Jul 13, 2025 am 02:43 AM

JavaScript的數(shù)據(jù)類(lèi)型分為原始類(lèi)型和引用類(lèi)型。原始類(lèi)型包括string、number、boolean、null、undefined和symbol,其值不可變且賦值時(shí)復(fù)制副本,因此互不影響;引用類(lèi)型如對(duì)象、數(shù)組和函數(shù)存儲(chǔ)的是內(nèi)存地址,指向同一對(duì)象的變量會(huì)相互影響。判斷類(lèi)型可用typeof和instanceof,但需注意typeofnull的歷史問(wèn)題。理解這兩類(lèi)差異有助於編寫(xiě)更穩(wěn)定可靠的代碼。

JavaScript時(shí)間對(duì)象,某人構(gòu)建了一個(gè)eactexe,在Google Chrome上更快的網(wǎng)站等等 JavaScript時(shí)間對(duì)象,某人構(gòu)建了一個(gè)eactexe,在Google Chrome上更快的網(wǎng)站等等 Jul 08, 2025 pm 02:27 PM

JavaScript開(kāi)發(fā)者們,大家好!歡迎閱讀本週的JavaScript新聞!本週我們將重點(diǎn)關(guān)注:Oracle與Deno的商標(biāo)糾紛、新的JavaScript時(shí)間對(duì)象獲得瀏覽器支持、GoogleChrome的更新以及一些強(qiáng)大的開(kāi)發(fā)者工具。讓我們開(kāi)始吧! Oracle與Deno的商標(biāo)之爭(zhēng)Oracle試圖註冊(cè)“JavaScript”商標(biāo)的舉動(dòng)引發(fā)爭(zhēng)議。 Node.js和Deno的創(chuàng)建者RyanDahl已提交請(qǐng)願(yuàn)書(shū),要求取消該商標(biāo),他認(rèn)為JavaScript是一個(gè)開(kāi)放標(biāo)準(zhǔn),不應(yīng)由Oracle

什麼是緩存API?如何與服務(wù)人員使用? 什麼是緩存API?如何與服務(wù)人員使用? Jul 08, 2025 am 02:43 AM

CacheAPI是瀏覽器提供的一種緩存網(wǎng)絡(luò)請(qǐng)求的工具,常與ServiceWorker配合使用,以提升網(wǎng)站性能和離線(xiàn)體驗(yàn)。 1.它允許開(kāi)發(fā)者手動(dòng)存儲(chǔ)如腳本、樣式表、圖片等資源;2.可根據(jù)請(qǐng)求匹配緩存響應(yīng);3.支持刪除特定緩存或清空整個(gè)緩存;4.通過(guò)ServiceWorker監(jiān)聽(tīng)fetch事件實(shí)現(xiàn)緩存優(yōu)先或網(wǎng)絡(luò)優(yōu)先等策略;5.常用於離線(xiàn)支持、加快重複訪(fǎng)問(wèn)速度、預(yù)加載關(guān)鍵資源及後臺(tái)更新內(nèi)容;6.使用時(shí)需注意緩存版本控制、存儲(chǔ)限制及與HTTP緩存機(jī)制的區(qū)別。

處理諾言:鏈接,錯(cuò)誤處理和承諾在JavaScript中 處理諾言:鏈接,錯(cuò)誤處理和承諾在JavaScript中 Jul 08, 2025 am 02:40 AM

Promise是JavaScript中處理異步操作的核心機(jī)制,理解鍊式調(diào)用、錯(cuò)誤處理和組合器是掌握其應(yīng)用的關(guān)鍵。 1.鍊式調(diào)用通過(guò).then()返回新Promise實(shí)現(xiàn)異步流程串聯(lián),每個(gè).then()接收上一步結(jié)果並可返回值或Promise;2.錯(cuò)誤處理應(yīng)統(tǒng)一使用.catch()捕獲異常,避免靜默失敗,並可在catch中返回默認(rèn)值繼續(xù)流程;3.組合器如Promise.all()(全成功才成功)、Promise.race()(首個(gè)完成即返回)和Promise.allSettled()(等待所有完成)

利用Array.Prototype方法用於JavaScript中的數(shù)據(jù)操作 利用Array.Prototype方法用於JavaScript中的數(shù)據(jù)操作 Jul 06, 2025 am 02:36 AM

JavaScript數(shù)組內(nèi)置方法如.map()、.filter()和.reduce()可簡(jiǎn)化數(shù)據(jù)處理;1).map()用於一對(duì)一轉(zhuǎn)換元素生成新數(shù)組;2).filter()按條件篩選元素;3).reduce()用於聚合數(shù)據(jù)為單一值;使用時(shí)應(yīng)避免誤用導(dǎo)致副作用或性能問(wèn)題。

JS綜述:深入研究JavaScript事件循環(huán) JS綜述:深入研究JavaScript事件循環(huán) Jul 08, 2025 am 02:24 AM

JavaScript的事件循環(huán)通過(guò)協(xié)調(diào)調(diào)用棧、WebAPI和任務(wù)隊(duì)列來(lái)管理異步操作。 1.調(diào)用棧執(zhí)行同步代碼,遇到異步任務(wù)時(shí)交由WebAPI處理;2.WebAPI在後臺(tái)完成任務(wù)後將回調(diào)放入相應(yīng)的隊(duì)列(宏任務(wù)或微任務(wù));3.事件循環(huán)檢查調(diào)用棧是否為空,若為空則從隊(duì)列中取出回調(diào)推入調(diào)用棧執(zhí)行;4.微任務(wù)(如Promise.then)優(yōu)先於宏任務(wù)(如setTimeout)執(zhí)行;5.理解事件循環(huán)有助於避免阻塞主線(xiàn)程並優(yōu)化代碼執(zhí)行順序。

了解事件在JavaScript DOM事件中冒泡和捕獲 了解事件在JavaScript DOM事件中冒泡和捕獲 Jul 08, 2025 am 02:36 AM

事件冒泡是從目標(biāo)元素向外傳播到祖先節(jié)點(diǎn),事件捕獲則是從外層向內(nèi)傳播到目標(biāo)元素。 1.事件冒泡:點(diǎn)擊子元素後,事件依次向上觸發(fā)父級(jí)元素的監(jiān)聽(tīng)器,例如點(diǎn)擊按鈕後先輸出Childclicked,再輸出Parentclicked。 2.事件捕獲:設(shè)置第三個(gè)參數(shù)為true,使監(jiān)聽(tīng)器在捕獲階段執(zhí)行,如點(diǎn)擊按鈕前先觸發(fā)父元素的捕獲監(jiān)聽(tīng)器。 3.實(shí)際用途包括統(tǒng)一管理子元素事件、攔截預(yù)處理和性能優(yōu)化。 4.DOM事件流分為捕獲、目標(biāo)和冒泡三個(gè)階段,默認(rèn)監(jiān)聽(tīng)器在冒泡階段執(zhí)行。

See all articles