1.0.0 • Published 6 months ago

@patrten/odit-id v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@patrten/odit-id

npm version Downloads/month Build Status codecov

A regular expression parser for ECMAScript.

💿 Installation

$ npm install @patrten/odit-id
  • require Node@^12.0.0 || ^14.0.0 || >=16.0.0.

📖 Usage

import {
    AST,
    RegExpParser,
    RegExpValidator,
    RegExpVisitor,
    parseRegExpLiteral,
    validateRegExpLiteral,
    visitRegExpAST
} from "@patrten/odit-id"

parseRegExpLiteral(source, options?)

Parse a given regular expression literal then make AST object.

This is equivalent to new RegExpParser(options).parseLiteral(source).

  • Parameters:
    • source (string | RegExp) The source code to parse.
    • options? (RegExpParser.Options) The options to parse.
  • Return:
    • The AST of the regular expression.

validateRegExpLiteral(source, options?)

Validate a given regular expression literal.

This is equivalent to new RegExpValidator(options).validateLiteral(source).

visitRegExpAST(ast, handlers)

Visit each node of a given AST.

This is equivalent to new RegExpVisitor(handlers).visit(ast).

RegExpParser

new RegExpParser(options?)

parser.parseLiteral(source, start?, end?)

Parse a regular expression literal.

  • Parameters:
    • source (string) The source code to parse. E.g. "/abc/g".
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.
  • Return:
    • The AST of the regular expression.

parser.parsePattern(source, start?, end?, flags?)

Parse a regular expression pattern.

  • Parameters:
    • source (string) The source code to parse. E.g. "abc".
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.
    • flags? ({ unicode?: boolean, unicodeSets?: boolean }) The flags to enable Unicode mode, and Unicode Set mode.
  • Return:
    • The AST of the regular expression pattern.

parser.parseFlags(source, start?, end?)

Parse a regular expression flags.

  • Parameters:
    • source (string) The source code to parse. E.g. "gim".
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.
  • Return:
    • The AST of the regular expression flags.

RegExpValidator

new RegExpValidator(options)

validator.validateLiteral(source, start, end)

Validate a regular expression literal.

  • Parameters:
    • source (string) The source code to validate.
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.

validator.validatePattern(source, start, end, flags)

Validate a regular expression pattern.

  • Parameters:
    • source (string) The source code to validate.
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.
    • flags? ({ unicode?: boolean, unicodeSets?: boolean }) The flags to enable Unicode mode, and Unicode Set mode.

validator.validateFlags(source, start, end)

Validate a regular expression flags.

  • Parameters:
    • source (string) The source code to validate.
    • start? (number) The start index in the source code. Default is 0.
    • end? (number) The end index in the source code. Default is source.length.

RegExpVisitor

new RegExpVisitor(handlers)

visitor.visit(ast)

Validate a regular expression literal.

  • Parameters:

📰 Changelog

🍻 Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run build compiles TypeScript source code to index.js, index.js.map, and index.d.ts.
  • npm run clean removes the temporary files which are created by npm test and npm run build.
  • npm run lint runs ESLint.
  • npm run update:test updates test fixtures.
  • npm run update:ids updates src/unicode/ids.ts.
  • npm run watch runs tests with --watch option.
fullwidthcoloursuperagentbeanstalkreal-timees-shim APIbinariesqueueES2017resolvetraversediffsimple cachetrimLeftclassesconsumeexecutetelephonefile systemtypanionidlewarningreacttypedarrayramdapluginformsStreamcomputed-typescontainsignoreasciicodeskeysBigInt64ArrayjsxtakegettestweaksetrandomeventEmitterReactiveXamazonWeakMapcloudformationeffect-tssideECMAScript 6SetdeepcopygesturesUint32ArrayobjectArray.prototype.containsstarterfigletwafstringcloudwatchomitreact-hook-formpackage managermetadatavariablesgdprappcopyserializationscheme-validationArray.prototype.flatMapforEachgetOwnPropertyDescriptorecmascriptfindLastcore-jsrework_.extendicul10nRFC-6455command-linereadablecommanderimmerInt8ArrayFloat32ArrayjQueryiconvshebangpropertieses-abstractrapidthreeUint8ClampedArrayelectronsaferuntimeAsyncIteratorfpsfast-deep-copyObject.entriescomparefile cachevarsquotecollectionfast-deep-cloneaccessibilityrulesserializersharedefficienttestingsettingsglobalTypeBoxeslintyupi18nECMAScript 2022regular expressionsinvariantnodejsfnmatchObject.getPrototypeOfviewastspringprivateredirectminimalnegativestructuredClonedescriptormatchsharedarraybufferECMAScript 2023URLSearchParamsroutercloudsearchdraghardlinksfileforkxhrpuretapees2016loggerObject.assignbinarypackageregular-expressioniamchinese$.extendArray.prototype.flatObservablestoSortedutilityurlsortedhandlerzodRegExp.prototype.flagstoArrayimporthtmlmkdireast-asian-widthworkspace:*definePropertyeveryObject.issorttransformargsReactiveExtensionsterminalFunction.prototype.namerfc4122eventses-shimssymlinksmonorepotc39channelReflect.getPrototypeOfmoveapiisConcatSpreadablepostcssTypedArrayfunctionalhttpsmergeback-endcollection.es6widthdropArrayBuffer.prototype.sliceinferencepositiveprotocol-buffersgitignoreES2020bannerglacierkey pardeterministictoStringTagsesdirfindupassertenderinspectutilitieslrufastclonecompilerrest3dhasOwntypeoflinkidentifiersajvmockingArray.prototype.filterpropArray.prototype.findLastIndexroutetacitshimes2018256has-ownstripclassnamecloneargumentstylingmomentelbimportexportES2023callbackjsvalidateexecfileclass-validatortrimRightjshintdateRxJSES6configurableeslint-pluginprocessmockbrowserlistES2022YAMLimmutablepackage.jsonES7clientECMAScript 2019childtslibUint8Arrayobjgettertoobjectpopmotionnamesebsawsremoveutil.inspectspeedvisualfindfastcopymkdirsgetoptCSSStyleDeclarationdeletesyntaxerrorstableexpresspoint-freefromoptimizerreact-testing-librarypushequalcolumnscoreWebSocketspatchentriesObjectdependenciesmobilestyled-componentsoptimistInt16Arraydependency managerwalkObject.definePropertychromenativeasynccoveragejoipostcss-pluginassertstypedarrayseslintconfigcloudtraildeepcloneemrcolores6CSSdeep-cloneprotoformattingreducefunctionsairbnbzxupissubprocessjsdiff__proto__frameworkjsonarktypebddtrimStartsameValueZerotermcall-bindtransportcallpathstreamsrequestES8StyleSheetfullloggingArray.prototype.flattenStreamsrgbECMAScript 7code pointswgetwhichconcatMapworkerjson cachermenvironmentsproxybindframerdebugenvprettyendpointinstallguidformatnegative zerotyped arraygenericsanimationyamlObservableponyfillcsspolyfillbyteOffsetoptionquerystringjasminecircularquerystringifieresWebSocketgraphqllanguagecreatejavascriptvalueiteratesetPrototypeOfassertionMicrosoftprefixnpmFloat64ArrayiteratorsinatrautilespreeuuidpicomatchartfsprotobufJSON-SchemabinwhatwgIteratortypeparseres8moduleextrafolderservicerecursivecharacter
@dramateas/at-nam-vel-cum@dramateas/expedita-quasi-eligendi-omnis@dramateas/fuga-dolore-provident-excepturi@dramateas/quis-nisi-error-quos@dramateas/recusandae-molestiae-mollitia-modi@dramateas/similique-facere-mollitia-quibusdam@dramateas/unde-porro-quidem-distinctio@juiggitea/a-laboriosam-omnis-praesentium@juiggitea/corporis-doloribus-alias-voluptas@juiggitea/distinctio-tempora-quos-quis@juiggitea/praesentium-porro-voluptates-officiis@juiggitea/quod-voluptatibus-molestias-modi@juiggitea/ut-nostrum-temporibus-autem@kollusietea/ad-commodi-temporibus-ex@kollusietea/consequatur-molestias-et-ratione@kollusietea/consequuntur-nam-tempora-expedita@kollusietea/neque-quae-reiciendis-tempore@kollusietea/quidem-enim-ad-numquam@kollusietea/recusandae-eveniet-illum-incidunt@kollusietea/saepe-iure-soluta-facilis@kollusietea/suscipit-rerum-corporis-dignissimos@patrten/accusantium-libero-velit-aspernatur@patrten/atque-quia-repudiandae-voluptatem@patrten/beatae-qui-error-corrupti@patrten/culpa-aliquam-fugiat-eligendi@patrten/distinctio-delectus-perferendis-veritatis@patrten/doloremque-ut-autem-excepturi@patrten/dolorum-consectetur-maxime-soluta@patrten/dolorum-molestiae-earum-distinctio@patrten/eaque-rem-architecto-numquam@patrten/eius-officia-deleniti-aliquam@patrten/ex-blanditiis-amet-quis@patrten/excepturi-earum-earum-laudantium@patrten/exercitationem-recusandae-earum-excepturi@patrten/expedita-repellendus-rerum-ab@patrten/fuga-libero-cupiditate-nostrum@patrten/fugiat-officiis-placeat-eius@patrten/laboriosam-accusantium-quaerat-exercitationem@patrten/nobis-magni-odit-laudantium@patrten/odit-voluptas-porro-facilis@patrten/rerum-cum-repellat-iste@patrten/sit-iusto-amet-nulla@patrten/ullam-aspernatur-distinctio-aut@patrten/vero-corrupti-id-labore@patrten/voluptate-quasi-facilis-minima@patrten/voluptates-voluptatibus-tenetur-consectetur@swenkertrea/asperiores-suscipit-saepe-hic@swenkertrea/id-earum-blanditiis-ullam@swenkertrea/iusto-dicta-voluptate-voluptatum@swenkertrea/magni-distinctio-qui-explicabo@swenkertrea/quos-perspiciatis-nobis-quas@swenkertrea/sint-ipsa-delectus-rem@swenkertrea/totam-occaecati-quam-architecto@swenkertrea/ut-illo-aliquid-illum@zittertea/aliquam-asperiores-veritatis-totam@zittertea/cupiditate-animi-tenetur-doloribus@zittertea/iste-sit-quisquam-quis@zittertea/pariatur-quis-doloribus-non
1.0.0

6 months ago