source: node_modules/axios/lib/platform/node/index.js

Last change on this file was ff72ad2, checked in by ste08 <sjovanoska@…>, 2 months ago

Adding review works\!

  • Property mode set to 100644
File size: 828 bytes
Line 
1import crypto from 'crypto';
2import URLSearchParams from './classes/URLSearchParams.js'
3import FormData from './classes/FormData.js'
4
5const ALPHA = 'abcdefghijklmnopqrstuvwxyz'
6
7const DIGIT = '0123456789';
8
9const ALPHABET = {
10 DIGIT,
11 ALPHA,
12 ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
13}
14
15const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
16 let str = '';
17 const {length} = alphabet;
18 const randomValues = new Uint32Array(size);
19 crypto.randomFillSync(randomValues);
20 for (let i = 0; i < size; i++) {
21 str += alphabet[randomValues[i] % length];
22 }
23
24 return str;
25}
26
27
28export default {
29 isNode: true,
30 classes: {
31 URLSearchParams,
32 FormData,
33 Blob: typeof Blob !== 'undefined' && Blob || null
34 },
35 ALPHABET,
36 generateString,
37 protocols: [ 'http', 'https', 'file', 'data' ]
38};
Note: See TracBrowser for help on using the repository browser.