1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["21564"],{98278:function(e,n,r){r.r(n),r.d(n,{metadata:function(){return a},default:function(){return m},frontMatter:function(){return s},contentTitle:function(){return u},toc:function(){return p},assets:function(){return c}});var a=JSON.parse('{"id":"babel-plugin-transform-simplify-comparison-operators","title":"babel-plugin-transform-simplify-comparison-operators","description":"Example","source":"@site/../docs/plugin-transform-simplify-comparison-operators.md","sourceDirName":".","slug":"/babel-plugin-transform-simplify-comparison-operators","permalink":"/docs/babel-plugin-transform-simplify-comparison-operators","draft":false,"unlisted":false,"editUrl":"https://github.com/babel/website/edit/main/docs/../docs/plugin-transform-simplify-comparison-operators.md","tags":[],"version":"current","frontMatter":{"id":"babel-plugin-transform-simplify-comparison-operators","title":"babel-plugin-transform-simplify-comparison-operators","sidebar_label":"simplify-comparison-operators"}}'),t=r(62540),l=r(43023),i=r(77779),o=r(98263);let s={id:"babel-plugin-transform-simplify-comparison-operators",title:"babel-plugin-transform-simplify-comparison-operators",sidebar_label:"simplify-comparison-operators"},u,c={},p=[{value:"Example",id:"example",level:2},{value:"Installation",id:"installation",level:2},{value:"Usage",id:"usage",level:2},{value:"With a configuration file (Recommended)",id:"with-a-configuration-file-recommended",level:3},{value:"Via CLI",id:"via-cli",level:3},{value:"Via Node API",id:"via-node-api",level:3}];function d(e){let n={code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"In"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:'title="JavaScript"',children:'typeof foo === "object";\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Out"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:'title="JavaScript"',children:'typeof foo == "object";\n'})}),"\n",(0,t.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,t.jsxs)(i.A,{groupId:"npm2yarn",children:[(0,t.jsx)(o.A,{value:"npm",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"npm install babel-plugin-transform-simplify-comparison-operators --save-dev\n"})})}),(0,t.jsx)(o.A,{value:"yarn",label:"Yarn",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"yarn add babel-plugin-transform-simplify-comparison-operators --dev\n"})})}),(0,t.jsx)(o.A,{value:"pnpm",label:"pnpm",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"pnpm add babel-plugin-transform-simplify-comparison-operators --save-dev\n"})})}),(0,t.jsx)(o.A,{value:"bun",label:"Bun",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-shell",children:"bun add babel-plugin-transform-simplify-comparison-operators --dev\n"})})})]}),"\n",(0,t.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,t.jsx)(n.h3,{id:"with-a-configuration-file-recommended",children:"With a configuration file (Recommended)"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",metastring:'title="babel.config.json"',children:'{\n "plugins": ["transform-simplify-comparison-operators"]\n}\n'})}),"\n",(0,t.jsx)(n.h3,{id:"via-cli",children:"Via CLI"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-sh",metastring:'title="Shell"',children:"babel --plugins transform-simplify-comparison-operators script.js\n"})}),"\n",(0,t.jsx)(n.h3,{id:"via-node-api",children:"Via Node API"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",metastring:'title="JavaScript"',children:'require("@babel/core").transformSync("code", {\n plugins: ["transform-simplify-comparison-operators"],\n});\n'})})]})}function m(e={}){let{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},98263:function(e,n,r){r.d(n,{A:function(){return o}});var a=r(62540);r(63696);var t=r(11750),l=r(23865);function i({children:e,className:n,hidden:r}){return(0,a.jsx)("div",{role:"tabpanel",className:(0,t.A)("tabItem_wHwb",n),hidden:r,children:e})}function o({children:e,className:n,value:r}){let{selectedValue:t,lazy:s}=(0,l.uc)(),u=r===t;return!u&&s?null:(0,a.jsx)(i,{className:n,hidden:!u,children:e})}},77779:function(e,n,r){r.d(n,{A:function(){return d}});var a=r(62540);r(63696);var t=r(11750),l=r(46065),i=r(23865),o=r(45194),s=r(83029);function u({className:e}){let{selectedValue:n,selectValue:r,tabValues:l,block:s}=(0,i.uc)(),c=[],{blockElementScrollPositionUntilNextRender:p}=(0,o.a_)(),d=e=>{let a=e.currentTarget,t=l[c.indexOf(a)].value;t!==n&&(p(a),r(t))},m=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{let r=c.indexOf(e.currentTarget)+1;n=c[r]??c[0];break}case"ArrowLeft":{let r=c.indexOf(e.currentTarget)-1;n=c[r]??c[c.length-1]}}n?.focus()};return(0,a.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,t.A)("tabs",{"tabs--block":s},e),children:l.map(({value:e,label:r,attributes:l})=>(0,a.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:e=>{c.push(e)},onKeyDown:m,onClick:d,...l,className:(0,t.A)("tabs__item","tabItem_l0OV",l?.className,{"tabs__item--active":n===e}),children:r??e},e))})}function c({children:e}){return(0,a.jsx)("div",{className:"margin-top--md",children:e})}function p({className:e,children:n}){return(0,a.jsxs)("div",{className:(0,t.A)(l.G.tabs.container,"tabs-container","tabList_J5MA"),children:[(0,a.jsx)(u,{className:e}),(0,a.jsx)(c,{children:n})]})}function d(e){let n=(0,s.A)(),r=(0,i.OC)(e);return(0,a.jsx)(i.O_,{value:r,children:(0,a.jsx)(p,{className:e.className,children:(0,i.vT)(e.children)})},String(n))}},23865:function(e,n,r){r.d(n,{OC:function(){return d},O_:function(){return h},uc:function(){return f},vT:function(){return c}});
1var a=r(62540),t=r(63696),l=r(49519),i=r(6743),o=r(88511),s=r(15396),u=r(89030);function c(e){return t.Children.toArray(e).filter(e=>"\n"!==e)}function p({value:e,tabValues:n}){return n.some(n=>n.value===e)}function d(e){let n,{defaultValue:r,queryString:a=!1,groupId:c}=e,d=function(e){let{values:n,children:r}=e;return(0,t.useMemo)(()=>{let e=n??t.Children.toArray(r).flatMap(e=>{if(!e)return[];if((0,t.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return[e];let n="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${n}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop. 2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:n,attributes:r,default:a}})=>({value:e,label:n,attributes:r,default:a})),a=(0,s.XI)(e,(e,n)=>e.value===n.value);if(a.length>0)throw Error(`Docusaurus error: Duplicate values "${a.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,r])}(e),[m,f]=(0,t.useState)(()=>(function({defaultValue:e,tabValues:n}){if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!p({value:e,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let r=n.find(e=>e.default)??n[0];if(!r)throw Error("Unexpected error: 0 tabValues");return r.value})({defaultValue:r,tabValues:d})),[h,b]=function({queryString:e=!1,groupId:n}){let r=(0,l.W6)(),a=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,o.aZ)(a),(0,t.useCallback)(e=>{if(!a)return;let n=new URLSearchParams(r.location.search);n.set(a,e),r.replace({...r.location,search:n.toString()})},[a,r])]}({queryString:a,groupId:c}),[v,g]=function({groupId:e}){let n=e?`docusaurus.tab.${e}`:null,[r,a]=(0,u.Dv)(n);return[r,(0,t.useCallback)(e=>{n&&a.set(e)},[n,a])]}({groupId:c}),x=p({value:n=h??v,tabValues:d})?n:null;return(0,i.A)(()=>{x&&f(x)},[x]),{selectedValue:m,selectValue:(0,t.useCallback)(e=>{if(!p({value:e,tabValues:d}))throw Error(`Can't select invalid tab value=${e}`);f(e),b(e),g(e)},[b,g,d]),tabValues:d,lazy:e.lazy??!1,block:e.block??!1}}let m=(0,t.createContext)(null);function f(){let e=t.useContext(m);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function h(e){return(0,a.jsx)(m.Provider,{value:e.value,children:e.children})}},43023:function(e,n,r){r.d(n,{R:function(){return i},x:function(){return o}});var a=r(63696);let t={},l=a.createContext(t);function i(e){let n=a.useContext(l);return a.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),a.createElement(l.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.