{"version":3,"file":"sample.mjs","names":[],"sources":["../../src/collection/sample.ts"],"sourcesContent":["/**\n * Gets a random element from collection\n * @param collection - The collection to sample\n * @returns Returns the random element\n * @example\n * const arr = [1, 2, 3, 4, 5];\n * sample(arr); // => random element from arr\n */\nexport function sample<T>(collection: T[]): T | undefined {\n  if (collection.length === 0) {\n    return undefined;\n  }\n\n  const randomIndex = Math.floor(Math.random() * collection.length);\n  return collection[randomIndex];\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,OAAU,YAAgC;CACxD,IAAI,WAAW,WAAW,GACxB;CAIF,OAAO,WADa,KAAK,MAAM,KAAK,OAAO,IAAI,WAAW,MAC9B;AAC9B"}