molly-db 1.0.14 → 1.0.15

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/main.js CHANGED
@@ -20,12 +20,11 @@ function startWorker(_path,_self){
20
20
  const wrk = new worker.Worker(
21
21
  _path,{ workerData:_self,
22
22
  env: worker.SHARE_ENV,
23
- }); wrk.on('message',(msg)=>{
24
- console.log(msg)
25
- response(msg)
26
23
  }); wrk.on('exit',(err)=>{ console.log(err);
27
24
  response(startWorker(_path,_self));
28
- });
25
+ }); wrk.on('message',(msg)=>{
26
+ console.log(msg); response(msg)
27
+ });
29
28
  });
30
29
  }
31
30
 
package/module/_init_.js CHANGED
@@ -27,7 +27,7 @@ function fillDB( _db, _table, _path ){
27
27
 
28
28
  /* --------------------------------------------------------------------------------------- */
29
29
 
30
- (async()=>{
30
+ (()=>{ return new Promise(async(response,reject)=>{
31
31
  try {
32
32
 
33
33
  const path = `${query.path}/_init_.json`;
@@ -65,4 +65,6 @@ function fillDB( _db, _table, _path ){
65
65
  fs.writeFileSync( path,JSON.stringify(db._init_) );
66
66
 
67
67
  } response();
68
- })();
68
+
69
+
70
+ }); })();
@@ -22,12 +22,14 @@ function json( _data ){
22
22
  function bodyParser( _data ){
23
23
 
24
24
  const date = Date.now(); _data = JSON.parse(_data);
25
- const result = typeof _data != 'String' ? _data : [ _data ];
25
+ const result = _data.length ? _data : [_data];
26
+
27
+ console.log( _data, typeof _data, _data.length, result );
26
28
 
27
29
  return result.map(x=>{ if( !x?.hash )
28
30
  x.hash = crypto.hash( date,Math.random() );
29
31
  return JSON.stringify(x);
30
- })
32
+ });
31
33
 
32
34
  }
33
35
 
@@ -12,10 +12,8 @@ const db = new Object();
12
12
  /* --------------------------------------------------------------------------------------- */
13
13
 
14
14
  function _init_(){
15
- return new Promise((response,reject)=>{
16
- try{ eval( fs.readFileSync(`${__dirname}/_init_.js`).toString() );
17
- } catch(e){ console.log(e); }
18
- });
15
+ try{ return eval( fs.readFileSync(`${__dirname}/_init_.js`).toString() );
16
+ } catch(e){ console.log(e); }
19
17
  }
20
18
 
21
19
  /* --------------------------------------------------------------------------------------- */
@@ -27,15 +25,11 @@ function app(req,res){
27
25
 
28
26
  /* --------------------------------------------------------------------------------------- */
29
27
 
30
- (()=>{
31
- http.createServer( app ).listen( query.port,()=>{
32
- _init_().then(()=>{
33
- worker.parentPort.postMessage({
34
- protocol: 'HTTP', status: 'started',
35
- workerID: process.pid, port: query.port,
36
- });
37
- }).catch(e=>{ console.log(e); process.exit(1); });
38
- });
39
- })();
28
+ (()=>{ http.createServer( app ).listen( query.port,()=>{
29
+ _init_().then(()=>{ worker.parentPort.postMessage({
30
+ workerID: process.pid, port: query.port,
31
+ protocol: 'HTTP', status: 'started',
32
+ }); }).catch(e=>{ process.exit(1); });
33
+ }); })();
40
34
 
41
35
  /* --------------------------------------------------------------------------------------- */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "MIT",
3
3
  "main": "main.js",
4
- "version": "1.0.14",
4
+ "version": "1.0.15",
5
5
  "name": "molly-db",
6
6
  "author": "bececrazy",
7
7
  "scripts": {