utilitas 1989.9.6 → 1989.9.10

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/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  // dependencies
2
2
  export * as base64url from 'base64url';
3
- export * as colors from 'colors/safe.js';
4
3
  export * as fetch from 'node-fetch';
5
4
  export * as fileType from 'file-type';
6
5
  export * as geoIp from 'fast-geoip';
@@ -20,6 +19,7 @@ export * as twilio from 'twilio';
20
19
  export * as uuid from 'uuid';
21
20
  export * as winston from 'winston';
22
21
  export * as winstonPapertrail from 'winston-papertrail-mproved';
22
+ export { default as colors } from 'colors/safe.js';
23
23
 
24
24
  // features
25
25
  export * as cache from './lib/cache.mjs';
@@ -36,4 +36,4 @@ export * as storage from './lib/storage.mjs';
36
36
  export * as tape from './lib/tape.mjs';
37
37
  export * as uoid from './lib/uoid.mjs';
38
38
  export * as utilitas from './lib/utilitas.mjs';
39
- export { default as default } from './lib/utilitas.mjs';
39
+ export * as default from './lib/utilitas.mjs';
package/lib/cache.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import utilitas from './utilitas.mjs';
1
+ import * as utilitas from './utilitas.mjs';
2
2
 
3
3
  const log = (content) => { return utilitas.modLog(content, 'cache'); };
4
4
 
@@ -21,7 +21,7 @@ const init = async (options) => {
21
21
  return redis;
22
22
  };
23
23
 
24
- export default {
24
+ export {
25
25
  init,
26
26
  // set,
27
27
  // get,
package/lib/dbio.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import utilitas from './utilitas.mjs';
1
+ import * as utilitas from './utilitas.mjs';
2
2
 
3
3
  const defaultPort = 3306;
4
4
  const orders = { '+': 'ASC', '-': 'DESC' };
@@ -261,7 +261,7 @@ const deleteAll = async (table, options) => {
261
261
  return await execute(assembleDelete(table));
262
262
  };
263
263
 
264
- export default {
264
+ export {
265
265
  assembleInsert,
266
266
  assembleQuery,
267
267
  assembleSet,
package/lib/email.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import utilitas from './utilitas.mjs';
1
+ import * as utilitas from './utilitas.mjs';
2
2
 
3
3
  const log = (content) => { return utilitas.modLog(content, 'email'); };
4
4
 
@@ -88,7 +88,7 @@ const send = async (email, subject, text, html, args, options) => {
88
88
  }, html ? { html } : {}));
89
89
  }
90
90
 
91
- export default {
91
+ export {
92
92
  getSenderName,
93
93
  init,
94
94
  rawSend,
@@ -47,7 +47,7 @@ const digestObject = (object, algorithm) => {
47
47
  return hash(getSortedQueryString(object), algorithm);
48
48
  };
49
49
 
50
- export default {
50
+ export {
51
51
  defaultAlgorithm,
52
52
  digestObject,
53
53
  getSortedQueryString,
package/lib/event.mjs CHANGED
@@ -1,8 +1,10 @@
1
- import { fileURLToPath } from 'url';
2
1
  import { v4 as uuidv4 } from 'uuid';
2
+ import * as utilitas from './utilitas.mjs';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
- import utilitas from './utilitas.mjs';
5
+
6
+ const fileURLToPath = (await import('url')).fileURLToPath
7
+ || ((url) => { return new URL('', url).pathname; });
6
8
 
7
9
  const __filename = fileURLToPath(import.meta.url);
8
10
  const jobs = {};
@@ -79,7 +81,7 @@ const bulk = async (absDir, options) => {
79
81
  file => /\.mjs$/i.test(file) && !file.startsWith('.')
80
82
  ), []];
81
83
  for (let file of files) {
82
- const mod = (await import(path.join(absDir, file))).default;
84
+ const mod = await import(path.join(absDir, file));
83
85
  if (!mod.run) { continue; }
84
86
  mod.name = mod.name || file.replace(/^(.*)\.mjs$/i, '$1');
85
87
  pmsRun.push(load(mod, options));
@@ -101,7 +103,7 @@ const end = async () => {
101
103
  log('Terminated.');
102
104
  };
103
105
 
104
- export default {
106
+ export {
105
107
  bulk,
106
108
  end,
107
109
  list,
package/lib/network.mjs CHANGED
@@ -1,9 +1,9 @@
1
+ import * as shell from './shell.mjs';
2
+ import * as utilitas from './utilitas.mjs';
1
3
  import fetch from 'node-fetch';
2
4
  import geoIp from 'fast-geoip';
3
5
  import libPing from 'ping';
4
6
  import publicIp from 'public-ip';
5
- import shell from './shell.mjs';
6
- import utilitas from './utilitas.mjs';
7
7
 
8
8
  const log = (content) => { return utilitas.modLog(content, 'network'); };
9
9
 
@@ -94,7 +94,7 @@ const getCurrentPosition = async () => {
94
94
  return Object.assign(loc, { ip });
95
95
  };
96
96
 
97
- export default {
97
+ export {
98
98
  getCurrentPosition,
99
99
  httping,
100
100
  pickFastestHost,
package/lib/sentinel.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import utilitas from './utilitas.mjs';
1
+ import * as utilitas from './utilitas.mjs';
2
2
 
3
3
  const log = (str, opts) => { return utilitas.modLog(str, 'sentinel', opts); };
4
4
 
@@ -21,6 +21,6 @@ const init = async (options) => {
21
21
  return sentry;
22
22
  };
23
23
 
24
- export default {
24
+ export {
25
25
  init,
26
26
  };
package/lib/shell.mjs CHANGED
@@ -1,6 +1,6 @@
1
+ import * as utilitas from './utilitas.mjs';
1
2
  import childProcess from 'child_process';
2
3
  import util from 'util';
3
- import utilitas from './utilitas.mjs';
4
4
 
5
5
  const log = (content) => { return utilitas.modLog(content, 'shell'); };
6
6
  const vF = (cmd, cbf) => { log(`Can not run in browser: ${cmd}`); cbf(); };
@@ -34,7 +34,7 @@ const assertExist = async (bin, er, code = 500) => {
34
34
  utilitas.assert(await exist(bin), er || `Command not found: ${bin}.`, code);
35
35
  };
36
36
 
37
- export default {
37
+ export {
38
38
  assertExist,
39
39
  exec,
40
40
  exist,
package/lib/shot.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as fileType from 'file-type';
2
+ import * as storage from './storage.mjs';
3
+ import * as utilitas from './utilitas.mjs';
2
4
  import fetch from 'node-fetch';
3
- import storage from './storage.mjs';
4
- import utilitas from './utilitas.mjs';
5
5
 
6
6
  const defFetchOpt = { redirect: 'follow', follow: 3, timeout: 1000 * 10 };
7
7
 
@@ -67,7 +67,7 @@ const get = async (url, options) => {
67
67
  };
68
68
  }
69
69
 
70
- export default {
70
+ export {
71
71
  checkVersion,
72
72
  get,
73
73
  getCurrentPosition,
package/lib/sms.mjs CHANGED
@@ -1,5 +1,5 @@
1
+ import * as utilitas from './utilitas.mjs';
1
2
  import util from 'util';
2
- import utilitas from './utilitas.mjs';
3
3
 
4
4
  const defaultTeleSignApi = 'https://rest-api.telesign.com';
5
5
  const defaultTimeout = 1000 * 10 // 10 secs
@@ -60,7 +60,7 @@ const send = async (phone, message) => {
60
60
  }
61
61
  };
62
62
 
63
- export default {
63
+ export {
64
64
  init,
65
65
  send,
66
66
  };
package/lib/storage.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
+ import * as utilitas from './utilitas.mjs';
2
3
  import fs from 'fs';
3
4
  import ini from 'ini';
4
5
  import os from 'os';
5
6
  import path from 'path';
6
- import utilitas from './utilitas.mjs';
7
7
 
8
8
  const [encoding, mode] = ['utf8', '0644'];
9
9
 
@@ -149,7 +149,7 @@ const exists = async (fp) => {
149
149
  try { return await fs.promises.stat(fp); } catch (_) { return null; }
150
150
  };
151
151
 
152
- export default {
152
+ export {
153
153
  assertPath,
154
154
  encodeBase64DataURL,
155
155
  exists,
package/lib/tape.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import utilitas from './utilitas.mjs';
1
+ import * as utilitas from './utilitas.mjs';
2
2
 
3
3
  // https://github.com/winstonjs/winston#logging-levels
4
4
  // const levels = ['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly'];
@@ -88,7 +88,7 @@ const end = async () => {
88
88
  }, 1000);
89
89
  };
90
90
 
91
- export default {
91
+ export {
92
92
  end,
93
93
  getLogger,
94
94
  init,
package/lib/uoid.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import { fileURLToPath } from 'url';
1
+ import * as encryption from './encryption.mjs';
2
+ import * as utilitas from './utilitas.mjs';
2
3
  import * as uuid from 'uuid';
3
- import encryption from './encryption.mjs';
4
- import utilitas from './utilitas.mjs';
4
+
5
+ const fileURLToPath = (await import('url')).fileURLToPath
6
+ || ((url) => { return new URL('', url).pathname; });
5
7
 
6
8
  const __filename = fileURLToPath(import.meta.url);
7
9
  const uuidRegTxt = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
@@ -30,7 +32,7 @@ const getRfcUrlNamespaceUuid = (url) => {
30
32
  return uuid.v5(url, uuid.v5.URL);
31
33
  };
32
34
 
33
- export default {
35
+ export {
34
36
  uuidRegTxt,
35
37
  create,
36
38
  getRfcUrlNamespaceUuid,
package/lib/utilitas.mjs CHANGED
@@ -1,7 +1,6 @@
1
- import { fileURLToPath } from 'url';
1
+ import * as storage from './storage.mjs';
2
2
  import colors from 'colors/safe.js';
3
3
  import path from 'path';
4
- import storage from './storage.mjs';
5
4
 
6
5
  Object.values = Object.values || ((obj) => {
7
6
  return Object.keys(obj).map((key) => {
@@ -13,6 +12,9 @@ RegExp.escape = RegExp.escape || ((str) => { //$& means the whole matched string
13
12
  return String(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
14
13
  }); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
15
14
 
15
+ const fileURLToPath = (await import('url')).fileURLToPath
16
+ || ((url) => { return new URL('', url).pathname; });
17
+
16
18
  const __filename = fileURLToPath(import.meta.url);
17
19
  const invalidTime = 'Invalid time.';
18
20
 
@@ -613,7 +615,7 @@ const purgeEmoji = (any, replace = '') => {
613
615
  );
614
616
  };
615
617
 
616
- export default {
618
+ export {
617
619
  arrayEqual,
618
620
  assembleApiUrl,
619
621
  assembleUrl,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for Node.js.",
4
- "version": "1989.9.6",
4
+ "version": "1989.9.10",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",