mihawk
Version:
A tiny & simple mock server tool, support json,js,cjs,ts(typescript).
19 lines (18 loc) • 675 B
JavaScript
;
import { isNumStrict } from '../utils/is';
import { shuffle, randPick } from '../utils/list';
export const pickRand = randPick;
export { default as dedupe } from 'free-dedupe';
export { default as deepmerge } from 'deepmerge';
export const shuffleList = shuffle;
export function shuffleString(str) {
return shuffleList(str.split('')).join('');
}
export function getListByPagination(list, options) {
let { index, size } = options || {};
index = isNumStrict(index) && index > 0 ? index : 1;
size = isNumStrict(size) && size >= 2 ? size : 10;
const start = (index - 1) * size;
const end = index * size;
return list.slice(start, end);
}