Package: node-tap / 8.0.0-3

module-buffer-to-string.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: bundle module buffer-to-string
 See copyright for more information
Last-Update: 2016-11-11
Forwarded: not-needed
Author: Jérémy Lal <kapouer@melix.org>
--- /dev/null
+++ b/node_modules/buffer-to-string.js
@@ -0,0 +1,18 @@
+'use strict';
+module.exports = function (buffer, limit) {
+	limit = limit || 20;
+	return buffer.toString('hex').split('')
+		.reduce(function (arr, char) {
+			if (arr.length && arr[arr.length - 1].length === 1) {
+				arr[arr.length - 1] += char;
+				if (arr.length && arr.length % limit === 0) {
+					arr[arr.length - 1] += '\n';
+				} else {
+					arr[arr.length - 1] += ' ';
+				}
+			} else {
+				arr.push(char);
+			}
+			return arr;
+		}, []).join('').trim();
+};