All files util.ts

75% Statements 3/4
25% Branches 1/4
100% Functions 0/0
66.67% Lines 2/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25322x                                   25x            
export function bufFromString(str: string): Buffer {
  const length = Buffer.byteLength(str);
  const buffer = Buffer.allocUnsafe
    ? Buffer.allocUnsafe(length)
    : new Buffer(length);
  buffer.write(str);
  return buffer;
}
 
export function emptyBuffer(): Buffer{
  const buffer = Buffer.allocUnsafe
    ? Buffer.allocUnsafe(0)
    : new Buffer(0);
  return buffer;
}
 
export function filterArray(arr: any[], filter: number[]): any[] {
  const rtn: any[] = [];
  for (let i = 0; i < arr.length; i++) {
    if (filter.indexOf(i) > -1) {
      rtn.push(arr[i]);
    }
  }
  return rtn;
}