const fs http childProcess = fs
internal.modules iterates Node's internal (built in) modules and exports only the valid ones. The invalid ones are those you can't or shouldn't require directly such as internals and 'sub modules' (containing a '/'). require('internal.modules') once
Implement this elegant functional reactive programming language pattern.
- npm install into your workdirectory, or
- npm install --global once and npm link it where it is needed.
/* module accessors are formatted as camelcased the JavaScript way. (stringDecoder, childProcess, ...) */const fs childProcess = fs
/* ES2018 spread syntax */const fs os ...theOthers = console /* all core modules except 'fs' and 'os' */ const net stream = net: 'changed' ...theOthers /* here, the value of 'net' is the net module of Node. */const net stream = ...theOthers net: 'changed' /* here, net = 'changed' because assignment happens after consuming theOthers */console
/* */let core = const http https config = } = corehttp
/* initialize */const querystring path express = mysql = } = var app = app appapp// ...
Why?
Because I type something like const fs = require('fs') (child_process, http, net, ...) a hundred times a day.
Links
- ECMAScript2018 specification (formalized best practices)
- Node.js v10.x API documentation