luizperes / simdjson_nodejs

Node.js bindings for the simdjson project: "Parsing gigabytes of JSON per second"
https://arxiv.org/abs/1902.08318
Apache License 2.0
549 stars 25 forks source link

Typescript types as index.d.ts file please #26

Closed nojvek closed 4 years ago

nojvek commented 4 years ago

Great library, although the interface is somewhat unintuitive. Is isValid the only method?

Would love to see typescript types so the library interface is fully documented. I can help here. Just don't really know what the interface right now is, and how to make most of the library.

luizperes commented 4 years ago

Hi @nojvek, fair point. I was taking a look at the readme and realized it could be a little more clear.

I will try to explain here a little better and will use that to change the README later. Please consider the the section Usage of the README.

Screen Shot 2020-04-01 at 1 44 11 PM

As I tried to show in the README, this simdjson wrapper has only three functions: isValid, parse and lazyParse. I will explain the rationale behind all of them.

isValid

parse

lazyParse

where:

type JSONDataType: is any of { string, number, object, array, boolean, null }

interface LazyParsedJSON {
    valueForKeyPath: (keyPath: string) => JSONDataType
}

I hope this is a little better than the current documentation. See that the type JSONDataType and interface LazyParsedJSON would not necessarily be reflected in TypeScript, but I hope that it helps it to make the project a little more clear. Also, see that the wrapper is in simdjson version 0.2.1 and @lemire has updated it to version 0.3 and I am working so to update the node library (issues #24, #23 and #3). So if you can help here, your work would really be appreciated!

Cheers, Luiz

luizperes commented 4 years ago

I've moved what I explained here to the file Documentation.md

nojvek commented 4 years ago

Sweeet. I will take a pass tomorrow.

luizperes commented 4 years ago

Closing this as PR #30 addresses that, thank you for your work @nojvek!