Socket
Socket
Sign inDemoInstall

micromark-util-events-to-acorn

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-util-events-to-acorn

micromark utility to try and parse events w/ acorn


Version published
Weekly downloads
1.6M
increased by3.48%
Maintainers
1
Weekly downloads
 
Created
Source

micromark-util-events-to-acorn

Build Coverage Downloads Size Sponsors Backers Chat

micromark utility to try and parse events w/ acorn.

Contents

Install

npm:

npm install micromark-util-events-to-acorn

Use

import {eventsToAcorn} from 'micromark-util-events-to-acorn'

// A factory that uses the utility:
/** @type {Tokenizer} */
function factoryMdxExpression(effects, ok, nok) {
  return start

  // …

  /** @type {State} */
  atClosingBrace(code) {
    // …

    // Gnostic mode: parse w/ acorn.
    const result = eventsToAcorn(
      self.events.slice(eventStart),
      acorn,
      acornOptions,
      {
        start: startPosition,
        expression: true,
        allowEmpty,
        prefix: spread ? '({' : '',
        suffix: spread ? '})' : ''
      }
    )

    // …
  }

  // …
}

API

This module exports the following identifiers: eventsToAcorn. There is no default export.

The export map supports the endorsed development condition. Run node --conditions development module.js to get instrumented dev code. Without this condition, production code is loaded.

eventsToAcorn(events, options)

Parameters
  • events (Array.<Event>) — Events
  • options.acorn (Acorn, required) — Object with acorn.parse and acorn.parseExpressionAt
  • options.acornOptions (AcornOptions) — Configuration for acorn
  • options.start (Point, optional) — Place where events start
  • options.prefix (string, default: '') — Text to place before events
  • options.suffix (string, default: '') — Text to place after events
  • options.expression (boolean, default: false) — Whether this is a program or expression
  • options.allowEmpty (boolean, default: false) — Whether an empty expression is allowed (programs are always allowed to be empty).
Returns
  • estree (Program?) — Estree node
  • error (Error?) — Error if unparseable
  • swallow (boolean) — Whether the error, if there is one, can be swallowed and more JavaScript could be valid.

Security

See security.md in micromark/.github for how to submit a security report.

Contribute

See contributing.md in micromark/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 19 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc