source: trip-planner-front/node_modules/@angular-devkit/schematics/src/rules/random.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
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.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10const host_tree_1 = require("../tree/host-tree");
11function generateStringOfLength(l) {
12 return new Array(l)
13 .fill(0)
14 .map((_x) => {
15 return 'abcdefghijklmnopqrstuvwxyz'[Math.floor(Math.random() * 26)];
16 })
17 .join('');
18}
19function random(from, to) {
20 return Math.floor(Math.random() * (to - from)) + from;
21}
22function default_1(options) {
23 return () => {
24 const root = 'root' in options ? options.root : '/';
25 const map = new host_tree_1.HostTree();
26 const nbFiles = 'multiFiles' in options
27 ? typeof options.multiFiles == 'number'
28 ? options.multiFiles
29 : random(2, 12)
30 : 1;
31 for (let i = 0; i < nbFiles; i++) {
32 const path = 'a/b/c/d/e/f'.slice(Math.random() * 10);
33 const fileName = generateStringOfLength(20);
34 const content = generateStringOfLength(100);
35 map.create(root + '/' + path + '/' + fileName, content);
36 }
37 return map;
38 };
39}
40exports.default = default_1;
Note: See TracBrowser for help on using the repository browser.