Skip to content

Commit

Permalink
Merge pull request #351 from kfbfarley/add-resolution
Browse files Browse the repository at this point in the history
Add resolution feature
  • Loading branch information
NetanelBasal authored Dec 14, 2023
2 parents 8b158f5 + 59a3261 commit b65531d
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Create massive amounts of fake data in the browser and NodeJS. Tree Shakeable &

</p>

&nbsp;202 Functions
&nbsp;203 Functions
&nbsp;Tree Shakable
&nbsp;Fully Typed
&nbsp;Factory Functions
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ title: Getting Started
/>
</p>

&nbsp;202 Functions
&nbsp;203 Functions
&nbsp;Tree Shakable
&nbsp;Fully Typed
&nbsp;Entity Functions
Expand Down
1 change: 1 addition & 0 deletions packages/falso/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export { randRabbit } from './lib/rabbit';
export { rand } from './lib/rand';
export { random, seed } from './lib/random';
export { randRecentDate } from './lib/recent-date';
export { randResolution } from './lib/resolution';
export { randRgb } from './lib/rgb';
export { randRole } from './lib/role';
export { randRoutingNumber } from './lib/routing-number';
Expand Down
116 changes: 116 additions & 0 deletions packages/falso/src/lib/resolution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"data": [
{
"width": "1024",
"height": "768"
},
{
"width": "2048",
"height": "1536"
},
{
"width": "1280",
"height": "800"
},
{
"width": "1920",
"height": "1080"
},
{
"width": "2560",
"height": "1440"
},
{
"width": "3840",
"height": "2160"
},
{
"width": "320",
"height": "480"
},
{
"width": "750",
"height": "1334"
},
{
"width": "1080",
"height": "1920"
},
{
"width": "1280",
"height": "720"
},
{
"width": "1920",
"height": "1080"
},
{
"width": "3840",
"height": "2160"
},
{
"width": "2732",
"height": "2048"
},
{
"width": "2160",
"height": "1620"
},
{
"width": "2560",
"height": "1600"
},
{
"width": "3440",
"height": "1440"
},
{
"width": "5120",
"height": "2880"
},
{
"width": "3840",
"height": "1600"
},
{
"width": "2560",
"height": "1080"
},
{
"width": "4096",
"height": "2160"
},
{
"width": "3840",
"height": "1080"
},
{
"width": "2960",
"height": "1440"
},
{
"width": "3120",
"height": "1440"
},
{
"width": "2560",
"height": "1312"
},
{
"width": "3840",
"height": "1200"
},
{
"width": "3840",
"height": "2160"
},
{
"width": "7680",
"height": "4320"
},
{
"width": "5120",
"height": "2160"
}
]
}
24 changes: 24 additions & 0 deletions packages/falso/src/lib/resolution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FakeOptions, fake } from './core/core';
import { data } from './resolution.json';

/**
* Generate random screen resolution
*
* @category internet
*
* @example
*
* randResolution()
*
* @example
*
* randResolution()
*
*
*/

export function randResolution<Options extends FakeOptions = never>(
options?: Options
) {
return fake(data, options);
}
16 changes: 16 additions & 0 deletions packages/falso/src/tests/resolution.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { randResolution } from '../lib/resolution';

describe('randResolution', () => {
it('should return an object with properties width and height', () => {
const resolution = randResolution();
const width = parseInt(resolution.width);
const height = parseInt(resolution.height);

expect(resolution).toBeTruthy();
expect(typeof resolution).toBe('object');
expect(resolution).toHaveProperty('width');
expect(resolution).toHaveProperty('height');
expect(Number.isInteger(width)).toBe(true);
expect(Number.isInteger(height)).toBe(true);
});
});

0 comments on commit b65531d

Please sign in to comment.