Completed
Branch v8.x (bf8300)
by Rafael S.
02:37
created

endianness.umd.js   A

Complexity

Total Complexity 12
Complexity/F 6

Size

Lines of Code 1
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
wmc 12
eloc 1
c 0
b 0
f 0
nc 32
mnd 3
bc 3
fnc 2
dl 0
loc 1
bpm 1.5
cpm 6
noi 3
rs 10
1
/*!
2
 * https://github.com/rochars/endianness
3
 * Copyright (c) 2017-2018 Rafael da Silva Rocha. MIT License.
4
 */
5
function endianness(d,c,a,b){b=void 0===b?d.length:b;if(b%c)throw Error("Bad buffer length.");for(a=void 0===a?0:a;a<b;a+=c)swap(d,c,a)}function swap(d,c,a){c--;for(var b=0;b<c;b++){var e=d[a+b];d[a+b]=d[a+c];d[a+c]=e;c--}};typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = endianness :typeof define === 'function' && define.amd ? define(['exports'], endianness) :typeof global !== 'undefined' ? global.endianness = endianness : null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
6