util

fis. util

fis 中工具类操作集合。lodash 中所有方法都挂载在此名字空间下面。

Source:

Example

/a/b//c\d/ -> /a/b/c/d

Methods

(static) applyMatches(path, matches, allowed)

将 matches 规则应用到某个对象上面。

Parameters:
Name Type Description
path String

路径。用来与 match 规则匹配

matches Array

规则数组

allowed Array

可以用来过滤掉不关心的字段。

Source:

(static) base64(data) → {String}

生成base64串

Parameters:
Name Type Description
data String | Buffer | Array

数据源

Source:
Returns:

base64串

Type
String

(static) camelcase(str) → {String}

驼峰写法转换

Parameters:
Name Type Description
str String

待转换字符串

Source:
Returns:

转换后的字符串

Type
String

(static) clone(source) → {any}

clone一个变量

Parameters:
Name Type Description
source any

变量

Source:
Returns:

clone值

Type
any

(static) copy(rSource, target, include, exclude, uncover, move)

复制符合include和exclude规则的文件到目标目录,若rSource为文件夹则递归其下属每个文件

Parameters:
Name Type Description
rSource String

源路径

target String

目标路径

include Array

包含匹配规则

exclude Array

排除匹配规则

uncover Boolean

是否覆盖

move Boolean

是否移动

Source:

(static) del()

删除指定目录下面的文件。

Source:

(static) download(url, callback, extract, opt)

下载功能实现

Parameters:
Name Type Description
url String

下载的url

callback function

回调

extract String

压缩提取路径

opt Object

配置

Source:

(static) escapeReg(str) → {String}

正则串编码转义

Parameters:
Name Type Description
str String

正则串

Source:
Returns:

普通字符串

Type
String

(static) escapeShellArg(命令)

shell编码转义

Parameters:
Name Type Description
命令 String
Source:

(static) escapeShellCmd(命令)

shell命令编码转义

Parameters:
Name Type Description
命令 String
Source:

(static) exist(filepath)

判断文件是否存在。

Parameters:
Name Type Description
filepath String

文件路径。

Source:

(static) ext(str) → {Object}

path处理

Parameters:
Name Type Description
str String

待处理的路径

Source:
Returns:
Type
Object
Example
str = /a.b.c/f.php?kw=%B2%E5%BB%AD#addfhubqwek
                     {
                        origin: '/a.b.c/f.php?kw=%B2%E5%BB%AD#addfhubqwek',
                        rest: '/a.b.c/f',
                        hash: '#addfhubqwek',
                        query: '?kw=%B2%E5%BB%AD',
                        fullname: '/a.b.c/f.php',
                        dirname: '/a.b.c',
                        ext: '.php',
                        filename: 'f',
                        basename: 'f.php'
                     }

(static) filter(str, include, exclude) → {Boolean}

str过滤处理,判断include中匹配str为true,exclude中不匹配str为true

Parameters:
Name Type Description
str String

待处理的字符串

include Array

include匹配规则

exclude Array

exclude匹配规则

Source:
Returns:

是否匹配

Type
Boolean

(static) find(rPath, include, exclude, root) → {Array}

若rPath为文件夹,夹遍历目录下符合include和exclude规则的全部文件;若rPath为文件,直接匹配该文件路径是否符合include和exclude规则

Parameters:
Name Type Description
rPath String

要查找的目录

include Array

包含匹配正则集合,可传null

exclude Array

排除匹配正则集合,可传null

root