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

  • 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
  • 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 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
  • 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
  • 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
  • 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
  • > var esprima = require('esprima');
    > var program = 'const answer = 42';
     
    > esprima.tokenize(program);
    [ { type: 'Keyword', value: 'const' },
      { type: 'Identifier', value: 'answer' },
      { type: 'Punctuator', value: '=' },
      { type: 'Numeric', value: '42' } ]
      
    &gt; esprima.parseScript(program);
    { type: 'Program',
      body:
       [ { type: 'VariableDeclaration',
           declarations: [Object],
           kind: 'const' } ],
      sourceType: 'script' }
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">import</span> esprima</code></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples