mihawk
Version:
A tiny & simple mock server tool, support json,js,cjs,ts(typescript).
28 lines (27 loc) • 1.37 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getListByPagination = exports.shuffleString = exports.shuffleList = exports.deepmerge = exports.dedupe = exports.pickRand = void 0;
const is_1 = require("../utils/is");
const list_1 = require("../utils/list");
exports.pickRand = list_1.randPick;
var free_dedupe_1 = require("free-dedupe");
Object.defineProperty(exports, "dedupe", { enumerable: true, get: function () { return __importDefault(free_dedupe_1).default; } });
var deepmerge_1 = require("deepmerge");
Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return __importDefault(deepmerge_1).default; } });
exports.shuffleList = list_1.shuffle;
function shuffleString(str) {
return (0, exports.shuffleList)(str.split('')).join('');
}
exports.shuffleString = shuffleString;
function getListByPagination(list, options) {
let { index, size } = options || {};
index = (0, is_1.isNumStrict)(index) && index > 0 ? index : 1;
size = (0, is_1.isNumStrict)(size) && size >= 2 ? size : 10;
const start = (index - 1) * size;
const end = index * size;
return list.slice(start, end);
}
exports.getListByPagination = getListByPagination;