script.io.js 2026.122.1345 → 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.
@@ -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
  *
@@ -371,7 +362,7 @@ Define (Function.file, "write", function (file, content, context) { if (context)
371
362
  Define (Function.file, "read", function (file, context) { if (context) return Function.file.api.readFile (file, context); else return Function.file.api.readFileSync (file); });
372
363
 
373
364
  /**
374
- * xxx
365
+ * hash
375
366
  *
376
367
  * title
377
368
  * description
@@ -380,6 +371,11 @@ Define (Function.file, "read", function (file, context) { if (context) return Fu
380
371
  * xxx://xxx.xxx.xxx/xxx
381
372
  */
382
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
+
383
379
  /**
384
380
  * appwrite
385
381
  *
@@ -394,9 +390,10 @@ Define (Function, "appwrite", function () {});
394
390
  Define (Function.appwrite, "require", function () { return Function.appwrite.api = require ("node-appwrite"); });
395
391
 
396
392
  Define (Function.appwrite, "db", class {
397
- constructor (config) {
393
+ constructor (config, json) {
398
394
  this.config = config;
399
395
  this.client = new Function.appwrite.api.Client ().setEndpoint (this.config.host).setProject (this.config.project);
396
+ this.json = json || {}
400
397
  if (this.config.collection) for (var i in this.config.collection) Function.appwrite.db.collection (i, this.config.collection [i]);
401
398
  }
402
399
  select (collection) { return new Function.appwrite.db.select (this, collection); }
@@ -405,25 +402,30 @@ Define (Function.appwrite, "db", class {
405
402
  Define (Function.appwrite.db, "select", class {
406
403
  constructor (db, collection) {
407
404
  this.db = db;
408
- this.collection = {name: collection, id: Function.appwrite.db.collection (collection)}
405
+ this.collection = {name: collection, id: Function.appwrite.db.collection (collection), json: this.db.json [collection] || []}
409
406
  }
410
- find (filter = {}) {
407
+ find (filter) {
408
+ var id;
409
+ if (typeof filter !== "object") filter = {id: (id = filter)}
411
410
  var __ = function (db) {
412
411
  return new Promise (async function (resolve, reject) {
413
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)]
414
416
  try {
415
- var database = new Function.appwrite.api.Databases (db.db.client);
416
- var result = await database.listDocuments ({
417
+ database = new Function.appwrite.api.Databases (db.db.client);
418
+ result = await database.listDocuments ({
417
419
  databaseId: db.db.config.id,
418
420
  collectionId: db.collection.id,
419
- queries: [
420
- Function.appwrite.api.Query.limit (5000),
421
- ],
421
+ queries,
422
422
  total: true,
423
423
  });
424
424
  }
425
425
  catch (e) { error = true; }
426
- resolve ({error, data: result.documents.map (function (data) { data.id = data.$id; return data; }).select (filter)});
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});
427
429
  });
428
430
  }
429
431
  return __ (this);
@@ -443,6 +445,25 @@ Define (Function.appwrite.db.collection, "object", {});
443
445
  * xxx://xxx.xxx.xxx/xxx
444
446
  */
445
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
+
446
467
  /**
447
468
  * html
448
469
  *
@@ -614,9 +635,10 @@ Symbol.export = {
614
635
  define: Object.define,
615
636
  object: Object, array: Array, string: String, number: Number, function: Function,
616
637
  date: Date, time: Date.time, event: Event, promise: Promise,
617
- url: URL, json: JSON,
638
+ url: URL, serialize: Function.serialize, xml: Function.xml, json: JSON,
618
639
  path: Function.path, file: Function.file, dir: Function.dir,
619
640
  html: Function.html,
641
+ hash: Function.hash, unique: Function.unique,
620
642
  appwrite: Function.appwrite,
621
643
  }
622
644
 
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.1345",
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>"