🐝 🐜 bbo is a useful utility collection library with zero dependencies.
Overview
Every frontend developer has his own utils library, and we often write methods that are easily forgotten and highly used. bbo is a super small and useful utils library for JavaScript. It isn't couping with lodash underscore lazy.js.
I sorted out the most frequently used functions in daily development. These functions are almost ubiquitous in your development, and they cannot be found in lodash and underscore.
Most code comes from the stackOverflow site in the high-score answers, so we pay tribute to the original authors.
With easy code and less than 7k gzip, bbo can be used anytime and anywhere with no worries.
See the latest docs/documentation for a full API reference or bbo-docs.
Why
When you use react, vue, angular,you often need to write a lot of utils methods. But lodash and underscore libraries are not omnipotent. So you have to find a lot of tool libraries. By using bbo, you can solve many small problems in the daily development. It is simple and compact!
Documentation
Functions
Usage
example
let username = bbo.getCookie('username'); // => 'bbo'
let json = cookie().getJson(); // => {a: 1, b: 2}
let isiPhone = bbo.isiPhone(); // => true
// X XS, XSMax, XR
let isIphoneXmodel = bbo.isIphoneXmodel(); // => false
bbo.log('hello world!');
let id = bbo.setTimesout(
function(word) {
console.log(word);
console.log(this); // => log {index: 3 ,times: 8, over: false}
},
1000 / 20,
8,
'helloWorld'
);
bbo.math.numberFormat(1234.56, 2, ',', ' '); // => '1 234,56'
Install
bbo supports Node.js, Rollup, Webpack, Browserify。
npm
Install the library with npm into your local modules directory:
npm install bbo --save
CommonJS modules
Then in your application require the entire library:
const bbo = require('bbo');
bbo.isiPhone(); // => 'true'
Or require individual functions:
const cookie = require('bbo/cookie');
ES2015 modules
Bbo is compatible with ES2015 modules to import the entire library:
import bbo from 'bbo';
Or import individual functions:
import storage from 'bbo/storage';
Browser
Load the UMD builds directly into browser's web page:
- dist/bbo.min.js , minified production-ready, with source map
- dist/bbo.js uncompressed with comments
<script src="bbo.min.js" type="text/javascript"></script>
Then a global variable bbo
is exposed for the entire library:
<script type="text/javascript">
bbo.cookie().getJson(); // => {a: 1, b: 2}
</script>
CDN
//mat1.gtimg.com/www/js/libs/bbo.min.js
Building
node is a dependency, use terminal/iTerm to install it with
git clone git://github.com/tnfe/bbo.git
...
npm install
npm run lint
npm run build
And run example
npm run start
//visit http://localhost:8080
Maintainers
Contribution
Contribution is welcome!
-
Create a pull request containing bug fixes or new features.
😎 -
Propose new functions, improvements, better documentation
See contributors.
If you want to participate in the creation of this project,Edit or add function,Fork this project,Modify and Pull requests or new Issues.
How to sync?
# Add upstream origin,Just execute it once
git remote add upstream [email protected]:tnfe/bbo.git
# Pull remote code
git pull upstream master
# Commit changes
git add .
git commit
# update fork
git push origin master
More: Syncing a fork
Changelog
Detailed changes for each release are documented in the release notes.
License
MIT.