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 helper functions for dealing with AnyXmlValue and export them #106

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

nytamin
Copy link
Contributor

@nytamin nytamin commented Oct 15, 2024

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a: Code improvement

Current Behavior

When consuming the @mos-connection/helper library, one has to make a few less-than-ideal checks when dealing with xml-based data (such as the data inside a roFullStory).

New Behavior

A few helpful methods are now exposed, such as:

// These methods returns the expected data type or throws if the data actually is not of the expected type.
MOS.ensureString(anyData, true) 
MOS.ensureXMLObject(anyData, true)
MOS.ensureSingular(anyData) // returns a singular value, ie not an array or object
MOS.ensureSingularArray(anyData) // returns an array of singular values

// These methods returns true if the data is of the specified type
MOS.isXMLObject(anyData)
MOS.isSingular(anyData)
MOS.isSingularArray(anyData)

// ...and more!

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 56.00000% with 44 lines in your changes missing coverage. Please review.

Project coverage is 75.42%. Comparing base (a43c217) to head (106bb46).

Files with missing lines Patch % Lines
packages/helper/src/utils/ensureMethods.ts 46.98% 44 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   75.33%   75.42%   +0.09%     
==========================================
  Files          67       68       +1     
  Lines        3985     3992       +7     
  Branches      951      928      -23     
==========================================
+ Hits         3002     3011       +9     
- Misses        904      954      +50     
+ Partials       79       27      -52     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jstarpl jstarpl requested a review from a team December 10, 2024 18:42
@nytamin nytamin merged commit 64771f5 into master Dec 11, 2024
16 checks passed
@nytamin nytamin deleted the fix/helper-methods branch December 11, 2024 12:51
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.

3 participants