spawn-term 0.1.45 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,21 +8,34 @@ Object.defineProperty(exports, "default", {
8
8
  return addLines;
9
9
  }
10
10
  });
11
+ var _newlineiterator = /*#__PURE__*/ _interop_require_default(require("newline-iterator"));
11
12
  var _readablestream = require("readable-stream");
12
- var REGEX_NEW_LINE = /\r?\n|\r/g;
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
13
18
  function addLines(fn) {
14
19
  var last = '';
15
20
  var stream = new _readablestream.Writable({
16
21
  write: function write(chunk, _enc, callback) {
17
- var more = last + chunk.toString('utf8');
18
- var lines = more.split(REGEX_NEW_LINE);
22
+ var string = last + chunk.toString('utf8');
23
+ var lines = [];
24
+ var iterator = (0, _newlineiterator.default)(string);
25
+ var next = iterator.next();
26
+ while(!next.done){
27
+ lines.push(next.value);
28
+ next = iterator.next();
29
+ }
19
30
  last = lines.pop();
20
31
  if (lines.length > 0) fn(lines);
21
32
  callback();
22
33
  }
23
34
  });
24
35
  stream.on('finish', function() {
25
- if (last.length) fn(last);
36
+ if (last.length) fn([
37
+ last
38
+ ]);
26
39
  last = '';
27
40
  });
28
41
  return stream;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst REGEX_NEW_LINE = /\\r?\\n|\\r/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(REGEX_NEW_LINE);\n last = lines.pop();\n if (lines.length > 0) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn(last);\n last = '';\n });\n return stream;\n}\n"],"names":["addLines","REGEX_NEW_LINE","fn","last","stream","Writable","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":";;;;+BAIA;;;eAAwBA;;;8BAJC;AAEzB,IAAMC,iBAAiB;AAER,SAASD,SAASE,EAAE;IACjC,IAAIC,OAAO;IAEX,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,IAAMC,OAAOP,OAAOI,MAAMI,QAAQ,CAAC;YACnC,IAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBE,OAAOS,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,GAAG,GAAGb,GAAGU;YACzBH;QACF;IACF;IACAL,OAAOY,EAAE,CAAC,UAAU;QAClB,IAAIb,KAAKY,MAAM,EAAEb,GAAGC;QACpBA,OAAO;IACT;IACA,OAAOC;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import newlineIterator from 'newline-iterator';\nimport { Writable } from 'readable-stream';\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const string = last + chunk.toString('utf8');\n\n const lines = [];\n const iterator = newlineIterator(string);\n let next = iterator.next();\n while (!next.done) {\n lines.push(next.value);\n next = iterator.next();\n }\n\n last = lines.pop();\n if (lines.length > 0) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["addLines","fn","last","stream","Writable","write","chunk","_enc","callback","string","toString","lines","iterator","newlineIterator","next","done","push","value","pop","length","on"],"mappings":";;;;+BAGA;;;eAAwBA;;;sEAHI;8BACH;;;;;;AAEV,SAASA,SAASC,EAAE;IACjC,IAAIC,OAAO;IAEX,IAAMC,SAAS,IAAIC,wBAAQ,CAAC;QAC1BC,OAAAA,SAAAA,MAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,IAAMC,SAASP,OAAOI,MAAMI,QAAQ,CAAC;YAErC,IAAMC,QAAQ,EAAE;YAChB,IAAMC,WAAWC,IAAAA,wBAAe,EAACJ;YACjC,IAAIK,OAAOF,SAASE,IAAI;YACxB,MAAO,CAACA,KAAKC,IAAI,CAAE;gBACjBJ,MAAMK,IAAI,CAACF,KAAKG,KAAK;gBACrBH,OAAOF,SAASE,IAAI;YACtB;YAEAZ,OAAOS,MAAMO,GAAG;YAChB,IAAIP,MAAMQ,MAAM,GAAG,GAAGlB,GAAGU;YACzBH;QACF;IACF;IACAL,OAAOiB,EAAE,CAAC,UAAU;QAClB,IAAIlB,KAAKiB,MAAM,EAAElB,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
@@ -1,18 +1,26 @@
1
+ import newlineIterator from 'newline-iterator';
1
2
  import { Writable } from 'readable-stream';
2
- const REGEX_NEW_LINE = /\r?\n|\r/g;
3
3
  export default function addLines(fn) {
4
4
  let last = '';
5
5
  const stream = new Writable({
6
6
  write (chunk, _enc, callback) {
7
- const more = last + chunk.toString('utf8');
8
- const lines = more.split(REGEX_NEW_LINE);
7
+ const string = last + chunk.toString('utf8');
8
+ const lines = [];
9
+ const iterator = newlineIterator(string);
10
+ let next = iterator.next();
11
+ while(!next.done){
12
+ lines.push(next.value);
13
+ next = iterator.next();
14
+ }
9
15
  last = lines.pop();
10
16
  if (lines.length > 0) fn(lines);
11
17
  callback();
12
18
  }
13
19
  });
14
20
  stream.on('finish', ()=>{
15
- if (last.length) fn(last);
21
+ if (last.length) fn([
22
+ last
23
+ ]);
16
24
  last = '';
17
25
  });
18
26
  return stream;
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import { Writable } from 'readable-stream';\n\nconst REGEX_NEW_LINE = /\\r?\\n|\\r/g;\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const more = last + chunk.toString('utf8');\n const lines = more.split(REGEX_NEW_LINE);\n last = lines.pop();\n if (lines.length > 0) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn(last);\n last = '';\n });\n return stream;\n}\n"],"names":["Writable","REGEX_NEW_LINE","addLines","fn","last","stream","write","chunk","_enc","callback","more","toString","lines","split","pop","length","on"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,kBAAkB;AAE3C,MAAMC,iBAAiB;AAEvB,eAAe,SAASC,SAASC,EAAE;IACjC,IAAIC,OAAO;IAEX,MAAMC,SAAS,IAAIL,SAAS;QAC1BM,OAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,MAAMC,OAAON,OAAOG,MAAMI,QAAQ,CAAC;YACnC,MAAMC,QAAQF,KAAKG,KAAK,CAACZ;YACzBG,OAAOQ,MAAME,GAAG;YAChB,IAAIF,MAAMG,MAAM,GAAG,GAAGZ,GAAGS;YACzBH;QACF;IACF;IACAJ,OAAOW,EAAE,CAAC,UAAU;QAClB,IAAIZ,KAAKW,MAAM,EAAEZ,GAAGC;QACpBA,OAAO;IACT;IACA,OAAOC;AACT"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/spawn-term/src/lib/addLines.ts"],"sourcesContent":["import newlineIterator from 'newline-iterator';\nimport { Writable } from 'readable-stream';\n\nexport default function addLines(fn) {\n let last = '';\n\n const stream = new Writable({\n write(chunk, _enc, callback) {\n const string = last + chunk.toString('utf8');\n\n const lines = [];\n const iterator = newlineIterator(string);\n let next = iterator.next();\n while (!next.done) {\n lines.push(next.value);\n next = iterator.next();\n }\n\n last = lines.pop();\n if (lines.length > 0) fn(lines);\n callback();\n },\n });\n stream.on('finish', () => {\n if (last.length) fn([last]);\n last = '';\n });\n return stream;\n}\n"],"names":["newlineIterator","Writable","addLines","fn","last","stream","write","chunk","_enc","callback","string","toString","lines","iterator","next","done","push","value","pop","length","on"],"mappings":"AAAA,OAAOA,qBAAqB,mBAAmB;AAC/C,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,eAAe,SAASC,SAASC,EAAE;IACjC,IAAIC,OAAO;IAEX,MAAMC,SAAS,IAAIJ,SAAS;QAC1BK,OAAMC,KAAK,EAAEC,IAAI,EAAEC,QAAQ;YACzB,MAAMC,SAASN,OAAOG,MAAMI,QAAQ,CAAC;YAErC,MAAMC,QAAQ,EAAE;YAChB,MAAMC,WAAWb,gBAAgBU;YACjC,IAAII,OAAOD,SAASC,IAAI;YACxB,MAAO,CAACA,KAAKC,IAAI,CAAE;gBACjBH,MAAMI,IAAI,CAACF,KAAKG,KAAK;gBACrBH,OAAOD,SAASC,IAAI;YACtB;YAEAV,OAAOQ,MAAMM,GAAG;YAChB,IAAIN,MAAMO,MAAM,GAAG,GAAGhB,GAAGS;YACzBH;QACF;IACF;IACAJ,OAAOe,EAAE,CAAC,UAAU;QAClB,IAAIhB,KAAKe,MAAM,EAAEhB,GAAG;YAACC;SAAK;QAC1BA,OAAO;IACT;IACA,OAAOC;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spawn-term",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "Formats spawn with for terminal grouping",
5
5
  "keywords": [
6
6
  "spawn",
@@ -43,6 +43,7 @@
43
43
  "core-js": "^3.40.0",
44
44
  "cross-spawn-cb": "^2.1.22",
45
45
  "lil-uuid": "^0.1.1",
46
+ "newline-iterator": "^0.3.29",
46
47
  "on-one": "^0.1.4",
47
48
  "queue-cb": "^1.4.16",
48
49
  "react": "^18.3.1",