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)];
    
    Docs
    0
  • var acorn = require("acorn");
    var jsx = require("acorn-jsx");
    var JSXParser = acorn.Parser.extend(jsx());
    JSXParser.parse("foo()", { ecmaVersion: 2020 });
    
    Docs
    0
  • const { makeTokenizer } = require("@tokenizer/http");
    const FileType = require("file-type");
    
    const audioTrackUrl =
      "https://test-audio.netlify.com/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/01%20-%20Diablo%20Swing%20Orchestra%20-%20Heroines.mp3";
    
    (async () => {
      const httpTokenizer = await makeTokenizer(audioTrackUrl);
      const fileType = await FileType.fromTokenizer(
        httpTokenizer
      );
    
      console.log(fileType);
      //=> {ext: 'mp3', mime: 'audio/mpeg'}
    })();
    
    Docs
    0
  • const FileType = require("file-type");
    const S3 = require("aws-sdk/clients/s3");
    const { makeTokenizer } = require("@tokenizer/s3");
    
    (async () => {
      // Initialize the S3 client
      const s3 = new S3();
    
      // Initialize the S3 tokenizer.
      const s3Tokenizer = await makeTokenizer(s3, {
        Bucket: "affectlab",
        Key: "1min_35sec.mp4",
      });
    
      // Figure out what kind of file it is.
      const fileType = await FileType.fromTokenizer(
        s3Tokenizer
      );
      console.log(fileType);
    })();
    
    Docs
    0
  • let acorn = require("acorn");
    console.log(acorn.parse("1 + 1", { ecmaVersion: 2020 }));
    
    Docs
    0
  • var acorn = require("acorn"),
      jsesc = require("jsesc"),
      walk = require("estree-walker").walk,
      MagicString = require("magic-string"),
      createFilter = require("rollup-pluginutils").createFilter,
      extname = require("path").extname;
    
    module.exports = function (options) {
      if (options == null) options = {};
      var filter = createFilter(
          options.include,
          options.exclude
        ),
        map = options.sourceMap !== false;
      return {
        transform: function (code, id) {
          if (!filter(id) || extname(id) !== ".js") return;
    
          var ast,
            magic = new MagicString(code),
            modified;
    
          try {
            ast = acorn.parse(code, {
              ecmaVersion: 6,
              sourceType: "module",
            });
          } catch (error) {
            error.message += " in " + id;
            throw error;
          }
    
          walk(ast, {
            enter: function (node, parent) {
              if (map) {
                magic.addSourcemapLocation(node.start);
                magic.addSourcemapLocation(node.end);
              }
              if (
                node.type === "Literal" &&
                typeof node.value === "string"
              ) {
                var raw0 = node.raw,
                  raw1 = jsesc(node.value, {
                    wrap: true,
                    quotes:
                      raw0[0] === "'" ? "single" : "double",
                  });
                if (raw0 !== raw1) {
                  modified = true;
                  magic.overwrite(node.start, node.end, raw1);
                }
              }
            },
          });
    
          return (
            modified && {
              code: magic.toString(),
              map: map && magic.generateMap(),
            }
          );
        },
      };
    };
    
    /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()", { ecmaVersion: 2020 });
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples