CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
index.js39 linesDownload Raw Back to node
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() + DIGIT13}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 || null34  },35  ALPHABET,36  generateString,37  protocols: [ 'http', 'https', 'file', 'data' ]38};39