Skip to content

Commit

Permalink
Merge pull request #7 from brianboyko/release/0.1.3
Browse files Browse the repository at this point in the history
Added SortByProperty
  • Loading branch information
kerryboyko authored Aug 15, 2021
2 parents 4887574 + 0c1b5d4 commit 3b92877
Show file tree
Hide file tree
Showing 64 changed files with 1,379 additions and 1,255 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.1.3] - 2021-15-8

### Added

- /src/collection/sortByProperty.ts - sorts an array of objects by the value of
one of it's properties (provided as a string).

### Changed

- moved version information to VERSION.ts in the root of the project (was
previously in the function that wrote documentation)

### Removed
40 changes: 36 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

## A Typescript-First utility library for Deno

## Getting Started

### Taskfile

To use Taskfile, it's recommended that you alias this to your shell:

```bash
alias deno-task='deno run --allow-run $(git rev-parse --show-toplevel)/Taskfile.ts'
```

Or for Windows PowerShell:

```powershell
Set-Alias -Name deno-task -Value deno run --allow-run ./Taskfile.ts
```

Then you will be able to execute the following from the command line:

- `deno-task docs` -- generates documentation.
- `deno-task fmt` -- formats the files.
- `deno-task test` -- runs the test suite.

Thanks to
[https://dev.to/vonheikemen/a-simple-way-to-replace-npm-scripts-in-deno-4j0g](https://dev.to/vonheikemen/a-simple-way-to-replace-npm-scripts-in-deno-4j0g)
for this idea.

### Using in your library

Just import from deno.land, we'll take care of the rest :)

Current version is "https://deno.land/x/[email protected]/"

### Why yet another utility library?

I'll be honest, I _love_ Lodash in my node projects. Even though I could
Expand All @@ -12,7 +44,7 @@ especially when going from Node to Deno.
Lodash was designed in a EMCA 3 kind of world, where things such as "filter" and
"slice" were not yet part of the official Javascript prototype. Moving forward,
there are a lot of utilities that a utility library can omit. Do we really need
_.last when we can just write arr[arr.length - 1]? Or _.compact when we can just
_.last when we can just write arr[arr.length - 1]? Or_.compact when we can just
write arr.filter(x => !!x)?

Instead of importing Lodash into the new Deno ecosystem, I thought it was a good
Expand Down Expand Up @@ -69,17 +101,17 @@ intersectionBy(Math.floor, [2.1, 1.2], [2.3, 3.2]);
At one point I considered using currying, but as this is a utility library, the
inefficiency of closures in V8 makes a simple function the way to go for now.

## Current High Priority Needs:
## Current High Priority Needs

### Debounce & Throttle

It can be difficult to test Debounce and Throttle, and I'm not 100% sure I got
the implementation right. I'd like another pair of eyes on it if it's possible,
and some more tests.

## Methods:
## Methods

### Currently Supported:
### Currently Supported

- array
- cartesianProduct
Expand Down
1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.3
39 changes: 19 additions & 20 deletions documentation/array/cartesianProduct.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

## cartesianProduct

#### import

```typescript
import cartesianProduct from "https://deno.land/x/[email protected].2/src/array/cartesianProduct.ts"
import cartesianProduct from "https://deno.land/x/[email protected].3/src/array/cartesianProduct.ts";
```

#### signature

```typescript
cartesianProduct = <T, U>(a: T[], b: U[]): [T, U][]
```
Takes two arrays of type T and type U respectively, and creates an array of tuple type [T, U] for every combination of the elements of a and b.
Takes two arrays of type T and type U respectively, and creates an array of
tuple type [T, U] for every combination of the elements of a and b.
#### Source:
Expand All @@ -27,25 +29,22 @@ export const cartesianProduct = <T, U>(a: T[], b: U[]): [T, U][] => {
};

export default cartesianProduct;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("cartesianProduct()", () => {
Rhum.testCase(
"Should calculate the cartesian product of two arrays",
() => {
Rhum.asserts.assertEquals(cartesianProduct(["x", "y"], [1, 2]), [
["x", 1],
["x", 2],
["y", 1],
["y", 2],
]);
},
);
});
Rhum.testSuite("cartesianProduct()", () => {
Rhum.testCase(
"Should calculate the cartesian product of two arrays",
() => {
Rhum.asserts.assertEquals(cartesianProduct(["x", "y"], [1, 2]), [
["x", 1],
["x", 2],
["y", 1],
["y", 2],
]);
},
);
});
```


10 changes: 4 additions & 6 deletions documentation/array/chunk.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

## chunk

#### import

```typescript
import chunk from "https://deno.land/x/[email protected].2/src/array/chunk.ts"
import chunk from "https://deno.land/x/[email protected].3/src/array/chunk.ts";
```

#### signature

```typescript
chunk = <T>(arr: T[], size: number = 1): T[][]
```
Expand All @@ -28,10 +29,9 @@ export const chunk = <T>(arr: T[], size = 1): T[][] => {
};

export default chunk;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("chunk()", () => {
Expand Down Expand Up @@ -70,5 +70,3 @@ Rhum.testSuite("chunk()", () => {
});
});
```


14 changes: 7 additions & 7 deletions documentation/array/chunkIntoParts.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@

## chunkIntoParts

#### import

```typescript
import chunkIntoParts from "https://deno.land/x/[email protected].2/src/array/chunkIntoParts.ts"
import chunkIntoParts from "https://deno.land/x/[email protected].3/src/array/chunkIntoParts.ts";
```

#### signature

```typescript
chunkIntoParts = <T>(arr: T[], parts = 1): T[][]
```
Takes an array (arr) and splits it into multiple parts (parts) of equal size. For example: an array of length 10 split into 3 parts would be split into 4, 4, and 2 parts
Takes an array (arr) and splits it into multiple parts (parts) of equal size.
For example: an array of length 10 split into 3 parts would be split into 4, 4,
and 2 parts
#### Source:
Expand All @@ -24,10 +27,9 @@ export const chunkIntoParts = <T>(arr: T[], parts = 1): T[][] => {
};

export default chunkIntoParts;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("chunkIntoParts()", () => {
Expand Down Expand Up @@ -89,5 +91,3 @@ Rhum.testSuite("chunkIntoParts()", () => {
});
});
```


13 changes: 6 additions & 7 deletions documentation/array/difference.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

## difference

#### import

```typescript
import difference from "https://deno.land/x/[email protected].2/src/array/difference.ts"
import difference from "https://deno.land/x/[email protected].3/src/array/difference.ts";
```

#### signature

```typescript
difference = <T>(a: T[], b: T[]): T[]
```
Takes two arrays (a, b) and returns an array of elements in a that do not exist in b
Takes two arrays (a, b) and returns an array of elements in a that do not exist
in b
#### Source:
Expand All @@ -23,10 +25,9 @@ export const difference = <T>(a: T[], b: T[]): T[] =>
differenceBy(identity, a, b);

export default difference;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("difference()", () => {
Expand All @@ -37,5 +38,3 @@ Rhum.testSuite("difference()", () => {
});
});
```


15 changes: 8 additions & 7 deletions documentation/array/differenceBy.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@

## differenceBy

#### import

```typescript
import differenceBy from "https://deno.land/x/[email protected].2/src/array/differenceBy.ts"
import differenceBy from "https://deno.land/x/[email protected].3/src/array/differenceBy.ts";
```

#### signature

```typescript
differenceBy = <T>(iteratee: Iteratee<T, any>, a: T[], b: T[]): T[]
```
Takes two arrays (a, b) and an iteratee. It returns an array of elements in a where the return of iteratee(a) does not equal any return of the map of b over iteratee. In other words, after running the function on both, remove any elements where iteratee(a) matches any iteratee(b)
Takes two arrays (a, b) and an iteratee. It returns an array of elements in a
where the return of iteratee(a) does not equal any return of the map of b over
iteratee. In other words, after running the function on both, remove any
elements where iteratee(a) matches any iteratee(b)
#### Source:
Expand All @@ -34,10 +38,9 @@ export const differenceBy = <T>(
};

export default differenceBy;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("differenceBy()", () => {
Expand All @@ -48,5 +51,3 @@ Rhum.testSuite("differenceBy()", () => {
});
});
```


14 changes: 7 additions & 7 deletions documentation/array/differenceWith.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

## differenceWith

#### import

```typescript
import differenceWith from "https://deno.land/x/[email protected].2/src/array/differenceWith.ts"
import differenceWith from "https://deno.land/x/[email protected].3/src/array/differenceWith.ts";
```

#### signature

```typescript
differenceWith = <T>(
comparator: Comparator<T>,
Expand All @@ -15,7 +16,9 @@ differenceWith = <T>(
)
```

Takes two arrays (a, b) and a comparator (which will return a boolean). It returns an array of elements in a where no element in b returns true for comparator(elemA, elemB)
Takes two arrays (a, b) and a comparator (which will return a boolean). It
returns an array of elements in a where no element in b returns true for
comparator(elemA, elemB)

#### Source:

Expand All @@ -37,10 +40,9 @@ export const differenceWith = <T>(
};

export default differenceWith;

```

#### Test Examples:
#### Test Examples:

```typescript
Rhum.testSuite("differenceWith()", () => {
Expand Down Expand Up @@ -69,5 +71,3 @@ Rhum.testSuite("differenceWith()", () => {
});
});
```


Loading

0 comments on commit 3b92877

Please sign in to comment.