library.exe 0.0.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.js +9 -0
- package/package.json +10 -0
- package/src/hash.js +21 -0
- package/src/http.js +6 -0
- package/src/path.js +24 -0
package/package.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Symbol.export.http = require ("./src/http");
|
|
2
|
+
Symbol.export.hash = require ("./src/hash");
|
|
3
|
+
Symbol.export.unique = Function.unique;
|
|
4
|
+
Symbol.export.path = require ("./src/path");
|
|
5
|
+
Symbol.export.file = Function.file;
|
|
6
|
+
Symbol.export.dir = Function.dir;
|
|
7
|
+
Symbol.export.function = Function;
|
|
8
|
+
|
|
9
|
+
module.exports = exports = Symbol.export;
|
package/package.json
ADDED
package/src/hash.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __crypto = require ("crypto");
|
|
2
|
+
|
|
3
|
+
Function.hash = function () {}
|
|
4
|
+
Function.hash.crypto = function () {}
|
|
5
|
+
Function.hash.crypto.api = __crypto;
|
|
6
|
+
Function.hash.md5 = function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); }
|
|
7
|
+
Function.hash.sha1 = function (input) { return Function.hash.crypto.api.createHash ("sha1").update (input).digest ("hex"); }
|
|
8
|
+
Function.hash.sha256 = function (input) { return Function.hash.crypto.api.createHash ("sha256").update (input).digest ("hex"); }
|
|
9
|
+
|
|
10
|
+
Function.unique = function () {}
|
|
11
|
+
Function.unique.shuffle = function (length = 64) { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, length); }
|
|
12
|
+
Function.unique.identity = function () { return Function.unique.id ().split ("-") [0]; }
|
|
13
|
+
Function.unique.id = function () {
|
|
14
|
+
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
15
|
+
const r = (Math.random () * 16) | 0;
|
|
16
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
17
|
+
return v.toString (16);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = exports = Function.hash;
|
package/src/http.js
ADDED
package/src/path.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __path = require ("path");
|
|
2
|
+
var __file = require ("fs");
|
|
3
|
+
|
|
4
|
+
Function.path = function () {}
|
|
5
|
+
Function.path.join = function (... path) { return Function.path.api.join (... path); }
|
|
6
|
+
Function.path.exist = function (... path) { return Function.file.api.existsSync (Function.path.api.join (... path)); }
|
|
7
|
+
Function.path.access = function (path, io) { return Function.file.api.accessSync (path, io); }
|
|
8
|
+
Function.path.access.write = function (path) { try { Function.path.access (path, Function.file.api.constants.W_OK); return true; } catch (e) { return false; } }
|
|
9
|
+
Function.path.current = function (path) { return "./" + path; }
|
|
10
|
+
Function.path.io = function (io) { if (Array.isArray (io)) return Function.path.io.value = io; else return Function.path.io.value.includes (io); }
|
|
11
|
+
Function.path.io ([]);
|
|
12
|
+
Function.path.api = __path;
|
|
13
|
+
|
|
14
|
+
Function.file = function () {}
|
|
15
|
+
Function.file.write = function (file, data, context) { if (Function.path.io ("write") === false) return null; if (context) return Function.file.api.writeFile (file, data, context); else return Function.file.api.writeFileSync (file, data); }
|
|
16
|
+
Function.file.read = function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); }
|
|
17
|
+
Function.file.exist = function (file) { return Function.file.api.lstatSync (file).isFile (); }
|
|
18
|
+
Function.file.extension = {text: ".txt", html: ".html", css: ".css", js: ".js", json: ".json"}
|
|
19
|
+
Function.file.api = __file;
|
|
20
|
+
|
|
21
|
+
Function.dir = function () {}
|
|
22
|
+
Function.dir.exist = function (dir) { return Function.file.api.lstatSync (dir).isDirectory (); }
|
|
23
|
+
|
|
24
|
+
module.exports = exports = Function.path;
|