Package Exports
- bape
- bape/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bape) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Bape - A Bathing Ape
Some useful Javascript functions and CSS style to reduce dumb work.
Inspired by Lodash.
Browser Support
Modern browsers and IE 11+
Installation
npm i bape --save
Example
// client
import random from 'bape/random'
random(0 , 1000) // generate a random integer number between 0 ~ 1000
// server
const random = require('bape/random')
random(0 , 1000) // generate a random integer number between 0 ~ 1000
API
Assertion
isObject(input)
isPlainObject(input)
isEmptyObject(input)
isNumber(input)
isJSON(input)
isURL(input)
Cookie
cookie
Generate random things
random(min = 0, max = 100, floating = 0)
randomString(length = 8)
randomCnString(length = 8)
Others
isEnter(e)
formatJSON(value, replacer = null, space = 2)
safelyGet(obj, 'a.b[1].c.d[0].e')
to get value from nested object without worring about error
Function
once(fn)
noop()
debounce(fn, wait, options)
throttle(fn, wait, options)
Array
remove(arr, item)
countArrayItem(arr)
EventEmitter
import EventEmitter from 'bape/events'
const event = new EventEmitter()
const removeListener = event.on('hello', () => console.log('hello'))
event.emit('hello')
removeListener()
Style
.ape-text-ellipsis
show ... when text is too long.ape-center
use flex layout to align child element center.ape-half-parent-width-square
generate a square that width is half of parent content width.ape-blur-text
.ape-hide
display none.ape-clearfix