UNPKG

1.33 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.dev/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.default = default_1;
11const host_tree_1 = require("../tree/host-tree");
12function generateStringOfLength(l) {
13 return new Array(l)
14 .fill(0)
15 .map((_x) => {
16 return 'abcdefghijklmnopqrstuvwxyz'[Math.floor(Math.random() * 26)];
17 })
18 .join('');
19}
20function random(from, to) {
21 return Math.floor(Math.random() * (to - from)) + from;
22}
23function default_1(options) {
24 return () => {
25 const root = 'root' in options ? options.root : '/';
26 const map = new host_tree_1.HostTree();
27 const nbFiles = 'multiFiles' in options
28 ? typeof options.multiFiles == 'number'
29 ? options.multiFiles
30 : random(2, 12)
31 : 1;
32 for (let i = 0; i < nbFiles; i++) {
33 const path = 'a/b/c/d/e/f'.slice(Math.random() * 10);
34 const fileName = generateStringOfLength(20);
35 const content = generateStringOfLength(100);
36 map.create(root + '/' + path + '/' + fileName, content);
37 }
38 return map;
39 };
40}