-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Boyko
committed
Aug 15, 2021
1 parent
4887574
commit 0c1b5d4
Showing
64 changed files
with
1,379 additions
and
1,255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -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], | ||
]); | ||
}, | ||
); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[][] | ||
``` | ||
|
@@ -28,10 +29,9 @@ export const chunk = <T>(arr: T[], size = 1): T[][] => { | |
}; | ||
|
||
export default chunk; | ||
|
||
``` | ||
|
||
#### Test Examples: | ||
#### Test Examples: | ||
|
||
```typescript | ||
Rhum.testSuite("chunk()", () => { | ||
|
@@ -70,5 +70,3 @@ Rhum.testSuite("chunk()", () => { | |
}); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -24,10 +27,9 @@ export const chunkIntoParts = <T>(arr: T[], parts = 1): T[][] => { | |
}; | ||
|
||
export default chunkIntoParts; | ||
|
||
``` | ||
|
||
#### Test Examples: | ||
#### Test Examples: | ||
|
||
```typescript | ||
Rhum.testSuite("chunkIntoParts()", () => { | ||
|
@@ -89,5 +91,3 @@ Rhum.testSuite("chunkIntoParts()", () => { | |
}); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -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()", () => { | ||
|
@@ -37,5 +38,3 @@ Rhum.testSuite("difference()", () => { | |
}); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -34,10 +38,9 @@ export const differenceBy = <T>( | |
}; | ||
|
||
export default differenceBy; | ||
|
||
``` | ||
|
||
#### Test Examples: | ||
#### Test Examples: | ||
|
||
```typescript | ||
Rhum.testSuite("differenceBy()", () => { | ||
|
@@ -48,5 +51,3 @@ Rhum.testSuite("differenceBy()", () => { | |
}); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, | ||
|
@@ -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: | ||
|
||
|
@@ -37,10 +40,9 @@ export const differenceWith = <T>( | |
}; | ||
|
||
export default differenceWith; | ||
|
||
``` | ||
|
||
#### Test Examples: | ||
#### Test Examples: | ||
|
||
```typescript | ||
Rhum.testSuite("differenceWith()", () => { | ||
|
@@ -69,5 +71,3 @@ Rhum.testSuite("differenceWith()", () => { | |
}); | ||
}); | ||
``` | ||
|
||
|
Oops, something went wrong.