Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🔥 First punt at priority option #223

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6160c3c
feat: 🔥 First punt at priority option
Mar 16, 2022
485782e
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
theryansmee Mar 22, 2022
6b57aa0
feat: 🔥 Clean up fakFromArray logic
theryansmee Mar 22, 2022
713c77d
feat: 🔥 Replace use of random index logic with getRandomInRange
theryansmee Mar 22, 2022
bbe7b0b
feat: 🔥 Revert rand element logic for now
theryansmee Mar 22, 2022
7f69bad
feat: 🔥 Allow devs to pass in comparison functions
theryansmee Mar 23, 2022
77831a5
feat: 🔥 Add custom comparison functions non-conforming function
theryansmee Mar 23, 2022
96acb7e
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
theryansmee Mar 24, 2022
af09284
feat: 🔥 Add json check unique function. Clean up code
theryansmee Mar 24, 2022
6833592
feat: 🔥 Add generic comparison function
Apr 1, 2022
13998f6
feat: 🔥 Replace duplicate checkUnique logic with objectIsUnique
Apr 4, 2022
717bb7d
feat: 🔥 Fix function name. Update file name
Apr 4, 2022
660f53a
test: 🥳 Move error to snapshot
Apr 4, 2022
b18c227
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
Apr 5, 2022
42a54d4
feat: 🔥 Fix snapshot
Apr 5, 2022
0ec65be
feat: 🔥 Move snapshots folder to tests/ route
Apr 5, 2022
ff6980a
feat: 🔥 Clean up core file
Apr 5, 2022
d57bd25
feat: 🔥 Add missing priority doc comment
Apr 5, 2022
fc5f8fc
test: 🥳 Replace flakey regex
Apr 5, 2022
67c4f5f
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
Apr 19, 2022
2b84b1a
feat: 🔥 return empty array if length is 0
Apr 19, 2022
d4d1fa3
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
May 3, 2022
32b84de
feat: 🔥 clean up unique validators
May 3, 2022
6f7dcc6
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
May 6, 2022
2d0aecc
feat: 🔥 Add tests for unique validators
May 6, 2022
dbddca3
feat: 🔥 Fix reversed logic and corresponding tests
May 6, 2022
2331772
feat: 🔥 Combine uniqueComparer and comparisonKeys into config
May 10, 2022
b54d6b2
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
May 10, 2022
39e7fa5
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
May 12, 2022
e29cc7f
feat: 🔥 Simplify priority documentation comment
May 12, 2022
641a875
feat: 🔥 Tweak documentation comment to be priority specific
May 12, 2022
c48790a
feat: 🔥 Revert package.lock
May 12, 2022
f29cca6
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
May 23, 2022
e7dac07
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
Jun 13, 2022
77edc54
feat: 🔥 Fix merge conflicts in core
Jun 13, 2022
fee5cf6
Merge remote-tracking branch 'origin/main' into feat/220-unique-values
Sep 12, 2022
23f628e
fix: 🐞 Fix outdated tests
Sep 12, 2022
e2fb265
refactor: 💡 Remove commented out code
Sep 12, 2022
086ec7b
test: 🥳 Add basic tests for core fake function
Sep 12, 2022
2e5b650
refactor: 💡 Code review changes
Sep 18, 2022
10cd7d0
refactor: 💡 Code review changes
Sep 18, 2022
274fdc9
refactor: 💡 Change request changes
Sep 18, 2022
1143091
refactor: 💡 Code review changes
Sep 18, 2022
2a037d0
Update packages/falso/src/lib/core/core.ts
theryansmee Sep 19, 2022
8869b35
refactor: 💡 Code review changes
Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/falso/src/lib/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function fakeFromArray<T, Options extends FakeOptions>(
const newArray: T[] = [];

while (clonedData.length && newArray.length !== options.length) {
const randomIndex = getRandomInRange({ max: clonedData.length - 1 });
theryansmee marked this conversation as resolved.
Show resolved Hide resolved
const randomIndex = Math.floor(random() * clonedData.length);
const item = clonedData[randomIndex];

newArray.push(item);
Expand All @@ -85,8 +85,7 @@ export function fakeFromArray<T, Options extends FakeOptions>(
}

export function randElement<T>(arr: T[]): T {
shaharkazaz marked this conversation as resolved.
Show resolved Hide resolved
const randomIndex = getRandomInRange({ max: arr.length - 1 });
return arr[randomIndex];
return arr[Math.floor(random() * arr.length)];
}

export interface RandomInRangeOptions {
Expand Down