UNPKG

stable-ts-type

Version:

Obtain the most stable type code of 'typescript' through multiple network requests

29 lines (28 loc) 1.07 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOnceMockInputList = void 0; const shuffle_seed_1 = __importDefault(require("shuffle-seed")); /** 多次mock的Input拆成多个一次的Input */ const getOnceMockInputList = (inputs, sort = 'random') => { var _a; const resultInputs = []; for (const input of inputs) { if (input.type === 'example-json') { resultInputs.push(input); } else { const mockCount = (_a = input.mockCount) !== null && _a !== void 0 ? _a : 1; for (let i = 0; i < mockCount; i++) { resultInputs.push(Object.assign(Object.assign({}, input), { mockCount: 1 })); } } } if (sort === 'random') { return shuffle_seed_1.default.shuffle(resultInputs, Date.now()); } return resultInputs; }; exports.getOnceMockInputList = getOnceMockInputList;