(obj)
| 3 | const web3Utils = require('web3-utils'); |
| 4 | |
| 5 | function _cast(obj) { |
| 6 | if (/^(\-|\+)?([1-9]+[0-9]*)$/.test(obj)) { // Int |
| 7 | obj = parseInt(obj); |
| 8 | } |
| 9 | else if (/^[+-]?([0-9]*[.])?[0-9]+$/.test(obj)) { // Float |
| 10 | obj = parseFloat(obj); |
| 11 | } |
| 12 | else if (/^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})$/.test(obj)) { // Datetime |
| 13 | var matches = /^(\d{1,2})[-\/](\d{1,2})[-\/](\d{4})$/.exec(obj); |
| 14 | var composedDate = new Date(matches[3], matches[1] - 1, matches[2]); |
| 15 | var timestampDate = composedDate.getTime(); |
| 16 | obj = timestampDate / 1000; |
| 17 | } |
| 18 | else if (obj.toLowerCase() === "true" || obj.toLowerCase() === "false") { // Boolean |
| 19 | obj = JSON.parse(obj.toLowerCase()); |
| 20 | } else if (web3Utils.isAddress(obj)) { |
| 21 | obj = web3Utils.toChecksumAddress(obj); |
| 22 | } |
| 23 | return obj; |
| 24 | } |
| 25 | |
| 26 | function parse(_csvFilePath, _batchSize) { |
| 27 | // Read file |
nothing calls this directly
no outgoing calls
no test coverage detected