Package Exports
- front-uitls
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 (front-uitls) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
front-tool
Install
[npm][]:
npm install front-toolUse
import {isIE, inBrowser, isIE, isIE9, isEdge, isAndroid, isIOS, ...} from 'front-tool'
API
hasProto [type Boolan] // 判断是否存在隐形原型'__proto__'
inBrowser [type Boolean] // 判断是否是存在window对象
isIE = UA [type Boolean] // 判断是否是IE浏览器
isIE9 [type Boolean]
isEdge [type Boolean]
isAndroid [type Boolean]
isIOS [type Boolean]
isChrome [type Boolean]
isFF [type Boolean] // 是否是火狐浏览器
isUndef [type Function(return Boolean)] //判断是否是未定义
isDef [type Function(return Boolean)] //判断是否是已定义
isTrue [type Function(return Boolean)]
isFalse [type Function(return Boolean)]
isObject [type Function(return Boolean)] // 判断是否为对象 如 Array Object Number String等js内部对象
isPlainObject [type Function(return Boolean)] // 判断是否是{}对象 如 isPlainObject({}) -> true
isRegExp [type Function(return Boolean)] // 判断是否是正则对象
isPromise [type Function(return Boolean)] // 判断是否是Promise对象
toString [type Function(return String)] // 转为字符串 如 toString({a: 3}) -> '{a: 3}' toString([3]) -> '[3]' toString(3) -> '3'
toNumber [type Function(return Number)] // 转为数字
export const toArray = (list, start) => {
start = start || 0
let i = list.length - start
let ret = new Array(i)
while (i--) {
ret[i] = list[i + start]
}
return ret
}
extend [type Function(return Object)] // 合并属性到目标对象
extend(to, _from) // to 目标对象 _from 源对象
extend({a: 2, b: 3}, {b: 4, c: 5}) -> {a: 2, b: 4, c: 5}
toObject [type Function(return Object)] // 数组对象转为简单对象
toObject([{a:2, b: 3}, {c: 4}, {b: 5, e: 6}]) -> {a:2, b: 5, c:4, e: 6}
identity [type Function] // 返回同样值 identity(3) -> 3 identity({}) -> {} identity([3]) -> [3]
no [type Function(return false)] // 返回false值
merge [type Function(return Object)] // 合并对象到目标对象 默认第一个参数为目标对象并返回对象
merge(obj2, obj3, obj4, ...)
merge({a: 2, b: 4}, {a: 3, c: 5}, {d: 5, e: 6}) -> {a: 3, b: 4, c: 5, d: 5, e: 6}