z-utils
javascript uitls
Last updated 2 years ago by zbm2001 .
Apache 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install z-utils 
SYNC missed versions from official npm registry.

utils

安装

npm i z-utils

组件接口

arraySlice(startIndex, endIndex)

即 Array.prototytpe.slice

示例

utils.arraySlice.call({length:1, 0:1}, 0, 1) => [1]

assign(target/, ...args/)

同 es5 的 Object.assign

示例

utils.assign({a:1}, {b:2}) => {a:1,b:2}

arrayForEach(func, scope)

即 Array.prototytpe.forEach

示例

utils.arrayForEach.call({length:1, 0:1}, (v) => {}, null)

create(obj, props)

同 es5 的 Object.create

示例

utils.create(Array.prototype) => []

global

js 全局宿主对象

示例

utils.global => window or global

hasOwnProperty(key)

即 Object.prototype.hasOwnProperty

示例

utils.hasOwnProperty.call({a:1}, 'a') => true

isArray(arr)

同 es5 的 Array.isArray

示例

utils.isArray([]) => true

isEmptyObject(obj)

判断对象是否有可枚举属性

示例

utils.isEmptyObject({}) => true

isNativeFunction(func)

判断参数是否为JS的原生方法

示例

utils.isNativeFunction([].push) => true

isPlainObject(obj)

判断对象是否由对象字面量或 new Object() 直接创建的

示例

utils.isPlainObject({a:1}) => true

keys(object)

获取一个对象的可枚举属性的数组

示例

utils.keys({a: 1, b: 2}) => ['a', 'b']

merge(target, ...overriders)

将属性树深度合并到目标对象

示例

utils.merge({a:{b:{c:1}}}, {a:{b:{d:2}}}) => {a:{b:{c:1,d:2}}}

namespace(root, sNamespace, variable)

为对象或任何类型的变量创建命名空间

示例

utils.namespace(window, 'a.b.c', 1) => windw.a.b.c === 1

referenceTypes

typeof 出的引用类型集

示例

utils.referenceTypes => {'function': !0, 'object': !0}

returnFalse()

始终返回 false 的函数

示例

utils.returnFalse => returnFalse

returnTrue()

始终返回 true 的函数

示例

utils.returnTrue => returnTrue

toString()

即 Object.prototype.toString

示例

utils.toString.call([]) => '[object Array]'

toArray(obj, startIndex, endIndex)

转换一个类数组对象为数组

示例

utils.toArray({length:1, 0:1}, 0, 1) => [1]

typeOf(obj)

返回参数的类型名称

示例

utils.typeOf(/a/) => 'RegExp'

uuid()

生成一个全局唯一标识符

示例

utils.uuid() => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

组件构建

从配置文件构建(rollup.config.js)

npm run build // rollup -c

或者:

自定义构建

npm run dev // node rollup

文档生成

npm install -global esdoc echo '{"source": "./src", "destination": "./doc"}' > .esdoc.json esdoc

文档

doc/index.html

或者:

dox

https://github.com/tj/dox

Current Tags

  • 1.6.4                                ...           latest (2 years ago)

32 Versions

  • 1.6.4                                ...           2 years ago
  • 1.6.3                                ...           2 years ago
  • 1.6.2                                ...           2 years ago
  • 1.6.1                                ...           2 years ago
  • 1.6.0                                ...           2 years ago
  • 1.5.1                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.8                                ...           3 years ago
  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 32
This Month 32
Last Day 0
Last Week 0
Last Month 36
Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |