Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 15, 2024 via pnpm

recast 0.23.4

JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator
Package summary
Share
0
issues
5
licenses
30
MIT
1
BSD-2-Clause
1
ISC
2
other licenses
BSD-3-Clause
1
0BSD
1
Package created
21 Sep 2012
Version published
11 Aug 2023
Maintainers
2
Total deps
34
Direct deps
5
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
30 Packages, Including:
assert@2.1.0
ast-types@0.16.1
available-typed-arrays@1.0.7
call-bind@1.0.7
define-data-property@1.1.4
define-properties@1.2.1
es-define-property@1.0.0
es-errors@1.3.0
for-each@0.3.3
function-bind@1.1.2
get-intrinsic@1.2.4
gopd@1.0.1
has-property-descriptors@1.0.2
has-proto@1.0.3
has-symbols@1.0.3
has-tostringtag@1.0.2
hasown@2.0.2
is-arguments@1.1.1
is-callable@1.2.7
is-generator-function@1.0.10
is-nan@1.3.2
is-typed-array@1.1.13
object-is@1.1.6
object-keys@1.1.1
object.assign@4.1.5
possible-typed-array-names@1.0.0
recast@0.23.4
set-function-length@1.2.2
util@0.12.5
which-typed-array@1.1.15

BSD 2-Clause "Simplified" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
esprima@4.0.1

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
inherits@2.0.4

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
source-map@0.6.1

BSD Zero Clause License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
include-copyright
include-license
include-original
Cannot
hold-liable
Must
1 Packages, Including:
tslib@2.6.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

5
All Dependencies CSV
β“˜ This is a list of recast 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
assert2.1.021.36 kBMIT
prod
ast-types0.16.199.66 kBMIT
prod
esprima4.0.150.86 kBBSD-2-Clause
prod
source-map0.6.1194.96 kBBSD-3-Clause
prod
tslib2.6.215.59 kB0BSD
prod

Visualizations

Frequently Asked Questions

What does recast do?

Recast is a powerful JavaScript library that provides functionality to transform JavaScript syntax trees, pretty-print the code in a nondestructive manner, and automatically generate source maps. Its main capability is to analyze and modify code at the syntax tree level, preserving the original formatting of any unmodified code. This makes it useful for making large-scale changes to JavaScript applications while ensuring code readability.

How do you use recast?

Using Recast in your JavaScript project starts with its installation, which can be accomplished via npm with npm install recast. The library can be imported into your JavaScript projects using named imports. Here is an example on how you can parse and print code with Recast:

import { parse, print } from "recast";

const source = '...'; // Some JavaScript code
console.log(print(parse(source)).code);

This will output the parsed and then printed JavaScript source code. The strength of Recast becomes evident when you want to manipulates the syntax tree between parsing and printing:

import * as recast from "recast";

const code = [
  "function add(a, b) {",
  "  return a + b;",
  "}"
].join("\n");

const ast = recast.parse(code);
const add = ast.program.body[0];
const b = recast.types.builders;

ast.program.body[0] = b.variableDeclaration("var", [
  b.variableDeclarator(add.id, b.functionExpression(
    null, 
    add.params,
    add.body
  ))
]);

const output = recast.print(ast).code;

This script takes a function declaration and turns it into a variable declaration, illustrating how you can use Recast to make changes to your JavaScript code programmatically.

Where are the recast docs?

Recast's documentation can be found in its source code hosted on GitHub at https://github.com/benjamn/recast. While the library doesn't have a dedicated API reference, its abilities and usage are thoroughly explained in the readme file. In addition to the basic documentation, developers looking to learn more about the types and interfaces of the library can reference the ast-types GitHub repository.