@ast-grep/napi
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -6,5 +6,15 @@ /* tslint:disable */ | ||
export const enum FrontEndLanguage { | ||
Html = 0, | ||
JavaScript = 1, | ||
Tsx = 2, | ||
TypeScript = 3 | ||
} | ||
export interface Pos { | ||
row: number | ||
col: number | ||
/** line number starting from 1 */ | ||
line: number | ||
/** column number starting from 1 */ | ||
column: number | ||
/** byte offset of the position */ | ||
index: number | ||
} | ||
@@ -15,2 +25,7 @@ export interface Range { | ||
} | ||
export interface NapiConfig { | ||
rule: any | ||
constraints?: any | ||
language?: FrontEndLanguage | ||
} | ||
export class SgNode { | ||
@@ -26,5 +41,7 @@ range(): Range | ||
follows(m: string): boolean | ||
getMatch(m: string): SgNode | null | ||
getMultipleMatches(m: string): Array<SgNode> | ||
children(): Array<SgNode> | ||
findByString(pattern: string): SgNode | null | ||
findAll(pattern: string): Array<SgNode> | ||
find(matcher: string | number | NapiConfig): SgNode | null | ||
findAll(matcher: string | number | NapiConfig): Array<SgNode> | ||
field(name: string): SgNode | null | ||
@@ -39,9 +56,29 @@ parent(): SgNode | null | ||
} | ||
export type SgRoot = AstGrep | ||
export class AstGrep { | ||
static html(src: string): SgRoot | ||
static js(src: string): SgRoot | ||
static ts(src: string): SgRoot | ||
static tsx(src: string): SgRoot | ||
export class SgRoot { | ||
root(): SgNode | ||
} | ||
export namespace html { | ||
export function parse(src: string): SgRoot | ||
export function kind(kindName: string): number | ||
export function pattern(pattern: string): NapiConfig | ||
} | ||
export namespace js { | ||
export function parse(src: string): SgRoot | ||
export function kind(kindName: string): number | ||
export function pattern(pattern: string): NapiConfig | ||
} | ||
export namespace jsx { | ||
export function parse(src: string): SgRoot | ||
export function kind(kindName: string): number | ||
export function pattern(pattern: string): NapiConfig | ||
} | ||
export namespace ts { | ||
export function parse(src: string): SgRoot | ||
export function kind(kindName: string): number | ||
export function pattern(pattern: string): NapiConfig | ||
} | ||
export namespace tsx { | ||
export function parse(src: string): SgRoot | ||
export function kind(kindName: string): number | ||
export function pattern(pattern: string): NapiConfig | ||
} |
10
index.js
@@ -239,5 +239,11 @@ const { existsSync, readFileSync } = require('fs') | ||
const { SgNode, AstGrep } = nativeBinding | ||
const { FrontEndLanguage, SgNode, SgRoot, html, js, jsx, ts, tsx } = nativeBinding | ||
module.exports.FrontEndLanguage = FrontEndLanguage | ||
module.exports.SgNode = SgNode | ||
module.exports.AstGrep = AstGrep | ||
module.exports.SgRoot = SgRoot | ||
module.exports.html = html | ||
module.exports.js = js | ||
module.exports.jsx = jsx | ||
module.exports.ts = ts | ||
module.exports.tsx = tsx |
{ | ||
"name": "@ast-grep/napi", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Search and Rewrite code at large scale using precise AST pattern", | ||
"main": "index.js", | ||
"repository": "https://github.com/HerringtonDarkholme/ast-grep", | ||
"repository": "https://github.com/ast-grep/ast-grep", | ||
"license": "MIT", | ||
@@ -67,9 +67,9 @@ "keywords": [ | ||
"optionalDependencies": { | ||
"@ast-grep/napi-win32-x64-msvc": "0.1.4", | ||
"@ast-grep/napi-darwin-x64": "0.1.4", | ||
"@ast-grep/napi-linux-x64-gnu": "0.1.4", | ||
"@ast-grep/napi-win32-ia32-msvc": "0.1.4", | ||
"@ast-grep/napi-darwin-arm64": "0.1.4", | ||
"@ast-grep/napi-win32-arm64-msvc": "0.1.4" | ||
"@ast-grep/napi-win32-x64-msvc": "0.1.5", | ||
"@ast-grep/napi-darwin-x64": "0.1.5", | ||
"@ast-grep/napi-linux-x64-gnu": "0.1.5", | ||
"@ast-grep/napi-win32-ia32-msvc": "0.1.5", | ||
"@ast-grep/napi-darwin-arm64": "0.1.5", | ||
"@ast-grep/napi-win32-arm64-msvc": "0.1.5" | ||
} | ||
} |
# @ast-grep/napi | ||
See https://github.com/HerringtonDarkholme/ast-grep | ||
See https://github.com/ast-grep/ast-grep | ||
@@ -5,0 +5,0 @@ ## Support matrix |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
13159
319