Global

Members

_defaultBrowsers

default support browsers

_muiltBrowsers

default muilt support browsers such as equal some version

(constant) alphaHexMap

设置style-config

amosCookie

api: parse serialize

(constant) colorKeyWordsHexStr

color keywords 对照表,值为 hex 16进制 string

(constant) DesUtils

Author:
  • ilex.h
See:
  • DESCore

DES加密 / 解密

encodeLen

url特殊字符转码

fieldContentRegExp

RegExp to match field-content in RFC 7230 sec 3.2

field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text obs-text = %x80-FF

hasOwnProperty

Used to check objects for own properties.

isArray

Is a given value an array? Delegates to ECMA5's native Array.isArray

isGIF

判断图片是 gif

Example
isGIF('a.gif'); // true
 isGIF('data:image/;base64,'); // true

isImageSrc

判断是一个 image 的路径 (包含 svg) /a/a/a.png|jpe?g|gif... http://a.b/a.png|jpe?g|gif... data:image/png|jpe?g|gif;base64,

Example
isImageSrc('/a/a/a.png'); // true
 isImageSrc('http://a.b/a.png'); // true
 isImageSrc('data:image/png|jpe?g|gif|svg;base64,'); // true

Log

Log.debug(...);

(constant) MAX_LENGTH :number

Default Value:
  • 9007199254740991

Maximum length of a typed array.

2^{53} - 1
Type:
  • number

(constant) PNGlib

Identicon.js 2.3.3 http://github.com/stewartlord/identicon.js

PNGLib required for PNG output http://www.xarg.org/download/pnglib.js

Copyright 2018, Stewart Lord Released under the BSD license http://www.opensource.org/licenses/bsd-license.php

(constant) utils

covert canvas to image and save the image file

Methods

_boost(a, b, operate, factor)

将需要计算的值进行放大处理

Parameters:
Name Type Description
a number

参与计算的值

b number

参与计算的值

operate number

操作运算,即放大之后进行其它计算

factor number

缩小的倍数

advancePolicy(password, secretKey) → {object}

普通密码生成策略

Parameters:
Name Type Description
password string

密码

secretKey string

秘钥

Returns:

{ password, secretKey }

Type
object

array2tree(data, filterFn, options)

将数据转化为tree使用的

Parameters:
Name Type Description
data any

待转化数据

filterFn any

执行过滤的函数

options any

配置信息,需要转化的对象key

Returns:

Array

arrayFilter(data, filterFn, options)

将数据转化为tree使用的

Parameters:
Name Type Description
data any

待转化数据

filterFn any

执行过滤的函数

options any

配置信息,需要设置过滤匹配的对象key,value, childrenKey

Returns:

Array

beautifyRoutes(routes, options)

美化 routes, 去掉 childrenKey 为空时该字段项

Parameters:
Name Type Description
routes *
options *

browserSupport(supBrowser, matchs)

check browser support

Example
normal:
     const support = browserSupport(['firefox/', 'chrome/'], {
          'firefox/': { limit: consts.GREATER_EQUAL, version: 50 },
          'chrome/': { limit: consts.GREATER_EQUAL, version: 55 }
        });
    ie:
    const support = browserSupport(['firefox/', 'chrome/', 'ie'], {
          'firefox/': { limit: consts.GREATER_EQUAL, version: 50 },
          'chrome/': { limit: consts.GREATER_EQUAL, version: 55 },
          'ie': { limit: consts.GREATER_EQUAL, version: 9 }
        });
Parameters:
Name Type Description
supBrowser Array

browsers

matchs object

the options of matchs

bt4ToHex(binary)

change the bit(it's length = 4) into the hex. return hex

Parameters:
Name Type Description
binary string

byteToString(byteData)

changw the bit(it's length = 64) into the string, return string

Parameters:
Name Type Description
byteData array

calcBrowserVersion(ua, mbs, limit, version)

calc version

Parameters:
Name Type Description
ua String
mbs String
limit Number
version Number

checkFileName(str, maxLen)

校验给定的 string 是否是 文件名

Parameters:
Name Type Default Description
str *
maxLen * 259
Returns:

checkFlash() → {Object}

检测浏览器是否安装了flash; 返回json,f:是否安装;v:若安装,则返回版本号

Returns:
Type
Object

clone(source) → {*}

Those data types can be cloned: Plain object, Array, TypedArray, number, string, null, undefined. Those data types will be assgined using the orginal data: BUILTIN_OBJECT Instance of user defined class will be cloned to a plain object, without properties in prototype. Other data types is not supported (not sure what will happen).

Caution: do not support clone Date, for performance consideration. (There might be a large number of date in series.data). So date should not be modified in and out of echarts.

Parameters:
Name Type Description
source *
Returns:

new

Type
*

clone(value) → {*}

Since:
  • 0.1.0
See:
  • dc.cloneDeep

Creates a shallow clone of value.

Note: This method is loosely based on the and supports cloning arrays, array buffers, booleans, date objects, maps, numbers, Object objects, regexes, sets, strings, symbols, and typed arrays. The own enumerable properties of arguments objects are cloned as plain objects. An empty object is returned for uncloneable values such as error objects, functions, DOM nodes, and WeakMaps.

Example
var objects = [{ 'a': 1 }, { 'b': 2 }];

var shallow = dc.clone(objects);
console.log(shallow[0] === objects[0]);
// => true
Parameters:
Name Type Description
value *

The value to clone.

Returns:

Returns the cloned value.

Type
*

completeUnit(val, tag) → {String}

补全单位

Parameters:
Name Type Description
val String | Number

待转换数字

tag String

单位 tag

Returns:
Type
String

contains(val, searchValue, positionopt) → {boolean}

Tests if an array-like value contains a search value.

Examples
var bool = contains( 'last man standing', 'stand' );
// returns true
var bool = contains( [ 1, 2, 3, 4 ], 2 );
// returns true
var bool = contains( 'presidential election', 'president' );
// returns true
var bool = contains( [ NaN, 2, 3, 4 ], NaN );
// returns true
var bool = contains( 'javaScript', 'js' );
// returns false
var bool = contains( [ 1, 2, 3, {} ], {} );
// returns false
var bool = contains( 'Hidden Treasures', '' );
// returns true
Parameters:
Name Type Attributes Default Description
val Collection | string

input value

searchValue *

search value

position integer <optional>
0

position at which to start searching for searchValue

Throws:
  • first argument must be array-like

    Type
    TypeError
  • must provide a search value

    Type
    Error
  • second argument must be a string when the first argument is a string

    Type
    TypeError
  • third argument must be an integer

    Type
    TypeError
Returns:

boolean indicating whether one value contains another

Type
boolean

customEqual(objA, objB, compare, compareContext)

See:

浅层次比较两个对象

Parameters:
Name Type Description
objA object
objB object
compare function

可选

compareContext any

debounce(delay, atBeginopt, callback) → {function}

Debounce execution of a function. Debouncing, unlike throttling, guarantees that a function is only executed a single time, either at the very beginning of a series of calls, or at the very end.

Parameters:
Name Type Attributes Description
delay Number

A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.

atBegin Boolean <optional>

Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed delay milliseconds after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call. (After the throttled-function has not been called for delay milliseconds, the internal counter is reset).

callback function

A function to be executed after delay milliseconds. The this context and all arguments are passed through, as-is, to callback when the debounced-function is executed.

Returns:

A new, debounced function.

Type
function

deepCopy(source)

deep deepCopy

Parameters:
Name Type Description
source any

deepEqual(valA, valB)

深度比较

Parameters:
Name Type Description
valA any
valB any

divide(a, b) → {Number}

Parameters:
Name Type Description
a Number
b Number
Returns:
Type
Number

drawPolygon(ctx, options)

绘制多边形

Parameters:
Name Type Description
ctx Context
options options

{ x: 中心点x坐标 y: 中心点y坐标 num: 图形边的个数 r: 图形的半径 width: 线宽 strokeStyle: 线颜色 fillStyle: 填充色 }

enc(dataByte, keyByte)

the 64 bit des core arithmetic

Parameters:
Name Type Description
dataByte array
keyByte array

encodeNumber(number, start, len, sign)

将数字部分内容转化为 *

Parameters:
Name Type Default Description
number Number

目标 Number

start Number 3

起始位置

len Number 4

转换位数

sign String *

替换的字符

eq(value, other) → {boolean}

Performs a comparison between two values to determine if they are equivalent.

Example
var object = { 'a': 1 };
var other = { 'a': 1 };

dc.eq(object, object);
// => true

dc.eq(object, other);
// => false

dc.eq('a', 'a');
// => true

dc.eq('a', Object('a'));
// => false

dc.eq(NaN, NaN);
// => true
Parameters:
Name Type Description
value *

The value to compare.

other *

The other value to compare.

Returns:

Returns true if the values are equivalent, else false.

Type
boolean

eq(value, other) → {boolean}

Since:
  • 4.0.0

Performs a comparison between two values to determine if they are equivalent.

Example
var object = { 'a': 1 };
var other = { 'a': 1 };

dc.eq(object, object);
// => true

dc.eq(object, other);
// => false

dc.eq('a', 'a');
// => true

dc.eq('a', Object('a'));
// => false

dc.eq(NaN, NaN);
// => true
Parameters:
Name Type Description
value *

The value to compare.

other *

The other value to compare.

Returns:

Returns true if the values are equivalent, else false.

Type
boolean

fileSizeToByte(size) → {Nubner}

将指定 size 中的数据,转化为 byte

  • 默认不区分大小写, mb/MB/Mb 均表示 mb
  • 默认去除内部所有空格, 1024 MB -> 1024mb
  • 无单位或者 number 类型,将直接转化为 number值,默认当 byte 处理
Example
fileSizeToByte('1kb'); // 1024
 fileSizeToByte('1mb'); // 1048576
 fileSizeToByte('1MB'); // 1048576
 fileSizeToByte('1gb'); // 1073741824
 fileSizeToByte('1tb'); // 1099511627776
 fileSizeToByte('123'); // 123
 fileSizeToByte(123); // 123
Parameters:
Name Type Description
size String

带有单位的 size,不带单位时,直接返回该值

Returns:

byte

Type
Nubner

fileterAllMatchedData(value, arr)

过滤所有匹配上的数据

Parameters:
Name Type Description
value any
arr any
Returns:

Array

filterAllCheckedData(vals, treeData)

过滤数据

Parameters:
Name Type Description
vals Array

数据集合

treeData any

tree数据

Returns:

Array

filterChilds(value, treeData)

过滤数据,只要子节点

Parameters:
Name Type Description
value any
treeData any
Returns:

Array

filterTreeLevel(datas, filterFn, options)

过滤树层级

Parameters:
Name Type Description
datas any

树数据

filterFn function

过滤方式

options object

{ levelKey: 'level', // level节点,默认'level' levelValue: 3, // 指定层级或去掉指定节点下的children childrenKey: 'children' // child节点,默认 'children' }

genBitmapImage()

create bitmap image 按照规则生成图片响应头和响应体

generateKeys(keyByte)

generate 16 keys for xor

Parameters:
Name Type Description
keyByte array

getFileExtension(filePath) → {String}

获取扩展名

Example
getFileExtension('a.png'); // png
 getFileExtension('a/a/a.png'); // png
 getFileExtension('a.a.a.png.jpg'); // jpg
 getFileExtension('a'); // ''
Parameters:
Name Type Description
filePath String
Returns:

ext

Type
String

getKeyBytes(key)

change the string into the bit array. return bit array(it's length % 64 = 0)

Parameters:
Name Type Description
key string

getTreeFlatKeys(item, options)

获取树结构数据 flat keys

Parameters:
Name Type Description
item *
options *
Returns:

[]

gradientColor(color, minValue, maxValue)

产生渐变色函数

Parameters:
Name Type Description
color object
minValue number
maxValue number

has(obj, path)

Shortcut function for checking if an object has a given property directly on itself (in other words, not on a prototype).

Parameters:
Name Type Description
obj *
path *

hasOwnProp(value, property) → {boolean}

Tests if an object has a specified property.

Examples
var beep = {
    'boop': true
};

var bool = hasOwnProp( beep, 'boop' );
// returns true
var beep = {
    'boop': true
};

var bool = hasOwnProp( beep, 'bap' );
// returns false
Parameters:
Name Type Description
value *

value to test

property *

property to test

Returns:

boolean indicating if an object has a specified property

Type
boolean

hexToBt4(hex)

change the hex into the bit(it's length = 4). return the bit(it's length = 4)

Parameters:
Name Type Description
hex string

imageCompress(file, callback, encoderOptions)

压缩图片

Parameters:
Name Type Description
file File

图片

callback function

(blob) => {}

encoderOptions Number

isBaseNaN(x) → {boolean}

Tests if a double-precision floating-point numeric value is NaN.

Examples
var bool = isBaseNaN( NaN );
// returns true
var bool = isBaseNaN( 7.0 );
// returns false
Parameters:
Name Type Description
x number

value to test

Returns:

boolean indicating whether the value is NaN

Type
boolean

isBlank(value)

空(null、undefined、'')

Parameters:
Name Type Description
value *
Returns:

isBoolean(obj)

Is a given value a boolean?

Parameters:
Name Type Description
obj *

isBuiltInObject(value) → {boolean}

Parameters:
Name Type Description
value *
Returns:
Type
boolean

isCollection(value) → {boolean}

Tests if a value is a collection.

Examples
var bool = isCollection( [] );
// returns true
var bool = isCollection( {} );
// returns false
Parameters:
Name Type Description
value *

value to test

Returns:

boolean indicating whether a value is a collection

Type
boolean

isDom(value) → {boolean}

is dom

Parameters:
Name Type Description
value *
Returns:
Type
boolean

isElement(obj)

Is a given value a DOM element?

Parameters:
Name Type Description
obj *

isEmpty(objOrArray)

Is a given array, string, or object empty? An "empty" object has no enumerable own-properties.

Parameters:
Name Type Description
objOrArray *

isEmpty(v)

判断 空

Example
undefined => true
  null => true
  '' => true
Parameters:
Name Type Description
v string

isEmptyObject(obj)

检测对象是否是空对象(不包含任何可读属性)。 方法只既检测对象本身的属性,不检测从原型继承的属性。

Parameters:
Name Type Description
obj *

isENumber(value)

判断是否是 number,支持 e

Parameters:
Name Type Description
value *

isFloat(value)

check value is float

Parameters:
Name Type Description
value *

isHexColor(color)

判断是否是hex颜色

Parameters:
Name Type Description
color string
Returns:

boolean

isInputEqual(newInputs, lastInputs) → {Boolean}

判断输入参数是否相同

Parameters:
Name Type Description
newInputs *
lastInputs *
Returns:
Type
Boolean

isInteger(x) → {boolean}

Tests if a finite double-precision floating-point number is an integer.

Examples
var bool = isInteger( 1.0 );
// returns true
var bool = isInteger( 3.14 );
// returns false
Parameters:
Name Type Description
x number

value to test

Returns:

boolean indicating whether the value is an integer

Type
boolean

isJson(obj)

判断对象是不是Json Object 对象,typeof === object && toString === '[object Object]'

Parameters:
Name Type Description
obj object
Returns:

boolean true 是 false不是

isKeyColor(color)

判断是否是 key color 颜色

Parameters:
Name Type Description
color string
Returns:

boolean

isKeyInObject(keys, obj)

判断key是否在object内 (采用 in 判断,继承属性均会判断)

Parameters:
Name Type Description
keys string | array
obj object

如果 obj 是 null or undefined 则直接 返回 false

isnan(value) → {boolean}

Tests if a value is a number object having a value of NaN.

Examples
var bool = isnan( NaN );
// returns false
var bool = isnan( new Number( NaN ) );
// returns true
Parameters:
Name Type Description
value *

value to test

Returns:

boolean indicating if a value is a number object having a value of NaN

Type
boolean

isNil(value) → {boolean}

Checks if value is null or undefined.

Example
isNil(null)
// => true

isNil(void 0)
// => true

isNil(NaN)
// => false
Parameters:
Name Type Description
value *

The value to check.

Returns:

Returns true if value is nullish, else false.

Type
boolean

isNull(obj)

Is a given value equal to null?

Parameters:
Name Type Description
obj *

isNullOrUndefined(arg) → {Boolean}

null or undefined

Parameters:
Name Type Description
arg *
Returns:
Type
Boolean

isNumber(value)

判断 number,采用正则表达式进行判断 正则表达式:/^(-|+)?([0-9]+(.[0-9]+)?|Infinity)$/

Parameters:
Name Type Description
value *

isNumber(value) → {boolean}

Tests if a value is a number primitive.

Examples
var bool = isNumber( 3.14 );
// returns true
var bool = isNumber( NaN );
// returns true
var bool = isNumber( new Number( 3.14 ) );
// returns true
Parameters:
Name Type Description
value *

value to test

Returns:

boolean indicating if a value is a number primitive

Type
boolean

isObject(obj)

Is a given variable an object?

Parameters:
Name Type Description
obj *

isObject(value) → {boolean}

Tests if a value is an object; e.g., {}.

Examples
var bool = isObject( {} );
// returns true
var bool = isObject( null );
// returns false
Parameters:
Name Type Description
value *

value to test

Returns:

boolean indicating whether value is an object

Type
boolean

isOnlyObject(obj)

obly object

Example
isOnlyObject([]); // false
 isOnlyObject({}); // true
 isOnlyObject(null); // false
 isOnlyObject(void 0); // false
 isOnlyObject(new Object()); // true
 isOnlyObject(Object.create({})); // true
Parameters:
Name Type Description
obj *

isOpacity(value)

check value is opacity value

Parameters:
Name Type Description
value *

isOwnKeyInObject(keys, obj)

判断key是否在object内 (采用 hasOwnProperty 判断,继承属性不会判断)

Parameters:
Name Type Description
keys string | array
obj object

如果 obj 是 null or undefined 则直接 返回 false

isPromise(value) → {Boolean}

判断是否是 promise

Parameters:
Name Type Description
value *
Returns:
Type
Boolean

isRegExp(value)

判断是否是 正则对象

Parameters:
Name Type Description
value *
Returns:

isRgbColor(color)

判断是否是rgb颜色

Parameters:
Name Type Description
color any
Returns:

boolean

isUndefined(obj)

Is a given variable undefined?

Parameters:
Name Type Description
obj *

isUrl(val)

测试是否是url

Parameters:
Name Type Description
val string

isValidDate(date)

检查date是否合法,返回 true 代表合法

Example
isValidDate('20'); // false
Parameters:
Name Type Description
date *

keyColorToHex(color)

key color 转化为 hex color。 如果不是 key color 则直接返回 color 自身

Parameters:
Name Type Description
color string

merge(target, source, overwriteopt)

Parameters:
Name Type Attributes Default Description
target *
source *
overwrite boolean <optional>
false

mergeAll(targetAndSources, overwriteopt) → {*}

Parameters:
Name Type Attributes Default Description
targetAndSources Array

The first item is target, and the rests are source.

overwrite boolean <optional>
false
Returns:

target

Type
*

mod(a, b) → {Number}

Parameters:
Name Type Description
a Number
b Number
Returns:
Type
Number

multiply(a, b) → {Number}

Parameters:
Name Type Description
a Number
b Number
Returns:
Type
Number

normalPolicy(password) → {object}

普通密码生成策略

Parameters:
Name Type Description
password string
Returns:

{ password, secretKey }

Type
object

null2default(str)

将null undefined 转化为 空字符串

Parameters:
Name Type Description
str *

objRGB2str(color)

将object的rgb转化成string {r:1,g:1,b:1,a:1} => 'rgba(1,1,1,1)' {r:1,g:1,b:1,a:0} => 'rgba(1,1,1,0)' {r:1,g:1,b:1} => 'rgba(1,1,1)'

Parameters:
Name Type Description
color object
Returns:

string

parse(str, optionsopt) → {object}

Parse a cookie header.

Parse the given cookie header string into an object The object has the various cookies as keys(names) => values

Parameters:
Name Type Attributes Description
str string
options object <optional>
Returns:
Type
object

pathToTree(input, options)

Example
const arr = [
  'main/',
  'main/a/',
  'main/a/new_b.png',
  'main/a/qa/',
  'main/a/qa/新建文本文档 (3).txt',
  'main/asdfasdfasdfasdfasdfasdfasdf.txt',
  'main/b.png',
  'main/instqj_gfzqhk.exe',
  'main/jupyter_notebook.png',
  'main/new_b.png',
  'main/output/new_b.png',
  'main/soffice.exe',
  'main/ti/asdfasdfasdfasdfasdfasdfasdf.txt',
  'main/watermark.zip',
  'main/红头文件 第十三个五年规划纲要 .pdf',
  'main/绝密发布《xx制造2025》%28全文%29.pdf',
  'main/新建文本文档 (3).txt',
  'main/新建文本文档.txt',
  'main/无厘头.docx',
  'main/变声C2011SP.exe',
  'console/tt/design1',
  'console/mm/vizlib'
];

    pathToTree(arr, { pathKey: 'title', childrenKey: 'children' });
Parameters:
Name Type Description
input *
options *

{pathKey: 'path', childrenKey: 'children', processor: (item, pathKey) => {}}

plus(a, b) → {Number}

Parameters:
Name Type Description
a Number
b Number
Returns:
Type
Number

Queue()

先进先出队列 (First Input First Output)

一种先进先出的数据缓存器

random()

random(6) //长度为6的字符串

randomInt()

randomInt(10, 100) // 10 到100的随机数

ranks(x, optionsopt) → {Array}

Computes the sample ranks for the values of an array-like object.

Examples
var arr = [ 1.1, 2.0, 3.5, 0.0, 2.4 ];
var out = ranks( arr );
// returns [ 2, 3, 5, 1, 4 ]
// Ties are averaged:
arr = [ 2, 2, 1, 4, 3 ];
out = ranks( arr );
// returns [ 2.5, 2.5, 1, 5, 4 ]
// Missing values are placed last:
arr = [ null, 2, 2, 1, 4, 3, NaN, NaN ];
out = ranks( arr );
// returns [ 6, 2.5, 2.5, 1, 5, 4, 7 ,8 ]
Parameters:
Name Type Attributes Description
x Collection

data array

options Object <optional>

options object

Properties
Name Type Attributes Default Description
method string <optional>
'average'

method name determining how ties are treated

missing string <optional>
'last'

determines where missing values go (first,last, or remove)

encoding Array <optional>
[null,NaN]

array of values encoding missing values

Throws:
  • first argument has to be an array-like object

    Type
    TypeError
  • options argument must be an object

    Type
    TypeError
  • must provide valid options

    Type
    TypeError
Returns:

array containing the computed ranks for the elements of x

Type
Array

recursive(children, cb)

递归

Parameters:
Name Type Description
children any
cb any

recursiveGen(children, levelopt)

构建数据,添加数据位置

Parameters:
Name Type Attributes Default Description
children any
level number <optional>
0
Returns:

Array

rgb2object(color)

将rgb颜色转化成object '12,12,12,12' => {r:12,g:12,b:12,a:12}

Example
rgb2object('rgba(241,112,19,1)'); // { r: '241', g: '112', b: '19', a: '1' }
 rgb2object('241,112,19,1'); // { r: '241', g: '112', b: '19', a: '1' }
Parameters:
Name Type Description
color any
Returns:

Object

saveAsImage(canvasElement, optionalopt, optionalopt, image)

saveAsImage

Parameters:
Name Type Attributes Description
canvasElement
optional Number <optional>

png width

optional Number <optional>

png height

image String

type

serialize(name, val, optionsopt) → {string}

Serialize data into a cookie header.

Serialize the a name value pair into a cookie string suitable for http headers. An optional options object specified cookie parameters.

serialize('foo', 'bar', { httpOnly: true }) => "foo=bar; httpOnly"

Parameters:
Name Type Attributes Description
name string
val string
options object <optional>
Returns:
Type
string

shallowEqual(objA, objB)

浅层次比较两个对象是否相等

Parameters:
Name Type Description
objA object
objB object

simpleEqual(objA, objB)

浅层次比较两个对象是否相等

Parameters:
Name Type Description
objA object
objB object

simpleThrottle()

函数节流简单实现 fn 执行的函数 interval 时间段 clear 是否清理前一次的事件,如果清理,则重新设置定时器

slpitArray(arr, num) → {Array}

分割数组

Example
slpitArray([1,2,3,4], 2); // [[1,2], [3,4]]
 slpitArray([1,2,3,4], 3); // [[1,2,3], [4]]
Parameters:
Name Type Description
arr Array
num Number

分段数

Returns:
Type
Array

some(arr, fun)

some some 为数组中的每一个元素执行一次 callback 函数,直到找到一个使得 callback 返回一个“真值”

Parameters:
Name Type Description
arr Array
fun function

stringIsJson(str) → {Boolean}

判断string能否被转成json 参数 str 如果不是 string 则直接返回 false

Parameters:
Name Type Description
str string
Returns:
Type
Boolean

strToBt(str)

change the string(it's length <= 4) into the bit array. return bit array(it's length = 64)

Parameters:
Name Type Description
str string

subObjectEqual(objSource, objTarget)

比较 objTarget 中的所有属性值,是否在 objSource 中相等

Parameters:
Name Type Description
objSource Object
objTarget Object

subtract(a, b) → {Number}

Parameters:
Name Type Description
a Number
b Number
Returns:
Type
Number

throttle(delay, noTrailingopt, callback, debounceModeopt) → {function}

Throttle execution of a function. Especially useful for rate limiting execution of handlers on events like resize and scroll.

Example
throttle(300, () => {  });
 debounce(300, () => {  });
 // cancel
 const throttled = throttle(300, () => {  });
 throttled.cancel();
Parameters:
Name Type Attributes Description
delay Number

A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.

noTrailing Boolean <optional>

Optional, defaults to false. If noTrailing is true, callback will only execute every delay milliseconds while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time after the last throttled-function call. (After the throttled-function has not been called for delay milliseconds, the internal counter is reset)

callback function

A function to be executed after delay milliseconds. The this context and all arguments are passed through, as-is, to callback when the throttled-function is executed.

debounceMode Boolean <optional>

If debounceMode is true (at begin), schedule clear to execute after delay ms. If debounceMode is false (at end), schedule callback to execute after delay ms.

Returns:

A new, throttled, function.

Type
function

toHexAlphaColor(hex, alpha) → {String}

将 hex color 添加上 alpha

Example
toHexAlphaColor('#efefef', 0.56); // #efefef8F
Parameters:
Name Type Description
hex String
alpha Number
Returns:
Type
String

toHexColor(stringRgb)

转化为hex颜色 (仅支持 RGB),如果是 rgba 时,则舍去 a

如果传入的是 key color 则直接转化为与之对应的 hex 值

Example
toHexColor('rgba(241,112,19)'); // #f17013
 toHexColor('rgba(241,112,19, 1)'); // #f17013
 toHexColor('rgba(241,112,19, 0.1)'); // #f17013
 toHexColor('red'); // #ff0000
 toHexColor(); // ''
 toHexColor(null); // ''
 toHexColor(123456); // ''
 toHexColor(0x123456123456); // ''
Parameters:
Name Type Description
stringRgb string

toRealSize(val, type, parentWH) → {Number}

将 size 值转化为真实的宽高值

Parameters:
Name Type Description
val *
type String

width、height 仅当 val 为百分值时,

parentWH *
Returns:
Type
Number

toRGBcolor(hexColor)

16进制颜色转为RGB格式

Example
toRGBcolor('#AABBCC'); // rgb(170,187,204)
Parameters:
Name Type Description
hexColor string

toStringHexColor(stringRgb)

RGB颜色转换为16进制

Example
toStringHexColor('rgba(241,112,19,1)'); // #f17013
 toStringHexColor('rgba(241,112,19, 0.1)'); // #f1701319
Parameters:
Name Type Description
stringRgb string

transformColor(c)

将16进制的颜色转换为rgb

Parameters:
Name Type Description
c string

useMd5Policy(password, secretKey)

采用MD5生成密码

Parameters:
Name Type Description
password string
secretKey string

useMd5Policy2(password, secretKey)

采用MD5生成密码

  1. password = md5(password);
  2. password = Store.encrypt(password + secretKey);
Parameters:
Name Type Description
password string
secretKey string

values(obj)

Retrieve the values of an object's properties.

Parameters:
Name Type Description
obj *