Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

generateRandomKey.js 568 B

před 3 roky
123456789101112131415161718192021222324252627
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. *
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. var seenKeys = {};
  13. var MULTIPLIER = Math.pow(2, 24);
  14. function generateRandomKey() {
  15. var key;
  16. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  17. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  18. }
  19. seenKeys[key] = true;
  20. return key;
  21. }
  22. module.exports = generateRandomKey;