utilitas 1989.9.47 → 1989.10.4
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 +94 -36
- package/lib/shot.mjs +2 -0
- package/lib/uoid.mjs +0 -1
- package/lib/utilitas.mjs +0 -1
- package/package.json +8 -2
package/index.mjs
CHANGED
|
@@ -1,39 +1,97 @@
|
|
|
1
1
|
// dependencies
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { default as colors } from 'colors/safe.js';
|
|
3
|
+
import { default as fetch } from 'node-fetch';
|
|
4
|
+
import { Tail as tail } from 'tail';
|
|
5
|
+
import * as base64url from 'base64url';
|
|
6
|
+
import * as fileType from 'file-type';
|
|
7
|
+
import * as geoIp from 'fast-geoip';
|
|
8
|
+
import * as ini from 'ini';
|
|
9
|
+
import * as jwt from 'jsonwebtoken';
|
|
10
|
+
import * as mailgun from 'mailgun-js';
|
|
11
|
+
import * as mailjet from 'node-mailjet';
|
|
12
|
+
import * as math from 'mathjs';
|
|
13
|
+
import * as mysql from 'mysql2/promise';
|
|
14
|
+
import * as ping from 'ping';
|
|
15
|
+
import * as qs from 'qs';
|
|
16
|
+
import * as redis from 'ioredis';
|
|
17
|
+
import * as sentry from '@sentry/node';
|
|
18
|
+
import * as telegraf from 'telegraf';
|
|
19
|
+
import * as telesign from 'telesignsdk';
|
|
20
|
+
import * as twilio from 'twilio';
|
|
21
|
+
import * as uuid from 'uuid';
|
|
23
22
|
// features
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
import * as bot from './lib/bot.mjs';
|
|
24
|
+
import * as cache from './lib/cache.mjs';
|
|
25
|
+
import * as dbio from './lib/dbio.mjs';
|
|
26
|
+
import * as email from './lib/email.mjs';
|
|
27
|
+
import * as encryption from './lib/encryption.mjs';
|
|
28
|
+
import * as event from './lib/event.mjs';
|
|
29
|
+
import * as network from './lib/network.mjs';
|
|
30
|
+
import * as sentinel from './lib/sentinel.mjs';
|
|
31
|
+
import * as shell from './lib/shell.mjs';
|
|
32
|
+
import * as shot from './lib/shot.mjs';
|
|
33
|
+
import * as sms from './lib/sms.mjs';
|
|
34
|
+
import * as storage from './lib/storage.mjs';
|
|
35
|
+
import * as tape from './lib/tape.mjs';
|
|
36
|
+
import * as uoid from './lib/uoid.mjs';
|
|
37
|
+
import * as utilitas from './lib/utilitas.mjs';
|
|
38
|
+
|
|
39
|
+
// Export
|
|
39
40
|
export * as default from './lib/utilitas.mjs';
|
|
41
|
+
export {
|
|
42
|
+
// dependencies
|
|
43
|
+
colors,
|
|
44
|
+
fetch,
|
|
45
|
+
tail,
|
|
46
|
+
base64url,
|
|
47
|
+
fileType,
|
|
48
|
+
geoIp,
|
|
49
|
+
ini,
|
|
50
|
+
jwt,
|
|
51
|
+
mailgun,
|
|
52
|
+
mailjet,
|
|
53
|
+
math,
|
|
54
|
+
mysql,
|
|
55
|
+
ping,
|
|
56
|
+
qs,
|
|
57
|
+
redis,
|
|
58
|
+
sentry,
|
|
59
|
+
telegraf,
|
|
60
|
+
telesign,
|
|
61
|
+
twilio,
|
|
62
|
+
uuid,
|
|
63
|
+
// features
|
|
64
|
+
bot,
|
|
65
|
+
cache,
|
|
66
|
+
dbio,
|
|
67
|
+
email,
|
|
68
|
+
encryption,
|
|
69
|
+
event,
|
|
70
|
+
network,
|
|
71
|
+
sentinel,
|
|
72
|
+
shell,
|
|
73
|
+
shot,
|
|
74
|
+
sms,
|
|
75
|
+
storage,
|
|
76
|
+
tape,
|
|
77
|
+
uoid,
|
|
78
|
+
utilitas,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Browser
|
|
82
|
+
let runningInBrowser = false;
|
|
83
|
+
try { runningInBrowser = !!window; } catch (e) { }
|
|
84
|
+
// import * as package from './package.json';
|
|
85
|
+
// https://www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/
|
|
86
|
+
const pack = {
|
|
87
|
+
...await storage.readJson('./package.json'),
|
|
88
|
+
runningInBrowser,
|
|
89
|
+
};
|
|
90
|
+
if (runningInBrowser) {
|
|
91
|
+
window._utilitas = pack;
|
|
92
|
+
window.utilitas = {
|
|
93
|
+
base64url, colors, encryption, event, fetch, fileType, ini, jwt, math,
|
|
94
|
+
network, qs, shell, shot, storage, uoid, utilitas, uuid,
|
|
95
|
+
};
|
|
96
|
+
console.log('[UTILITAS](https://github.com/Leask/utilitas) is ready!');
|
|
97
|
+
} else { global._utilitas = pack; }
|
package/lib/shot.mjs
CHANGED
|
@@ -45,6 +45,8 @@ const getCurrentPosition = async () => {
|
|
|
45
45
|
return rp;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
// @todo: support etag cache and expire time features:
|
|
49
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
|
|
48
50
|
const get = async (url, options) => {
|
|
49
51
|
utilitas.assert(url, 'URL is required.');
|
|
50
52
|
options = options || {};
|
package/lib/uoid.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import * as uuid from 'uuid';
|
|
|
4
4
|
|
|
5
5
|
const fileURLToPath = (await import('url')).fileURLToPath
|
|
6
6
|
|| ((url) => { return new URL('', url).pathname; });
|
|
7
|
-
|
|
8
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
8
|
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}';
|
|
10
9
|
const compactUuid = (uuid) => uuid.replace(/\-/ig, '');
|
package/lib/utilitas.mjs
CHANGED
|
@@ -14,7 +14,6 @@ RegExp.escape = RegExp.escape || ((str) => { //$& means the whole matched string
|
|
|
14
14
|
|
|
15
15
|
const fileURLToPath = (await import('url')).fileURLToPath
|
|
16
16
|
|| ((url) => { return new URL('', url).pathname; });
|
|
17
|
-
|
|
18
17
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
18
|
const invalidTime = 'Invalid time.';
|
|
20
19
|
|
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.
|
|
4
|
+
"version": "1989.10.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"ncuinit": "npm install -g npm-check-updates",
|
|
17
17
|
"updep": "npx ncu -u && npm install && npm install node-fetch@2 && ( git commit -am 'update dependencies' || true )",
|
|
18
18
|
"gitsync": "git pull && git push",
|
|
19
|
-
"
|
|
19
|
+
"build": "./node_modules/.bin/webpack-cli --config webpack.config.mjs",
|
|
20
|
+
"prepublishOnly": "npm run build && npm version patch && npm run updep && npm run gitsync"
|
|
20
21
|
},
|
|
21
22
|
"author": "Leask Wong <i@leaskh.com>",
|
|
22
23
|
"license": "MIT",
|
|
@@ -45,5 +46,10 @@
|
|
|
45
46
|
"telesignsdk": "^2.2.1",
|
|
46
47
|
"twilio": "^3.75.1",
|
|
47
48
|
"uuid": "^8.3.2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"browserify-fs": "^1.0.0",
|
|
52
|
+
"node-polyfill-webpack-plugin": "^1.1.4",
|
|
53
|
+
"webpack-cli": "^4.9.2"
|
|
48
54
|
}
|
|
49
55
|
}
|