Sample

Schnappinger/jsweet/def.js.Uint8Array

Human rating uses the original dataset scale.

Human3.9
Lines453

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
34.4Δ 16.9
Scalabrino0.6790–1; higher is more readable
33.6Δ 17.8
Dorn00–1; higher is more readable
5.3Δ 46.0
Mi0.1320–1; higher is more readable
11.6Δ 39.8
LLOC68Logical lines; fewer is more readable
30.7Δ 20.6
DeepSeek V4 Pro12.670–20; mean of three runs
18.8Δ 32.5
GPT-6.1 Sol140–20; mean of three runs
16.2Δ 35.1
BTTF0.4430–1; higher is more readable
38.6Δ 12.7
Human3.91–4; original rating
51.3

Views

Source code

package def.js; import jsweet.util.function.Function4; /** * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ public class Uint8Array extends def.js.Object implements Iterable<java.lang.Double> { /** * The size in bytes of each element in the array. */ public final double BYTES_PER_ELEMENT=0; /** * The ArrayBuffer instance referenced by the array. */ public final ArrayBuffer buffer=null; /** * The length in bytes of the array. */ public final double byteLength=0; /** * The offset in bytes of the array. */ public final double byteOffset=0; /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target * @param target If target is negative, it is treated as length+target where length is the * length of the array. * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ native public Uint8Array copyWithin(double target, double start, double end); /** * Determines whether all the members of an array satisfy the specified test. * @param callbackfn A function that accepts up to three arguments. The every method calls * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public java.lang.Boolean every(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn, java.lang.Object thisArg); /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ native public Uint8Array fill(double value, double start, double end); /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls * the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public Uint8Array filter(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn, java.lang.Object thisArg); /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. * @param predicate find calls predicate once for each element of the array, in ascending * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ native public double find(jsweet.util.function.TriFunction<Double,Double,Array<Double>,java.lang.Boolean> predicate, java.lang.Object thisArg); /** * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. * @param predicate find calls predicate once for each element of the array, in ascending * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ native public double findIndex(java.util.function.Function<Double,java.lang.Boolean> predicate, java.lang.Object thisArg); /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the * callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public void forEach(jsweet.util.function.TriConsumer<Double,Double,Uint8Array> callbackfn, java.lang.Object thisArg); /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ native public double indexOf(double searchElement, double fromIndex); /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ native public java.lang.String join(java.lang.String separator); /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ native public double lastIndexOf(double searchElement, double fromIndex); /** * The length of the array. */ public final double length=0; /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the * callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public Uint8Array map(jsweet.util.function.TriFunction<Double,Double,Uint8Array,Double> callbackfn, java.lang.Object thisArg); /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ native public double reduce(Function4<Double,Double,Double,Uint8Array,Double> callbackfn, double initialValue); /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ native public <U> U reduce(Function4<U,Double,Double,Uint8Array,U> callbackfn, U initialValue); /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ native public double reduceRight(Function4<Double,Double,Double,Uint8Array,Double> callbackfn, double initialValue); /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ native public <U> U reduceRight(Function4<U,Double,Double,Uint8Array,U> callbackfn, U initialValue); /** * Reverses the elements in an Array. */ native public Uint8Array reverse(); /** * Sets a value or an array of values. * @param index The index of the location to set. * @param value The value to set. */ native public void set(double index, double value); /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ native public void set(ArrayLike<Double> array, double offset); /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. */ native public Uint8Array slice(double start, double end); /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public java.lang.Boolean some(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn, java.lang.Object thisArg); /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ native public Uint8Array sort(java.util.function.BiFunction<Double,Double,Double> compareFn); /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ native public Uint8Array subarray(double begin, double end); /** * Converts a number to a string by using the current locale. */ native public String toLocaleString(); /** * Returns a string representation of an array. */ native public java.lang.String toString(); native public java.lang.Double $get(double index); public static final Uint8Array prototype=null; public Uint8Array(double length){} public Uint8Array(ArrayLike<Double> array){} public Uint8Array(ArrayBuffer buffer, double byteOffset, double length){} /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ native public static Uint8Array of(double... items); /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(ArrayLike<Double> arrayLike, java.util.function.BiFunction<Double,Double,Double> mapfn, java.lang.Object thisArg); /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target * @param target If target is negative, it is treated as length+target where length is the * length of the array. * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. * @param end If not specified, length of the this object is used as its default value. */ native public Uint8Array copyWithin(double target, double start); /** * Determines whether all the members of an array satisfy the specified test. * @param callbackfn A function that accepts up to three arguments. The every method calls * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public java.lang.Boolean every(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn); /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ native public Uint8Array fill(double value, double start); /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ native public Uint8Array fill(double value); /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls * the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public Uint8Array filter(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn); /** * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. * @param predicate find calls predicate once for each element of the array, in ascending * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ native public double find(jsweet.util.function.TriFunction<Double,Double,Array<Double>,java.lang.Boolean> predicate); /** * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. * @param predicate find calls predicate once for each element of the array, in ascending * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ native public double findIndex(java.util.function.Function<Double,java.lang.Boolean> predicate); /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the * callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public void forEach(jsweet.util.function.TriConsumer<Double,Double,Uint8Array> callbackfn); /** * Returns the index of the first occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ native public double indexOf(double searchElement); /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ native public java.lang.String join(); /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ native public double lastIndexOf(double searchElement); /** * Calls a defined callback function on each element of an array, and returns an array that * contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the * callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public Uint8Array map(jsweet.util.function.TriFunction<Double,Double,Uint8Array,Double> callbackfn); /** * Calls the specified callback function for all the elements in an array. The return value of * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ native public double reduce(Function4<Double,Double,Double,Uint8Array,Double> callbackfn); /** * Calls the specified callback function for all the elements in an array, in descending order. * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls * the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ native public double reduceRight(Function4<Double,Double,Double,Uint8Array,Double> callbackfn); /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ native public void set(ArrayLike<Double> array); /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. */ native public Uint8Array slice(double start); /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. */ native public Uint8Array slice(); /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ native public java.lang.Boolean some(jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean> callbackfn); /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ native public Uint8Array sort(); /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ native public Uint8Array subarray(double begin); public Uint8Array(ArrayBuffer buffer, double byteOffset){} public Uint8Array(ArrayBuffer buffer){} /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(ArrayLike<Double> arrayLike, java.util.function.BiFunction<Double,Double,Double> mapfn); /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(ArrayLike<Double> arrayLike); /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ native public void set(Double[] array, double offset); public Uint8Array(Double[] array){} /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(Double[] arrayLike, java.util.function.BiFunction<Double,Double,Double> mapfn, java.lang.Object thisArg); /** * Sets a value or an array of values. * @param array A typed or untyped array of values to set. * @param offset The index in the current array at which the values are to be written. */ native public void set(Double[] array); /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(Double[] arrayLike, java.util.function.BiFunction<Double,Double,Double> mapfn); /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ native public static Uint8Array from(Double[] arrayLike); /** From Iterable, to allow foreach loop (do not use directly). */ @jsweet.lang.Erased native public java.util.Iterator<java.lang.Double> iterator(); protected Uint8Array(){} }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.8105.505−267.482
Source linesThe number of non-empty source lines.453+181.2
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.437−6.656

Intercept 8.87 + feature contributions = -84.067 (log-odds).
Score = sigmoid(-84.067) = 0.

Score0.679

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.391−12.808
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.452.506+5.915
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.156.971−2.984
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.133−2.631
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.156.987+1.728
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.02+0.745
Indentation frequencyHow rapidly indentation changes from line to line.1−0.703

Intercept 0.07 + feature contributions = -10.666 (log-odds).
Score = sigmoid(-10.666) = 0.

Score0.132
Score68
Run 1

The code is structurally organized and flat, with one method per line, but suffers from extreme length and redundancy. Each method has extensive Javadoc, often duplicative across overloads, which obscures the actual signatures. Action granularity is good but reading flow is disrupted by repetitive documentation and scattered constructor/static method overloads. Clarity of intent is mostly clear from method names, yet the sheer volume of boilerplate makes the class hard to navigate. Overall, it is readable in small sections but overwhelming as a whole.

Run 2

The code is well-organized as a generated API binding for Uint8Array, with consistent structure: fields, constructors, and methods grouped logically, and each element documented with JSDoc. It is flat (no nesting) and each line represents a single action, making individual declarations easy to read. However, the extreme length, repetitive overloads, and redundant verbose documentation reduce readability. The intent is clear but buried under boilerplate. Long parameterized types like `jsweet.util.function.TriFunction<Double,Double,Uint8Array,java.lang.Boolean>` hurt scanning and comprehension. Reading flow is natural for an API reference but tedious for a human reader. Overall, it is mechanically readable but not optimized for human maintainability.

Run 3

The code is a straightforward API binding for a typed array, with a clear structure: constants, fields, overloaded methods, and constructors. It is flat and has no logical nesting. Each method is documented and occupies one line plus Javadoc. However, readability suffers from extreme repetition—overloaded variants of the same method (e.g., fill, filter, from, set, slice) are scattered and duplicated across the class, creating unnecessary length. The heavy use of fully qualified types like jsweet.util.function.TriFunction and java.util.function.BiFunction makes signatures verbose and harder to scan. Grouping overloads together and using shorter type aliases would improve flow. The overall intent is clear, but the code's verbosity and redundancy reduce readability.

Run 1

Code Structure: A coherent typed-array API, but fields, constructors, static methods, and overloads are scattered rather than consistently grouped. Nesting: Almost entirely flat declarations, making individual members easy to scan. Clarity of intent: Descriptive method names and extensive documentation explain most operations; placeholder values, empty constructors, inconsistent callback types, and copied comments referencing absent parameters introduce ambiguity. Code length: Individual declarations are concise, but repeated documentation and widely separated overloads make the class unnecessarily cumbersome to navigate. Action granularity: Each line generally contains one declaration, with no compressed multi-action logic. Reading flow: The initial method sequence is predictable, but later overload batches force readers to jump around. Long fully qualified generic signatures, inconsistent spacing, and uneven comment formatting further reduce scanning efficiency. Overall, readable as an API binding, but substantially less readable as a continuous source file.

Run 2

Code Structure: A coherent API declaration, but fields, constructors, static factories, and related overloads are scattered rather than grouped. Nesting: Completely flat apart from the class scope, making individual declarations easy to inspect. Clarity of intent: Descriptive method names and extensive documentation explain most operations; copied comments referencing absent parameters and inconsistent descriptions introduce ambiguity. Code length: Numerous overloads are reasonable for a binding, but repeated documentation makes the file unnecessarily bulky. Action granularity: Each line generally contains one declaration, with no compound operations. Reading flow: Consistent declaration patterns help scanning, but distant overloads, long fully qualified generic signatures, inconsistent spacing, and repetitive comments interrupt navigation. Overall, individual members are readable, while organization and documentation quality reduce whole-file readability.

Run 3

Code Structure: A coherent typed-array API, but fields, constructors, static methods, and overloads are scattered rather than consistently grouped. Nesting: Very flat, with no nested control flow; declarations are easy to isolate. Clarity of intent: Descriptive method names and extensive documentation explain most operations, although copied comments reference absent parameters or describe behavior inconsistently. Placeholder fields and empty constructors require familiarity with binding classes. Code length: Individual declarations are concise, but repeated documentation and dispersed overloads substantially inflate the file. Action granularity: Each line generally contains one declaration, with no compound operational statements. Reading flow: The repeated declaration pattern is predictable, but long fully qualified generic signatures, inconsistent spacing, and distant related overloads hinder scanning. Grouping overloads, consolidating documentation, and standardizing formatting would improve readability.