Skip to content

Commit 75c2cba

Browse files
authored
Merge pull request #5 from joaopalmeiro/fix-jp-fix-typos
fix(docs): fix typos and bad syntax in comments and documentation pages
2 parents 8adf498 + 59d41c7 commit 75c2cba

27 files changed

Lines changed: 59 additions & 42 deletions

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ series [How to Contribute to an Open Source Project on GitHub][egghead]
1515
> pull requests from branches on your fork. To do this, run:
1616
>
1717
> ```
18-
> git remote add upstream https://github.com/@feedzai/js-utilities
18+
> git remote add upstream https://github.com/feedzai/js-utilities
1919
> git fetch upstream
20-
> git branch --set-upstream-to=upstream/master master
20+
> git branch --set-upstream-to=upstream/main main
2121
> ```
2222
>
2323
> This will add the original repository as a "remote" called "upstream," Then
2424
> fetch the git information from that remote, then set your local `main`
25-
> branch to use the upstream master branch whenever you run `git pull`. Then you
25+
> branch to use the upstream main branch whenever you run `git pull`. Then you
2626
> can make all of your pull request branches based on this `main` branch.
2727
> Whenever you want to update your version of `main`, do a regular `git pull`.
2828
@@ -40,5 +40,5 @@ requests! Thanks!
4040
4141
<!-- prettier-ignore-start -->
4242
[egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
43-
[issues]: https://github.com/@feedzai/js-utilities/issues
43+
[issues]: https://github.com/feedzai/js-utilities/issues
4444
<!-- prettier-ignore-end -->

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ It also comes with comprehensive documentation, making it a breeze to navigate a
3131

3232
The package is available in both CommonJS and ES Modules formats so, whether you're working in a traditional environment or embracing the latest ES Modules, we have you covered.
3333

34-
For JavaScript and TypeScript developers seeking a lightweight but robust toolkit that balances simplicity with utility, `@feedzai/js-utilities` might jus be the answer!
34+
For JavaScript and TypeScript developers seeking a lightweight but robust toolkit that balances simplicity with utility, `@feedzai/js-utilities` might just be the answer!
3535

3636
## Table of Contents
3737

@@ -168,6 +168,7 @@ import * as JS_UTILS from "@feedzai/js-utilities";
168168

169169
| Name | Source |
170170
| ------------------ | ------------------------------------------------------------------------------------------------------- |
171+
| formatDate | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/dates/format-date.ts) |
171172
| getBrowserTimezone | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/dates/get-browser-timezone.ts) |
172173

173174
### Events
@@ -252,6 +253,7 @@ import * as JS_UTILS from "@feedzai/js-utilities";
252253
| ------------------ | -------------------------------------------------------------------------------------------------------- |
253254
| callIfExists | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/utilities/call-if-exists.ts) |
254255
| emptyFunction | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/utilities/empty-function.ts) |
256+
| generateUUID | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/utilities/generate-uuid.ts) |
255257
| makeCancelable | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/utilities/make-cancelable.ts) |
256258
| throwError | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/utilities/throw-error.ts) |
257259
| HTTP StatusCodes | [source](https://github.com/feedzai/js-utilities/blob/main/src/functions/constants/http-status-codes.ts) |
@@ -271,6 +273,8 @@ import * as JS_UTILS from "@feedzai/js-utilities";
271273
| useConstant | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-constant.ts) |
272274
| useCopyToClipboard | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-copy-to-clipboard.ts) |
273275
| useEffectOnce | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-effect-once.ts) |
276+
| useEnsuredForwardedRef | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-ensured-forwarded-ref.ts) |
277+
| useIntersection | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-intersection.ts) |
274278
| useLifecycle | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-lifecycle.ts) |
275279
| useLiveRef | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-live-ref.ts) |
276280
| useMergeRefs | [source](https://github.com/feedzai/js-utilities/tree/main/src/hooks/use-merge-refs.ts) |
@@ -288,13 +292,13 @@ To run tests locally:
288292

289293
```
290294
# using npm
291-
npm run test:open
295+
npm run test:unit
292296
293297
# using npm (headless)
294298
npm run test
295299
296300
# using yarn
297-
yarn test:open
301+
yarn test:unit
298302
299303
# using yarn (headless)
300304
yarn test

cypress/test/functions/array.cy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ describe("flatten", () => {
265265
const result = _.flatten(array);
266266
expect(result).to.deep.equal([]);
267267
});
268+
269+
it("should fully flatten when level exceeds the nesting depth", () => {
270+
const array = [1, [2, [3, [4]], 5]];
271+
const result = _.flatten(array, 5);
272+
expect(result).to.deep.equal([1, 2, 3, 4, 5]);
273+
});
268274
});
269275

270276
describe("find", () => {

cypress/test/functions/typed.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ describe("isObject", () => {
126126
it("should return false for a new String('')", () => {
127127
expect(_.isObject(new String(""))).to.be.false;
128128
});
129+
130+
it("should return false for an array", () => {
131+
expect(_.isObject([1, 2, 3])).to.be.false;
132+
});
133+
134+
it("should return false for an arrow function", () => {
135+
expect(_.isObject(() => {})).to.be.false;
136+
});
129137
});
130138

131139
describe("isPlainObject", () => {

docs/docs/functions/arbitrarily/draw.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This helper can also be useful for using inside tests where - given a list of po
88
## API
99

1010
```typescript
11-
function random(lower?: number, upper?: number | boolean, floating?: boolean): number;
11+
function draw<T>(array: readonly T[]): T | null;
1212
```
1313

1414
### Usage

docs/docs/functions/arrays/flatten.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ const array = [1, [2, [3, [4]], 5]]
1919
flatten(array, true)
2020
// => [1, 2, 3, 4, 5]
2121

22-
flattenDepth(array, 1)
22+
flatten(array, 1)
2323
// => [1, 2, [3, [4]], 5]
2424

25-
flattenDepth(array, 2)
25+
flatten(array, 2)
2626
// => [1, 2, 3, [4], 5]
2727

28-
flatten(array, 5]])
29-
// => [1, 2, [3, [4]], 5]
30-
28+
flatten(array, 5)
29+
// => [1, 2, 3, 4, 5]
3130
```

docs/docs/functions/arrays/remove-index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const DATA = [
2323
"Maggie"
2424
];
2525

26-
const SORTED = removeIndex(1);
26+
const RESULT = removeIndex(DATA, 1);
2727

28-
console.log(SORTED) // ["Homer","Lisa","Bart","Maggie"];
28+
console.log(RESULT) // ["Homer","Lisa","Bart","Maggie"];
2929
```

docs/docs/functions/arrays/remove-item.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const DATA = [
2222
"Maggie"
2323
];
2424

25-
const SORTED = removeItem("Marge");
25+
const RESULT = removeItem(DATA, "Marge");
2626

27-
console.log(SORTED) // ["Homer","Lisa","Bart","Maggie"];
27+
console.log(RESULT) // ["Homer","Lisa","Bart","Maggie"];
2828
```

docs/docs/functions/objects/get.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ get(complexObject, 'a[0].bar.c')
2525
// => 3
2626

2727
get(complexObject, ['a', '0', 'bar', 'c'])
28-
// => 2
28+
// => 3
2929

3030
get(simpleObject, 'a.bar.c', 'default')
3131
// => 'default'

docs/docs/functions/objects/is-equal.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function isEqual<TType>(x: TType, y: TType): boolean;
1212
### Usage
1313

1414
```typescript
15-
import { has } from '@feedzai/js-utilities';
15+
import { isEqual } from '@feedzai/js-utilities';
1616

1717
isEqual(null, null)
1818
// => true

0 commit comments

Comments
 (0)