saxophone icon indicating copy to clipboard operation
saxophone copied to clipboard

Add type declarations for TypeScript users

Open maxkreja opened this issue 5 years ago • 6 comments

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.

maxkreja avatar Nov 13 '19 06:11 maxkreja

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.

matteodelabre avatar Nov 22 '19 19:11 matteodelabre

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

carathorys avatar Mar 10 '20 14:03 carathorys

@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 avatar Jan 29 '21 18:01 dobromyslov

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

dobromyslov avatar Jan 29 '21 18:01 dobromyslov

@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 https://github.com/lddubeau/saxes/issues/32#issuecomment-640493042

@matteodelabre could you please add benchmark comparison with saxes?

dobromyslov avatar Jan 30 '21 11:01 dobromyslov

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

kpachbiu88 avatar Sep 15 '21 08:09 kpachbiu88