Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/assets/javascripts/diffs/utils
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/utils')
-rw-r--r--app/assets/javascripts/diffs/utils/diff_file.js2
-rw-r--r--app/assets/javascripts/diffs/utils/uuids.js76
2 files changed, 1 insertions, 77 deletions
diff --git a/app/assets/javascripts/diffs/utils/diff_file.js b/app/assets/javascripts/diffs/utils/diff_file.js
index 7e6fde320d2..a96c1207a04 100644
--- a/app/assets/javascripts/diffs/utils/diff_file.js
+++ b/app/assets/javascripts/diffs/utils/diff_file.js
@@ -1,4 +1,5 @@
import { truncateSha } from '~/lib/utils/text_utility';
+import { uuids } from '~/lib/utils/uuids';
import {
DIFF_FILE_SYMLINK_MODE,
@@ -7,7 +8,6 @@ import {
DIFF_FILE_AUTOMATIC_COLLAPSE,
} from '../constants';
import { getDerivedMergeRequestInformation } from './merge_request';
-import { uuids } from './uuids';
function fileSymlinkInformation(file, fileList) {
const duplicates = fileList.filter((iteratedFile) => iteratedFile.file_hash === file.file_hash);
diff --git a/app/assets/javascripts/diffs/utils/uuids.js b/app/assets/javascripts/diffs/utils/uuids.js
deleted file mode 100644
index 98fe4bf9664..00000000000
--- a/app/assets/javascripts/diffs/utils/uuids.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * @module uuids
- */
-
-/**
- * A string or number representing a start state for a random generator
- * @typedef {(Number|String)} Seed
- */
-/**
- * A UUIDv4 string in the format <code>Hex{8}-Hex{4}-4Hex{3}-[89ab]Hex{3}-Hex{12}</code>
- * @typedef {String} UUIDv4
- */
-
-import { MersenneTwister } from 'fast-mersenne-twister';
-import { isString } from 'lodash';
-import stringHash from 'string-hash';
-import { v4 } from 'uuid';
-
-function getSeed(seeds) {
- return seeds.reduce((seedling, seed, i) => {
- let thisSeed = 0;
-
- if (Number.isInteger(seed)) {
- thisSeed = seed;
- } else if (isString(seed)) {
- thisSeed = stringHash(seed);
- }
-
- return seedling + (seeds.length - i) * thisSeed;
- }, 0);
-}
-
-function getPseudoRandomNumberGenerator(...seeds) {
- let seedNumber;
-
- if (seeds.length) {
- seedNumber = getSeed(seeds);
- } else {
- seedNumber = Math.floor(Math.random() * 10 ** 15);
- }
-
- return new MersenneTwister(seedNumber);
-}
-
-function randomValuesForUuid(prng) {
- const randomValues = [];
-
- for (let i = 0; i <= 3; i += 1) {
- const buffer = new ArrayBuffer(4);
- const view = new DataView(buffer);
-
- view.setUint32(0, prng.randomNumber());
-
- randomValues.push(view.getUint8(0), view.getUint8(1), view.getUint8(2), view.getUint8(3));
- }
-
- return randomValues;
-}
-
-/**
- * Get an array of UUIDv4s
- * @param {Object} [options={}]
- * @param {Seed[]} [options.seeds=[]] - A list of mixed strings or numbers to seed the UUIDv4 generator
- * @param {Number} [options.count=1] - A total number of UUIDv4s to generate
- * @returns {UUIDv4[]} An array of UUIDv4s
- */
-export function uuids({ seeds = [], count = 1 } = {}) {
- const rng = getPseudoRandomNumberGenerator(...seeds);
- return (
- // Create an array the same size as the number of UUIDs requested
- Array(count)
- .fill(0)
- // Replace each slot in the array with a UUID which needs 16 (pseudo)random values to generate
- .map(() => v4({ random: randomValuesForUuid(rng) }))
- );
-}