Skip to content

Commit

Permalink
feat(number)!: change int default params (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Dec 17, 2022
1 parent b7dbfac commit 0b2fa1a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/modules/number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class NumberModule {
*
* @param options Maximum value or options object. Defaults to `{}`.
* @param options.min Lower bound for generated number. Defaults to `0`.
* @param options.max Upper bound for generated number. Defaults to `min + 99999`.
* @param options.max Upper bound for generated number. Defaults to `Number.MAX_SAFE_INTEGER`.
*
* @throws When options define `max < min`.
*
Expand All @@ -42,7 +42,7 @@ export class NumberModule {
options = { max: options };
}

const { min = 0, max = min + 99999 } = options;
const { min = 0, max = Number.MAX_SAFE_INTEGER } = options;
const effectiveMin = Math.ceil(min);
const effectiveMax = Math.floor(max);

Expand Down
56 changes: 28 additions & 28 deletions test/__snapshots__/datatype.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ exports[`datatype > 42 > array > noArgs 1`] = `
[
"ky2eiXX/J/",
"&Kq@X.b]\\"&",
72199,
93855,
6503186795855872,
8453731307749376,
"!1}2Z=YQ!I",
"<QYF-%<{C6",
")jZ3DP|XL%",
60754,
17052,
5472277529362432,
1535944771502080,
"'\\"yxzUlD=\\"",
]
`;
Expand All @@ -19,17 +19,17 @@ exports[`datatype > 42 > array > with length 1`] = `
[
"ky2eiXX/J/",
"&Kq@X.b]\\"&",
72199,
93855,
6503186795855872,
8453731307749376,
]
`;
exports[`datatype > 42 > array > with length range 1`] = `
[
95071,
8563273238577152,
"eiXX/J/*&K",
33370,
14286,
3005779955154944,
1286829863075840,
]
`;
Expand Down Expand Up @@ -93,7 +93,7 @@ exports[`datatype > 42 > hexadecimal > with length, prefix, and casing 1`] = `"0
exports[`datatype > 42 > hexadecimal > with prefix 1`] = `"0x8"`;
exports[`datatype > 42 > json 1`] = `"{\\"foo\\":\\"ky2eiXX/J/\\",\\"bar\\":\\"&Kq@X.b]\\\\\\"&\\",\\"bike\\":72199,\\"a\\":93855,\\"b\\":\\"!1}2Z=YQ!I\\",\\"name\\":\\"<QYF-%<{C6\\",\\"prop\\":\\")jZ3DP|XL%\\"}"`;
exports[`datatype > 42 > json 1`] = `"{\\"foo\\":\\"ky2eiXX/J/\\",\\"bar\\":\\"&Kq@X.b]\\\\\\"&\\",\\"bike\\":6503186795855872,\\"a\\":8453731307749376,\\"b\\":\\"!1}2Z=YQ!I\\",\\"name\\":\\"<QYF-%<{C6\\",\\"prop\\":\\")jZ3DP|XL%\\"}"`;

exports[`datatype > 42 > number > noArgs 1`] = `37454`;

Expand Down Expand Up @@ -131,23 +131,23 @@ exports[`datatype > 42 > uuid 5`] = `"d95f4984-24c2-410f-ac63-400d3bbbcc91"`;

exports[`datatype > 1211 > array > noArgs 1`] = `
[
45901,
77826,
4134441414819840,
7010029022478336,
"-}$_/\`4hHA",
"afl\\"h^]dnw",
"<q|p|5KWu3",
"CZ|Jh!E=x\\"",
42131,
15894,
3794869965291520,
1431627091673088,
"V<1bEQuA|p",
"DW9F=V1(U7",
]
`;

exports[`datatype > 1211 > array > with length 1`] = `
[
45901,
77826,
4134441414819840,
7010029022478336,
"-}$_/\`4hHA",
"afl\\"h^]dnw",
]
Expand All @@ -156,9 +156,9 @@ exports[`datatype > 1211 > array > with length 1`] = `
exports[`datatype > 1211 > array > with length range 1`] = `
[
"ti5-}$_/\`4",
42075,
3789861976801280,
"0afl\\"h^]dn",
43503,
3918465303838720,
"q|p|5KWu3/",
]
`;
Expand Down Expand Up @@ -223,7 +223,7 @@ exports[`datatype > 1211 > hexadecimal > with length, prefix, and casing 1`] = `

exports[`datatype > 1211 > hexadecimal > with prefix 1`] = `"0xE"`;

exports[`datatype > 1211 > json 1`] = `"{\\"foo\\":45901,\\"bar\\":77826,\\"bike\\":\\"-}$_/\`4hHA\\",\\"a\\":\\"afl\\\\\\"h^]dnw\\",\\"b\\":\\"<q|p|5KWu3\\",\\"name\\":\\"CZ|Jh!E=x\\\\\\"\\",\\"prop\\":42131}"`;
exports[`datatype > 1211 > json 1`] = `"{\\"foo\\":4134441414819840,\\"bar\\":7010029022478336,\\"bike\\":\\"-}$_/\`4hHA\\",\\"a\\":\\"afl\\\\\\"h^]dnw\\",\\"b\\":\\"<q|p|5KWu3\\",\\"name\\":\\"CZ|Jh!E=x\\\\\\"\\",\\"prop\\":3794869965291520}"`;

exports[`datatype > 1211 > number > noArgs 1`] = `92852`;

Expand Down Expand Up @@ -262,32 +262,32 @@ exports[`datatype > 1211 > uuid 5`] = `"7b91ce88-effb-4d1d-93bb-ad759e00b86c"`;
exports[`datatype > 1337 > array > noArgs 1`] = `
[
"U/4:SK$>6Q",
26194,
2359372120326144,
"{:e=+kD)[B",
"e|/Jqjjj!B",
"GDWQgC2M;q",
40502,
44050,
3648103756333056,
3967686428065792,
".Gm3tRwnZ2",
95735,
42541,
8623125245722624,
3831794621218816,
]
`;
exports[`datatype > 1337 > array > with length 1`] = `
[
"U/4:SK$>6Q",
26194,
2359372120326144,
"{:e=+kD)[B",
"e|/Jqjjj!B",
]
`;
exports[`datatype > 1337 > array > with length range 1`] = `
[
15868,
1429298200182784,
":SK$>6QX9@",
27048,
2436284417048576,
]
`;
Expand Down Expand Up @@ -351,7 +351,7 @@ exports[`datatype > 1337 > hexadecimal > with length, prefix, and casing 1`] = `
exports[`datatype > 1337 > hexadecimal > with prefix 1`] = `"0x5"`;
exports[`datatype > 1337 > json 1`] = `"{\\"foo\\":\\"U/4:SK$>6Q\\",\\"bar\\":26194,\\"bike\\":\\"{:e=+kD)[B\\",\\"a\\":\\"e|/Jqjjj!B\\",\\"b\\":\\"GDWQgC2M;q\\",\\"name\\":40502,\\"prop\\":44050}"`;
exports[`datatype > 1337 > json 1`] = `"{\\"foo\\":\\"U/4:SK$>6Q\\",\\"bar\\":2359372120326144,\\"bike\\":\\"{:e=+kD)[B\\",\\"a\\":\\"e|/Jqjjj!B\\",\\"b\\":\\"GDWQgC2M;q\\",\\"name\\":3648103756333056,\\"prop\\":3967686428065792}"`;
exports[`datatype > 1337 > number > noArgs 1`] = `26202`;
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/helpers.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ exports[`helpers > 42 > slugify > noArgs 1`] = `""`;

exports[`helpers > 42 > slugify > some string 1`] = `"hello-world"`;

exports[`helpers > 42 > unique > with () => number 1`] = `37454`;
exports[`helpers > 42 > unique > with () => number 1`] = `3373557438480384`;

exports[`helpers > 42 > unique > with () => number and args 1`] = `19`;

Expand Down Expand Up @@ -340,7 +340,7 @@ exports[`helpers > 1211 > slugify > noArgs 1`] = `""`;

exports[`helpers > 1211 > slugify > some string 1`] = `"hello-world"`;

exports[`helpers > 1211 > unique > with () => number 1`] = `92852`;
exports[`helpers > 1211 > unique > with () => number 1`] = `8363366036799488`;

exports[`helpers > 1211 > unique > with () => number and args 1`] = `47`;

Expand Down Expand Up @@ -508,7 +508,7 @@ exports[`helpers > 1337 > slugify > noArgs 1`] = `""`;

exports[`helpers > 1337 > slugify > some string 1`] = `"hello-world"`;

exports[`helpers > 1337 > unique > with () => number 1`] = `26202`;
exports[`helpers > 1337 > unique > with () => number 1`] = `2360108468142080`;

exports[`helpers > 1337 > unique > with () => number and args 1`] = `13`;

Expand Down
52 changes: 26 additions & 26 deletions test/__snapshots__/image.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ exports[`image > 42 > avatarGitHub 1`] = `"https://avatars.githubusercontent.com

exports[`image > 42 > avatarLegacy 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/468.jpg"`;

exports[`image > 42 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=79654"`;
exports[`image > 42 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=7174621373661184"`;

exports[`image > 42 > url > with height 1`] = `"https://loremflickr.com/640/128?lock=79654"`;
exports[`image > 42 > url > with height 1`] = `"https://loremflickr.com/640/128?lock=7174621373661184"`;

exports[`image > 42 > url > with width 1`] = `"https://loremflickr.com/128/480?lock=79654"`;
exports[`image > 42 > url > with width 1`] = `"https://loremflickr.com/128/480?lock=7174621373661184"`;

exports[`image > 42 > url > with width and height 1`] = `"https://loremflickr.com/128/128?lock=79654"`;
exports[`image > 42 > url > with width and height 1`] = `"https://loremflickr.com/128/128?lock=7174621373661184"`;

exports[`image > 42 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=3373557438480384"`;

exports[`image > 42 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=3373557438480384"`;

exports[`image > 42 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=3373557438480384"`;

exports[`image > 42 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=3373557438480384"`;

exports[`image > 42 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=3373557438480384"`;

exports[`image > 42 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=37454"`;
exports[`image > 42 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=3373557438480384"`;

exports[`image > 42 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/374/640/480"`;

Expand Down Expand Up @@ -74,17 +74,17 @@ exports[`image > 1211 > url > with width 1`] = `"https://picsum.photos/id/459/12

exports[`image > 1211 > url > with width and height 1`] = `"https://picsum.photos/id/459/128/128"`;

exports[`image > 1211 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=8363366036799488"`;

exports[`image > 1211 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=8363366036799488"`;

exports[`image > 1211 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=8363366036799488"`;

exports[`image > 1211 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=8363366036799488"`;

exports[`image > 1211 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=8363366036799488"`;

exports[`image > 1211 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=92852"`;
exports[`image > 1211 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=8363366036799488"`;

exports[`image > 1211 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/929/640/480"`;

Expand Down Expand Up @@ -126,25 +126,25 @@ exports[`image > 1337 > avatarGitHub 1`] = `"https://avatars.githubusercontent.c

exports[`image > 1337 > avatarLegacy 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/327.jpg"`;

exports[`image > 1337 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=56052"`;
exports[`image > 1337 > url > noArgs 1`] = `"https://loremflickr.com/640/480?lock=5048803172286464"`;

exports[`image > 1337 > url > with height 1`] = `"https://loremflickr.com/640/128?lock=56052"`;
exports[`image > 1337 > url > with height 1`] = `"https://loremflickr.com/640/128?lock=5048803172286464"`;

exports[`image > 1337 > url > with width 1`] = `"https://loremflickr.com/128/480?lock=56052"`;
exports[`image > 1337 > url > with width 1`] = `"https://loremflickr.com/128/480?lock=5048803172286464"`;

exports[`image > 1337 > url > with width and height 1`] = `"https://loremflickr.com/128/128?lock=56052"`;
exports[`image > 1337 > url > with width and height 1`] = `"https://loremflickr.com/128/128?lock=5048803172286464"`;

exports[`image > 1337 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=2360108468142080"`;

exports[`image > 1337 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > with all options 1`] = `"https://loremflickr.com/128/128/cats?lock=2360108468142080"`;

exports[`image > 1337 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > with category 1`] = `"https://loremflickr.com/640/480/cats?lock=2360108468142080"`;

exports[`image > 1337 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > with height 1`] = `"https://loremflickr.com/640/128?lock=2360108468142080"`;

exports[`image > 1337 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > with width 1`] = `"https://loremflickr.com/128/480?lock=2360108468142080"`;

exports[`image > 1337 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=26202"`;
exports[`image > 1337 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=2360108468142080"`;

exports[`image > 1337 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/262/640/480"`;

Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/number.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports[`number > 42 > hex > with options 1`] = `"4"`;

exports[`number > 42 > hex > with value 1`] = `"0"`;

exports[`number > 42 > int > noArgs 1`] = `37454`;
exports[`number > 42 > int > noArgs 1`] = `3373557438480384`;

exports[`number > 42 > int > with options 1`] = `4`;

Expand Down Expand Up @@ -66,7 +66,7 @@ exports[`number > 1211 > hex > with options 1`] = `"a"`;

exports[`number > 1211 > hex > with value 1`] = `"1"`;

exports[`number > 1211 > int > noArgs 1`] = `92852`;
exports[`number > 1211 > int > noArgs 1`] = `8363366036799488`;

exports[`number > 1211 > int > with options 1`] = `10`;

Expand Down Expand Up @@ -102,7 +102,7 @@ exports[`number > 1337 > hex > with options 1`] = `"2"`;

exports[`number > 1337 > hex > with value 1`] = `"0"`;

exports[`number > 1337 > int > noArgs 1`] = `26202`;
exports[`number > 1337 > int > noArgs 1`] = `2360108468142080`;

exports[`number > 1337 > int > with options 1`] = `2`;

Expand Down

0 comments on commit 0b2fa1a

Please sign in to comment.