script.io.js 2026.126.2027 → 2026.127.27
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.js +2 -0
- package/node_packages/script.js +66 -11
- package/package.json +1 -1
package/index.js
CHANGED
package/node_packages/script.js
CHANGED
|
@@ -554,8 +554,70 @@ Define (Function.hash, "require", function () { Function.hash.crypto.api = requi
|
|
|
554
554
|
Define (Function.hash, "crypto", function () {});
|
|
555
555
|
Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
|
|
556
556
|
|
|
557
|
+
Define (Function, "unique", function () {});
|
|
558
|
+
Define (Function.unique, "shuffle", function () { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, 64); });
|
|
559
|
+
Define (Function.unique, "id", function () {
|
|
560
|
+
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
561
|
+
const r = (Math.random () * 16) | 0;
|
|
562
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
563
|
+
return v.toString (16);
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
|
|
557
567
|
/**
|
|
558
|
-
*
|
|
568
|
+
* mongo
|
|
569
|
+
*
|
|
570
|
+
* title
|
|
571
|
+
* description
|
|
572
|
+
* sub description
|
|
573
|
+
*
|
|
574
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
Define (Function, "mongo", function () {});
|
|
578
|
+
Define (Function.mongo, "require", function () { return Function.mongo.api = require ("mongodb"); });
|
|
579
|
+
|
|
580
|
+
Define (Function.mongo, "db", class {
|
|
581
|
+
constructor (url, option) {
|
|
582
|
+
this.client = new Function.mongo.api.MongoClient (url, option);
|
|
583
|
+
}
|
|
584
|
+
connect () {
|
|
585
|
+
return this.client.connect ();
|
|
586
|
+
}
|
|
587
|
+
db (db) {
|
|
588
|
+
return new Function.mongo.db.client (this.client, db);
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
Define (Function.mongo.db, "client", class {
|
|
593
|
+
constructor (client, db) {
|
|
594
|
+
this.client = client;
|
|
595
|
+
this.db = this.client.db (db);
|
|
596
|
+
}
|
|
597
|
+
collection (collection) {
|
|
598
|
+
return new Function.mongo.db.collection (this.client, this.db, collection);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
Define (Function.mongo.db, "collection", class {
|
|
603
|
+
constructor (client, db, collection) {
|
|
604
|
+
this.client = client;
|
|
605
|
+
this.db = db;
|
|
606
|
+
this.collection = this.db.collection (collection);
|
|
607
|
+
}
|
|
608
|
+
select () {
|
|
609
|
+
var __ = function (mongo) {
|
|
610
|
+
return new Promise (async function (resolve, reject) {
|
|
611
|
+
var result = mongo.collection.find ({}).toArray ();
|
|
612
|
+
resolve (result);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
return __ (this);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* socket.io
|
|
559
621
|
*
|
|
560
622
|
* title
|
|
561
623
|
* description
|
|
@@ -564,6 +626,9 @@ Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api
|
|
|
564
626
|
* xxx://xxx.xxx.xxx/xxx
|
|
565
627
|
*/
|
|
566
628
|
|
|
629
|
+
Define (Function, "socket", function () {});
|
|
630
|
+
Define (Function.socket, "require", function () { return Function.socket.api = require ("socket.io"); });
|
|
631
|
+
|
|
567
632
|
/**
|
|
568
633
|
* 3rd party
|
|
569
634
|
*
|
|
@@ -595,16 +660,6 @@ Define (Function.help, "argument", function () {
|
|
|
595
660
|
return result;
|
|
596
661
|
});
|
|
597
662
|
|
|
598
|
-
Define (Function, "unique", function () {});
|
|
599
|
-
Define (Function.unique, "shuffle", function () { return String.char.alpha.numeric.repeat (16).shuffle ().substr (0, 64); });
|
|
600
|
-
Define (Function.unique, "id", function () {
|
|
601
|
-
return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
|
|
602
|
-
const r = (Math.random () * 16) | 0;
|
|
603
|
-
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
604
|
-
return v.toString (16);
|
|
605
|
-
});
|
|
606
|
-
});
|
|
607
|
-
|
|
608
663
|
Function.ajax = function () {}
|
|
609
664
|
|
|
610
665
|
Function.ajax.get = function (url, context) {
|
package/package.json
CHANGED