Today, finding small code components means searching the web (e.g. googling stack overflow...) and copy-pasting them across multiple repositories. We all do it, and we all know it's bad: it creates an unmaintainable, hard to update code base with an ever growing technological debt.
The alternative, treating few lines of code as entire packages, means creating a heavy dependency tree while relying on external sources. We all remember the left pad story. We also know that a bigger dependency tree equals a slower build and a heavier app.
Bit is a distributed code component manager that saves the need to copy-paste code components or to install entire packages for a few lines of code. Each code component can be easily published, found or injected into your code in seconds and without effort.
A simple code component like this:
function padLeft (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
str = ch + str;
}
return str;
}
module.exports = padLeft;
Simply becomes:
const padLeft = bit('pad-left');
padLeft(str, len, ch);
It allows you to design lighter applications with super fast installation and a duplication-free and easy-to-maintain code base which does not depend on external sources.
npm -g bit-bin (not supported yet)
- install dependencies using yarn
$ yarn
- you can use npm instead
$ npm i
- install command globally and link (in order to use the "bit" command globaly and always use the latest development build)
npm install -g
npm link
- install
flow
and make sure you haveflow-typed
installed.
npm install -g flow-bin flow-typed
- install type definitions using flow-typed
flow-typed install
- build legacy and modern distributions:
npm run build
- use with watch, to run the build on every code modification
npm run watch
- run the unit tests
npm test
- run eslint
npm run lint