holepunch-hop 0.4.8 → 0.5.3
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/.vscode/settings.json +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/package.json +1 -1
- package/src/adapters/sqliteDatabase.js +0 -0
- package/src/adapters/timeConvertor.js +3 -0
- package/src/index.js +0 -1
- package/src/ledger/kbledger.js +0 -0
- package/src/network/peers.js +0 -0
- package/src/storage/bees.js +229 -39
- package/src/storage/drive.js +27 -2
- package/src/storage/fileParser.js +0 -0
- package/test/datacommands/files/data/jan3-bitcoin.csv +0 -0
- package/test/datacommands/files/large-csv.test.js +0 -0
- package/test/datacommands/files/small-csv.test.js +0 -0
- package/test/datacommands/ledger/save-get-ledger.test.js +0 -0
- package/test/datacommands/results/save-get-results.test.js +0 -0
- package/test/holepunch-initiate.test.js +0 -0
- package/test/large-csv.test.js +0 -0
- package/test/multipers/ten-peers-network.test.js +0 -0
- package/test/setup-bee-holepunch.test.js +0 -0
- package/test/setup-holepunch.test.js +0 -0
- package/test/threepers/peer3-geninvite-after.test.js +0 -0
- package/test/threepers/three-peers.test.js +0 -0
- package/test/threepers/two-then-three.test.js +0 -0
- package/test/twopeers/peerClient-Server.test.js +0 -0
- package/test/twopeers/reconnect-peers.test.js +0 -0
- package/test/twopeers/reconnect-serverthen-conerr.test.js +0 -0
- package/test/twopeers/reconnect-then-conerr.test.js +0 -0
- package/test/twopeers/two-peer-one-disconnect.test.js +0 -0
- package/test/twopeers/two-peer-server-disconnect.test.js +0 -0
- package/vitest.config.js +0 -0
package/.vscode/settings.json
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|
|
@@ -25,6 +25,8 @@ class TimeConvertor extends EventEmitter {
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
testDataExtact = function (sampleDate) {
|
|
28
|
+
console.log('time adopter')
|
|
29
|
+
console.log(sampleDate)
|
|
28
30
|
let parseDate0 = DateTime.fromISO(sampleDate)
|
|
29
31
|
let parseDate1 = DateTime.fromHTTP(sampleDate)
|
|
30
32
|
let parseDate2 = DateTime.fromJSDate(sampleDate)
|
|
@@ -35,6 +37,7 @@ class TimeConvertor extends EventEmitter {
|
|
|
35
37
|
// .fromJSDate(sampleDate) // .fromHTTP(sampleDate) // fromFormat(sampleDate, "YYY-MM-DD ") //.fromISO(sampleDate) // or DateTime. fromFormat("23-06-2019", "dd-MM-yyyy") .(splitRow[0])// new Date(splitRow[0])
|
|
36
38
|
// console.log(parseDate) */
|
|
37
39
|
let millDate = parseDate2.toMillis()
|
|
40
|
+
console.log(millDate)
|
|
38
41
|
return millDate
|
|
39
42
|
}
|
|
40
43
|
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import Hyperswarm from 'hyperswarm'
|
|
|
15
15
|
import goodbye from 'graceful-goodbye'
|
|
16
16
|
import b4a from 'b4a'
|
|
17
17
|
|
|
18
|
-
// import { Node } from 'hyperbee/lib/messages.js'
|
|
19
18
|
import BeeWorker from './storage/bees.js'
|
|
20
19
|
import DriveWorker from './storage/drive.js'
|
|
21
20
|
import PeerWorker from './network/peers.js'
|
package/src/ledger/kbledger.js
CHANGED
|
File without changes
|
package/src/network/peers.js
CHANGED
|
File without changes
|
package/src/storage/bees.js
CHANGED
|
@@ -87,8 +87,7 @@ class HyperBee extends EventEmitter {
|
|
|
87
87
|
valueEncoding: 'json' // same options as above
|
|
88
88
|
})
|
|
89
89
|
await this.dbBentochat.ready()
|
|
90
|
-
beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(
|
|
91
|
-
|
|
90
|
+
beePubkeys.push({store:'bentochat', privacy: 'private', pubkey: b4a.toString(core14.key, 'hex')})
|
|
92
91
|
|
|
93
92
|
const core4 = this.store.get({ name: 'hopresults' })
|
|
94
93
|
this.dbHOPresults = new Hyperbee(core4, {
|
|
@@ -100,12 +99,12 @@ class HyperBee extends EventEmitter {
|
|
|
100
99
|
beePubkeys.push({store:'hopresults', privacy: 'private', pubkey: b4a.toString(core4.key, 'hex')})
|
|
101
100
|
|
|
102
101
|
const core5 = this.store.get({ name: 'kbledger' })
|
|
103
|
-
this.
|
|
102
|
+
this.dbCohereceLedger = new Hyperbee(core5, {
|
|
104
103
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
105
104
|
valueEncoding: 'json' // same options as above
|
|
106
105
|
})
|
|
107
|
-
await this.
|
|
108
|
-
// this.client.replicate(this.
|
|
106
|
+
await this.dbCohereceLedger.ready()
|
|
107
|
+
// this.client.replicate(this.dbCohereceLedger.feed)
|
|
109
108
|
beePubkeys.push({store:'kbledger', pubkey: b4a.toString(core5.key, 'hex')})
|
|
110
109
|
// stores of cues, media, research, markers, products/treatments
|
|
111
110
|
|
|
@@ -130,7 +129,15 @@ class HyperBee extends EventEmitter {
|
|
|
130
129
|
valueEncoding: 'json' // same options as above
|
|
131
130
|
})
|
|
132
131
|
await this.dbBentomodels.ready()
|
|
133
|
-
beePubkeys.push({store:'bentomodels', privacy: 'public', pubkey: b4a.toString(
|
|
132
|
+
beePubkeys.push({store:'bentomodels', privacy: 'public', pubkey: b4a.toString(core13.key, 'hex')})
|
|
133
|
+
|
|
134
|
+
const core15 = this.store.get({ name: 'bentoboxes' })
|
|
135
|
+
this.dbBentoBoxes = new Hyperbee(core15, {
|
|
136
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
137
|
+
valueEncoding: 'json' // same options as above
|
|
138
|
+
})
|
|
139
|
+
await this.dbBentoBoxes.ready()
|
|
140
|
+
beePubkeys.push({store:'bentoboxes', privacy: 'private', pubkey: b4a.toString(core15.key, 'hex')})
|
|
134
141
|
|
|
135
142
|
const core8 = this.store.get({ name: 'bentodecisions' })
|
|
136
143
|
this.dbBentodecisions = new Hyperbee(core8, {
|
|
@@ -140,7 +147,6 @@ class HyperBee extends EventEmitter {
|
|
|
140
147
|
await this.dbBentodecisions.ready()
|
|
141
148
|
beePubkeys.push({store:'bentodecisions', pubkey: b4a.toString(core8.key, 'hex')})
|
|
142
149
|
|
|
143
|
-
|
|
144
150
|
const core9 = this.store.get({ name: 'bentomarkers' })
|
|
145
151
|
this.dbBentomarkers = new Hyperbee(core9, {
|
|
146
152
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
@@ -149,7 +155,6 @@ class HyperBee extends EventEmitter {
|
|
|
149
155
|
await this.dbBentomarkers.ready()
|
|
150
156
|
beePubkeys.push({store:'bentomarkers', privacy: 'private', pubkey: b4a.toString(core9.key, 'hex')})
|
|
151
157
|
|
|
152
|
-
|
|
153
158
|
const core10 = this.store.get({ name: 'research' })
|
|
154
159
|
this.dbBentoresearch = new Hyperbee(core10, {
|
|
155
160
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
@@ -158,7 +163,6 @@ class HyperBee extends EventEmitter {
|
|
|
158
163
|
await this.dbBentoresearch.ready()
|
|
159
164
|
beePubkeys.push({store:'research', privacy: 'public', pubkey: b4a.toString(core10.key, 'hex')})
|
|
160
165
|
|
|
161
|
-
|
|
162
166
|
const core11 = this.store.get({ name: 'bentoproducts' })
|
|
163
167
|
this.dbBentoproducts = new Hyperbee(core11, {
|
|
164
168
|
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
@@ -174,7 +178,24 @@ class HyperBee extends EventEmitter {
|
|
|
174
178
|
})
|
|
175
179
|
await this.dbBentomedia.ready()
|
|
176
180
|
beePubkeys.push({store:'bentomedia', privacy: 'private', pubkey: b4a.toString(core12.key, 'hex')})
|
|
177
|
-
|
|
181
|
+
|
|
182
|
+
const core16 = this.store.get({ name: 'besearch' })
|
|
183
|
+
this.dbBesearch = new Hyperbee(core16, {
|
|
184
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
185
|
+
valueEncoding: 'json' // same options as above
|
|
186
|
+
})
|
|
187
|
+
await this.dbBesearch.ready()
|
|
188
|
+
beePubkeys.push({store:'besearch', privacy: 'private', pubkey: b4a.toString(core16.key, 'hex')})
|
|
189
|
+
|
|
190
|
+
const core17 = this.store.get({ name: 'beebeelearn' })
|
|
191
|
+
this.dbBeeBeeLearn = new Hyperbee(core17, {
|
|
192
|
+
keyEncoding: 'utf-8', // can be set to undefined (binary), utf-8, ascii or and abstract-encoding
|
|
193
|
+
valueEncoding: 'json' // same options as above
|
|
194
|
+
})
|
|
195
|
+
await this.dbBeeBeeLearn.ready()
|
|
196
|
+
beePubkeys.push({store:'beebeelearn', privacy: 'public', pubkey: b4a.toString(core17.key, 'hex')})
|
|
197
|
+
|
|
198
|
+
// testing help remove for production
|
|
178
199
|
this.emit('hbee-live')
|
|
179
200
|
// return beePubkeys
|
|
180
201
|
let startBeePubkey = {}
|
|
@@ -184,17 +205,17 @@ class HyperBee extends EventEmitter {
|
|
|
184
205
|
this.liveBees = startBeePubkey
|
|
185
206
|
this.wsocket.send(JSON.stringify(startBeePubkey))
|
|
186
207
|
this.activeBees = beePubkeys
|
|
187
|
-
}
|
|
188
208
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
await this.dbKBledger.put(ledgerEntry.hash, ledgerEntry.data)
|
|
209
|
+
// test list of results
|
|
210
|
+
/* let listResults = await this.peerResults()
|
|
211
|
+
console.log(listResults)
|
|
212
|
+
for (let res of listResults) {
|
|
213
|
+
await this.deleteResultsItem(res.key)
|
|
214
|
+
} */
|
|
196
215
|
}
|
|
197
216
|
|
|
217
|
+
/* HOP query results */
|
|
218
|
+
|
|
198
219
|
/**
|
|
199
220
|
* save HOPresults
|
|
200
221
|
* @method saveHOPresults
|
|
@@ -204,6 +225,36 @@ class HyperBee extends EventEmitter {
|
|
|
204
225
|
await this.dbHOPresults.put(refContract.hash, refContract.data)
|
|
205
226
|
}
|
|
206
227
|
|
|
228
|
+
peerResults = async function () {
|
|
229
|
+
const nodeData = this.dbHOPresults.createReadStream()
|
|
230
|
+
let resData = []
|
|
231
|
+
for await (const { key, value } of nodeData) {
|
|
232
|
+
resData.push({ key, value })
|
|
233
|
+
}
|
|
234
|
+
return resData
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* lookup results per dataprint hash
|
|
239
|
+
* @method peerResultsItem
|
|
240
|
+
*
|
|
241
|
+
*/
|
|
242
|
+
peerResultsItem = async function (key) {
|
|
243
|
+
const resultData = await this.dbHOPresults.get(key)
|
|
244
|
+
return resultData
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* delete results
|
|
249
|
+
* @method deleteResultsItem
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
deleteResultsItem = async function (key) {
|
|
253
|
+
const resultData = await this.dbHOPresults.del(key)
|
|
254
|
+
return resultData
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
207
258
|
/** CHAT */
|
|
208
259
|
|
|
209
260
|
/**
|
|
@@ -361,6 +412,53 @@ class HyperBee extends EventEmitter {
|
|
|
361
412
|
return deleteInfo
|
|
362
413
|
}
|
|
363
414
|
|
|
415
|
+
/** BENTOBOXES */
|
|
416
|
+
/**
|
|
417
|
+
* save model
|
|
418
|
+
* @method saveModel
|
|
419
|
+
*/
|
|
420
|
+
saveBentoBox = async function (boxInfo) {
|
|
421
|
+
await this.dbBentoBoxes.put(boxInfo.id, boxInfo.data)
|
|
422
|
+
let checkSave = await this.getBentoBox(boxInfo.id)
|
|
423
|
+
return checkSave
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* get one cue by id
|
|
428
|
+
* @method getModel
|
|
429
|
+
*
|
|
430
|
+
*/
|
|
431
|
+
getBentoBox = async function (key) {
|
|
432
|
+
const nodeData = await this.dbBentoBoxes.get(key)
|
|
433
|
+
return nodeData
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* get all cuees
|
|
438
|
+
* @method getModelHistory
|
|
439
|
+
*
|
|
440
|
+
*/
|
|
441
|
+
getBentoBoxHistory = async function (key) {
|
|
442
|
+
const boxHistory = await this.dbBentoBoxes.createReadStream()
|
|
443
|
+
let boxData = []
|
|
444
|
+
for await (const { key, value } of boxHistory) {
|
|
445
|
+
boxData.push({ key, value })
|
|
446
|
+
}
|
|
447
|
+
return boxData
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* delete nxp ref contract from peer library
|
|
452
|
+
* @method deleteBentoBox
|
|
453
|
+
*/
|
|
454
|
+
deleteBentoBox = async function (box) {
|
|
455
|
+
const deleteStatus = await this.dbBentoBoxes.del(box.id)
|
|
456
|
+
let deleteInfo = {}
|
|
457
|
+
deleteInfo.id = box.id
|
|
458
|
+
return deleteInfo
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
|
|
364
462
|
/** MODELS */
|
|
365
463
|
/**
|
|
366
464
|
* save model
|
|
@@ -644,6 +742,103 @@ class HyperBee extends EventEmitter {
|
|
|
644
742
|
return deleteInfo
|
|
645
743
|
}
|
|
646
744
|
|
|
745
|
+
/** Besearch */
|
|
746
|
+
/**
|
|
747
|
+
* save besearch
|
|
748
|
+
* @method saveBesearch
|
|
749
|
+
*
|
|
750
|
+
*/
|
|
751
|
+
saveBesearch = async function (cuesInfo) {
|
|
752
|
+
await this.dbBesearch.put(cuesInfo.id, cuesInfo.data)
|
|
753
|
+
let checkSave = await this.getBesearch(cuesInfo.id)
|
|
754
|
+
return checkSave
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* get one cue by id
|
|
759
|
+
* @method getBesearch
|
|
760
|
+
*
|
|
761
|
+
*/
|
|
762
|
+
getBesearch = async function (key) {
|
|
763
|
+
const nodeData = await this.dbBesearch.get(key)
|
|
764
|
+
return nodeData
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* get all Besearch
|
|
769
|
+
* @method getBesearchHistory
|
|
770
|
+
*
|
|
771
|
+
*/
|
|
772
|
+
getBesearchHistory = async function (key) {
|
|
773
|
+
const cuesHistory = await this.dbBesearch.createReadStream()
|
|
774
|
+
let cuesData = []
|
|
775
|
+
for await (const { key, value } of cuesHistory) {
|
|
776
|
+
cuesData.push({ key, value })
|
|
777
|
+
}
|
|
778
|
+
return cuesData
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* delete contract
|
|
783
|
+
* @method deleteBentoBesearch
|
|
784
|
+
*/
|
|
785
|
+
deleteBentoBesearch = async function (cue) {
|
|
786
|
+
const deleteStatus = await this.dbBesearch.del(cue.id)
|
|
787
|
+
let deleteInfo = {}
|
|
788
|
+
deleteInfo.spaceid = cue.id
|
|
789
|
+
return deleteInfo
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
/** BEEBEE LEARN via @teach */
|
|
794
|
+
/**
|
|
795
|
+
* save chat history
|
|
796
|
+
* @method saveBeeBeeLearn
|
|
797
|
+
*
|
|
798
|
+
*/
|
|
799
|
+
saveBeeBeeLearn = async function (teachSession) {
|
|
800
|
+
await this.dbBeeBeeLearn.put(teachSession.id, teachSession.session)
|
|
801
|
+
let checkSave = await this.getBeeBeeLearn(teachSession.id)
|
|
802
|
+
return checkSave
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* delete chat item
|
|
807
|
+
* @method deleteBeeBeeLearn
|
|
808
|
+
*
|
|
809
|
+
*/
|
|
810
|
+
deleteBeeBeeLearn = async function (key) {
|
|
811
|
+
await this.dbBeeBeeLearn.del(key)
|
|
812
|
+
let deleteInfo = {}
|
|
813
|
+
deleteInfo.id = key
|
|
814
|
+
return deleteInfo
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* lookup peer teach session layout default
|
|
819
|
+
* @method getBeeBeeLearn
|
|
820
|
+
*
|
|
821
|
+
*/
|
|
822
|
+
getBeeBeeLearn = async function (key) {
|
|
823
|
+
const nodeData = await this.dbBeeBeeLearn.get(key)
|
|
824
|
+
return nodeData
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* lookup range save learn @teach history
|
|
829
|
+
* @method getBeeBeeLearnHistory
|
|
830
|
+
*
|
|
831
|
+
*/
|
|
832
|
+
getBeeBeeLearnHistory = async function (range) {
|
|
833
|
+
const teachHistoryData = this.dbBeeBeeLearn.createReadStream() // { gt: 'a', lt: 'z' }) // anything >a and <z
|
|
834
|
+
let teachData = []
|
|
835
|
+
for await (const { key, value } of teachHistoryData) {
|
|
836
|
+
teachData.push({ key, value })
|
|
837
|
+
}
|
|
838
|
+
return teachData
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// old solo spaces
|
|
647
842
|
/**
|
|
648
843
|
* save space layout of bentobox
|
|
649
844
|
* @method saveSolospace
|
|
@@ -781,6 +976,16 @@ class HyperBee extends EventEmitter {
|
|
|
781
976
|
return moduleData
|
|
782
977
|
}
|
|
783
978
|
|
|
979
|
+
/* COHERENCE LEDGER Knowledge Bundle Ledger */
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* save kbledger entry
|
|
983
|
+
* @method saveKBLentry
|
|
984
|
+
*
|
|
985
|
+
*/
|
|
986
|
+
saveKBLentry = async function (ledgerEntry) {
|
|
987
|
+
await this.dbCohereceLedger.put(ledgerEntry.data, ledgerEntry.hash)
|
|
988
|
+
}
|
|
784
989
|
|
|
785
990
|
/**
|
|
786
991
|
* get all kbl entries
|
|
@@ -788,7 +993,7 @@ class HyperBee extends EventEmitter {
|
|
|
788
993
|
*
|
|
789
994
|
*/
|
|
790
995
|
KBLentries = async function (dataPrint) {
|
|
791
|
-
const nodeData = this.
|
|
996
|
+
const nodeData = this.dbCohereceLedger.createReadStream()
|
|
792
997
|
let ledgerData = []
|
|
793
998
|
for await (const { key, value } of nodeData) {
|
|
794
999
|
ledgerData.push({ key, value })
|
|
@@ -797,30 +1002,15 @@ class HyperBee extends EventEmitter {
|
|
|
797
1002
|
}
|
|
798
1003
|
|
|
799
1004
|
/**
|
|
800
|
-
* lookup
|
|
801
|
-
* @method
|
|
1005
|
+
* lookup coherence ledger per results id
|
|
1006
|
+
* @method peerLedgerProof
|
|
802
1007
|
*
|
|
803
1008
|
*/
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
return
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* lookup specific result UUID
|
|
811
|
-
* @method peerResults
|
|
812
|
-
*
|
|
813
|
-
*/
|
|
814
|
-
peerResults = async function () {
|
|
815
|
-
const nodeData = this.dbKBledger.createReadStream()
|
|
816
|
-
let resData = []
|
|
817
|
-
for await (const { key, value } of nodeData) {
|
|
818
|
-
resData.push({ key, value })
|
|
819
|
-
}
|
|
820
|
-
return resData
|
|
1009
|
+
peerLedgerProof = async function (dataPrint) {
|
|
1010
|
+
const ledgerData = await this.dbCohereceLedger.get(dataPrint.resultuuid)
|
|
1011
|
+
return ledgerData
|
|
821
1012
|
}
|
|
822
1013
|
|
|
823
|
-
|
|
824
1014
|
/**
|
|
825
1015
|
* get stream data for keystore db
|
|
826
1016
|
* @method getStreamHyperbeeDB
|
package/src/storage/drive.js
CHANGED
|
@@ -135,7 +135,7 @@ class HypDrive extends EventEmitter {
|
|
|
135
135
|
saveCSVfilecontent = async function (fData) {
|
|
136
136
|
// extract header info first
|
|
137
137
|
let headerInfo = this.fileUtility.webCSVparse(fData)
|
|
138
|
-
let hyperdrivePath = 'csv/' + fData.data[0].
|
|
138
|
+
let hyperdrivePath = 'csv/' + fData.data[0].file
|
|
139
139
|
let confirmSave = await this.drive.put(hyperdrivePath, fData.data[0].content)
|
|
140
140
|
let saveStatus = {}
|
|
141
141
|
saveStatus.save = confirmSave
|
|
@@ -341,6 +341,24 @@ class HypDrive extends EventEmitter {
|
|
|
341
341
|
return localFile
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
/**
|
|
345
|
+
* CSV rebuidl file and give directory location
|
|
346
|
+
* @method CSVhyperdriveLocalfile
|
|
347
|
+
*
|
|
348
|
+
*/
|
|
349
|
+
CSVhyperdriveLocalfile = async function (path) {
|
|
350
|
+
console.log('hyperdreive----')
|
|
351
|
+
console.log(path)
|
|
352
|
+
// File reads to buffer and recreate file
|
|
353
|
+
// const bufFromGet2 = await this.drive.get(path)
|
|
354
|
+
const { value: entry } = await this.drive.entry(path)
|
|
355
|
+
const blobs = await this.drive.getBlobs()
|
|
356
|
+
const bufFromEntry = await blobs.get(entry.blob)
|
|
357
|
+
let localFile = 'localcsv'
|
|
358
|
+
fs.writeFileSync(localFile, bufFromEntry)
|
|
359
|
+
return localFile
|
|
360
|
+
}
|
|
361
|
+
|
|
344
362
|
/**
|
|
345
363
|
* set file path, read and make sqlite3 connect db
|
|
346
364
|
* @method SQLiteSetup
|
|
@@ -433,7 +451,14 @@ class HypDrive extends EventEmitter {
|
|
|
433
451
|
let parseDate4 = DateTime.local(sampleDate)
|
|
434
452
|
// .fromJSDate(sampleDate) // .fromHTTP(sampleDate) // fromFormat(sampleDate, "YYY-MM-DD ") //.fromISO(sampleDate) // or DateTime. fromFormat("23-06-2019", "dd-MM-yyyy") .(splitRow[0])// new Date(splitRow[0])
|
|
435
453
|
*/
|
|
436
|
-
|
|
454
|
+
let millDate = ''
|
|
455
|
+
if (parseDate0.reason !== 'unparsable' || parseDate0.reason !== 'invalid input') {
|
|
456
|
+
millDate = parseDate0.toMillis()
|
|
457
|
+
} else if (parseDate1.reason !== 'unparsable' || parseDate1.reason !== 'invalid input') {
|
|
458
|
+
millDate = parseDate1.toMillis()
|
|
459
|
+
} else if (parseDate2.reason !== 'unparsable' || parseDate2.reason !== 'invalid input') {
|
|
460
|
+
millDate = parseDate2.toMillis()
|
|
461
|
+
}
|
|
437
462
|
return millDate
|
|
438
463
|
}
|
|
439
464
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/large-csv.test.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/vitest.config.js
CHANGED
|
File without changes
|