1.2.3 • Published 4 years ago

front-uitls v1.2.3

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

front-uitls

Install

npm:

$ npm install front-uitls

front-uitls 是一个简单的前端工具库, 提供各种前端常用而且便捷的方法 可以快速使用 主旨在提供一套逻辑判断的全面js方法库

Use

import {isIE, inBrowser, isIE, isIE9, isEdge, isAndroid, isIOS, ...} from 'front-uitls'

API

isPlainObject({})
//=> true
toString({a: 3}) 
//=> '{a: 3}' 
toString([3]) 
//=> '[3]' 
toString(3) 
//=> '3'
toArray('ass3434', 2)
//=> ['s', '3', '4', '3', '4']
extend(to, _from) // to 目标对象 _from 源对象 

extend({a: 2, b: 3}, {b: 4, c: 5})
//=> {a: 2, b: 4, c: 5}
toObject([{a:2, b: 3}, {c: 4}, {b: 5, e: 6}])
//=> {a:2, b: 5, c:4, e: 6}
identity(3)
//=> 3 
identity({}) 
//=> {} 
identity([3]) 
//=> [3]
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}
randomn(5)
//=> 13560
randomn(21)
//=> 124406475752653050000
formatThousand(5435345.45)
//=> "5,435,345.45"
formatThousand(564565465.56456456)
//=> "564,565,465.5645646"

// 同样的,你也可以在vue框架中使用, 如下实例demo.

<template>
    <div>{{ number1 | formatThousand }}</div>
</template>

import { formatThousand } from 'front-uitls'
export default {
  data () {
    return {
      number1: 234234.3434
    }
  },
  filters: {
    formatThousand
  }
}

<style lang="less">
</style>
formatDate(date, fmt) // date 时间戳(单位毫秒) fmt 日期格式 (默认值 'yyyy-MM-dd hh:mm')
formatDate(1355247273000)
//=> "2012-12-12 01:34"
formatDate(1355247273000, 'yyyy/MM/dd hh:mm')
//=> "2012/12/12 01:34"

// 同样的,你也可以在vue框架中使用, 如下实例demo.

<template>
    <div>{{ date1 | formatDate('yyyy/MM/dd') }}</div>
</template>

import { formatDate } from 'front-uitls'
export default {
  data () {
    return {
      date1: 1355247273000
    }
  },
  filters: {
    formatDate
  }
}

<style lang="less">
</style>
// 数值类型描述 => "number" "string" "array" "object" "null" "undefined"
getType(3)
//=> "number"
getType('adf')
//=> "string"
getType([{a: 3}, 3])
//=> "array"
getType({d: 4})
//=> "object"
getType(null)
//=> "null"
getType(undefined)
//=> "undefined"
clone(3)
//=> 3
clone('test')
//=> "test"
clone({a: 3, b: 34})
//=> {a: 3, b: 34}
clone([343, 434])
//=> [343, 434]
1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago