File tree Expand file tree Collapse file tree 3 files changed +26
-15
lines changed
Expand file tree Collapse file tree 3 files changed +26
-15
lines changed Original file line number Diff line number Diff line change 1+ [
2+ " Chrome" ,
3+ " Edge" ,
4+ " Firefox" ,
5+ " Internet Explorer" ,
6+ " Safari" ,
7+ " Opera" ,
8+ " Yandex" ,
9+ " Chromium" ,
10+ " Vivaldi" ,
11+ " Baidu" ,
12+ " Brave" ,
13+ ]
Original file line number Diff line number Diff line change 1+ import path from 'node:path' ;
2+ import fs from 'node:fs' ;
3+ import { loadJsonFileSync } from 'load-json-file' ;
4+
15export default function browser ( ) {
2- const browsers = [
3- 'Chrome' ,
4- 'Edge' ,
5- 'Firefox' ,
6- 'Internet Explorer' ,
7- 'Safari' ,
8- 'Opera' ,
9- 'Yandex' ,
10- 'Chromium' ,
11- 'Vivaldi' ,
12- 'Baidu' ,
13- 'Brave' ,
14- ] ;
6+ const filePath = `./browsers.json` ;
7+ let browsers = [ ] ;
8+ browsers = fs . existsSync ( path . resolve ( filePath ) ) ? loadJsonFileSync ( filePath ) : loadJsonFileSync ( path . resolve ( 'node_modules/@fakerjs/browser/' , filePath ) ) ;
159 return browsers [ Math . floor ( Math . random ( ) * browsers . length ) ] ;
1610}
Original file line number Diff line number Diff line change 11{
22 "name" : " @fakerjs/browser" ,
3- "version" : " 1.0 .0" ,
3+ "version" : " 1.1 .0" ,
44 "description" : " Browser package provides functionality to generate a fake browser value." ,
55 "license" : " MIT" ,
66 "repository" : " faker-javascript/browser" ,
1717 "scripts" : {
1818 "test" : " c8 ava; xo --space 4; tsd;"
1919 },
20+ "dependencies" : {
21+ "load-json-file" : " ^7.0.1"
22+ },
2023 "devDependencies" : {
2124 "ava" : " ^4.0.0" ,
2225 "c8" : " ^7.11.0" ,
2528 },
2629 "files" : [
2730 " index.js" ,
28- " index.d.ts"
31+ " index.d.ts" ,
32+ " browsers.json"
2933 ],
3034 "keywords" : [
3135 " fakerjs" ,
You can’t perform that action at this time.
0 commit comments