Code Monkey home page Code Monkey logo

bbo's Introduction

中文 / English

logo


npm version gzip size monthly npm installs license

🐝🐜 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

device args http string array
ua args open trim unique
isIos trash getUrlParam fillZero uniqueBy
isiPhone noop setUrlParam longUnique uniqueFrom
isIPad merge deleteUrlParam stripTags random
isAndroid over objectParam capitalize randomSize
isMobile call httpGet deCapitalize shuffle
isPC bom httpPost isAbsoluteURL contains
isWeixin stopPropagation random mapString includesAll
isNewsApp g randomColor mask includesAny
isQQ gc randomA2B splitLines removeAt
mqqbrowser c randomKey camelize remove
isTenvideo query behavior underscored compact
isWeiShi show trigger dasherize compactAll
isIphoneXmodel hide lockTouch truncate pluck
isIE elementContains copyToClipboard byteSize union
ieVersion formToObject mlodash byteLen unionBy
log getStyle getTag repeat unionWith
log setStyle hasOwnProperty endsWith intersect
logs attr isObject startsWith intersectBy
removeConsole load isArray containsWith difference
other loadImages isString xssFilter differenceBy
uuid loadjs isBoolean effortIndex max
hash loadcss isNumber capwords min
judge fill isMap object equal
getType fill0 isSet properObject allEqual
isTypeof floor isFunction objectDiff all
construct chainAsync isEmpty addedDiff any
paramsName numberFormat isShallowEqual deletedDiff chunk
eventEmitter modulo has detailedDiff countBy
times cookie toPath updatedDiff countOccurrences
setTimesout cookie reduce drop
clearTimesout setCookie forEach dropRight
getDate getCookie map dropWhile
formatPassTime deleteCookie find dropRightWhile
formatRemainTime parseCookie findIndex column
formatDuration image get search
sleep checkImageSize debounce unary
json imageOptimization throttle indexBy
toJson pick
jsonp omit
storage isSymbol
storage isDate
deepClone

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。

commonjs

npm

bbo

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

browsers

Load the UMD builds directly into browser's web page:

<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

@vsuke.

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.

bbo's People

Contributors

halldwang avatar arjenhill avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.