Socket
Book a DemoInstallSign in
Socket

@knighted/reparse

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knighted/reparse

Multiple swc parsings of the same file with correct spans.

2.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@knighted/reparse

CI codecov NPM version

Multiple SWC parsings of the same file with correct spans.

Provides a workaround for swc/1366.

Requirements

  • Node >= 20.11.0
  • @swc/core >= 1.5.24 as peer dependency

Example

There are four exports reparse, reparseFile, reparseSync and reparseFileSync.

import { reparse } from '@knighted/reparse'
import assert from 'node:assert/strict'

const ast1 = await reparse('const foo = "bar"')
const ast2 = await reparse('const foo = "bar"')

assert.equal(ast1.span.start, ast2.span.start)
assert.equal(ast1.span.end, ast2.span.end)

Sync file example:

import { reparseFileSync } from '@knighted/reparse'

const ast0 = reparseFileSync('./file.ts')
const ast1 = reparseFileSync('./file.ts')

console.log(ast0.span.start === ast1.span.start) // true

Keywords

swc

FAQs

Package last updated on 18 Jun 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.