From 178d1bd986bc07d6336c64cd4c9fb1f410e5807b Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Thu, 22 Aug 2024 20:45:41 +0000 Subject: [PATCH] docs(transformer): add documentation for exponentiation-operator plugin (#5084) follow-up #4881 --- .../src/es2016/exponentiation_operator.rs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/oxc_transformer/src/es2016/exponentiation_operator.rs b/crates/oxc_transformer/src/es2016/exponentiation_operator.rs index 08e283cab..39dbd68ab 100644 --- a/crates/oxc_transformer/src/es2016/exponentiation_operator.rs +++ b/crates/oxc_transformer/src/es2016/exponentiation_operator.rs @@ -1,3 +1,35 @@ +//! ES2016: Exponentiation Operator +//! +//! This plugin transforms the exponentiation operator (`**`) to `Math.pow`. +//! +//! > This plugin is included in `preset-env`, in ES2016 +//! +//! ## Example +//! +//! Input: +//! ```js +//! let x = 10 ** 2; +//! +//! x **= 3; +//! ``` +//! +//! Output: +//! ```js +//! let x = Math.pow(10, 2); +//! +//! x = Math.pow(x, 3); +//! ``` +//! +//! ## Implementation +//! +//! Implementation based on [@babel/plugin-transform-exponentiation-operator](https://babel.dev/docs/babel-plugin-transform-exponentiation-operator). +//! +//! ## References: +//! +//! * Babel plugin implementation: +//! * Exponentiation operator TC39 proposal: +//! * Exponentiation operator specification: + use std::cell::Cell; use oxc_allocator::{CloneIn, Vec};