this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use `random-item` instead of maintaining our own

+24 -5
+19
package-lock.json
··· 8 8 "name": "bb26", 9 9 "version": "2.1.1", 10 10 "license": "MIT", 11 + "dependencies": { 12 + "random-item": "^3.1.0" 13 + }, 11 14 "devDependencies": { 12 15 "@types/jest": "^27.0.2", 13 16 "del-cli": "^4.0.1", ··· 8065 8068 "dev": true, 8066 8069 "engines": { 8067 8070 "node": ">=10" 8071 + }, 8072 + "funding": { 8073 + "url": "https://github.com/sponsors/sindresorhus" 8074 + } 8075 + }, 8076 + "node_modules/random-item": { 8077 + "version": "3.1.0", 8078 + "resolved": "https://registry.npmjs.org/random-item/-/random-item-3.1.0.tgz", 8079 + "integrity": "sha512-0DyAT8LYBNQKSkqcPjia/HNoWCZ5JWBdAQWjBQVh5DMVv3Fv7V90I8/AuUf8NW4zdFn27i9qj8Kp6wI5JsiiOA==", 8080 + "engines": { 8081 + "node": ">=8" 8068 8082 }, 8069 8083 "funding": { 8070 8084 "url": "https://github.com/sponsors/sindresorhus" ··· 17074 17088 "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", 17075 17089 "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", 17076 17090 "dev": true 17091 + }, 17092 + "random-item": { 17093 + "version": "3.1.0", 17094 + "resolved": "https://registry.npmjs.org/random-item/-/random-item-3.1.0.tgz", 17095 + "integrity": "sha512-0DyAT8LYBNQKSkqcPjia/HNoWCZ5JWBdAQWjBQVh5DMVv3Fv7V90I8/AuUf8NW4zdFn27i9qj8Kp6wI5JsiiOA==" 17077 17096 }, 17078 17097 "randombytes": { 17079 17098 "version": "2.1.0",
+3
package.json
··· 28 28 "test": "xo && jest", 29 29 "test:coverage": "xo && jest --coverage" 30 30 }, 31 + "dependencies": { 32 + "random-item": "^3.1.0" 33 + }, 31 34 "devDependencies": { 32 35 "@types/jest": "^27.0.2", 33 36 "del-cli": "^4.0.1",
+2 -2
source/random.ts
··· 1 + import * as randomItem from 'random-item'; 1 2 import range from './range'; 2 - import sample from './sample'; 3 3 4 4 /** 5 5 * Produces a random string between the inclusive `lower` and `upper` bounds. If ··· 21 21 const start = upper ? lower : 'A'; 22 22 const end = upper ?? lower; 23 23 24 - return sample(range(start, end)); 24 + return randomItem(range(start, end)); 25 25 }
-3
source/sample.ts
··· 1 - export default function sample<T>(array: T[]): T { 2 - return array[Math.floor(Math.random() * array.length)]; 3 - }