pathchain 1.0.51 → 1.0.53
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 +6 -6
- package/checker.js +21 -1
- package/index.js +14 -96
- package/maker.js +13 -3
- package/package.json +1 -1
- package/updater.js +1 -1
package/README.md
CHANGED
|
@@ -447,13 +447,13 @@ message node {
|
|
|
447
447
|
Parameter rules:
|
|
448
448
|
|Parameter |Required |
|
|
449
449
|
|-------------------------|----------|
|
|
450
|
-
|{string} author |(
|
|
450
|
+
|{string} author |(optional)|
|
|
451
451
|
|{string} text |(optional)|
|
|
452
452
|
|{string} format |(optional)|
|
|
453
453
|
|
|
454
454
|
|
|
455
455
|
---
|
|
456
|
-
Summoning `makeNode(
|
|
456
|
+
Summoning `makeNode(author, text, format)`:
|
|
457
457
|
```javascript
|
|
458
458
|
const pathchain = require("pathchain"); // Summoning pathchain
|
|
459
459
|
|
|
@@ -535,9 +535,9 @@ Parameter rules:
|
|
|
535
535
|
|Parameter |Required |
|
|
536
536
|
|-------------------------|----------|
|
|
537
537
|
|{string} target |(required)|
|
|
538
|
-
|{string} prev |(
|
|
539
|
-
|{string} next |(
|
|
540
|
-
|{string} author |(
|
|
538
|
+
|{string} prev |(optional)|
|
|
539
|
+
|{string} next |(optional)|
|
|
540
|
+
|{string} author |(optional)|
|
|
541
541
|
|{string} ancestor |(optional)|
|
|
542
542
|
|{string} format |(optional)|
|
|
543
543
|
|
|
@@ -548,7 +548,7 @@ Summoning `makeLink(target, prev, next, author, ancestor, format)`:
|
|
|
548
548
|
const pathchain = require("pathchain"); // Summoning pathchain
|
|
549
549
|
|
|
550
550
|
// Nodelink creation
|
|
551
|
-
var link_buff = pathchain.makelink(
|
|
551
|
+
var link_buff = pathchain.makelink(target);
|
|
552
552
|
|
|
553
553
|
console.log("Link buffer: ", link_buff);
|
|
554
554
|
```
|
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/index.js
CHANGED
|
@@ -184,29 +184,29 @@ exports.getNodeObj = (xnode, xauthor="") => {
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
///////////////////////
|
|
187
|
-
///
|
|
187
|
+
/// LINK ///
|
|
188
188
|
///////////////////////
|
|
189
189
|
|
|
190
|
-
/**
|
|
191
|
-
* [
|
|
190
|
+
/** makeLink
|
|
191
|
+
* [Link maker]
|
|
192
192
|
*
|
|
193
|
-
* @return {string}
|
|
193
|
+
* @return {string} link_buffer
|
|
194
194
|
*/
|
|
195
|
-
exports.
|
|
196
|
-
const
|
|
197
|
-
return
|
|
195
|
+
exports.makeLink = (target="", prev="", next = "", xauthor = "", ancestor = "", format = 'MM DD YYYY HH:mm:SSS [GMT]Z') => {
|
|
196
|
+
const link_buffer = maker.link(target, prev, next, xauthor, ancestor, format);
|
|
197
|
+
return link_buffer;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
/**
|
|
201
|
-
* [Function that recieves a
|
|
200
|
+
/** getLinkObj
|
|
201
|
+
* [Function that recieves a link hash and returns the link object]
|
|
202
202
|
*
|
|
203
|
-
* @param {string}
|
|
203
|
+
* @param {string} xlink (required)
|
|
204
204
|
*
|
|
205
|
-
* @return {obj}
|
|
205
|
+
* @return {obj} link_object (link object)
|
|
206
206
|
*/
|
|
207
|
-
exports.
|
|
208
|
-
const
|
|
209
|
-
return
|
|
207
|
+
exports.getLinkObj = (xlink, xauthor="") => {
|
|
208
|
+
const link_object = getter.getLinkObj(xlink, xauthor);
|
|
209
|
+
return link_object;
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
|
|
@@ -236,88 +236,6 @@ exports.getPathObj = (xpath, xauthor="") => {
|
|
|
236
236
|
return path_object;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
///////////////////////
|
|
241
|
-
/// PATHLINK ///
|
|
242
|
-
///////////////////////
|
|
243
|
-
|
|
244
|
-
/** makePathlink
|
|
245
|
-
* [Pathlink maker]
|
|
246
|
-
*
|
|
247
|
-
* @return {string} pathlink_buffer
|
|
248
|
-
*/
|
|
249
|
-
exports.makePathlink = (first="", second="", xauthor = "", ancestor = "", format = 'MM DD YYYY HH:mm:SSS [GMT]Z') => {
|
|
250
|
-
const pathlink_buffer = maker.pathlink(first, second, xauthor, ancestor, format);
|
|
251
|
-
return pathlink_buffer;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** getPathlinkObj
|
|
255
|
-
* [Function that recieves a pathlink hash and returns the pathlink object]
|
|
256
|
-
*
|
|
257
|
-
* @param {string} xpathlink (required)
|
|
258
|
-
*
|
|
259
|
-
* @return {obj} pathlink_object (pathlink object)
|
|
260
|
-
*/
|
|
261
|
-
exports.getPathlinkObj = (xpathlink, xauthor="") => {
|
|
262
|
-
const pathlink_object = getter.getPathlinkObj(xpathlink, xauthor);
|
|
263
|
-
return pathlink_object;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
//////////////////
|
|
268
|
-
/// TREE ///
|
|
269
|
-
//////////////////
|
|
270
|
-
|
|
271
|
-
/** makeTree
|
|
272
|
-
* [Tree maker]
|
|
273
|
-
*
|
|
274
|
-
* @return {string} tree_buffer
|
|
275
|
-
*/
|
|
276
|
-
exports.makeTree = (text ="", head="", xauthor = "", ancestor="", format = 'MM DD YYYY HH:mm:SSS [GMT]Z') => {
|
|
277
|
-
const tree_buffer = maker.tree(text, head, xauthor, ancestor, format);
|
|
278
|
-
return tree_buffer;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/** getTreeObj
|
|
282
|
-
* [Function that recieves a tree hash and returns the tree object]
|
|
283
|
-
*
|
|
284
|
-
* @param {string} xtree (required)
|
|
285
|
-
*
|
|
286
|
-
* @return {obj} tree_object (tree object)
|
|
287
|
-
*/
|
|
288
|
-
exports.getTreeObj = (xtree, xauthor="") => {
|
|
289
|
-
const tree_object = getter.getTreeObj(xtree, xauthor);
|
|
290
|
-
return tree_object;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
///////////////////////
|
|
295
|
-
/// TREELINK ///
|
|
296
|
-
///////////////////////
|
|
297
|
-
|
|
298
|
-
/** makeTreelink
|
|
299
|
-
* [Treelink maker]
|
|
300
|
-
*
|
|
301
|
-
* @return {string} treelink_buffer
|
|
302
|
-
*/
|
|
303
|
-
exports.makeTreelink = (first="", second="", xauthor = "", ancestor = "", format = 'MM DD YYYY HH:mm:SSS [GMT]Z') => {
|
|
304
|
-
const treelink_buffer = maker.treelink(first, second, xauthor, ancestor, format);
|
|
305
|
-
return treelink_buffer;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** getTreelinkObj
|
|
309
|
-
* [Function that recieves a treelink hash and returns the treelink object]
|
|
310
|
-
*
|
|
311
|
-
* @param {string} xtreelink (required)
|
|
312
|
-
*
|
|
313
|
-
* @return {obj} treelink_object (treelink object)
|
|
314
|
-
*/
|
|
315
|
-
exports.getTreelinkObj = (xtreelink, xauthor="") => {
|
|
316
|
-
const treelink_object = getter.getTreelinkObj(xtreelink, xauthor);
|
|
317
|
-
return treelink_object;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
239
|
////////////////////
|
|
322
240
|
/// LABEL ///
|
|
323
241
|
////////////////////
|
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: "
|
|
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/" +
|
|
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
|
|
422
|
+
return link_hash;
|
|
413
423
|
}
|
|
414
424
|
|
|
415
425
|
|
package/package.json
CHANGED