In your command-line run the following commands:
brew doctor
brew update
const CHUNK_SIZE = 10000000; // 10MB | |
async function start() { | |
const stream = fs.createReadStream('./file', { highWaterMark: CHUNK_SIZE }); | |
for await(const data of stream) { | |
// do something with data | |
} | |
} | |
start(); |
const CHUNK_SIZE = 10000000; // 10MB | |
const data = fs.readFileSync('./file'); | |
for(let bytesRead = 0; bytesRead < data.length; bytesRead = bytesRead + CHUNK_SIZE) { | |
// do something with data | |
} |
function bytesToSize (bytes) { | |
if (bytes === 0) return '0 B'; | |
var k = 1024; | |
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] | |
var i = Math.floor(Math.log(bytes) / Math.log(k)) | |
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i] | |
} |
In your command-line run the following commands:
brew doctor
brew update
const trace = label => value => { | |
console.log(`{$label} : {$value}`); | |
return value; | |
} |
const fs = require('fs') | |
const rootDir = require('../utils/rootDir') | |
const env = { | |
// accepts a filename and if no filename, it defaults to .env | |
config: filename => { | |
filename === undefined ? (filename = '.env') : filename | |
fs.readFileSync(`${rootDir}/${filename}`, 'utf-8') |
// Async compose | |
const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input)); | |
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise | |
compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`)) |
// Object.assign has an issue with nested Objects. This prevents that leakage | |
const cloneObj = (existingObj) => { | |
return JSON.parse(JSON.stringify(existingObj)) | |
} |
" Basic settings | |
set nocompatible " behave like vim, not old vi | |
set modelines=0 " don't use modelines | |
set viminfo='20,\"50 " use a viminfo file,... | |
set history=50 " and limit history | |
set ruler " show the cursor position | |
set title " show title on the window | |
set autoread " reload file if changed outside vim | |
set autowrite " save file on some commands | |
set scrolloff=1 " minimal no. of lines around cursor |
var http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
http.createServer(function (request, response) { | |
console.log('request ', request.url); | |
var filePath = '.' + request.url; | |
if (filePath == './') { | |
filePath = './index.html'; |