-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# deverything | ||
|
||
## 0.32.0 | ||
|
||
### Minor Changes | ||
|
||
- scrambler | ||
|
||
## 0.31.0 | ||
|
||
### Minor Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { expect, test } from "@jest/globals"; | ||
import { scrambleText } from "./scrambleText"; | ||
|
||
test("scrambleText", async () => { | ||
const string = "Hello World, \n how are we?"; | ||
const scrambled = scrambleText(string); | ||
expect(scrambled).toHaveLength(26); | ||
expect(scrambled).not.toBe(string); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { randomChar } from "../random/randomChar"; | ||
import { letterRegex } from "../regex/letterRegex"; | ||
|
||
export const scrambleText = (str: string): string => { | ||
return str.replace(letterRegex, () => { | ||
return randomChar(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { randomInt } from "./randomInt"; | ||
|
||
export const randomChar = () => { | ||
return String.fromCharCode(randomInt(97, 122)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { SPECIAL_CHARACTERS } from "../constants/unicode"; | ||
import { randomArrayItem } from "./randomArrayItem"; | ||
import { randomHtmlColorName } from "./randomHtmlColorName"; | ||
import { randomInt } from "./randomInt"; | ||
import { randomString } from "./randomString"; | ||
|
||
export const randomPassword = ({ minChars = 9 }: { minChars?: number } = {}) => | ||
randomHtmlColorName().padEnd(minChars, "-") + // So it has an upper case, at least 9 charss | ||
randomArrayItem(SPECIAL_CHARACTERS) + // So it has a special character | ||
randomInt(11, 99); // So it has a number | ||
export const randomPassword = ({ | ||
minChars = 9, | ||
maxChars = 32, | ||
}: { minChars?: number; maxChars?: number } = {}) => | ||
randomString({ length: 1 }).toUpperCase() + // Upper case | ||
randomString({ length: randomInt(minChars, maxChars) - 3 }) + // At least 9 chars | ||
randomArrayItem(SPECIAL_CHARACTERS) + // Special character | ||
randomInt(1, 9); // Number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { describe, it, expect } from "@jest/globals"; | ||
import { randomString } from "./randomString"; | ||
|
||
describe(`randomString`, () => { | ||
it(`no args`, () => { | ||
expect(randomString().length).toBe(10); | ||
expect(randomString({ length: 19 }).length).toBe(19); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { array } from "../helpers"; | ||
import { randomChar } from "./randomChar"; | ||
|
||
export const randomString = ({ | ||
length = 10, | ||
}: { | ||
length?: number; | ||
} = {}) => { | ||
return array(length, () => randomChar()).join(""); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const letterRegex = new RegExp(/\p{L}/, "gu"); |