Skip to content

Commit

Permalink
add and (equally alias) and or (neither alias), update readme, done #4,…
Browse files Browse the repository at this point in the history
… done #5
  • Loading branch information
icmx committed Mar 10, 2022
1 parent 2793333 commit 8d31d62
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ Tiny collection of essential JavaScript utilities.

## Usage

Install:

```
npm install nukit
npm i nukit
```

Import:

```ts
import { isNumber, oneOf, pick } from 'nukit';

Expand All @@ -21,7 +25,7 @@ const value = pick(['apple', 'banana', 'carrot']);
## Why?

- TypeScript — nice types support
- Small & Simple — only 34 functions in 5 kilobytes of compiled code
- Small & Simple — 28 essential functions with 10 shortcuts in about 5 kilobytes of compiled code
- Modern — it doesn't rewrites ESNext features that already exists

## Contents
Expand All @@ -40,7 +44,9 @@ const value = pick(['apple', 'banana', 'carrot']);
- [**allOf**](src/filters/allOf/index.ts) — returns true if all values in array meets filter condition
- [**oneOf**](src/filters/oneOf/index.ts) — returns true if at least one of values in array meets filter condition
- [**equally**](src/filters/equally/index.ts) — returns true if all of predicates are true
- [**and**](src/filters/and/index.ts) — alias
- [**neither**](src/filters/neither/index.ts) — returns true if at least one of predicates is true
- [**or**](src/filters/or/index.ts) — alias

### Mappers

Expand Down
6 changes: 6 additions & 0 deletions src/filters/and/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { equally } from '../equally';

/**
* Returns true if all of predicates are true. Alias to **equally**.
*/
export const and = equally;
2 changes: 2 additions & 0 deletions src/filters/equally/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { resolvePredicate } from '../../utils/resolvePredicate';

/**
* Returns true if all of predicates are true.
*
* **and** — alias.
*/
export const equally = (...predicates: Predicate[]): boolean => {
for (let i = 0; i < predicates.length; i++) {
Expand Down
2 changes: 2 additions & 0 deletions src/filters/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './allOf';
export * from './and';
export * from './equally';
export * from './isArray';
export * from './isBoolean';
Expand All @@ -11,3 +12,4 @@ export * from './isString';
export * from './isUndefined';
export * from './neither';
export * from './oneOf';
export * from './or';
2 changes: 2 additions & 0 deletions src/filters/neither/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { resolvePredicate } from '../../utils/resolvePredicate';

/**
* Returns true if at least one of predicates is true.
*
* **or** — alias
*/
export const neither = (...predicates: Predicate[]): boolean => {
for (let i = 0; i < predicates.length; i++) {
Expand Down
7 changes: 7 additions & 0 deletions src/filters/or/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { neither } from '../neither';

/**
* Returns true if at least one of predicates is true. Alias to
* **neither**.
*/
export const or = neither;

0 comments on commit 8d31d62

Please sign in to comment.