Page MenuHomePhabricator

[lib] Add utilities for Uint8Array data
ClosedPublic

Authored by bartek on Mar 28 2023, 11:03 AM.
Tags
None
Referenced Files
F1671458: D7223.id24419.diff
Sat, Apr 27, 10:30 PM
F1671456: D7223.id24398.diff
Sat, Apr 27, 10:29 PM
F1671455: D7223.id24299.diff
Sat, Apr 27, 10:29 PM
F1671454: D7223.id24316.diff
Sat, Apr 27, 10:29 PM
F1671403: D7223.id.diff
Sat, Apr 27, 10:26 PM
F1671378: D7223.diff
Sat, Apr 27, 9:58 PM
Unknown Object (File)
Mar 28 2024, 7:59 AM
Unknown Object (File)
Mar 28 2024, 7:59 AM
Subscribers

Details

Summary

This diff adds a few convenience functions to deal with Uint8Arrays.

Test Plan

Added unit tests

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Mar 28 2023, 12:02 PM
bartek added a reviewer: ashoat.
bartek added inline comments.
lib/media/data-utils.js
48–53 ↗(On Diff #24299)

A significant part of this function is a copy-paste (with slight modifications) from the 2nd link. The author published it under MIT license. Where should I put the license note? cc @ashoat

lib/media/data-utils.js
48–53 ↗(On Diff #24299)

If possible, preference to always "rewrite with inspiration"... ie. open up the 2nd link, open up your code editor, do not do copy-paste at any point, but instead write it in your own voice, with the other code as inspiration. Some lines (eg. (chunk & 16515072) >> 18) cannot be written any other way, but it is not necessarily a license violation to have that same line if it is the only way to write it

If you don't feel like that is possible in this case, then you should separate the code that is copy-pasted into a separate file, ideally in a folder that clearly indiciates it is copy-pasted (eg. folder named third-party, for instance) and include the LICENSE directly above the code. This isn't as good since we'll have to find some way to include it in acknowledgements (once we implement that) and may forget it, but if there is no alternative then it's acceptable

ashoat requested changes to this revision.Mar 28 2023, 1:24 PM

Requesting changes to either "rewrite with inspiration" or to move copy-pasted code to a third-party folder with the license

This revision now requires changes to proceed.Mar 28 2023, 1:24 PM
lib/media/data-utils.js
48–53 ↗(On Diff #24299)

I'll go with the separate-file 3rd party solution because I'm going to replace it with native code anyway. I don't want to waste time rewriting this.

Moved the 3rd-party function to a separate file and attached license. I'll also create a task to replace this with native code

This revision is now accepted and ready to land.Mar 29 2023, 11:32 AM
This revision was automatically updated to reflect the committed changes.