How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • module.exports = function(options) {
      
      //...
    return {
        transform: function(code, id) {
          
          //...
    var ast, magic = new MagicString(code), modified;
    
          try {
            ast = acorn.parse(code, {ecmaVersion: 6, sourceType: "module"});
          } catch (error) {
            error.message += " in " + id;
            throw error;
          }
    
          
    
          //...
    }
      };
    }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">module</span> <span class="token keyword">export</span><span class="token operator">=</span> <span class="token punctuation">(</span>property<span class="token punctuation">)</span> <span class="token keyword">export</span><span class="token operator">=</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">options<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span> <span class="token function-variable function">transform</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">code<span class="token operator">:</span> any<span class="token punctuation">,</span> id<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">undefined</span><span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre>
    /mbostock/rollup-plugin-ascii BSD-3-Clause
    0
  • function rename(code, tokenTo, tokenFrom) {
    
      
    
      //...
    try {
        ast = acorn.parse(code, {
          ecmaVersion: 11,
          ranges: true,
          allowReturnOutsideFunction: true
        });
      } catch(err) {
        // this should probably log something and/or exit violently
        return code;
      }
    
      
    
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">rename</span><span class="token punctuation">(</span><span class="token parameter">code<span class="token operator">:</span> any<span class="token punctuation">,</span> tokenTo<span class="token operator">:</span> any<span class="token punctuation">,</span> tokenFrom<span class="token operator">:</span> any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    /calvinmetcalf/derequire mit
    0
  • let acorn = require("acorn");
    console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}));
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">namespace</span> acorn <span class="token keyword">import</span> acorn</code></pre>
    Docs
    0
  • function transform (code) {
        var ast = acorn.parse(code, { sourceType: 'module' });
        return escodegen.generate(unassert(ast));
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">transform</span><span class="token punctuation">(</span><span class="token parameter">code<span class="token operator">:</span> any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    /unassert-js/unassert-cli MIT
    0
  • var acorn = require("acorn");
    var jsx = require("acorn-jsx");
    var JSXParser = acorn.Parser.extend(jsx());
    JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">namespace</span> acorn <span class="token keyword">import</span> acorn</code></pre>
    Docs
    0
  • var acorn = require("acorn");
    var jsx = require("acorn-jsx");
    var JSXParser = acorn.Parser.extend(jsx());
    JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">namespace</span> acorn <span class="token keyword">import</span> acorn</code></pre>
    Docs
    0
  • for (let token of acorn.tokenizer(str)) {
      // iterate over the tokens
    }
    
    // transform code to array of tokens:
    var tokens = [...acorn.tokenizer(str)];
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">let</span> token<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • const transformFile = (fileName, whiteListedModules) => {
      
      //...
    try {
        
        //...
    const inputCode = fs.readFileSync(fileName, 'utf8');
        const ast = parser.parse(inputCode, {
          sourceType: 'module',
          plugins: parserPlugins,
        });
    
        // Run the plugin
        
        //...
    } catch (err) {
        console.error('Error for file:', fileName);
        console.error(err);
      }
    };
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> <span class="token function-variable function">transformFile</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">fileName<span class="token operator">:</span> any<span class="token punctuation">,</span> whiteListedModules<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">void</span></code></pre>
    /Ghost---Shadow/unit-test-recorder mit
    0
  • const check = function (code, options) {
      
      //...
    type = type.toUpperCase();
      const ast = parser.parse(code, {
        plugins: ['flow', 'dynamicImport'],
        sourceType: 'module'
      });
      let tokenList = [];
    
      
    
      //...
    }
    
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> <span class="token function-variable function">check</span><span class="token operator">:</span> <span class="token punctuation">(</span><span class="token parameter">code<span class="token operator">:</span> any<span class="token punctuation">,</span> options<span class="token operator">:</span> any</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token builtin">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span></code></pre>
    /didi/chameleon apache-2.0
    0
  • function ReactHotExportLoader(source) {
      
      //...
    if (!source || isProductionEnv() || shouldSkip()) {
        return source;
      }
    
      const ast = parse(source, {
        sourceType: 'module',
        plugins: ['jsx', ...plugins],
      });
    
    
      let importReactLibrary = false;
      let exportReactComponent = false;
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">ReactHotExportLoader</span><span class="token punctuation">(</span><span class="token parameter">source<span class="token operator">:</span> any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    /ahonn/react-hot-export-loader mit
    0
  • function transform(code, componentName) {
      const ast = parser.parse(code, {
        sourceType: 'module',
        plugins: [['decorators-legacy', { decoratorsBeforeExport: false }]],
      });
    
      let umlData = '';
    
      let memberDefs = [];
      let serviceDefs = [];
      let extendDefs = [];
      let className = '';
      
      //...
    }
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">transform</span><span class="token punctuation">(</span><span class="token parameter">code<span class="token operator">:</span> any<span class="token punctuation">,</span> componentName<span class="token operator">:</span> any</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">string</span></code></pre>
    /rajasegar/ember-gen-uml mit
    0
  • function generateCode(definition, options) {
      
      //...
    const ast = parse(source, {
        sourceType: 'module',
        plugins: ['typescript'],
      });
    
      
    
      //...
    }
    
    
    
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">generateCode</span><span class="token punctuation">(</span><span class="token parameter">definition<span class="token operator">:</span> object<span class="token punctuation">,</span> options<span class="token operator">:</span> object</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">string</span></code><div class="typing-tooltip-markup">Generate codes<br><br><em>@param</em> <code>definition</code><br><br><em>@param</em> <code>options</code></div></pre>
    /nodejh/sequelize-automate mit
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples