superlib 1.0.21 → 1.2.0
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/dist/basic/BaseError.d.ts +4 -0
- package/dist/basic/BaseError.d.ts.map +1 -0
- package/dist/basic/BaseError.js +6 -0
- package/dist/basic/Result.d.ts +29 -0
- package/dist/basic/Result.d.ts.map +1 -0
- package/dist/basic/Result.js +55 -0
- package/dist/basic/ResultAsync.d.ts +9 -0
- package/dist/basic/ResultAsync.d.ts.map +1 -0
- package/dist/basic/ResultAsync.js +41 -0
- package/dist/basic/assert.d.ts +8 -0
- package/dist/basic/assert.d.ts.map +1 -0
- package/dist/basic/assert.js +25 -0
- package/dist/basic/index.d.ts +5 -0
- package/dist/basic/index.d.ts.map +1 -0
- package/dist/basic/index.js +4 -0
- package/dist/decorators/Retry.d.ts +3 -0
- package/dist/decorators/Retry.d.ts.map +1 -0
- package/dist/decorators/Retry.js +9 -0
- package/dist/decorators/Timeout.d.ts +3 -0
- package/dist/decorators/Timeout.d.ts.map +1 -0
- package/dist/decorators/Timeout.js +9 -0
- package/dist/decorators/common.d.ts +2 -0
- package/dist/decorators/common.d.ts.map +1 -0
- package/dist/decorators/common.js +17 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/platform/JsonHttpClient/JsonHttpClient.d.ts +18 -0
- package/dist/platform/JsonHttpClient/JsonHttpClient.d.ts.map +1 -0
- package/dist/platform/JsonHttpClient/JsonHttpClient.js +48 -0
- package/dist/platform/JsonHttpClient/index.d.ts +2 -0
- package/dist/platform/JsonHttpClient/index.d.ts.map +1 -0
- package/dist/platform/JsonHttpClient/index.js +1 -0
- package/dist/platform/ProcessContext/EnvReader.d.ts +12 -0
- package/dist/platform/ProcessContext/EnvReader.d.ts.map +1 -0
- package/dist/platform/ProcessContext/EnvReader.js +56 -0
- package/dist/platform/ProcessContext/ProcessContext.d.ts +40 -0
- package/dist/platform/ProcessContext/ProcessContext.d.ts.map +1 -0
- package/dist/platform/ProcessContext/ProcessContext.js +57 -0
- package/dist/platform/ProcessContext/index.d.ts +3 -0
- package/dist/platform/ProcessContext/index.d.ts.map +1 -0
- package/dist/platform/ProcessContext/index.js +2 -0
- package/dist/platform/filesystem/AbsolutePath.d.ts +18 -0
- package/dist/platform/filesystem/AbsolutePath.d.ts.map +1 -0
- package/dist/platform/filesystem/AbsolutePath.js +28 -0
- package/dist/platform/filesystem/FileSystem.d.ts +19 -0
- package/dist/platform/filesystem/FileSystem.d.ts.map +1 -0
- package/dist/platform/filesystem/FileSystem.js +92 -0
- package/dist/platform/filesystem/IFileSystem.d.ts +46 -0
- package/dist/platform/filesystem/IFileSystem.d.ts.map +1 -0
- package/dist/platform/filesystem/IFileSystem.js +1 -0
- package/dist/platform/filesystem/MemoryFileSystem.d.ts +29 -0
- package/dist/platform/filesystem/MemoryFileSystem.d.ts.map +1 -0
- package/dist/platform/filesystem/MemoryFileSystem.js +126 -0
- package/dist/platform/filesystem/index.d.ts +5 -0
- package/dist/platform/filesystem/index.d.ts.map +1 -0
- package/dist/platform/filesystem/index.js +4 -0
- package/dist/platform/get-port/checkPort.d.ts +2 -0
- package/dist/platform/get-port/checkPort.d.ts.map +1 -0
- package/dist/platform/get-port/checkPort.js +20 -0
- package/dist/platform/get-port/getPort.d.ts +8 -0
- package/dist/platform/get-port/getPort.d.ts.map +1 -0
- package/dist/platform/get-port/getPort.js +13 -0
- package/dist/platform/safeFetch/index.d.ts +2 -0
- package/dist/platform/safeFetch/index.d.ts.map +1 -0
- package/dist/platform/safeFetch/index.js +1 -0
- package/dist/platform/safeFetch/makeSafeFetch.d.ts +23 -0
- package/dist/platform/safeFetch/makeSafeFetch.d.ts.map +1 -0
- package/dist/platform/safeFetch/makeSafeFetch.js +19 -0
- package/dist/random/FixedRandom.d.ts +12 -0
- package/dist/random/FixedRandom.d.ts.map +1 -0
- package/dist/random/FixedRandom.js +43 -0
- package/dist/random/Random.d.ts +18 -0
- package/dist/random/Random.d.ts.map +1 -0
- package/dist/random/Random.js +24 -0
- package/dist/random/RealRandom.d.ts +5 -0
- package/dist/random/RealRandom.d.ts.map +1 -0
- package/dist/random/RealRandom.js +6 -0
- package/dist/random/SeededRandom.d.ts +10 -0
- package/dist/random/SeededRandom.d.ts.map +1 -0
- package/dist/random/SeededRandom.js +15 -0
- package/dist/random/index.d.ts +5 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/random/index.js +4 -0
- package/dist/schema/StandardSchema.d.ts +60 -0
- package/dist/schema/StandardSchema.d.ts.map +1 -0
- package/dist/schema/StandardSchema.js +1 -0
- package/dist/schema/validateSchema.d.ts +9 -0
- package/dist/schema/validateSchema.d.ts.map +1 -0
- package/dist/schema/validateSchema.js +9 -0
- package/dist/task/all.d.ts +14 -0
- package/dist/task/all.d.ts.map +1 -0
- package/dist/task/all.js +61 -0
- package/dist/task/index.d.ts +15 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/index.js +11 -0
- package/dist/task/pipe.d.ts +8 -0
- package/dist/task/pipe.d.ts.map +1 -0
- package/dist/task/pipe.js +11 -0
- package/dist/task/retry.d.ts +27 -0
- package/dist/task/retry.d.ts.map +1 -0
- package/dist/task/retry.js +61 -0
- package/dist/task/timeout.d.ts +21 -0
- package/dist/task/timeout.d.ts.map +1 -0
- package/dist/task/timeout.js +39 -0
- package/dist/task/types.d.ts +3 -0
- package/dist/task/types.d.ts.map +1 -0
- package/dist/task/types.js +1 -0
- package/dist/time/Clock.d.ts +18 -0
- package/dist/time/Clock.d.ts.map +1 -0
- package/dist/time/Clock.js +26 -0
- package/dist/time/index.d.ts +4 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +3 -0
- package/dist/time/sleep.d.ts +3 -0
- package/dist/time/sleep.d.ts.map +1 -0
- package/dist/time/sleep.js +5 -0
- package/dist/time/temporal.d.ts +5 -0
- package/dist/time/temporal.d.ts.map +1 -0
- package/dist/time/temporal.js +20 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +57 -17
- package/README.md +0 -46
- package/elm-projects.js +0 -62
- package/index.js +0 -3
- package/lib.js +0 -117
- package/libm.js +0 -52
- package/projects.js +0 -145
- package/providers/github.js +0 -22
- package/providers/lib/connection.js +0 -19
- package/providers/npmjs.js +0 -22
- package/tests/providers.js +0 -13
- package/tests/utilities.js +0 -13
- package/utilities.js +0 -116
package/utilities.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var fs = require('fs')
|
|
3
|
-
var colors = require('colors')
|
|
4
|
-
|
|
5
|
-
class Utilities {
|
|
6
|
-
|
|
7
|
-
testing() {
|
|
8
|
-
global.testing = true
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
isTesting() {
|
|
12
|
-
return process.env.NODE_ENV == "test" || process.env.TESTING || global.testing || this.fileExists(`${process.cwd()}/.testing`)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
debug() {
|
|
16
|
-
return process.env.DEBUG || this.fileExists(`${process.cwd()}/.debug`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
log(msg) {
|
|
20
|
-
if(this.debug()) {
|
|
21
|
-
console.log(colors.yellow(msg))
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
listFindShortestMatch(array, term) {
|
|
26
|
-
if(array && term) {
|
|
27
|
-
let matches = array.filter(el => this.cointainsStringInsensitive(el, term))
|
|
28
|
-
if(matches) {
|
|
29
|
-
return matches.sort((a, b) => a.length - b.length)[0]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
isString(s) {
|
|
35
|
-
return typeof(s) === 'string' || s instanceof String
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// todo: JSDOC
|
|
39
|
-
arraySortByKey(array, key, num) {
|
|
40
|
-
let maxVal = num ? Number.MAX_VALUE : "zzzzzzzzzzzzzz"
|
|
41
|
-
return array.sort((a, b) => {
|
|
42
|
-
let x = a[key] || maxVal
|
|
43
|
-
let y = b[key] || maxVal
|
|
44
|
-
return ((x < y) ? -1 : ((x > y) ? 1 : 0))
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
arrayUnique(arr) {
|
|
49
|
-
return [...new Set( arr )];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* USAGE:
|
|
53
|
-
function double(num, callback) { callback(2 * num) }
|
|
54
|
-
util.asyncMap([1,2,3], double).then(xs => console.log(xs))
|
|
55
|
-
*/
|
|
56
|
-
asyncMap(arr, f) {
|
|
57
|
-
// use Promise.prototype.catch otherwise exceptions are swallowed
|
|
58
|
-
// after the last .then make a .catch
|
|
59
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
|
|
60
|
-
return Promise.all(arr.map(v => new Promise((s, r) => f(v, s))))
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
cointainsStringInsensitive(str, term) {
|
|
64
|
-
if(str && term) {
|
|
65
|
-
return str.toLowerCase().indexOf(term.toLowerCase()) > -1
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
listSearch(list, term) {
|
|
70
|
-
return list.filter(el => this.cointainsStringInsensitive(el, term))
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
countOccurences(str, char) {
|
|
74
|
-
return str.split(char).length - 1
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
isDirectory(path) {
|
|
78
|
-
try
|
|
79
|
-
{
|
|
80
|
-
return fs.lstatSync(path).isDirectory()
|
|
81
|
-
}
|
|
82
|
-
catch (err)
|
|
83
|
-
{
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
fileExists(filePath)
|
|
89
|
-
{
|
|
90
|
-
// what about fs.existsSync("index.js") ?
|
|
91
|
-
// modern:
|
|
92
|
-
// if(fs.existsSync(path)) {
|
|
93
|
-
// // Do something
|
|
94
|
-
// }
|
|
95
|
-
try
|
|
96
|
-
{
|
|
97
|
-
return fs.statSync(filePath).isFile()
|
|
98
|
-
}
|
|
99
|
-
catch (err)
|
|
100
|
-
{
|
|
101
|
-
return false
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
scanDir(path, callback) {
|
|
106
|
-
fs.readdirSync(path).map(file => `${path}/${file}`).forEach(path => callback(path))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// like readdirSync but it returns the full path instead of just file/folder names
|
|
110
|
-
scanDirSync(path) {
|
|
111
|
-
return fs.readdirSync(path).map(file => `${path}/${file}`)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
module.exports = new Utilities()
|