🕴 likeaboss
export like a boss with functions, dynamic & static requires, module & web support; easy, fast & tiny.
works with:
- 📼 es5
- 🍬 es6+
- 🌊 typescript
- 🗼 babel
- 🕸 web
- 🔙🔚 node
- other?
📦 usage
yarn add likeabossnpm i likeaboss --save
🌐 documentation
🔬 tests
📘 examples
const Export = const pkg = // export directly on the module without module.exports// or do `exports = module.exports = ` when using .exportExport // main export to be decorated // export for web usage when needed // load dynamic dir__dirname + '/your-dist-folder' // and all other props you want to use // only `required` when used // finish
dynamics
only used when the "import"er / client does
or
const PluginEh = ClassOrFunction
🕳 diving deeper examples
⛓ fluent function export
const Export = { // magical things when called as a function} const Canada = canada: true exports = moduleexports = Export
fluent fn with requires
dynamic and static requires, dynamic requires only are required when they are used
const Export = { console} exports = moduleexports = Export dir__dirname
🦐 importing:
requires
./eh/src/Boss.js
console // requires the BossPlugin console
object function with requires
same as with fluent, but using object syntax
const Export = exports = moduleexports = Export
module
no need to reassign exports and modules ([exports] is optional 2nd arg)
Exports
👽 exports
file size (~700 bytes)
from
// imports the `from` static fnconst from = const Export =
generate
🚧⚗ warning, experimental
// export.jsconst gen = { /* magic */ } const Eh = eh: trueconst Canada = canada: true exports = moduleexports = Exports dir__dirname console // outputs exporting string// node export.js > index.js
⚖️ benchmark
using 🏋️⛓ bench-chain
optimized x 30975 ops/sec ±1348% 50 runs sampledfluent x 20434 ops/sec ±352% 73 runs sampled
with last example
timesconsole.log({})
: ~ ⏲ 35000ms / 35ms- fluent: ~ ⏲ 1300 microseconds / 1.3ms
- optimized: ~ ⏲ 400 microseconds / .4ms
exports = module.exports = ...
: ~ ⏲ 100-200 microseconds / .1ms-.2ms
🏭
output
example generated output pseudo code
{}const ex = Eh: eh: true Canada: canada: true Boss: 'boss' plugins: {} Statics: static: true __esModule: true Object exdefault = ex Object