vtils
Version:
一个面向业务的 JavaScript/TypeScript 实用程序库。
30 lines (26 loc) • 709 B
JavaScript
exports.__esModule = true;
exports.placeKitten = placeKitten;
function getAvaliableSize(size) {
return Math.min(1000, Math.max(10, Math.round(size / 10) * 10));
}
/**
* 给定大小获取占位猫咪图片。
*
* @param size 大小
* @returns 返回占位图地址
*/
/**
* 给定宽高获取占位猫咪图片。
*
* @param width 宽度
* @param height 高度
* @returns 返回占位图地址
*/
function placeKitten(width, height) {
var _height;
height = (_height = height) != null ? _height : width;
width = getAvaliableSize(width);
height = getAvaliableSize(height);
return "https://cdn.jsdelivr.net/gh/fjc0k/placekitten/images/" + width + "/" + height + ".jpg";
}
;