@vbarbarosh/node-helpers 3.29.1 → 3.30.1

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "3.29.1",
5
+ "version": "3.30.1",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
@@ -3,7 +3,7 @@ const ignore = require('./ignore');
3
3
  const ssh2 = require('ssh2');
4
4
  const waitcb = require('./waitcb');
5
5
 
6
- async function sftp_get_file_info(url, {log = ignore})
6
+ async function sftp_get_file_info(url, {user_friendly_status = ignore})
7
7
  {
8
8
  const u = new URL(url);
9
9
  const host = u.host;
@@ -12,7 +12,7 @@ async function sftp_get_file_info(url, {log = ignore})
12
12
  const password = decodeURIComponent(u.password);
13
13
  const pathname = u.pathname;
14
14
 
15
- log('Establishing connection...');
15
+ user_friendly_status('Establishing connection...');
16
16
  const conn = new ssh2.Client();
17
17
  try {
18
18
  await new Promise(function (resolve, reject) {
@@ -21,10 +21,10 @@ async function sftp_get_file_info(url, {log = ignore})
21
21
  conn.connect({host, port, username, password});
22
22
  });
23
23
 
24
- log('Asking for an sftp service...');
24
+ user_friendly_status('Asking for an sftp service...');
25
25
  const sftp = await waitcb(cb => conn.sftp(cb));
26
26
 
27
- log('Requesting file info...');
27
+ user_friendly_status('Requesting file info...');
28
28
  const [stat, lstat, readdir] = await Promise.all([
29
29
  waitcb(cb => sftp.stat(pathname, cb)),
30
30
  waitcb(cb => sftp.lstat(pathname, cb)),
@@ -2,7 +2,7 @@ const ignore = require('./ignore');
2
2
  const ssh2 = require('ssh2');
3
3
  const waitcb = require('./waitcb');
4
4
 
5
- async function sftp_get_stream_range(url, first, last, {log = ignore} = {})
5
+ async function sftp_get_stream_range(url, first, last, {user_friendly_status = ignore} = {})
6
6
  {
7
7
  const u = new URL(url);
8
8
  const host = u.host;
@@ -11,7 +11,7 @@ async function sftp_get_stream_range(url, first, last, {log = ignore} = {})
11
11
  const password = decodeURIComponent(u.password);
12
12
  const pathname = u.pathname;
13
13
 
14
- log('Establishing connection...');
14
+ user_friendly_status('Establishing connection...');
15
15
  const conn = new ssh2.Client();
16
16
  await new Promise(function (resolve, reject) {
17
17
  conn.on('ready', resolve);
@@ -19,10 +19,10 @@ async function sftp_get_stream_range(url, first, last, {log = ignore} = {})
19
19
  conn.connect({host, port, username, password});
20
20
  });
21
21
 
22
- log('Asking for an sftp service...');
22
+ user_friendly_status('Asking for an sftp service...');
23
23
  const sftp = await waitcb(cb => conn.sftp(cb));
24
24
 
25
- log('Requesting file info...');
25
+ user_friendly_status('Requesting file info...');
26
26
  const stat = await waitcb(cb => sftp.stat(pathname, cb));
27
27
 
28
28
  if (first < 0 || last >= stat.size) {
@@ -36,6 +36,7 @@ async function sftp_get_stream_range(url, first, last, {log = ignore} = {})
36
36
  last,
37
37
  total: stat.size,
38
38
  };
39
+ out.total = out.content_range.total;
39
40
  out.once('error', function () {
40
41
  conn.destroy();
41
42
  });
@@ -0,0 +1,11 @@
1
+ const stream_strpbrk = require('./stream_strpbrk');
2
+
3
+ /**
4
+ * Split stream into lines
5
+ */
6
+ function stream_lines()
7
+ {
8
+ return stream_strpbrk('\r\n');
9
+ }
10
+
11
+ module.exports = stream_lines;