pathchain 1.1.36 → 1.1.38
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 +61 -8
- package/getter.js +6 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -740,14 +740,28 @@ var path_chain_obj = pathchain.getPathchainObj(path_buff);
|
|
|
740
740
|
console.log("Path chain obj: ", path_chain_obj);
|
|
741
741
|
```
|
|
742
742
|
|
|
743
|
-
|
|
744
|
-
```
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
743
|
+
Console:
|
|
744
|
+
``` bash
|
|
745
|
+
Pathchain object: [
|
|
746
|
+
{
|
|
747
|
+
register: 'moments/253414143d338fc68096a0e3710caf0874056ccebab0c5440cc1d2316b696814',
|
|
748
|
+
author: 'entities/23223e7b9a2e98456d42963de23a165c43248e1430adfaf4fd461959a109306c',
|
|
749
|
+
text: 'This is the content of a third public node',
|
|
750
|
+
tag: 'nodes/415024cff8dd263b3252592903b5d8f098298a0eed3ab67f372ea305cf2e137b'
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
register: 'moments/86e1a2571fb12fa4af49f43ead01819b85376564e017bda6f656cde6d33dc070',
|
|
754
|
+
author: 'entities/23223e7b9a2e98456d42963de23a165c43248e1430adfaf4fd461959a109306c',
|
|
755
|
+
text: 'This is the content of a second public node',
|
|
756
|
+
tag: 'nodes/0d1686603951c3e92a3122375d27a6ead4c3131d81fd321aee04c4729657b41d'
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
register: 'moments/897a9171765ca68fb5aa264b41040e107d741307918e1acd6dda2dbea36d7dfc',
|
|
760
|
+
author: 'entities/23223e7b9a2e98456d42963de23a165c43248e1430adfaf4fd461959a109306c',
|
|
761
|
+
text: 'This is the content of a public node',
|
|
762
|
+
tag: 'nodes/480cd79de90f3cd6d5aabd7847d0eb8ed416eb5c1054e27866e29524e6da754e'
|
|
763
|
+
}
|
|
764
|
+
]
|
|
751
765
|
```
|
|
752
766
|
|
|
753
767
|
## Label
|
|
@@ -833,3 +847,42 @@ var obj = pathchain.getObj(node_buff);
|
|
|
833
847
|
|
|
834
848
|
console.log("Object: ", obj);
|
|
835
849
|
```
|
|
850
|
+
|
|
851
|
+
Console:
|
|
852
|
+
```bash
|
|
853
|
+
Retrieving object of type: nodes
|
|
854
|
+
Object: {
|
|
855
|
+
register: 'moments/253414143d338fc68096a0e3710caf0874056ccebab0c5440cc1d2316b696814',
|
|
856
|
+
author: 'entities/23223e7b9a2e98456d42963de23a165c43248e1430adfaf4fd461959a109306c',
|
|
857
|
+
text: 'This is the content of a third public node',
|
|
858
|
+
tag: 'nodes/415024cff8dd263b3252592903b5d8f098298a0eed3ab67f372ea305cf2e137b'
|
|
859
|
+
}
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
#### Generic Object Type getter
|
|
864
|
+
|
|
865
|
+
Parameter rules:
|
|
866
|
+
|Parameter |Required |
|
|
867
|
+
|-------------------------|----------|
|
|
868
|
+
|{string} xaddress |(required)|
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
---
|
|
872
|
+
Summoning `getType(xaddress)`:
|
|
873
|
+
```javascript
|
|
874
|
+
const pathchain = require("pathchain"); // Summoning pathchain
|
|
875
|
+
|
|
876
|
+
// Having the tag/address of any object from the pathchain
|
|
877
|
+
var buff_address = "nodes/415024cff8dd263b3252592903b5d8f098298a0eed3ab67f372ea305cf2e137b"
|
|
878
|
+
|
|
879
|
+
// Infer its type!
|
|
880
|
+
var buff_type = pathchain.getType(buff_address);
|
|
881
|
+
|
|
882
|
+
console.log("Type: ", buff_type);
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
Console:
|
|
886
|
+
```bash
|
|
887
|
+
Type: node
|
|
888
|
+
```
|
package/getter.js
CHANGED
|
@@ -166,7 +166,7 @@ function getObj(xaddress) {
|
|
|
166
166
|
const filePath = `files/${xaddress}`;
|
|
167
167
|
|
|
168
168
|
var splitted_address = xaddress.split("/");
|
|
169
|
-
console.log("Splitted address: ", splitted_address);
|
|
169
|
+
// console.log("Splitted address: ", splitted_address);
|
|
170
170
|
var obj_type = splitted_address[splitted_address.length - 2];
|
|
171
171
|
console.log("Retrieving object of type: ", obj_type);
|
|
172
172
|
|
|
@@ -275,18 +275,15 @@ function getPathchainObj(xpath, xauthor = '') {
|
|
|
275
275
|
var pathObj = pathProto.path.decode(fileContents);
|
|
276
276
|
|
|
277
277
|
var head_link = this.getObj(pathObj.head);
|
|
278
|
-
console.log("Head link", head_link);
|
|
279
|
-
|
|
280
|
-
var head_obj = this.getObj(head_link.target);
|
|
281
|
-
console.log("Head target object", head_obj);
|
|
282
|
-
|
|
278
|
+
// console.log("Head link", head_link);
|
|
279
|
+
|
|
283
280
|
var obj_list = [];
|
|
284
281
|
var current_link = head_link;
|
|
285
282
|
|
|
286
283
|
// As the head is the last inserted element, we go backwards till there's no more linked elements
|
|
287
284
|
while (current_link.prev !== current_link.tag) {
|
|
288
|
-
console.log("Current link: ", current_link);
|
|
289
|
-
console.log("Trying to retrieve object from: ", current_link.target);
|
|
285
|
+
// console.log("Current link: ", current_link);
|
|
286
|
+
// console.log("Trying to retrieve object from: ", current_link.target);
|
|
290
287
|
const current_obj = this.getObj(current_link.target);
|
|
291
288
|
console.log("Pushing object: ", current_obj);
|
|
292
289
|
obj_list.push(current_obj);
|
|
@@ -294,7 +291,7 @@ function getPathchainObj(xpath, xauthor = '') {
|
|
|
294
291
|
}
|
|
295
292
|
console.log("Pushing last element (current link target): ", current_link.target);
|
|
296
293
|
var current_link_target_obj = this.getObj(current_link.target);
|
|
297
|
-
console.log("
|
|
294
|
+
console.log("Last element target object: ", current_link_target_obj);
|
|
298
295
|
obj_list.push(current_link_target_obj);
|
|
299
296
|
|
|
300
297
|
return obj_list;
|
package/package.json
CHANGED