pathchain 1.0.51 → 1.0.52

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/README.md CHANGED
@@ -447,13 +447,13 @@ message node {
447
447
  Parameter rules:
448
448
  |Parameter |Required |
449
449
  |-------------------------|----------|
450
- |{string} author |(required)|
450
+ |{string} author |(optional)|
451
451
  |{string} text |(optional)|
452
452
  |{string} format |(optional)|
453
453
 
454
454
 
455
455
  ---
456
- Summoning `makeNode(secret, text, format)`:
456
+ Summoning `makeNode(author, text, format)`:
457
457
  ```javascript
458
458
  const pathchain = require("pathchain"); // Summoning pathchain
459
459
 
package/checker.js CHANGED
@@ -41,6 +41,25 @@ function checkEmptyDir(dir) {
41
41
  return empty_dir
42
42
  }
43
43
 
44
+ /** checkFile
45
+ * [Function that returns TRUE if file exists, FALSE if not]
46
+ *
47
+ * @param {string} dir (required)
48
+ *
49
+ * @return {bool} empty_dir
50
+ */
51
+ function checkFile(dir){
52
+ try {
53
+ if (fs.existsSync(dir)) {
54
+ return true;
55
+ }
56
+ } catch(err) {
57
+ console.error(err)
58
+ }
59
+ return false;
60
+ }
61
+
62
+
44
63
  /** isSecretUsed
45
64
  * [Function that returns TRUE if secret has been used, FALSE if not]
46
65
  *
@@ -77,5 +96,6 @@ function isSecretUsed(xsecret, xauthor = "") {
77
96
 
78
97
  // CHECKING THE SECRET CHECKS THE SECRET
79
98
 
80
- module.exports = { checkDir, checkFiles, checkEmptyDir, isSecretUsed };
99
+ module.exports = { checkDir, checkFiles, checkFile, checkEmptyDir, isSecretUsed };
100
+
81
101
 
package/maker.js CHANGED
@@ -285,7 +285,7 @@ function path(text, head, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [GMT]
285
285
  register: "moments/"+register_moment_hash,
286
286
  author: author,
287
287
  text: text,
288
- head: "nodelinks/" + head,
288
+ head: "links/" + head,
289
289
  ancestor: author_folder + "paths/" + ancestor,
290
290
  tag: author_folder + "paths/" + path_hash,
291
291
  })
@@ -394,6 +394,16 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
394
394
  }
395
395
 
396
396
  // Find the target to figure out its nature (node, path or label)
397
+ if(checker.checkFile("files/" + author_folder + "nodes/" + target) == true){
398
+ console.log("Target is a node")
399
+ }
400
+ if(checker.checkFile("files/" + author_folder + "paths/" + target) == true){
401
+ console.log("Target is a path")
402
+ }
403
+ if(checker.checkFile("files/" + author_folder + "labels/" + target) == true){
404
+ console.log("Target is a label")
405
+ }
406
+
397
407
 
398
408
 
399
409
  var buffer = link_pb.link.encode({
@@ -403,13 +413,13 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
403
413
  next: "links/" + next,
404
414
  target: target,
405
415
  ancestor: author_folder + "links/" + ancestor,
406
- tag: author_folder + "links/" + nodelink_hash
416
+ tag: author_folder + "links/" + link_hash
407
417
  })
408
418
 
409
419
  checker.checkDir("files/" + author_folder + "links/") // checking
410
420
  fs.writeFileSync("files/" + author_folder + "links/" + link_hash, buffer);
411
421
 
412
- return nodelink_hash;
422
+ return link_hash;
413
423
  }
414
424
 
415
425
 
package/package.json CHANGED
@@ -34,5 +34,5 @@
34
34
  "deprecated": false,
35
35
  "description": "![image](https://user-images.githubusercontent.com/104391124/282268780-cbbc1ee6-8d97-4d80-b896-66ae3eb723dd.png)",
36
36
  "name": "pathchain",
37
- "version": "1.0.51"
37
+ "version": "1.0.52"
38
38
  }
package/updater.js CHANGED
@@ -9,7 +9,7 @@ var pb = require('protocol-buffers');
9
9
  * @return {string} xsecret
10
10
  */
11
11
  function useSecret(xsecret, xauthor = "") {
12
- if(xauthor != ""){
12
+ if(xauthor == ""){
13
13
  xauthor = xauthor + '/';
14
14
  }
15
15