Passed
Branch v15.x (8faa65)
by Rafael S.
02:24
created

scripts/shims.js   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 10
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
eloc 8
nc 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
wmc 2
mnd 1
bc 3
fnc 1
bpm 3
cpm 2
noi 0
1
/**
2
 * Write a string of UTF-8 characters as a byte buffer.
3
 * @param {string} str The string to pack.
4
 * @return {!Uint8Array|Array<number>} The buffer with the packed string written.
5
 */
6
function packString (str) {
7
  var buffer;
8
  if (typeof Uint8Array === 'function') {
9
    buffer =  new Uint8Array(utf8BufferSize(str));
10
  } else {
11
    buffer = [];
12
  }
13
  pack(str, buffer, 0);
14
  return buffer;
15
}
16