Comparing version 1.1.0 to 2.0.0-beta.0
@@ -7,5 +7,7 @@ // Generated by dts-bundle v0.7.3 | ||
import { RegExpValidator } from "regexpp/validator"; | ||
import { RegExpVisitor } from "regexpp/visitor"; | ||
export { AST, RegExpParser, RegExpValidator }; | ||
export function parseRegExpLiteral(source: string, options?: RegExpParser.Options): AST.RegExpLiteral; | ||
export function parseRegExpLiteral(source: string | RegExp, options?: RegExpParser.Options): AST.RegExpLiteral; | ||
export function validateRegExpLiteral(source: string, options?: RegExpValidator.Options): void; | ||
export function visitRegExpAST(node: AST.Node, handlers: RegExpVisitor.Handlers): void; | ||
} | ||
@@ -15,8 +17,7 @@ | ||
export type Node = BranchNode | LeafNode; | ||
export type BranchNode = RegExpLiteral | Pattern | Disjunction | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion | CharacterClassRange; | ||
export type BranchNode = RegExpLiteral | Pattern | Alternative | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion | CharacterClassRange; | ||
export type LeafNode = BoundaryAssertion | CharacterSet | Character | Backreference | Flags; | ||
export type Element = Disjunction | Group | CapturingGroup | Quantifier | CharacterClass | Assertion | CharacterSet | Character | Backreference; | ||
export type Element = Assertion | Quantifier | QuantifiableElement; | ||
export type QuantifiableElement = Group | CapturingGroup | CharacterClass | CharacterSet | Character | Backreference | LookaheadAssertion; | ||
export type CharacterClassElement = EscapeCharacterSet | UnicodePropertyCharacterSet | Character | CharacterClassRange; | ||
export type AlternativeElement = Group | CapturingGroup | Quantifier | CharacterClass | Assertion | CharacterSet | Character | Backreference; | ||
export type QuantifiableElement = Group | CapturingGroup | CharacterClass | LookaheadAssertion | CharacterSet | Character | Backreference; | ||
export interface NodeBase { | ||
@@ -38,19 +39,19 @@ type: Node["type"]; | ||
parent: RegExpLiteral | null; | ||
elements: Element[]; | ||
alternatives: Alternative[]; | ||
} | ||
export interface Disjunction extends NodeBase { | ||
type: "Disjunction"; | ||
export interface Alternative extends NodeBase { | ||
type: "Alternative"; | ||
parent: Pattern | Group | CapturingGroup | LookaroundAssertion; | ||
alternatives: AlternativeElement[][]; | ||
elements: Element[]; | ||
} | ||
export interface Group extends NodeBase { | ||
type: "Group"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
elements: Element[]; | ||
parent: Alternative | Quantifier; | ||
alternatives: Alternative[]; | ||
} | ||
export interface CapturingGroup extends NodeBase { | ||
type: "CapturingGroup"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
name: string | null; | ||
elements: Element[]; | ||
alternatives: Alternative[]; | ||
references: Backreference[]; | ||
@@ -61,17 +62,17 @@ } | ||
type: "Assertion"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
kind: "lookahead"; | ||
negate: boolean; | ||
elements: Element[]; | ||
alternatives: Alternative[]; | ||
} | ||
export interface LookbehindAssertion extends NodeBase { | ||
type: "Assertion"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | LookaroundAssertion; | ||
parent: Alternative; | ||
kind: "lookbehind"; | ||
negate: boolean; | ||
elements: Element[]; | ||
alternatives: Alternative[]; | ||
} | ||
export interface Quantifier extends NodeBase { | ||
type: "Quantifier"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | LookaroundAssertion; | ||
parent: Alternative; | ||
min: number; | ||
@@ -84,3 +85,3 @@ max: number; | ||
type: "CharacterClass"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
negate: boolean; | ||
@@ -99,3 +100,3 @@ elements: CharacterClassElement[]; | ||
type: "Assertion"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
kind: "start" | "end"; | ||
@@ -105,3 +106,3 @@ } | ||
type: "Assertion"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
kind: "word"; | ||
@@ -113,3 +114,3 @@ negate: boolean; | ||
type: "CharacterSet"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
kind: "any"; | ||
@@ -119,3 +120,3 @@ } | ||
type: "CharacterSet"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion; | ||
parent: Alternative | Quantifier | CharacterClass; | ||
kind: "digit" | "space" | "word"; | ||
@@ -126,3 +127,3 @@ negate: boolean; | ||
type: "CharacterSet"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion; | ||
parent: Alternative | Quantifier | CharacterClass; | ||
kind: "property"; | ||
@@ -135,3 +136,3 @@ key: string; | ||
type: "Character"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | CharacterClass | LookaroundAssertion | CharacterClassRange; | ||
parent: Alternative | Quantifier | CharacterClass | CharacterClassRange; | ||
value: number; | ||
@@ -141,3 +142,3 @@ } | ||
type: "Backreference"; | ||
parent: Pattern | Disjunction | Group | CapturingGroup | Quantifier | LookaroundAssertion; | ||
parent: Alternative | Quantifier; | ||
ref: number | string; | ||
@@ -215,1 +216,39 @@ resolved: CapturingGroup; | ||
declare module 'regexpp/visitor' { | ||
import { Alternative, Assertion, Backreference, CapturingGroup, Character, CharacterClass, CharacterClassRange, CharacterSet, Flags, Group, Node, Pattern, Quantifier, RegExpLiteral } from "regexpp/ast"; | ||
export class RegExpVisitor { | ||
constructor(handlers: RegExpVisitor.Handlers); | ||
visit(node: Node): void; | ||
} | ||
export namespace RegExpVisitor { | ||
interface Handlers { | ||
onAlternativeEnter?(node: Alternative): void; | ||
onAlternativeLeave?(node: Alternative): void; | ||
onAssertionEnter?(node: Assertion): void; | ||
onAssertionLeave?(node: Assertion): void; | ||
onBackreferenceEnter?(node: Backreference): void; | ||
onBackreferenceLeave?(node: Backreference): void; | ||
onCapturingGroupEnter?(node: CapturingGroup): void; | ||
onCapturingGroupLeave?(node: CapturingGroup): void; | ||
onCharacterEnter?(node: Character): void; | ||
onCharacterLeave?(node: Character): void; | ||
onCharacterClassEnter?(node: CharacterClass): void; | ||
onCharacterClassLeave?(node: CharacterClass): void; | ||
onCharacterClassRangeEnter?(node: CharacterClassRange): void; | ||
onCharacterClassRangeLeave?(node: CharacterClassRange): void; | ||
onCharacterSetEnter?(node: CharacterSet): void; | ||
onCharacterSetLeave?(node: CharacterSet): void; | ||
onFlagsEnter?(node: Flags): void; | ||
onFlagsLeave?(node: Flags): void; | ||
onGroupEnter?(node: Group): void; | ||
onGroupLeave?(node: Group): void; | ||
onPatternEnter?(node: Pattern): void; | ||
onPatternLeave?(node: Pattern): void; | ||
onQuantifierEnter?(node: Quantifier): void; | ||
onQuantifierLeave?(node: Quantifier): void; | ||
onRegExpLiteralEnter?(node: RegExpLiteral): void; | ||
onRegExpLiteralLeave?(node: RegExpLiteral): void; | ||
} | ||
} | ||
} | ||
{ | ||
"name": "regexpp", | ||
"version": "1.1.0", | ||
"version": "2.0.0-beta.0", | ||
"description": "Regular expression parser for ECMAScript 2018.", | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=6.5.0" | ||
}, | ||
@@ -14,26 +14,20 @@ "main": "index", | ||
"devDependencies": { | ||
"@types/eslint": "^4.16.0", | ||
"@types/mocha": "^2.2.48", | ||
"@types/node": "^9.4.6", | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-transform-es2015-destructuring": "^6.23.0", | ||
"babel-plugin-transform-es2015-parameters": "^6.24.1", | ||
"babel-plugin-transform-es2015-spread": "^6.22.0", | ||
"@types/eslint": "^4.16.2", | ||
"@types/mocha": "^5.2.2", | ||
"@types/node": "^10.3.3", | ||
"coveralls": "^3.0.1", | ||
"dts-bundle": "^0.7.3", | ||
"eslint": "^4.18.0", | ||
"eslint-config-mysticatea": "^13.0.2", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-prettier": "^2.4.0", | ||
"mocha": "^5.0.1", | ||
"npm-run-all": "^4.1.2", | ||
"prettier": "^1.9.2", | ||
"eslint": "^4.19.1", | ||
"eslint-plugin-mysticatea": "^5.0.0-beta.15", | ||
"mocha": "^5.2.0", | ||
"npm-run-all": "^4.1.3", | ||
"nyc": "^12.0.2", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.56.1", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-node-resolve": "^3.0.3", | ||
"rollup": "^0.60.7", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"rollup-watch": "^4.3.1", | ||
"ts-node": "^5.0.0", | ||
"typescript": "^2.7.2", | ||
"typescript-eslint-parser": "^14.0.0" | ||
"ts-node": "^6.1.1", | ||
"typescript": "^2.9.2", | ||
"typescript-eslint-parser": "^16.0.0" | ||
}, | ||
@@ -43,12 +37,12 @@ "scripts": { | ||
"build": "run-s build:*", | ||
"build:tsc": "tsc --module es2015 --target es2015", | ||
"build:mjs": "rollup -c rollup-mjs.config.js", | ||
"build:js": "rollup -c rollup-js.config.js", | ||
"build:tsc": "tsc --module es2015", | ||
"build:rollup": "rollup -c", | ||
"build:dts": "dts-bundle --name regexpp --main .temp/index.d.ts --out ../index.d.ts", | ||
"clean": "rimraf .temp index.*", | ||
"lint": "eslint src test tools --ext .ts", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint scripts src test --ext .ts", | ||
"pretest": "run-s build lint", | ||
"test": "_mocha --require ts-node/register --reporter dot --timeout 10000 \"test/*.ts\"", | ||
"update:test": "ts-node tools/update-fixtures.ts", | ||
"update:ids": "ts-node tools/update-unicode-ids.ts", | ||
"test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000", | ||
"update:test": "ts-node scripts/update-fixtures.ts", | ||
"update:ids": "ts-node scripts/update-unicode-ids.ts", | ||
"preversion": "npm test", | ||
@@ -58,3 +52,3 @@ "version": "npm run -s build", | ||
"prewatch": "npm run -s clean", | ||
"watch": "npm run -s test -- --watch-extensions .ts --watch --growl" | ||
"watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions .ts --watch --growl" | ||
}, | ||
@@ -61,0 +55,0 @@ "repository": { |
@@ -6,2 +6,3 @@ # regexpp | ||
[![Build Status](https://travis-ci.org/mysticatea/regexpp.svg?branch=master)](https://travis-ci.org/mysticatea/regexpp) | ||
[![Coverage Status](https://coveralls.io/repos/github/mysticatea/regexpp/badge.svg)](https://coveralls.io/github/mysticatea/regexpp) | ||
[![Dependency Status](https://david-dm.org/mysticatea/regexpp.svg)](https://david-dm.org/mysticatea/regexpp) | ||
@@ -17,3 +18,3 @@ | ||
- require Node.js 4.0.0 or newer. | ||
- require Node.js 6.5.0 or newer. | ||
@@ -27,4 +28,6 @@ ## 📖 Usage | ||
RegExpValidator, | ||
RegExpVisitor, | ||
parseRegExpLiteral, | ||
validateRegExpLiteral, | ||
visitRegExpAST | ||
} from "regexpp" | ||
@@ -40,3 +43,3 @@ ``` | ||
- **Parameters:** | ||
- `source` (`string`) The source code to parse. | ||
- `source` (`string | RegExp`) The source code to parse. | ||
- `options?` ([`RegExpParser.Options`]) The options to parse. | ||
@@ -56,2 +59,12 @@ - **Return:** | ||
### visitRegExpAST(ast, handlers) | ||
Visit each node of a given AST. | ||
This is equivalent to `new RegExpVisitor(handlers).visit(ast)`. | ||
- **Parameters:** | ||
- `ast` ([`AST.Node`]) The AST to visit. | ||
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks. | ||
### RegExpParser | ||
@@ -133,2 +146,16 @@ | ||
### RegExpVisitor | ||
#### new RegExpVisitor(handlers) | ||
- **Parameters:** | ||
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks. | ||
#### visitor.visit(ast) | ||
Validate a regular expression literal. | ||
- **Parameters:** | ||
- `ast` ([`AST.Node`]) The AST to visit. | ||
## 📰 Changelog | ||
@@ -154,3 +181,5 @@ | ||
[`RegExpParser.Options`]: src/parser.ts#L527 | ||
[`AST.Node`]: src/ast.ts#L4 | ||
[`RegExpParser.Options`]: src/parser.ts#L539 | ||
[`RegExpValidator.Options`]: src/validator.ts#L127 | ||
[`RegExpVisitor.Handlers`]: src/visitor.ts#L204 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1251124
18
14324
179
0
1