Skip to content

Commit 83d0878

Browse files
committed
fix: hasEmpty method
1 parent 30d9a91 commit 83d0878

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@ jobs:
2424
cache: "yarn"
2525

2626
- run: yarn install --frozen-lockfile
27-
- run: yarn format-check
28-
- run: yarn test-cov
29-
- run: yarn build
27+
- run: yarn ci

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
coverage/

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "array-utils-ts",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"author": "Vlad Pronsky <[email protected]>",
66
"repository": "vladkens/array-utils-ts",
77
"description": "",
@@ -12,11 +12,11 @@
1212
],
1313
"scripts": {
1414
"build": "rm -rf dist && pkgroll --minify && ls -lah dist",
15-
"test": "uvu -r tsm tests/",
15+
"test": "uvu -r tsm src '\\.test\\.ts$'",
1616
"test-cov": "c8 --include=src yarn test",
1717
"test-watch": "watchexec -e ts 'clear && yarn test'",
18-
"format": "prettier --write '{src,tests}/**/*.{js,jsx,ts,tsx}'",
19-
"format-check": "prettier --check '{src,tests}/**/*.{js,jsx,ts,tsx}'"
18+
"format": "prettier --write .",
19+
"ci": "yarn test-cov && yarn build"
2020
},
2121
"dependencies": {},
2222
"devDependencies": {

tests/main.test.ts renamed to src/main.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from "uvu"
22
import { equal } from "uvu/assert"
3-
import { filterEmpty, filterNullable, isUniq } from "../src/main"
3+
import { filterEmpty, filterNullable, hasEmpty, isUniq } from "./main"
44

55
test("filterNullable", () => {
66
equal(filterNullable([1, 2, 3]), [1, 2, 3])
@@ -62,4 +62,12 @@ test("isUniq", () => {
6262
equal(isUniq([a, a]), false)
6363
})
6464

65+
test("hasEmpty", () => {
66+
equal(hasEmpty([1, 2, 3]), false)
67+
equal(hasEmpty(["a", "b"]), false)
68+
equal(hasEmpty(["a", "b", ""]), true)
69+
equal(hasEmpty(["a", "b", null]), true)
70+
equal(hasEmpty(["a", "b", undefined]), true)
71+
})
72+
6573
test.run()

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const isUniq = <T>(arr: T[]): boolean => {
1919
}
2020

2121
export const hasEmpty = <T>(arr: T[]): boolean => {
22-
return arr.every((el) => el !== null && el !== undefined && el !== "")
22+
return !arr.every((el) => el !== null && el !== undefined && el !== "")
2323
}
2424

2525
export const toggleItem = <T>(arr: T[], item: T): T[] => {

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@
229229
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
230230
integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==
231231

232-
"@types/punycode@^2.1.0":
233-
version "2.1.0"
234-
resolved "https://registry.yarnpkg.com/@types/punycode/-/punycode-2.1.0.tgz#89e4f3d09b3f92e87a80505af19be7e0c31d4e83"
235-
integrity sha512-PG5aLpW6PJOeV2fHRslP4IOMWn+G+Uq8CfnyJ+PDS8ndCbU+soO+fB3NKCKo0p/Jh2Y4aPaiQZsrOXFdzpcA6g==
236-
237232
238233
version "1.20.2"
239234
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975"
@@ -796,11 +791,6 @@ prettier@^2.8.8:
796791
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
797792
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
798793

799-
punycode@^2.3.0:
800-
version "2.3.0"
801-
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
802-
integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==
803-
804794
require-directory@^2.1.1:
805795
version "2.1.1"
806796
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"

0 commit comments

Comments
 (0)