Title

Global

Methods

# dateFormat(date,, format,) → {string}

Date format and output the formatted date;
Parameters:
Name Type Description
date, number | Date the origin date which you want to format;
format, string the format that the date you want to output;
Since:
  • 1.0.0
Author:
  • yhm1694;

View Source dateFormat.js, line 17

formatDate, return the formatted date;
string
Example
dateFormat(1531643785284, 'yyyy-MM-dd');

// => '2018-07-15'

# debounce(func, wait)

debounce
Parameters:
Name Type Description
func function
wait number
Since:
  • 1.3.0
Author:
  • caiyue;

View Source debounce.js, line 16

Example
var debounced = debounce(()=>{console.log(123)}, 500);
//cancel the debounce function
debounced.cancel();

# durationFormat(seconds, format, withLeadingZero, keepZeroPlace) → {string}

format duration by template `format`
Parameters:
Name Type Default Description
seconds number 0 seconds of duration
format string 'hh小时mm分钟ss秒' output template hh will be replaced by hours value, mm will be replaced by minutes value ss will be replaced by seconds value
withLeadingZero boolean false if `x`(e.g hours) value less than 9, then return 0x, e.g 02
keepZeroPlace boolean false if `x`(e.g hours) value is 0, don't return default

View Source durationFormat.ts, line 17

string
Example
durationFormat(43875); // 12小时11分钟15秒
durationFormat(43875, 'hh:mm:ss', true, true); // 12:11:15

# generateUUID() → {string}

Generate UUID, maybe used to render react list;
Since:
  • 1.1.0
Author:
  • yhm1694;

View Source generateUUID.js, line 15

uuid;
string
Example
generateUUID();

// => 'af22-3fa8-4028-8dea-30a2'

# removeNodebffPrefix(url, env, forceAddHost, prefix) → {string}

add host for url & remove node bff
Parameters:
Name Type Default Description
url string url needed to be handle
env string prod the build env
forceAddHost boolean false is force to add host to all url
prefix string /bendbff url with special prefix will be replace to empty

View Source removeNodebffPrefix.js, line 9

the new url be handled
string

# throttle(func, wait)

throttle
Parameters:
Name Type Description
func function
wait number
Since:
  • 1.3.0
Author:
  • caiyue;

View Source throttle.js, line 16

Example
var debounced = throttle(()=>{console.log(123)}, 500);
//cancel the throttle function
debounced.cancel();

# unique(arr) → {array}

array to unique,
Parameters:
Name Type Description
arr array the first array incoming;
Since:
  • 1.1.0;
Author:
  • fl2294;

View Source unique.js, line 14

;
array
Example
unique([1, 3, 5, 6, 8, 8, 6, 3, [1,2], [1,2], {item: 1, 2: 3}, {item: 1, 2: 3}])
// => [1, 3, 5, 6, 8, [1,2], {item: 1, 2: 3}]