Skip to content

Commit

Permalink
fix: hasEmpty method
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Jul 6, 2023
1 parent 30d9a91 commit 83d0878
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ jobs:
cache: "yarn"

- run: yarn install --frozen-lockfile
- run: yarn format-check
- run: yarn test-cov
- run: yarn build
- run: yarn ci
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
coverage/
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "array-utils-ts",
"version": "0.1.0",
"version": "0.1.1",
"author": "Vlad Pronsky <v.pronsky@gmail.com>",
"repository": "vladkens/array-utils-ts",
"description": "",
Expand All @@ -12,11 +12,11 @@
],
"scripts": {
"build": "rm -rf dist && pkgroll --minify && ls -lah dist",
"test": "uvu -r tsm tests/",
"test": "uvu -r tsm src '\\.test\\.ts$'",
"test-cov": "c8 --include=src yarn test",
"test-watch": "watchexec -e ts 'clear && yarn test'",
"format": "prettier --write '{src,tests}/**/*.{js,jsx,ts,tsx}'",
"format-check": "prettier --check '{src,tests}/**/*.{js,jsx,ts,tsx}'"
"format": "prettier --write .",
"ci": "yarn test-cov && yarn build"
},
"dependencies": {},
"devDependencies": {
Expand Down
10 changes: 9 additions & 1 deletion tests/main.test.ts → src/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test } from "uvu"
import { equal } from "uvu/assert"
import { filterEmpty, filterNullable, isUniq } from "../src/main"
import { filterEmpty, filterNullable, hasEmpty, isUniq } from "./main"

test("filterNullable", () => {
equal(filterNullable([1, 2, 3]), [1, 2, 3])
Expand Down Expand Up @@ -62,4 +62,12 @@ test("isUniq", () => {
equal(isUniq([a, a]), false)
})

test("hasEmpty", () => {
equal(hasEmpty([1, 2, 3]), false)
equal(hasEmpty(["a", "b"]), false)
equal(hasEmpty(["a", "b", ""]), true)
equal(hasEmpty(["a", "b", null]), true)
equal(hasEmpty(["a", "b", undefined]), true)
})

test.run()
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const isUniq = <T>(arr: T[]): boolean => {
}

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

export const toggleItem = <T>(arr: T[], item: T): T[] => {
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==

"@types/punycode@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@types/punycode/-/punycode-2.1.0.tgz#89e4f3d09b3f92e87a80505af19be7e0c31d4e83"
integrity sha512-PG5aLpW6PJOeV2fHRslP4IOMWn+G+Uq8CfnyJ+PDS8ndCbU+soO+fB3NKCKo0p/Jh2Y4aPaiQZsrOXFdzpcA6g==

"@types/resolve@1.20.2":
version "1.20.2"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.20.2.tgz#97d26e00cd4a0423b4af620abecf3e6f442b7975"
Expand Down Expand Up @@ -796,11 +791,6 @@ prettier@^2.8.8:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

punycode@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
Expand Down

0 comments on commit 83d0878

Please sign in to comment.