Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: clone, compare2Objects, decimal2Binary and isTruthyFalsy #96 an…
…d organize functions
- Loading branch information
1 parent
d4b1b1f
commit 00440d4
Showing
18 changed files
with
230 additions
and
56 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
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
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,23 @@ | ||
import { FIFO } from "./FIFO"; | ||
import { LIFO } from "./LIFO"; | ||
|
||
import { stringToCamelCase, camelCaseToNormal } from "./camelCase.js"; | ||
import { stringToCapitalize, capitalizeToNormal } from "./capitalizeCase.js"; | ||
import { stringToKebabCase, kebabCaseToNormal } from "./kebabCase.js"; | ||
import { stringToScreamingSnakeCase, screamingSnakeCaseToNormal, screamingSnakeCaseToNormalDeprecated } from "./screamingSnakeCase.js"; | ||
import { stringToSnakeCase, snakeCaseToNormal } from "./snakeCase.js"; | ||
|
||
/** | ||
* Deprecated functions/class | ||
* @namespace Deprecated | ||
*/ | ||
export { | ||
FIFO, | ||
LIFO, | ||
|
||
stringToCamelCase, camelCaseToNormal, | ||
stringToCapitalize, capitalizeToNormal, | ||
stringToKebabCase, kebabCaseToNormal, | ||
stringToScreamingSnakeCase, screamingSnakeCaseToNormal, screamingSnakeCaseToNormalDeprecated, | ||
stringToSnakeCase, snakeCaseToNormal, | ||
}; |
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
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
/** | ||
* Invert all letters from a given text | ||
* | ||
* @example reverseString("beep"); // peeb | ||
* @example reverseString("Beep"); // peeB | ||
* @example reverseString("Beep Boop"); // pooB peeB | ||
* @example reverseString("beep boop 1 20"); // 02 1 poob peeb | ||
* | ||
* @param {string} str - the text to transform | ||
* @returns {string} | ||
*/ | ||
export function reverseString(str) { return str.split("").reverse().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,33 @@ | ||
import { clone } from "../src/index"; | ||
|
||
describe("clone.js", () => { | ||
it("should return a new object with the same properties", () => { | ||
expect(clone({})).toEqual({}); | ||
|
||
const mockObject1 = { one: 1 }; | ||
expect(clone(mockObject1)).not.toBe(mockObject1); | ||
expect(clone(mockObject1)).toEqual(mockObject1); | ||
|
||
const mockObject2 = { one: 1, arr: ["A", "B"] }; | ||
expect(clone(mockObject2)).toEqual(mockObject2); | ||
}); | ||
|
||
it("should return a new array with the same values", () => { | ||
expect(clone([])).toEqual([]); | ||
|
||
const mockArr1 = [1, 2]; | ||
expect(clone(mockArr1)).not.toBe(mockArr1); | ||
expect(clone(mockArr1)).toContain(1); | ||
expect(clone(mockArr1)).toEqual(mockArr1); | ||
|
||
const mockArr2 = ["A", { one: 1 }, { b: 2 }]; | ||
expect(clone(mockArr2)).toContain("A"); | ||
expect(clone(mockArr2)).toEqual(mockArr2); | ||
}); | ||
|
||
it("should return the same given value for non object args", () => { | ||
expect(clone(1)).toBe(1); | ||
expect(clone("B")).toBe("B"); | ||
expect(clone(true)).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.