Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type declarations for TypeScript users #7

Open
maxkreja opened this issue Nov 13, 2019 · 6 comments
Open

Add type declarations for TypeScript users #7

maxkreja opened this issue Nov 13, 2019 · 6 comments

Comments

@maxkreja
Copy link

maxkreja commented Nov 13, 2019

It would be nice to have type declarations for TypeScript for this parser. Unfortunately the JSDoc type declarations aren't enough for TypeScript to work.

I will create the declarations based on your code and submit a pull request when it's done.

@matteodelabre
Copy link
Owner

Hi Max! Thank you for your interest in this parser. Unfortunately, I’m not that familiar with TypeScript, but I’d gladly accept your pull request if you find the time to add those declarations.

@carathorys
Copy link

Hi!

I've made a fork from this, and tried to convert it to TypeScript :)
You can check out my solution, I hope you'll like it. I've released it as saxophone-ts as it is a bit different than the original saxophone is, but it also have type declarations, so probably you can use it.

One additional thought:
After I made some changes, I was curios about how it performs, so I extended the original benchmarks, added the original Saxophone, and ran the test, the results are:

➜  saxophone-ts git:(master)> npm run benchmark

> [email protected] benchmark /Users/gallayb/src/saxophone-ts
> node benchmark --unhandled-rejections=none

SaxophoneTs x 13,804 ops/sec ±0.77% (88 runs sampled)
Saxophone x 7,731 ops/sec ±0.68% (89 runs sampled)
EasySax x 8,725 ops/sec ±0.52% (89 runs sampled)
node-expat x 862 ops/sec ±0.57% (88 runs sampled)
libxmljs.SaxParser x 772 ops/sec ±0.50% (88 runs sampled)
sax-js x 857 ops/sec ±0.41% (87 runs sampled)
Fastest is SaxophoneTs

@dobromyslov
Copy link

@carathorys have you seen these changes since your last commit?
https://github.com/carathorys/saxophone-ts/network

@matteodelabre has fixed and improved some parts of the original JS code.
@Miyou has also improved your TS version here: https://github.com/Miyou/saxophone-ts

Lets create types with https://github.com/microsoft/dts-gen

@dobromyslov
Copy link

@matteodelabre could you please merge these type definitions?
https://github.com/matteodelabre/saxophone/pull/12/files

@dobromyslov
Copy link

@maxkreja try to use saxes (https://github.com/lddubeau/saxes). It's a sax-js successor written in TypeScript. There is a stream wrapper available for it https://github.com/SmallhillCZ/saxes-stream and an async/await wrapper for serial events processing could also be created as proposed here lddubeau/saxes#32 (comment)

@matteodelabre could you please add benchmark comparison with saxes?

@kpachbiu88
Copy link

Just install additional package and use Sax with types
https://www.npmjs.com/package/@types/sax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants