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

Converting binary search helper to TS #2129

Merged
merged 1 commit into from Feb 13, 2019

Conversation

michaelcunningham19
Copy link
Member

This PR will...

... convert our binary search helper to TypeScript

Why is this Pull Request needed?

Part of the on-going effort to introduce TypeScript to the project

Are there any points in the code the reviewer needs to double check?

The added function signature for BinarySearchComparison - thoughts on the return type/value enforcement? Was thinking simply number would suffice.

As well, the parameter T was added as it makes working with the search function nicer looking IMO, example:

BinarySearch.search<Fragment>(frags, fragComparisonFunction)

Resolves issues:

None in particular

Checklist

  • changes have been done against master branch, and PR does not conflict
  • [ ] new unit / functional tests have been added (whenever applicable) N/A
  • [ ] API or design changes are documented in API.md N/A

Copy link
Member

@tjenkinson tjenkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one point

@@ -0,0 +1,44 @@
type BinarySearchComparison < T > = (candidate: T) => -1 | 0 | 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: <T>

Also we should export type this. Generally anything that is used on the public path should be exported

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
If I remember correctly, changing < T > to <T> resulted in this eslint error: https://eslint.org/docs/rules/space-infix-ops

I'd hate to suppress that eslint rule though, as it should error/warn in the case of const sum = 1+ 2 shouldn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah if it's a lint thing then fine as long as it is consistent everywhere :)

@johnBartos johnBartos merged commit 52bc8fb into master Feb 13, 2019
@tjenkinson
Copy link
Member

tjenkinson commented Feb 13, 2019 via email

@johnBartos johnBartos added this to In progress in Typescript Integration via automation Feb 13, 2019
@michaelcunningham19 michaelcunningham19 deleted the misc/typescriptify-binary-search branch February 13, 2019 19:15
dyue added a commit to dyue/hls.js that referenced this pull request Mar 9, 2019
* origin/master: (59 commits)
  Change networkDetails type to "unknown".
  mp4-remuxer / remuxAudio() : recompute mdatSize / dont rely on audioTrack.len (video-dev#2096)
  Typo fix for destory -> destroy.
  Change responseType to string
  Callbacks are defined, removing TODO.
  video-devGH-2082: Replacing usage of Array.prototype.find/findIndex (video-dev#2117)
  Reduce GC pressure from ID3._utf8ArrayToStr (video-dev#2035)
  (misc): converting binary search to typescript (video-dev#2129)
  (misc) Removing IE8-specific (dead) vtt/cue code
  Fixed case of 'They use hls.js in production!' header and updated Viacom image link to new domain and using https (video-dev#2127)
  remove events/EventEmitter && move Observer to ts (video-dev#2097)
  Basic typescript of event handler.
  Update webpack to use babel loader with support for TS. (video-dev#2119)
  Allow console statement in test bench and saucelabs code.
  Lint fixes
  Playlist Loader conversion to TypeScript.
  Playlist-loader rename.
  Change IV handling for initSegments to just log a warning.
  Add handling for AES-128 encrypted initialization segments needing IV.
  (misc) Adding ace editor to demo to enable advanced customization (video-dev#2077)
  ...
@itsjamie itsjamie moved this from In progress to Reviewer approved in Typescript Integration Mar 11, 2019
@itsjamie itsjamie moved this from Reviewer approved to Done in Typescript Integration Mar 11, 2019
@johnBartos johnBartos added this to the 0.13.0 milestone Aug 13, 2019
@robwalch robwalch added this to Done in 0.13.0 Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.13.0
  
Done
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants