pathchain 1.0.54 → 1.0.56

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.
Files changed (2) hide show
  1. package/getter.js +11 -119
  2. package/package.json +1 -1
package/getter.js CHANGED
@@ -188,39 +188,39 @@ function getNodeObj(xnode, xauthor) {
188
188
  }
189
189
 
190
190
 
191
- /** getNodelinkObj
192
- * [Function that recieves a nodelink hash and returns the nodelink object]
191
+ /** getLinkObj
192
+ * [Function that recieves a link hash and returns the link object]
193
193
  *
194
- * @param {string} xnodelink (required)
194
+ * @param {string} xlink (required)
195
195
  *
196
196
  * @return void
197
197
  */
198
- function getNodelinkObj(xnodelink, xauthor) {
198
+ function getLinkObj(xlink, xauthor) {
199
199
 
200
200
  if(xauthor != ""){
201
201
  xauthor = xauthor + '/';
202
202
  }
203
203
 
204
204
  // LOADING PB
205
- var nodelink_pb = pb(fs.readFileSync('node_modules/pathchain/proto/nodelink.proto'))
205
+ var link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'))
206
206
 
207
207
  // NOT FOUND EXCEPTION
208
208
  var fileContents;
209
209
  try {
210
- fileContents = fs.readFileSync("files/" + xauthor + "nodelinks/" + xnodelink);
210
+ fileContents = fs.readFileSync("files/" + xauthor + "links/" + xlink);
211
211
  } catch (err) {
212
212
  if (err.code === 'ENOENT') {
213
- return "Nodelink not found";
213
+ return "Link not found";
214
214
  } else {
215
215
  throw err;
216
216
  }
217
217
  }
218
218
 
219
219
  // DECODING NODE
220
- var nodelink_enc = fileContents
221
- var nodelink_obj = nodelink_pb.nodelink.decode(nodelink_enc)
220
+ var link_enc = fileContents
221
+ var link_obj = link_pb.link.decode(link_enc)
222
222
 
223
- return nodelink_obj;
223
+ return link_obj;
224
224
  }
225
225
 
226
226
 
@@ -260,114 +260,6 @@ function getPathObj(xpath, xauthor) {
260
260
  }
261
261
 
262
262
 
263
- /** getPathlinkObj
264
- * [Function that recieves a pathlink hash and returns the pathlink object]
265
- *
266
- * @param {string} xpathlink (required)
267
- *
268
- * @return void
269
- */
270
- function getPathlinkObj(xpathlink, xauthor) {
271
-
272
- if(xauthor != ""){
273
- xauthor = xauthor + '/';
274
- }
275
-
276
- // LOADING PB
277
- var pathlink_pb = pb(fs.readFileSync('node_modules/pathchain/proto/pathlink.proto'))
278
-
279
- // NOT FOUND EXCEPTION
280
- var fileContents;
281
- try {
282
- fileContents = fs.readFileSync("files/" + xauthor + "pathlinks/" + xpathlink);
283
- } catch (err) {
284
- if (err.code === 'ENOENT') {
285
- return "Pathlink not found";
286
- } else {
287
- throw err;
288
- }
289
- }
290
-
291
- // DECODING PATHLINK
292
- var pathlink_enc = fileContents
293
- var pathlink_obj = pathlink_pb.pathlink.decode(pathlink_enc)
294
-
295
- return pathlink_obj;
296
- }
297
-
298
-
299
- /** getTreeObj
300
- * [Function that recieves a tree hash and returns the tree object]
301
- *
302
- * @param {string} xtree (required)
303
- *
304
- * @return void
305
- */
306
- function getTreeObj(xtree, xauthor) {
307
-
308
- if(xauthor != ""){
309
- xauthor = xauthor + '/';
310
- }
311
-
312
- // LOADING PB
313
- var tree_pb = pb(fs.readFileSync('node_modules/pathchain/proto/tree.proto'))
314
-
315
- // NOT FOUND EXCEPTION
316
- var fileContents;
317
- try {
318
- fileContents = fs.readFileSync("files/" + xauthor + "trees/" + xtree);
319
- } catch (err) {
320
- if (err.code === 'ENOENT') {
321
- return "Tree not found";
322
- } else {
323
- throw err;
324
- }
325
- }
326
-
327
- // DECODING TREE
328
- var tree_enc = fileContents
329
- var tree_obj = tree_pb.tree.decode(tree_enc)
330
-
331
- return tree_obj;
332
- }
333
-
334
-
335
- /** getTreelinkObj
336
- * [Function that recieves a treelink hash and returns the treelink object]
337
- *
338
- * @param {string} xtreelink (required)
339
- *
340
- * @return void
341
- */
342
- function getTreelinkObj(xtreelink, xauthor) {
343
-
344
- if(xauthor != ""){
345
- xauthor = xauthor + '/';
346
- }
347
-
348
- // LOADING PB
349
- var treelink_pb = pb(fs.readFileSync('node_modules/pathchain/proto/treelink.proto'))
350
-
351
- // NOT FOUND EXCEPTION
352
- var fileContents;
353
- try {
354
- fileContents = fs.readFileSync("files/" + xauthor + "treelinks/" + xtreelink);
355
- } catch (err) {
356
- if (err.code === 'ENOENT') {
357
- return "Treelink not found";
358
- } else {
359
- throw err;
360
- }
361
- }
362
-
363
- // DECODING TREELINK
364
- var treelink_enc = fileContents
365
- var treelink_obj = treelink_pb.treelink.decode(treelink_enc)
366
-
367
- return treelink_obj;
368
- }
369
-
370
-
371
263
  /** getLabelObj
372
264
  * [Function that recieves a label hash and returns the label object]
373
265
  *
@@ -404,4 +296,4 @@ function getLabelObj(xlabel, xauthor) {
404
296
  }
405
297
 
406
298
 
407
- module.exports = { getCurrentDate, getMomentObj, getPioneerObj, getSecretObj, getEntityObj, getNodeObj, getNodelinkObj, getPathObj, getPathlinkObj, getTreeObj, getTreelinkObj, getLabelObj }
299
+ module.exports = { getCurrentDate, getMomentObj, getPioneerObj, getSecretObj, getEntityObj, getNodeObj, getLinkObj, getPathObj, getTreeObj, getLabelObj }
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.54"
37
+ "version": "1.0.56"
38
38
  }