script.io.js 2026.122.1019 → 2026.123.955

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  require ("./node_packages/script.js");
2
2
  Function.path.require ();
3
3
  Function.file.require ();
4
+ Function.appwrite.require ();
4
5
  module.exports = exports = Symbol.export;
@@ -78,6 +78,7 @@ Define (Array.prototype, "shuffle", function () { var array = this.clone (); var
78
78
  Define (Array.prototype, "limit", function (limit) { return this.clone ().slice (0, limit); });
79
79
  Define (Array.prototype, "page", function (page, limit) { return this.clone ().slice (((page - 1) * (limit || Array.config.page.limit)), (page * (limit || Array.config.page.limit))); });
80
80
  Define (Array.prototype, "distinct", function (key = "id", distinct = []) { return this.filter (function (array) { if (distinct.includes (array [key])) return false; else { distinct.push (array [key]); return true; } }); });
81
+ Define (Array.prototype, "implode", function (array) { var data = this.clone (); data.push (... array); return data; });
81
82
 
82
83
  Define (Array.prototype, "select", function (filter) {
83
84
  return this.filter (function (array, index) {
@@ -330,16 +331,6 @@ Define (JSON.db, "select", class {
330
331
  Define (JSON.db, "file", function (key, value) { if (value) return JSON.db.file.object [key] = value; else return JSON.db.file.object [key] || key; });
331
332
  Define (JSON.db.file, "object", {});
332
333
 
333
- /**
334
- * miscellaneous
335
- *
336
- * title
337
- * description
338
- * sub description
339
- *
340
- * xxx://xxx.xxx.xxx/xxx
341
- */
342
-
343
334
  /**
344
335
  * path
345
336
  *
@@ -353,6 +344,7 @@ Define (JSON.db.file, "object", {});
353
344
  Define (Function, "path", function () {});
354
345
  Define (Function.path, "require", function () { return Function.path.api = require ("path"); });
355
346
  Define (Function.path, "join", function (... path) { return Function.path.api.join (... path); });
347
+ Define (Function.path, "current", function (path) { return "./" + path; });
356
348
 
357
349
  /**
358
350
  * file
@@ -370,7 +362,7 @@ Define (Function.file, "write", function (file, content, context) { if (context)
370
362
  Define (Function.file, "read", function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); });
371
363
 
372
364
  /**
373
- * xxx
365
+ * hash
374
366
  *
375
367
  * title
376
368
  * description
@@ -379,8 +371,13 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
379
371
  * xxx://xxx.xxx.xxx/xxx
380
372
  */
381
373
 
374
+ Define (Function, "hash", function () {});
375
+ Define (Function.hash, "require", function () { Function.hash.crypto.api = require ("crypto"); });
376
+ Define (Function.hash, "crypto", function () {});
377
+ Define (Function.hash, "md5", function (input) { return Function.hash.crypto.api.createHash ("md5").update (input).digest ("hex"); });
378
+
382
379
  /**
383
- * xxx
380
+ * appwrite
384
381
  *
385
382
  * title
386
383
  * description
@@ -389,6 +386,55 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
389
386
  * xxx://xxx.xxx.xxx/xxx
390
387
  */
391
388
 
389
+ Define (Function, "appwrite", function () {});
390
+ Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
391
+
392
+ Define (Function.appwrite, "db", class {
393
+ constructor (config, json) {
394
+ this.config = config;
395
+ this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
396
+ this.json = json || {}
397
+ if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
398
+ }
399
+ select (collection) { return new Function.appwrite.db.select (this, collection); }
400
+ });
401
+
402
+ Define (Function.appwrite.db, "select", class {
403
+ constructor (db, collection) {
404
+ this.db = db;
405
+ this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
406
+ }
407
+ find (filter) {
408
+ var id;
409
+ if (typeof filter !== "object") filter = {id: (id = filter)}
410
+ var __ = function (db) {
411
+ return new Promise (async function (resolve, reject) {
412
+ var error = false;
413
+ var database, result, queries;
414
+ if (id) queries = [Function.appwrite.api.Query.limit (1)]
415
+ else queries = [Function.appwrite.api.Query.limit (5000)]
416
+ try {
417
+ database = new Function.appwrite.api.Databases (db.db.client);
418
+ result = await database.listDocuments ({
419
+ databaseId: db.db.config.id,
420
+ collectionId: db.collection.id,
421
+ queries,
422
+ total: true,
423
+ });
424
+ }
425
+ catch (e) { error = true; }
426
+ var data = result.documents.map (function (data) { return data; }).select (filter);
427
+ data = db.collection.json.select (filter).implode (data);
428
+ resolve ({error, data});
429
+ });
430
+ }
431
+ return __ (this);
432
+ }
433
+ });
434
+
435
+ Define (Function.appwrite.db, "collection", function (key, value) { if (value) return Function.appwrite.db.collection.object [key] = value; else return Function.appwrite.db.collection.object [key] || key; });
436
+ Define (Function.appwrite.db.collection, "object", {});
437
+
392
438
  /**
393
439
  * xxx
394
440
  *
@@ -399,6 +445,25 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
399
445
  * xxx://xxx.xxx.xxx/xxx
400
446
  */
401
447
 
448
+ /**
449
+ * miscellaneous
450
+ *
451
+ * title
452
+ * description
453
+ * sub description
454
+ *
455
+ * xxx://xxx.xxx.xxx/xxx
456
+ */
457
+
458
+ Define (Function, "unique", function () {});
459
+ Define (Function.unique, "id", function () {
460
+ return ("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx").replace (/[xy]/g, function (c) {
461
+ const r = (Math.random () * 16) | 0;
462
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
463
+ return v.toString (16);
464
+ });
465
+ });
466
+
402
467
  /**
403
468
  * html
404
469
  *
@@ -570,9 +635,11 @@ Symbol.export = {
570
635
  define: Object.define,
571
636
  object: Object, array: Array, string: String, number: Number, function: Function,
572
637
  date: Date, time: Date.time, event: Event, promise: Promise,
573
- url: URL, json: JSON,
638
+ url: URL, serialize: Function.serialize, xml: Function.xml, json: JSON,
574
639
  path: Function.path, file: Function.file, dir: Function.dir,
575
640
  html: Function.html,
641
+ hash: Function.hash, unique: Function.unique,
642
+ appwrite: Function.appwrite,
576
643
  }
577
644
 
578
645
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "script.io.js",
3
3
  "description": "Hello World",
4
- "version": "2026.122.1019",
4
+ "version": "2026.123.955",
5
5
  "author": "Seindi Rahmat Barus <xseindi@gmail.com>",
6
6
  "contributors": [
7
7
  "Seindi Rahmat Barus <xseindi@gmail.com>"