npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bgnos-utils

v0.0.6

Published

### install

Downloads

2

Readme

JbsUtils

install

npm install @51job/jbs-utils

Use

` import JbsUtils from "@51job/jbs-utils"

const {add} = JbsUtils;

console.log(add(1, 2)) `

Base

isNaN (val) 判断是否非数值,如果 value 是一个 NaN,那么返回 true,否则返回 false

      `isNaN(undefined) // true
            JbsUtils.isNaN(undefined) // false
            JbsUtils.isNaN(NaN) // true` 

isFinite (val) 判断是否为有限数值

      `JbsUtils.isFinite(NaN) // false
            JbsUtils.isFinite(0) // true
            JbsUtils.isFinite(2e64) // true` 

isUndefined (val) 判断 Undefined

      `JbsUtils.isUndefined(0) // false
            JbsUtils.isUndefined() // true` 

isArray (val) 判断是否数组

      `JbsUtils.isArray(null) // false
            JbsUtils.isArray({}) // false
            JbsUtils.isArray([1,2,3]) // true` 

isFloat (val) 判断是否小数

      `JbsUtils.isFloat(null) // false
            JbsUtils.isFloat(0) // false
            JbsUtils.isFloat(3) // false
            JbsUtils.isFloat(3.3) // true` 

isInteger (val) 判断是否整数

      `JbsUtils.isInteger(null) // false
            JbsUtils.isInteger(3.3) // false
            JbsUtils.isInteger(3) // true
            JbsUtils.isInteger(0) // true` 

isFunction (val) 判断是否方法

      `JbsUtils.isFunction({}) // false
            JbsUtils.isFunction(function(){}) // true` 

isBoolean (val) 判断是否 Boolean 对象

      `JbsUtils.isBoolean('false') // false
            JbsUtils.isBoolean(true) // true` 

isString (val) 判断是否 String 对象

      `JbsUtils.isString(1) // false
            JbsUtils.isString(true) // false
            JbsUtils.isString('') // true
            JbsUtils.isString('abc') // true` 

isNumber (val) 判断是否 Number 对象

      `JbsUtils.isNumber(null) // false
            JbsUtils.isNumber('1') // false
            JbsUtils.isNumber(1) // true` 

isRegExp (val) 判断是否 RegExp 对象

      `JbsUtils.isRegExp(null) // false
            JbsUtils.isRegExp('a') // false
            JbsUtils.isRegExp(new RegExp('a')) // true
            JbsUtils.isRegExp(/\d/) // true` 

isObject (val) 判断是否 Object 对象

      `JbsUtils.isObject(null) // true
            JbsUtils.isObject([]) // true
            JbsUtils.isObject({}) // true
            JbsUtils.isObject(123) // false` 

isPlainObject (val) 判断是否是一个对象

      `JbsUtils.isPlainObject(null) // false
            JbsUtils.isPlainObject([]) // false
            JbsUtils.isPlainObject(123) // false
            JbsUtils.isPlainObject({}) // true` 

isDate (val) 判断是否 Date 对象,如果是无效日期 Invalid Date 也返回 true

      `JbsUtils.isDate('2017-12-20') // false
            JbsUtils.isDate(1514096716800) // false
            JbsUtils.isDate(new Date('abc')) // Invalid Date => true
            JbsUtils.isDate(new Date()) // true` 

isValidDate (val) 和 isDate 的区别是同时判断类型与有效日期,如果为无效日期 Invalid Date 则返回 false

      `JbsUtils.isValidDate('2017-12-20') // false
            JbsUtils.isValidDate(1514096716800) // false
            JbsUtils.isValidDate(new Date('abc')) // Invalid Date => false
            JbsUtils.isValidDate(new Date()) // true` 

isError (val) 判断是否 Error 对象

      `JbsUtils.isError(null) // false
            JbsUtils.isError({}) // false
            JbsUtils.isError(new TypeError('error')) // true
            JbsUtils.isError(new Error('error')) // true` 

isTypeError (val) 判断是否 TypeError 对象

      `JbsUtils.isTypeError(null) // false
            JbsUtils.isTypeError({}) // false
            JbsUtils.isTypeError(new Error('error')) // false
            JbsUtils.isTypeError(new TypeError('error')) // true` 

isEmpty (val) 判断是否为空对象

      `JbsUtils.isEmpty([11, 22]) // false
            JbsUtils.isEmpty({a:null}) // false
            JbsUtils.isEmpty(null) // true
            JbsUtils.isEmpty({}) // true
            JbsUtils.isEmpty([]) // true` 

isNull (val) 判断是否为 Null

      `JbsUtils.isNull(0) // false
            JbsUtils.isNull('') // false
            JbsUtils.isNull(null) // true` 

isSymbol (val) 判断是否 Symbol 对象

      `JbsUtils.isSymbol('a') // false
            JbsUtils.isSymbol(Symbol('a')) // true` 

isArguments (val) 判断是否 Arguments 对象

      `JbsUtils.isArguments([]) // false
            JbsUtils.isArguments(arguments) // true` 

isElement (val) 判断是否 Element 对象

      `JbsUtils.isElement({}) // false
            JbsUtils.isElement(document.createElement('div')) // true` 

isDocument (val) 判断是否 Document 对象

      `JbsUtils.isDocument({}) // false
            JbsUtils.isDocument(document.createElement('div')) // false
            JbsUtils.isDocument(document) // true` 

isWindow (val) 判断是否 Window 对象

      `JbsUtils.isWindow({}) // false
            JbsUtils.isWindow(document) // false
            JbsUtils.isWindow(window) // true` 

isFormData (val) 判断是否 FormData 对象

      `JbsUtils.isFormData({}) // false
            JbsUtils.isFormData(new FormData()) // true` 

isMap (val) 判断是否 Map 对象

      `JbsUtils.isMap({}) // false
            JbsUtils.isMap(new Map()) // true` 

isWeakMap (val) 判断是否 WeakMap 对象

      `JbsUtils.isWeakMap({}) // false
            JbsUtils.isWeakMap(new WeakMap()) // true` 

isSet (val) 判断是否 Set 对象

      `JbsUtils.isSet({}) // false
            JbsUtils.isSet(new Set()) // true` 

isWeakSet (val) 判断是否 WeakSet 对象

      `JbsUtils.isWeakSet({}) // false
            JbsUtils.isWeakSet(new WeakSet()) // true` 

isLeapYear (date) 判断是否闰年

      `JbsUtils.isLeapYear(1606752000000)  // true
            JbsUtils.isLeapYear('2018-12-01') // false
            JbsUtils.isLeapYear('2020-12-01') // true
            JbsUtils.isLeapYear(new Date('2020/12/01')) // true` 

isMatch (obj, source) 判断属性中的键和值是否包含在对象中

      `JbsUtils.isMatch({ aa: 11, bb: 22 }, { bb: 22 })  // true
            JbsUtils.isMatch({ aa: 11, bb: 22 }, { bb: 33 })  // false` 

isEqual (obj1, obj2) 深度比较两个对象之间的值是否相等

      `JbsUtils.isEqual({}, []) // false
            JbsUtils.isEqual({0: 1}, [1]) // false
            JbsUtils.isEqual({name: 'test1'}, {name: 'test1'}) // true
            JbsUtils.isEqual({name: 'test1', list: [11, /\d/]}, {name: 'test1', list: [11,  /\d/]}) // true
            JbsUtils.isEqual({name: 'test1', list: [11, 33, {a: /\D/}]}, {name: 'test1', list: [11, 33, {a: /\d/}]}) // false` 

isEqualWith (obj1, obj2, func) 深度比较两个对象之间的值是否相等,使用自定义比较函数

      `JbsUtils.isEqualWith({0: 1}, [1]) // false
            JbsUtils.isEqualWith({0: 1}, [1], (v1, v2) => true) // true
            JbsUtils.isEqualWith([1], [1]) // true
            JbsUtils.isEqualWith([1], [1], (v1, v2) => false) // false` 

isDateSame (date1, date2, format) 判断两个日期是否相同

      `JbsUtils.isDateSame('2018-12-01', '2018-12-01') // true
            JbsUtils.isDateSame(new Date(), '2018-12-01', 'yyyy') // 判断是否同一年 true
            JbsUtils.isDateSame(new Date(), JbsUtils.toStringDate('12/30/2018', 'MM/dd/yyyy'), 'MM') // 判断是否同一月 true
            JbsUtils.isDateSame(new Date(), new Date(), 'dd') // 判断是否同一日 true
            JbsUtils.isDateSame(new Date(), new Date(), 'yyyyMMdd') // 判断是否同年同月同日 true` 

getType (obj) 获取对象类型

      `JbsUtils.getType() // 'undefined'
            JbsUtils.getType(null) // 'null'
            JbsUtils.getType('') // 'string'
            JbsUtils.getType(/\d/) // 'regexp'
            JbsUtils.getType(1) // 'number'
            JbsUtils.getType([]) // 'array'
            JbsUtils.getType({}) // 'object'
            JbsUtils.getType(new Error()) // 'error'
            JbsUtils.getType(function(){}) // 'function'` 

uniqueId (prefix) 获取一个全局唯一标识

      `JbsUtils.uniqueId() // 1
            JbsUtils.uniqueId() // 2
            JbsUtils.uniqueId('prefix_') // 'prefix_3'` 

getSize (obj) 返回对象的长度

      `JbsUtils.getSize('123') // 3
            JbsUtils.getSize([1, 3]) // 2
            JbsUtils.getSize({a: 2, b: 5}) // 2` 

toStringJSON (str) 字符串转 JSON

      `JbsUtils.toStringJSON('{"a":1}') // {a: 1}
            JbsUtils.toStringJSON('[11,22]') // [11, 22]` 

toJSONString (obj) JSON 转字符串

      `JbsUtils.toJSONString({a: 1}) // '{"a":1}'
            JbsUtils.toJSONString([11, 22]) // '[11,22]'` 

keys (obj) 获取对象所有属性

      `JbsUtils.keys({a: 11}) // ['a']` 

values (obj) 获取对象所有值

      `JbsUtils.values({a: 11}) // [11]` 

entries (obj) 获取对象所有属性、值

      `JbsUtils.entries({a: 11}) // [['a', 11]]
            JbsUtils.entries([11, 22]) // [['0', 11], ['1', 22]]` 

first (obj) 获取对象第一个值

      `JbsUtils.first({a: 11, b : 22}) // 11
            JbsUtils.first([11, 22]) // 11` 

last (obj) 获取对象最后一个值

      `JbsUtils.last({a: 11, b: 22}) // 22
            JbsUtils.last([11, 22]) // 22` 

each (obj, iterate [, context]) 通用迭代器

      `JbsUtils.each([11, 22, 33], (item, key) => {
              // 通用迭代器,支持遍历任意类型
            })` 

lastEach (obj, iterate [, context]) 通用迭代器,从最后开始迭代

      `JbsUtils.lastEach([11, 22, 33], (item, key) => {
              // 通用迭代器,支持遍历任意类型
            })` 

range (start, stop, step) 序号列表生成函数

      `JbsUtils.range(0) // []
            JbsUtils.range(10) // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
            JbsUtils.range(-5, 5) // [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4]
            JbsUtils.range(0, 10, 2) // [0, 2, 4, 6, 8]` 

Object

has (obj, property) 检查键、路径是否是该对象的属性

      `JbsUtils.has({a: {b: 11, c: 22, d: [33, 44]}}, 'a.b') // true
            JbsUtils.has({a: {b: 11, c: 22, d: [33, 44]}}, 'a.e') // false
            JbsUtils.has({a: {b: 11, c: 22, d: [33, 44]}}, 'a.d[0]') // true
            JbsUtils.has({a: {b: 11, c: 22, d: [33, {f: 66}]}}, 'a.d[1].f') // true
            JbsUtils.has({a: {b: 11, c: 22, d: [33, 44]}}, ['a', 'd[1]']) // true
            JbsUtils.has({a: {b: 11, c: 22, d: [33, 44]}}, ['a', 'd[3]']) // false` 

get (obj, property, defaultValue) 获取对象的属性的值,如果值为 undefined,则返回默认值

      `JbsUtils.get({a: {b: 11, c: 22, d: [33, 44]}}, 'a.b') // 11
            JbsUtils.get({a: {b: 11, c: 22, d: [33, 44]}}, 'a.e', 'default') // 'default'
            JbsUtils.get({a: {b: 11, c: 22, d: [33, 44]}}, 'a.d[0]') // 33
            JbsUtils.get({a: {b: 11, c: 22, d: [33, {f: 66}]}}, 'a.d[1].f') // 66
            JbsUtils.get({a: {b: 11, c: 22, d: [33, 44]}}, ['a', 'c']) // 22` 

set (obj, property, value) 设置对象属性上的值。如果属性不存在则创建它

      `JbsUtils.set({}, 'a.d[0]', 33) // {a: {d: [33]}}
            JbsUtils.set({a: {}}, 'a.d[0].f.h', 44) // {a: {d: [{f: {h: 44}}]}}
            JbsUtils.set({}, ['a', 'c'], 22) // {a: {c: 22}}
            JbsUtils.set({}, ['a', 'd[0]', 'f', 'h'], 44) // {a: {d: [{f: {h: 44}}]}}` 

clear (obj[, defs, assigns]) 清空对象; defs如果不传(清空所有属性)、如果传对象(清空并继承)、如果传值(给所有赋值)

      `let a = [11, 22, 33, 33]
            JbsUtils.clear(a) // []
            JbsUtils.clear(a, undefined) // [undefined, undefined, undefined, undefined]
            JbsUtils.clear(a, null) // [null, null, null, null]
            let b = {b1: 11, b2: 22}
            JbsUtils.clear(b) // {}
            JbsUtils.clear(b, undefined) // {b1: undefined, b2: undefined}
            JbsUtils.clear(b, null) // {b1: null, b2: null}` 

assign (target, ...sources) 将一个或多个源对象复制到目标对象中

      `const obj1 = {a: 0, b: {b1: 11}}
            const obj2 = JbsUtils.assign(obj1, {a: 11}, {c: 33})
            // {a: 11, b: {b1: 11}, c: 33}

            const obj3 = {a: 0, b: {b1: 11}}
            const obj4 = JbsUtils.assign(obj1, {a: 11, b: {b2: 22}})
            // {a: 11, b: {b2: 22}}` 

merge (target, ...sources) 将一个或多个源对象合并到目标对象中,和 assign 的区别是会将对象或数组类型递归合并

      `const obj1 = [{a: 11}, {b: 22}]
            const obj2 = JbsUtils.merge(obj1, [{c: 33}, {d: 44}])
            // [{a: 11, c: 33}, {b: 22, d: 44}]

            const obj3 = {a: 0, b: {b1: 11}, c: {c1: {d: 44}}}
            const obj4 = JbsUtils.merge(obj1, {a: 11, b: {b2: 22}, c: {f1: 55}})
            // {a: 11, b: {b1: 11, b2: 22}, c: {c1: {d: 44}, f1: 55}}` 

clone (obj, deep) 浅拷贝/深拷贝,和 assign 的区别是支持对象的递归克隆

      `let v1 = {a: 11, b: {b1: 22}}
            let v2 = JbsUtils.clone(v1)
            if (v1.b === v2.b) {
              // true
            }
            let v3 = JbsUtils.clone(v1, true)
            if (v1.b === v3.b) {
              // false
            }` 

destructuring (obj, ...target) 将一个或者多个对象值解构到目标对象

      `JbsUtils.destructuring({a: null}, {a: 11, b: 22, c: 33}) // {a: 11}
            JbsUtils.destructuring({a: 11, d: 44}, {a: 11, b: 22, c: 33}) // {a: 11, d: 44}
            JbsUtils.destructuring({a: 11, c: 33, d: 44}, {a: 11, b: 22, c: null, e: 55, f: 66}) // {a: 11, c: null, d: 44}` 

objectEach (obj, iterate [, context]) 对象迭代器

      `JbsUtils.objectEach([11, 22, 33], (item, key) => {
              // 对象迭代器,只能用于遍历对象,性能高于 each
            })` 

lastObjectEach (obj, iterate [, context]) 通用迭代器,从最后开始迭代

      `JbsUtils.lastObjectEach([11, 22, 33], (item, key) => {
              // 对象迭代器,只能用于遍历对象,性能高于 lastEach
            })` 

objectMap (obj, iterate [, context]) 指定方法后的返回值组成的新对象

      `JbsUtils.objectMap({a: {type: 'a'}, b: {type: 'b'}}, item => item.type) // {a: "a", b: "b"}` 

pick (obj, array) 根据 keys 过滤指定的属性值 或者 接收一个判断函数,返回一个新的对象

      `JbsUtils.pick({name: 'test11', age: 25, height: 176}, 'name', 'height') // {name: 'test11', height: 176}
            JbsUtils.pick({name: 'test11', age: 25, height: 176}, ['name', 'age']) // {name: 'test11', age: 25}
            JbsUtils.pick({name: 'test11', age: 25, height: 176}, val => JbsUtils.isNumber(val)) // {age: 25, height: 176}` 

omit (obj, array) 根据 keys 排除指定的属性值 或者 接收一个判断函数,返回一个新的对象

      `JbsUtils.omit({name: 'test11', age: 25, height: 176}, 'name', 'height') // {age: 25}
            JbsUtils.omit({name: 'test11', age: 25, height: 176}, ['name', 'age']) // {height: 176}
            JbsUtils.omit({name: 'test11', age: 25, height: 176}, val => JbsUtils.isNumber(val)) // {name: 'test11'}` 

Function

noop () 一个空的方法,始终返回 undefined,可用于初始化值

      `[11, 22, 33].map(JbsUtils.noop)
            // [undefined, undefined, undefined]` 

delay (callback, wait[, ...arguments]) 该方法和 setTimeout 一样的效果,区别就是支持额外参数

      `JbsUtils.delay(function (name) {
              console.log(name)
            }, 300, 'test11')
            // 'test11'` 

bind (callback, context[, ...arguments]) 创建一个绑定上下文的函数

      `let rest = JbsUtils.bind(function (val) {
              return this.name + ' = ' + val
            }, {name: 'test'})
            rest(222) // 'test = 222'
            rest(333) // 'test = 333'` 

once (callback, context[, ...arguments]) 创建一个只能调用一次的函数,只会返回第一次执行后的结果

      `let rest = JbsUtils.once(function (val) {
              return this.name + ' = ' + val
            }, {name: 'test'})
            rest(222) // 'test = 222'
            rest(333) // 'test = 222'` 

after (count, callback, context) 创建一个函数, 调用次数超过 count 次之后执行回调并将所有结果记住后返回

      `function getJSON (url, callback) {
              setTimeout(function() {
                callback({name: 'test1'})
              }, 200)
            }

            // 如果你想确保所有异步请求完成之后才执行这个函数
            let finish = JbsUtils.after(3, function (rests) {
              console.log('All finish')
            })
            getJSON('/api/list1', finish)
            getJSON('/api/list2', finish)
            getJSON('/api/list3', finish)` 

before (count, callback, context) 创建一个函数, 调用次数不超过 count 次之前执行回调并将所有结果记住后返回

      `document.querySelector('.btn').addEventListener('click', JbsUtils.before(4, function (rests) {
              console.log('只能点击三次')
            }))` 

throttle (callback, wait[, options]) 节流函数;当被调用 n 毫秒后才会执行,如果在这时间内又被调用则至少每隔 n 秒毫秒调用一次该函数

      `function scrollEvent (evnt) {
              console.log('至少每隔wait秒毫秒之内只会调用一次')
            }

            // 在计时结束之前执行
            document.body.addEventListener('scroll', JbsUtils.throttle(scrollEvent, 100))
            // 在计时结束之前执行
            document.body.addEventListener('scroll', JbsUtils.throttle(scrollEvent, 100, {
              leading: true,
              trailing: false
            }))
            // 在计时结束之后执行
            document.body.addEventListener('scroll', JbsUtils.throttle(scrollEvent, 100, {
              leading: false,
              trailing: true
            }))

            let func = JbsUtils.throttle(function (msg) {
              console.log(msg)
            }, 300)
            func('执行一次')
            func.cancel()
            func('取消后中断计时,再次调用会马上执行')` 

debounce (callback, wait[, options]) 函数去抖;当被调用 n 毫秒后才会执行,如果在这时间内又被调用则将重新计算执行时间

      `function resizeEvent (evnt) {
              console.log('如果wait毫秒内重复调用则会重新计时,在函数最后一次调用wait毫秒之后才会执行回调')
            }

            // 在计时结束之后执行
            document.addEventListener('resize', JbsUtils.debounce(resizeEvent, 100))
            // 在计时结束之前执行
            document.addEventListener('resize', JbsUtils.debounce(resizeEvent, 100, true))
            // 在计时结束之前执行
            document.addEventListener('resize', JbsUtils.debounce(resizeEvent, 100, {
              leading: true,
              trailing: false
            }))
            // 在计时结束之后执行
            document.addEventListener('resize', JbsUtils.debounce(resizeEvent, 100, {
              leading: false,
              trailing: true
            }))

            let func = JbsUtils.debounce(function (msg) {
              console.log(msg)
            }, 300)
            func('计时结束之前执行一次')
            func.cancel()
            func('取消后中重新计时,在计时结束之前执行')` 

Array

arrayEach (obj, iterate [, context]) 数组迭代器

      `JbsUtils.arrayEach([11, 22, 33], (item, key) => {
              // 数组迭代器,只能用于遍历(数组或伪数组),性能高于 each
            })` 

lastArrayEach (obj, iterate [, context]) 数组迭代器,从最后开始迭代

      `JbsUtils.lastArrayEach([11, 22, 33], (item, key) => {
              // 数组迭代器,只能用于遍历(数组或伪数组),性能高于 lastEach
            })` 

slice (array, start, end) 裁剪(数组或伪数组),从 start 位置开始到 end 结束,但不包括 end 本身的位置

      `JbsUtils.slice([11, 22, 33, 44], 1) // [22, 33, 44]
            JbsUtils.slice([11, 22, 33, 44], 1, 3) // [22, 33]
            function method () {
              JbsUtils.slice(arguments, 1, 3) // [22, 33]
            }
            method(11, 22, 33, 44)` 

indexOf (obj, val) 返回对象第一个索引值

      `JbsUtils.indexOf([11, 22, 33, 22], 55) // -1
            JbsUtils.indexOf([11, 22, 33, 22], 22) // 1` 

arrayIndexOf (obj, val) 返回数组第一个索引值,比 indexOf 快

      `JbsUtils.arrayIndexOf([11, 22, 33, 22], 55) // -1
            JbsUtils.arrayIndexOf([11, 22, 33, 22], 22) // 1` 

findIndexOf (obj, iterate [, context]) 返回对象第一个索引值

      `JbsUtils.findIndexOf([11, 22, 33, 22], item => item === 55) // -1
            JbsUtils.findIndexOf([11, 22, 33, 22], item => item === 22) // 1` 

lastIndexOf (obj, val) 从最后开始的索引值,返回对象第一个索引值

      `JbsUtils.lastIndexOf([11, 22, 33, 22], 55) // -1
            JbsUtils.lastIndexOf([11, 22, 33, 22], 22) // 3` 

arrayLastIndexOf (obj, val) 从最后开始的索引值,返回数组第一个索引值,比 indexOf 快

      `JbsUtils.arrayLastIndexOf([11, 22, 33, 22], 55) // -1
            JbsUtils.arrayLastIndexOf([11, 22, 33, 22], 22) // 3` 

findLastIndexOf (obj, iterate [, context]) 从最后开始的索引值,返回对象第一个索引值

      `JbsUtils.findLastIndexOf([11, 22, 33, 22], item => item === 55) // -1
            JbsUtils.findLastIndexOf([11, 22, 33, 22], item => item === 22) // 3` 

includes (obj, val) 判断对象是否包含该值,成功返回 true 否则 false

      `JbsUtils.includes([11], 22) // false
            JbsUtils.includes([11, 22], 22) // true` 

includeArrays (array1, array2) 判断数组是否包含另一数组

      `JbsUtils.includeArrays([11, 22, 33], []) // true
            JbsUtils.includeArrays([11, 22, 33], [11]) // true
            JbsUtils.includeArrays([11, 22, 33], [22, 33]) // true
            JbsUtils.includeArrays([11, 22, 33], [22, 44]) // false` 

remove (obj, iterate) 移除对象属性

      `let list1 = [11, 22, 33, 44]
            JbsUtils.remove(list1, 2) // list1 = [11, 22, 44]
            let list2 = [11, 22, 33, 44]
            JbsUtils.remove(list2, item => item === 22) // list2 = [11, 33, 44]` 

orderBy | sortBy (arr, fieldConfs [, context]) 将数组进行排序

      `// 数值排序
            JbsUtils.orderBy([11, 55, 99, 77, 11, 55, 22])
            // [11,11,22,55,55,77,99]
            JbsUtils.orderBy([11, 55, 99, 77, 11, 55, 22], { order: 'desc' })
            // [99, 77, 55, 55, 22, 11, 11]

            // 字母排序
            JbsUtils.orderBy(['x', 'z', 'g', 'q', 'e', 'b', 'a', 'g', 'f', 'c', 'j'])
            // ["a","b","c","e","f","g","g","j","q","x","z"]

            // 中文排序
            JbsUtils.orderBy(['小', '何', '李', '林', '有', '好', '啊', '的', '出', '库', '徐'])
            // ["啊","出","的","好","何","库","李","林","小","徐","有"]

            // 深层对象
            JbsUtils.orderBy([{ age: 27 }, { age: 26 }, { age: 28 }], 'age')
            // [{"age":26},{"age":27},{"age":28}]
            JbsUtils.orderBy([{ age: 27 }, { age: 26 }, { age: 28 }], [['age', 'asc']])
            // [{"age":26},{"age":27},{"age":28}]

            // 多字段排序
            JbsUtils.orderBy([
              { name: 'x', age: 26 },
              { name: 'd', age: 27 },
              { name: 'z', age: 26 },
              { name: 'z', age: 24 },
              { name: 'z', age: 25 }
            ], [['age', 'asc'], ['name', 'desc']])
            // [{"name":"z","age":24},{"name":"z","age":25},{"name":"z","age":26},{"name":"x","age":26},{"name":"d","age":27}]

            // 自定义组合排序
            JbsUtils.orderBy([
              { name: 'x', age: 26 },
              { name: 'd', age: 27 },
              { name: 'x', age: 26 },
              { name: 'z', age: 26 }
            ], [[item => item.name, 'asc'], [item => item.age, 'desc']])
            // [{"name":"d","age":27},{"name":"x","age":26},{"name":"x","age":26},{"name":"z","age":26}]` 

shuffle (array) 将一个数组随机打乱,返回一个新的数组

      `JbsUtils.shuffle([11, 22, 33, 44, 55]) // [22, 33, 55, 11, 44]` 

sample (array, number) 从一个数组中随机返回几个元素

      `JbsUtils.sample([11, 22, 33, 44, 55], 3) // [22, 33, 55]` 

some (obj, iterate [, context]) 对象中的值中的每一项运行给定函数,如果函数对任一项返回 true,则返回 true,否则返回 false

      `JbsUtils.some([{value: 11}, {value: 22}], item => item.value === 55) // false` 

every (obj, iterate [, context]) 对象中的值中的每一项运行给定函数,如果该函数对每一项都返回 true,则返回 true,否则返回 false

      `JbsUtils.every([{value: 11}, {value: 22}], item => item.value === 11) // false` 

filter (obj, iterate [, context]) 根据回调过滤数据

      `JbsUtils.filter([{value: 11}, {value: 22}], item => item.value > 11) // [{value: 22}]` 

find (obj, iterate [, context]) 查找匹配第一条数据

      `JbsUtils.find([{value: 11}, {value: 22}], item => item.value === 55) // null` 

findKey (obj, iterate [, context]) 查找匹配第一条数据的键

      `JbsUtils.findKey([{value: 11}, {value: 22}], item => item.value === 22) // '1'
            JbsUtils.findKey({aa: 11, bb: 22, cc: 33}, item => item === 22) // 'bb'` 

map (obj, iterate [, context]) 指定方法后的返回值组成的新数组

      `JbsUtils.map([{value: 11}, {value: 22}], item => item.value) // [11, 22]` 

copyWithin (array, target, start [, end]) 浅复制数组的一部分到同一数组中的另一个位置,数组大小不变

      `JbsUtils.copyWithin([11, 22, 33, 44], 0, 2) // [33, 44, 33, 44]
            JbsUtils.copyWithin([11, 22, 33, 44], 0, -1) // [44, 22, 33, 44]` 

sum (obj, iterate [, context]) 求和函数,将数值相加

      `JbsUtils.sum([22, 66, 88]) // 176
            JbsUtils.sum([{value: 11}, {value: 22}, {value: 66}], 'value') // 99
            JbsUtils.sum({val1: 21, val2: 34, val3: 47}) // 102` 

mean (obj, iterate [, context]) 求平均值函数

      `JbsUtils.mean({ val1: 21, val2: 34, val3: 47 }) // 34
            JbsUtils.mean([22, 66, 60, 60]) // 52
            JbsUtils.mean([{value: 34}, {value: 22}], 'value') // 28
            JbsUtils.mean([{value: 11}, {value: 22}, {value: 66}], item => item.value * 2) // 66
            JbsUtils.mean({val1: 21, val2: 34, val3: 45, val4: 55}) // 38.75` 

toArray (array) 将对象或者伪数组转为新数组

      `JbsUtils.toArray([]) // []
            JbsUtils.toArray({}) // []
            JbsUtils.toArray({name: 'test1', age: 25}) // ['test1', 25]
            JbsUtils.toArray(arguments) // [...]
            JbsUtils.toArray(document.querySelectorAll('div')) // [...]` 

reduce (array, iterate [, initialValue]) 接收一个函数作为累加器,数组中的每个值(从左到右)开始合并,最终为一个值

      `JbsUtils.reduce([22, 66, 88], (previous, item) => previous + item) // 176` 

zip (...[]) 将每个数组中相应位置的值合并在一起

      `JbsUtils.zip(['name1', 'name2', 'name3'], [true, true, false], [30, 40, 20])
            // [['name1', true, 30], ['name2', true, 40], ['name3', false, 20]]` 

unzip (arrays) 与 zip 相反

      `JbsUtils.unzip([['name1', true, 30], ['name2', true, 40], ['name3', false, 20]])
            // [['name1', 'name2', 'name3'], [true, true, false], [30, 40, 20]]` 

zipObject (props, values) 根据键数组、值数组对转换为对象

      `JbsUtils.zipObject(['aa', 'bb', 'cc'], [11, 22, 33])
            // { aa: 11, bb: 22, cc: 33 }` 

uniq (array) 数组去重

      `JbsUtils.uniq([11, 22, 33, 33, 22, 55]) // [11, 22, 33, 55]` 

union (...array) 将多个数的值返回唯一的并集数组

      `JbsUtils.union([11, 22], [33, 22], [44, 11]) // [11, 22, 33, 44]` 

flatten (array, deep) 将一个多维数组拍平

      `JbsUtils.flatten([[1, 2, 3], [4, 5, 6], [7, 8]])
            // [1, 2, 3, 4, 5, 6, 7, 8]` 

chunk (array, size) 将一个数组分割成大小的组。如果数组不能被平均分配,那么最后一块将是剩下的元素

      `JbsUtils.chunk(['a', 'b', 'c', 'd'], 2) // [['a', 'b'], ['c', 'd']]
            JbsUtils.chunk(['a', 'b', 'c', 'd'], 3) // [['a', 'b', 'c'], ['d']]` 

property (path) 返回一个获取对象属性的函数

      `let getName = JbsUtils.property('name')
            getName({name: 'test11', age: 25, height: 176}) // 'test11'
            getName({age: 25, height: 176}) // undefined` 

pluck (array, key) 获取数组对象中某属性值,返回一个数组

      `JbsUtils.pluck([{a: 11, b: 22}, {a: 33, b: 44}], 'a') // [11, 33]
            JbsUtils.pluck([[11, 22, 33], [44, 55, 66]], 1) // [22, 55]` 

invoke (list, path, ...arguments) 在list的每个元素上执行方法,任何传递的额外参数都会在调用方法的时候传递给它

      `JbsUtils.invoke([[3, 1, 6, 7], [3, 2, 1, 8]], 'sort') // [[1, 3, 6, 7], [1, 2, 3, 8]]
            JbsUtils.invoke(['123', '456'], 'split') // [['123'], ['456']]
            JbsUtils.invoke([123, 456], String.prototype.split, '') // [['1', '2', '3'], ['4', '5', '6']]
            JbsUtils.invoke([{a: {b: [2, 0, 1]}}, {a: {b: [2, 1]}}, {a: {b: [4, 8, 1]}}], ['a', 'b', 'sort'])
            // [[0, 1, 2], [1, 2], [1, 4, 8]]` 

groupBy (obj, iterate [, context]) 集合分组,默认使用键值分组,如果有 iterate 则使用结果进行分组

      `JbsUtils.groupBy([{type: 'a'}, {type: 'b'}], 'type') // {a: [{type: 'a'}], b: [{type: 'b'}]}
            JbsUtils.groupBy([{type: 'a'}, {type: 'a'}, {type: 'b'}], 'type')
            // {a: [{type: 'a'}, {type: 'a'}], b: [{type: 'b'}]}` 

countBy (obj, iterate [, context]) 集合分组统计,返回各组中对象的数量统计

      `JbsUtils.countBy([{type: 'a'}, {type: 'b'}], 'type') // {a: 1, b: 1}
            JbsUtils.countBy([{type: 'a'}, {type: 'a'}, {type: 'b'}], 'type') // {a: 2, b: 1}` 

toArrayTree (array, options) 一个高性能的树结构转换函数,将一个带层级的数据列表转成树结构

      `// 默认树结构
            let list1 = [
              {id: 1, name: '111'},
              {id: 2, parentId: 1, name: '222'},
              {id: 3, name: '333'},
              {id: 4, parentId: 2, name: '444'}
            ]
            JbsUtils.toArrayTree(list1)
            /*
            [
              {
                "id":1,
                "name":"111",
                "children":[
                  {
                    "id":2,
                    "parentId":1,
                    "name":"222",
                    "children":[
                      {
                        "id":4,
                        "parentId":2,
                        "name":"444",
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "id":3,
                "name":"333",
                "children":[]
              }
            ]
            */

            // 返回带排序的树结构
            let list2 = [
              {id: 1, name: '111', seq: 5},
              {id: 2, parentId: 1, name: '222', seq: 3},
              {id: 3, name: '333', seq: 6},
              {id: 4, parentId: 2, name: '444', seq: 2},
              {id: 5, parentId: 1, name: '555', seq: 1}
            ]
            JbsUtils.toArrayTree(list2, {sortKey: 'seq'})
            /*
            [
              {
                "id":1,
                "name":"111",
                "seq":5,
                "children":[
                  {
                    "id":5,
                    "parentId":1,
                    "name":"555",
                    "seq":1,
                    "children":[]
                  },
                  {
                    "id":2,
                    "parentId":1,
                    "name":"222",
                    "seq":3,
                    "children":[
                      {
                        "id":4,
                        "parentId":2
                        ,"name":"444",
                        "seq":2,
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "id":3,
                "name":"333",
                "seq":6,
                "children":[]
              }
            ]
            */

            // 自定义数据存放属性
            let list3 = [
              {id: 1, name: '111'},
              {id: 2, parentId: 1, name: '222'},
              {id: 3, name: '333'},
              {id: 4, parentId: 2, name: '444'},
              {id: 5, parentId: 22, name: '555'}
            ]
            JbsUtils.toArrayTree(list3, {data: 'data'})
            /*
            [
              {
                "data":{"id":1,"name":"111"},
                "id":1,
                "children":[
                  {
                    "data":{"id":2,"parentId":1,"name":"222"},
                    "id":2,
                    "parentId":1,
                    "children":[
                      {
                        "data":{"id":4,"parentId":2,"name":"444"},
                        "id":4,
                        "parentId":2,
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "data":{"id":3,"name":"333"},
                "id":3,
                "children":[]
              },
              {
                "data":{"id":5,"parentId":22,"name":"555"},
                "id":5,
                "parentId":22,
                "children":[]
              }
            ]
            */

            // 如果设置为严格模式,(非父子关联及冗余)的数据会被忽略
            let list4 = [
              {id: 1, name: '111'},
              {id: 2, parentId: 1, name: '222'},
              {id: 3, name: '333'},
              {id: 4, parentId: 2, name: '444'},
              {id: 5, parentId: 22, name: '555'}
            ]
            JbsUtils.toArrayTree(list4, {strict: true, parentKey: 'parentId', key: 'id', children: 'children', data: 'data'})
            /*
            [
              {
                "data":{"id":1,"name":"111"},
                "id":1,
                "children":[
                  {
                    "data":{"id":2,"parentId":1,"name":"222"},
                    "id":2,
                    "parentId":1,
                    "children":[
                      {
                        "data":{"id":4,"parentId":2,"name":"444"},
                        "id":4,
                        "parentId":2,
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "data":{"id":3,"name":"333"},
                "id":3,
                "children":[]
              }
            ]
            */` 

toTreeArray (array, options) 将一个树结构转成数组列表

      `let list1 = [
              {
                "id":1,
                "name":"111",
                "children":[
                  {
                    "id":2,
                    "parentId":1,
                    "name":"222",
                    "children":[
                      {
                        "id":4,
                        "parentId":2,
                        "name":"444",
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "id":3,
                "name":"333",
                "children":[]
              }
            ]
            JbsUtils.toTreeArray(list1)
            /*
            [
              {id: 1, name: '111'},
              {id: 2, parentId: 1, name: '222'},
              {id: 4, parentId: 2, name: '444'}
              {id: 3, name: '333'}
            ]
            */

            let list2 = [
              {
                "data":{"id":1,"name":"111"},
                "id":1,
                "children":[
                  {
                    "data":{"id":2,"parentId":1,"name":"222"},
                    "id":2,
                    "parentId":1,
                    "children":[
                      {
                        "data":{"id":4,"parentId":2,"name":"444"},
                        "id":4,
                        "parentId":2,
                        "children":[]
                      }
                    ]
                  }
                ]
              },
              {
                "data":{"id":3,"name":"333"},
                "id":3,
                "children":[]
              },
              {
                "data":{"id":5,"parentId":22,"name":"555"},
                "id":5,
                "parentId":22,
                "children":[]
              }
            ]
            JbsUtils.toTreeArray(list2, {data: 'data'})
            /*
            [
              {id: 1, name: '111'},
              {id: 2, parentId: 1, name: '222'},
              {id: 4, parentId: 2, name: '444'},
              {id: 3, name: '333'},
              {id: 5, parentId: 22, name: '555'}
            ]
            */` 

findTree (obj, iterate[, options, context]) 从树结构中查找匹配第一条数据的键、值、路径

      `var tree1 = [
              { id: 1 },
              {
                id: 2,
                children: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                children: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.findTree(tree1, item => item.id === 20) // { item: {id: 20}, ... }

            var tree2 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                childs: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.findTree(tree2, item => item.id === 20, { children: 'childs' }) // { item: {id: 20}, ... }` 

eachTree (obj, iterate[, options, context]) 从树结构中遍历数据的键、值、路径

      `var tree1 = [
              { id: 1 },
              {
                id: 2,
                children: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                children: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.eachTree(tree1, item => {
              // ...
            })

            var tree2 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                childs: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.eachTree(tree2, item => {
              // ...
            }, { children: 'childs' })` 

mapTree (obj, iterate[, options, context]) 从树结构中指定方法后的返回值组成的新数组

      `var tree1 = [
              { id: 1 },
              {
                id: 2,
                children: [
                  { id: 20 }
                ]
              }, {
                id: 3,
                children: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.mapTree(tree1, item => {
              return {
                id: item.id * 2
              }
            })
            // [
            //   { id: 2 },
            //   {
            //     id: 4,
            //     children: [
            //       { id: 40 }
            //     ]
            //   }, {
            //     id: 6,
            //     children: [
            //       { id: 60 }
            //     ]
            //   }
            // ]

            var tree2 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                childs: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.mapTree(tree2, item => {
              return {
                id: item.id * 2
              }
            }, {children: 'childs'})
            // [
            //   { id: 2 },
            //   {
            //     id: 4,
            //     childs: [
            //       { id: 40 }
            //     ]
            //   },
            //   {
            //     id: 6,
            //     childs: [
            //       { id: 60 }
            //     ]
            //   }
            // ]

            var tree3 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                childs: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.mapTree(tree3, item => {
              return {
                id: item.id * 2
              }
            }, { children: 'childs', mapChildren: 'list' })
            // [
            //   { id: 2 },
            //   {
            //     id: 4,
            //     list: [
            //       { id: 40 }
            //     ]
            //   },
            //   {
            //     id: 6,
            //     list: [
            //       { id: 60 }
            //     ]
            //   }
            // ]` 

filterTree (obj, iterate[, options, context]) 从树结构中根据回调过滤数据

      `var tree1 = [
              { id: 1 },
              {
                id: 2,
                children: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                children: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.filterTree(tree1, item => item.id === 1)
            // { id: 1 }

            var tree2 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 20 }
                ]
              },
              {
                id: 3,
                childs: [
                  { id: 30 }
                ]
              }
            ]
            JbsUtils.filterTree(tree2, item => item.id >= 3, {children: 'childs'})
            // [
            //   {
            //     id: 3,
            //     childs: [
            //       { id: 30 }
            //     ]
            //   }
            // ]` 

searchTree (obj, iterate[, options, context]) 从树结构中根据回调查找数据

      `var tree1 = [
              { id: 1 },
              {
                id: 2,
                children: [
                  { id: 0 }
                ]
              },
              {
                id: 3,
                children: [
                  {
                    id: 30,
                    children: [
                      { id: 3001 }
                    ]
                  },
                  { id: 31 }
                ]
              }
            ]
            JbsUtils.searchTree(tree1, item => item.id === 3)
            // [
            //   {
            //     id: 3,
            //     children: [
            //       {
            //         id: 30,
            //         children: [
            //           { id: 3001 }
            //         ]
            //       },
            //       { id: 31 }
            //     ]
            //   }
            // ]

            var tree2 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 0 }
                ]
              },
              {
                id: 3,
                childs: [
                  {
                    id: 30,
                    childs: [
                      { id: 3001 }
                    ]
                  },
                  { id: 31 }
                ]
              }
            ]
            JbsUtils.searchTree(tree2, item => item.id === 30, { children: 'childs' })
            // [
            //   {
            //     id: 3,
            //     childs: [
            //       {
            //         id: 30,
            //         childs: [
            //           { id: 3001 }
            //         ]
            //       }
            //     ]
            //   }
            // ]

            var tree3 = [
              { id: 1 },
              {
                id: 2,
                childs: [
                  { id: 0 }
                ]
              },
              {
                id: 3,
                childs: [
                  {
                    id: 30,
                    childs: [
                      { id: 3001 }
                    ]
                  },
                  { id: 31 }
                ]
              }
            ]
            JbsUtils.searchTree(tree3, item => item.id === 30, { children: 'childs', mapChildren: 'list' })
            // [
            //   {
            //     id: 3,
            //     childs: [
            //       {
            //         id: 30,
            //         childs: [
            //           { id: 3001 }
            //         ]
            //       },
            //       { id: 31 }
            //     ]
            //     list: [
            //       {
            //         id: 30,
            //         list: [
            //           { id: 3001 }
            //         ]
            //       }
            //     ]
            //   }
            // ]` 

Date

now () 返回当前时间戳

      `JbsUtils.now() // Date.now() 获取当前时间戳 1514096716800` 

timestamp (date[, format]) 将日期转为时间戳

      `JbsUtils.timestamp() // JbsUtils.now() = Date.now() 获取当前时间戳 1514096716800
            JbsUtils.timestamp(new Date()) // 1514096716800
            JbsUtils.timestamp('2018-12-01') // 1543593600000
            JbsUtils.timestamp('2017/12/20 10:10:30.459', 'yyyy/MM/dd HH:mm:ss.SSS') // 1513735830459` 

toStringDate (str, format) 任意格式字符串转为日期

      `JbsUtils.toStringDate('12/20/2017')
            // 如果解析错误则返回 new Date('Invalid Date')
            JbsUtils.toStringDate('2017-12-20')
            // new Date(2017, 11, 20)
            JbsUtils.toStringDate('2017-12-20 10:10:30')
            // new Date(2017, 11, 20, 10, 10, 30)
            JbsUtils.toStringDate('2017-12-20 10:10:30.568')
            // new Date(2017, 11, 20, 10, 10, 30, 568)
            JbsUtils.toStringDate('2017-12-20 10:10:30.2514766')
            // new Date(2017, 11, 20, 10, 10, 30, 251)
            JbsUtils.toStringDate('2017-12-20T10:10:30.738+0800')
            // Wed Dec 20 2017 10:10:30 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('2017-12-20T10:10:30.738+01:00')
            // Wed Dec 20 2017 17:10:30 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('2017-12-20T10:10:30.738Z')
            // Wed Dec 20 2017 18:10:30 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('12/20/2017', 'MM/dd/yyyy')
            // Wed Dec 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('20171220101030', 'yyyyMMddHHmmss')
            // Wed Dec 20 2017 10:10:30 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('2017/12/20 10:10:30', 'yyyy/MM/dd HH:mm:ss')
            // Wed Dec 20 2017 10:10:00 GMT+0800 (中国标准时间)
            JbsUtils.toStringDate('12/20/2017 10:10:30.100', 'MM/dd/yyyy HH:mm:ss.SSS')
            // Wed Dec 20 2017 10:10:30 GMT+0800 (中国标准时间)` 

toDateString (date [, format, options]) 日期格式化为任意格式字符串(需要注意如果使用了年的第几周等特殊格式,可能会导致跨年偏移,应该避免和年份同时使用)

      `JbsUtils.toDateString(1483250730000)
            // '2017-01-01 14:05:30'
            JbsUtils.toDateString(new Date())
            // '2017-01-01 14:05:30'
            JbsUtils.toDateString('2017-01-01 10:05:30', 'MM/dd/yyyy')
            // '01/01/2017'
            JbsUtils.toDateString('2017-01-01 10:05:30', 'M/d/yyyy')
            // '1/1/2017'
            JbsUtils.toDateString(new Date(), 'yyyyMMddHHmmssSSS')
            // '20170101140530099'
            JbsUtils.toDateString(new Date(), 'yyyy-MM-dd HH:mm:ss.SSS')
            // '2017-01-01 14:05:30.099'
            JbsUtils.toDateString(new Date(), 'yyyy-MM-dd hh:mm:ss.SSS GMTZ')
            // '2017-01-01 02:05:30.099 GMT+08:00'
            JbsUtils.toDateString(new Date(), 'yyyy-MM-dd hh:mm:ss.SSS GMTZZ')
            // '2017-01-01 02:05:30.099 GMT+0800'
            JbsUtils.toDateString(new Date(), 'yyyy-M-d h:m:s.S')
            // '2017-1-1 2:5:30.99'
            JbsUtils.toDateString(new Date(), 'yyyy年MM月dd日 HH时mm分ss秒S毫秒,星期E 第q季度')
            // '2017年01月01日 14时05分30秒99毫秒,星期0 第1季度'
            JbsUtils.toDateString(new Date(), 'yy年M月d日 HH时m分s秒S毫秒,星期E 第q季度')
            // '17年1月1日 14时5分30秒99毫秒,星期0 第1季度'
            JbsUtils.toDateString(new Date(), 'yyyy年MM月dd日 hh时mm分ss秒SSS毫秒 ZZ 星期E e 第q季 今年第D天 a A')
            // '2017年01月01日 02时05分30秒099毫秒 +0800 星期0 -1 第1季 今年第1天 pm PM'
            JbsUtils.toDateString(new Date(), '[yyyy-MM] yyyy-MM-dd')
            // 'yyyy-MM 2017-01-01'` 

getWhatYear (date, offsetYear [, offsetMonth]) 返回前几年或后几年的日期,可以指定年的最初时间(first)、年的最后时间(last)、年的月份(0~11),默认当前

      `JbsUtils.getWhatYear(new Date(), -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatYear(1513735830000, -1) // Tue Dec 20 2016 10:10:30 GMT+0800 (中国标准时间)
            JbsUtils.getWhatYear('2017-12-20', -1) // Tue Dec 20 2016 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatYear('2017-12-20', 1) // Thu Dec 20 2018 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatYear('2017-12-20', 0, 'first') // Sun Jan 01 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatYear('2017-12-20', 0, 'last') // Sun Dec 31 2017 23:59:59 GMT+0800 (中国标准时间)` 

getWhatMonth (date, offsetMonth [, offsetDay]) 返回前几月或后几月的日期,可以指定月初(first)、月末(last)、天数,默认当前

      `JbsUtils.getWhatMonth(new Date(), -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatMonth(1513735830000, -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatMonth('2017-12-20', -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatMonth('2017-12-20', 1) // Sat Jan 20 2018 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatMonth('2017-12-20', -1, 'first') // Wed Nov 01 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatMonth('2017-12-20', 1, 'last') // Wed Jan 31 2018 23:59:59 GMT+0800 (中国标准时间)` 

getWhatWeek (date, offsetWeek [, offsetDay, startDay]) 返回前几周或后几周的日期,可以指定星期几(0~6)与周视图的起始天(0~6,默认1),默认当前

      `JbsUtils.getWhatWeek(new Date(), -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek(1513735830000, -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek('2017-12-20', -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek('2017-12-20', 1) // Sun Dec 31 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek('2017-12-20', -1, 5, 1) // Fri Dec 15 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek('2017-12-20', 0, 0, 0) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatWeek('2017-12-20', 1, 0, 0) // Sun Dec 24 2017 00:00:00 GMT+0800 (中国标准时间)` 

getWhatDay (date, offsetDay [, offsetMode]) 返回前几天或后几天的日期,可以指定当天最初时间(first)、当天的最后时间(last)

      `JbsUtils.getWhatDay(new Date(), -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatDay(1513735830000, -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatDay('2017-12-20', -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatDay('2017-12-20', 1) // Tue Dec 21 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatDay('2017-12-20', 0, 'first') // Wed Dec 20 2017 00:00:00 GMT+0800 (中国标准时间)
            JbsUtils.getWhatDay('2017-12-20', 0, 'last') // Wed Dec 20 2017 23:59:59 GMT+0800 (中国标准时间)` 

getDayOfYear (date [, offsetYear]) 返回某个年份的天数,可以指定前几个年或后几个年,默认当前

      `JbsUtils.getDayOfYear(new Date()) // 365
            JbsUtils.getDayOfYear(1513735830000) // 365
            JbsUtils.getDayOfYear('2017-12-20') // 365
            JbsUtils.getDayOfYear('2019-12-20', 1) // 366
            JbsUtils.getDayOfYear('2020-12-20') // 366` 

getYearDay (date) 返回某个年份的第几天

      `JbsUtils.getYearDay(new Date()) // 149
            JbsUtils.getYearDay('2017-01-20') // 20
            JbsUtils.getYearDay('2018-05-20') // 140` 

getYearWeek (date) 返回某个年份的第几周

      `JbsUtils.getYearWeek(new Date()) // 22
            JbsUtils.getYearWeek('2017-01-20') // 3
            JbsUtils.getYearWeek('2018-05-20') // 20` 

getMonthWeek (date) 返回某个月份的第几周

      `JbsUtils.getMonthWeek(new Date()) // 4
            JbsUtils.getMonthWeek('2017-01-20') // 3
            JbsUtils.getMonthWeek('2018-05-20') // 2` 

getDayOfMonth (date [, month]) 返回某个月份的天数,可以指定前几个月或后几个月,默认当前

      `JbsUtils.getDayOfMonth(new Date()) // 31
            JbsUtils.getDayOfMonth(1513735830000) // 31
            JbsUtils.getDayOfMonth('2017-12-20') // 31
            JbsUtils.getDayOfMonth('2017-12-20', -1) // 30
            JbsUtils.getDayOfMonth('2017-12-20', 1) // 31` 

getDateDiff (startDate, endDate [, rules]) 返回两个日期之间差距,如果结束日期小于开始日期 done 为 fasle

      ``JbsUtils.getDateDiff('2017-11-20', '2017-12-21')
            // { done: true, time: 2678400000, yyyy: 0, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, S: 0 }
            JbsUtils.getDateDiff('2017-12-20', '2017-12-21')
            // { done: true, time: 86400000, yyyy: 0, MM: 0, dd: 1, HH: 0, mm: 0, ss: 0, S: 0 }
            JbsUtils.getDateDiff('2018-01-01', '2017-