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

Change XMLBuilder typings to expose correct function name #396

Merged

Conversation

andersem
Copy link
Contributor

@andersem andersem commented Nov 20, 2021

The typings defined parse, even if the actual class exposes build.

Also changing the parameter name from options to jObj

Purpose / Goal

Improve the experience using XMLBuilder in v4 with Typescript by using the correct function name, build instead of parse.

This pull request doesn't have an issue connected with it, as it's quite small.

Expected:

When using XMLBuilder with Typescript, it should suggest and accept new Builder(options).build

Actual:

When using XMLBuilder with Typescript, it suggests and accepts new Builder(options).parse, which is not defined on the actual class. Attempting to use new Builder(options).build raises a Typescript error, and we need to use // @ts-ignore to be able to build.

Benchmarks:

Shouldn't affect performance, but just to show that I skimmed through the contribution guidelines:

node XmlBuilder.js
Running Suite: XML Builder benchmark
fxp : 61781.672750776546 requests/second
fxp - preserve order : 331720539.54804766 requests/second
xml2js  : 3493.707511368985 requests/second

node XmlParser.js
Running Suite: XML Parser benchmark
fxp v3 : 10805.277764633815 requests/second
fxp : 10587.343533433563 requests/second
fxp - preserve order : 11910.25930150525 requests/second
xml2js  : 2377.2217768943174 requests/second

Type

Please mention the type of PR

  • Bug Fix
  • Refactoring / Technology upgrade
  • New Feature

Note : Please ensure that you've read contribution guidelines before raising this PR. If your PR is in progress, please prepend [WIP] in PR title. Your PR will be reviewed when [WIP] will be removed from the PR title.

Bookmark this repository for further updates.

The typings defined `parse`, even if the actual class exposes `build`.

Also changing the parameter name from `options` to `jObj`
@amitguptagwl amitguptagwl merged commit c0b39a9 into NaturalIntelligence:master Nov 21, 2021
@andersem andersem deleted the fix-xml-build-typing branch December 17, 2021 20:44
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

Successfully merging this pull request may close these issues.

None yet

2 participants