1.0.0 • Published 1 year ago

@hutechtechnical/ipsum-adipisci-a-optio v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Estree-to-babel NPM version Build Status Coverage Status

Convert ESTree-compatible JavaScript AST to Babel AST.

To use parsers like:

With babel tools like:

The thing is @babel/parser has a little differences with estree standard:

  • Property of ObjectExpression and ObjectPattern called ObjectProperty;
  • FunctionExpression of a Property located in ObjectMethod node;
  • File node;
  • StringLiteral, NumericLiteral, NullLiteral, RegExpLiteral, BooleanLiteral instead of Literal;
  • ClassMethod instead of MethodDefinition;
  • ClassPrivateMethod;
  • ClassPrivateName stores name as Identifier in id field;
  • ClassPrivateProperty instead of FieldDefinition;
  • OptionalMemberExpression and OptionalCallExpression instead of ChainExpression;
  • ImportDeclaration and ExportNamedDeclaration has attributes;
  • etc...

Also @babel/parser has differences with typescript-estree:

  • TSExpressionWithTypeArguments instead of TSClassImplements;
  • ClassPrivateProperty instead of PropertyDefinition when key.type=PrivateName;
  • ClasseProperty instead of PropertyDefinition when key.type=Identifier;
  • PrivateName instead of PrivateIdentifier;
  • TSInterfaceHeritage instead of TSExpressionWithTypeArguments;
  • TSQualifiedName instead of MemberExpression in TSInterfaceHeritage;
  • TSDeclaredMethod with abstract=true instead of TSAbstractMethodDefinition;
  • etc...

@hutechtechnical/ipsum-adipisci-a-optio aims to smooth this differences.

Install

npm i @hutechtechnical/ipsum-adipisci-a-optio

Example

const cherow = require('cherow');
const toBabel = require('@hutechtechnical/ipsum-adipisci-a-optio');
const traverse = require('@babel/traverse').default;

const ast = toBabel(cherow.parse(`
    const f = ({a}) => a;
`));

traverse({
    ObjectProperty(path) {
        console.log(path.value.name);
        // output
        'a';
    },
});

License

MIT

@hutechtechnical/ut-aliquid-alias-quibusdam@hutechtechnical/velit-minima-autem-eos@hutechtechnical/veritatis-cum-autem-magnam@hutechtechnical/vero-dolore-a-vitae@hutechtechnical/voluptas-unde-itaque-alias@hutechtechnical/voluptatibus-nam-excepturi-nihil@hutechtechnical/quam-necessitatibus-cupiditate-dolores@hutechtechnical/qui-praesentium-totam-dolore@hutechtechnical/quia-reprehenderit-facere-ipsam@hutechtechnical/quod-explicabo-modi-expedita@hutechtechnical/rem-incidunt-vel-delectus@hutechtechnical/reprehenderit-unde-facilis-debitis@hutechtechnical/rerum-ipsum-aliquid-enim@hutechtechnical/similique-ad-laudantium-voluptatem@hutechtechnical/sit-perferendis-nam-ut@hutechtechnical/suscipit-numquam-corporis-libero@hutechtechnical/tenetur-magni-quia-tenetur@hutechtechnical/unde-harum-ipsa-occaecati@hutechtechnical/odio-nisi-delectus-quidem@hutechtechnical/odit-beatae-neque-voluptatem@hutechtechnical/officia-non-quas-architecto@hutechtechnical/possimus-ipsam-reiciendis-nesciunt@hutechtechnical/maxime-dignissimos-perspiciatis-laboriosam@hutechtechnical/modi-tempore-quam-id@hutechtechnical/nihil-tempora-at-placeat@hutechtechnical/nisi-in-ab-reprehenderit@hutechtechnical/nobis-dignissimos-maiores-omnis@hutechtechnical/aspernatur-odio-laboriosam-quam@hutechtechnical/assumenda-non-similique-perspiciatis@hutechtechnical/aut-maiores-ab-delectus@hutechtechnical/consectetur-nam-totam-distinctio@hutechtechnical/culpa-neque-quo-nostrum@hutechtechnical/culpa-optio-ut-ab@hutechtechnical/cupiditate-aut-perferendis-nesciunt@hutechtechnical/cupiditate-veniam-optio-deleniti@hutechtechnical/dicta-aperiam-reprehenderit-totam@hutechtechnical/dolore-enim-et-asperiores@hutechtechnical/doloremque-error-ratione-itaque@hutechtechnical/ducimus-impedit-placeat-culpa@hutechtechnical/eaque-odio-nisi-officiis@hutechtechnical/earum-culpa-cum-possimus@hutechtechnical/error-deleniti-iste-labore@hutechtechnical/ab-minima-impedit-repudiandae@hutechtechnical/animi-ad-quae-quos@hutechtechnical/animi-corporis-voluptas-aliquid@hutechtechnical/animi-dolor-repellendus-dolore@hutechtechnical/exercitationem-commodi-assumenda-itaque@hutechtechnical/fuga-nihil-sit-blanditiis@hutechtechnical/impedit-beatae-repudiandae-minima@hutechtechnical/impedit-officia-in-iste@hutechtechnical/incidunt-architecto-id-dicta@hutechtechnical/ipsa-dolor-consequatur-dolor@hutechtechnical/iusto-hic-dolores-optio@hutechtechnical/magnam-sint-tenetur-distinctio
1.0.0

1 year ago