-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9.2.0 R.once TS type definition miss to context argument and its type (…
…#729) * dsa * chore@small * prepare * fix 726 * feat@fix --------- Co-authored-by: Deyan Totev <[email protected]>
- Loading branch information
1 parent
6863db5
commit 1d8507b
Showing
17 changed files
with
218 additions
and
43 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 |
---|---|---|
|
@@ -10214,7 +10214,7 @@ This method is also known as P combinator. | |
|
||
```typescript | ||
|
||
once<T extends AnyFunction>(func: T): T | ||
once<T extends AnyFunction, C = unknown>(fn: T, context?: C): T | ||
``` | ||
|
||
It returns a function, which invokes only once `fn` function. | ||
|
@@ -10235,7 +10235,7 @@ addOnce(1) | |
<summary>All TypeScript definitions</summary> | ||
|
||
```typescript | ||
once<T extends AnyFunction>(func: T): T; | ||
once<T extends AnyFunction, C = unknown>(fn: T, context?: C): T; | ||
``` | ||
|
||
</details> | ||
|
@@ -10304,6 +10304,17 @@ test('happy path', () => { | |
)).toBe(60) | ||
expect(addOneOnce(40)).toBe(60) | ||
}) | ||
|
||
test('with context', () => { | ||
const context = { name: 'fris' } | ||
const getNameOnce = once(function (){ | ||
return this.name | ||
}, context) | ||
|
||
expect(getNameOnce()).toBe('fris') | ||
expect(getNameOnce()).toBe('fris') | ||
expect(getNameOnce()).toBe('fris') | ||
}) | ||
``` | ||
|
||
</details> | ||
|
@@ -10324,6 +10335,14 @@ describe('R.once', () => { | |
const result = runOnce(1) | ||
result // $ExpectType number | ||
}) | ||
it('with context', () => { | ||
const runOnce = once(function (this: any, x: number) { | ||
return x + 2 | ||
}) | ||
|
||
const result = runOnce.call({}, 1) | ||
result // $ExpectType number | ||
}) | ||
}) | ||
``` | ||
|
||
|
@@ -17067,13 +17086,17 @@ unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T): (x: T) => T; | |
<summary><strong>R.unless</strong> source</summary> | ||
|
||
```javascript | ||
export function unless(predicate, whenFalse){ | ||
if (arguments.length === 1){ | ||
return _whenFalse => unless(predicate, _whenFalse) | ||
} | ||
import { curry } from './curry.js' | ||
|
||
function unlessFn( | ||
predicate, whenFalseFn, input | ||
){ | ||
if (predicate(input)) return input | ||
|
||
return input => predicate(input) ? input : whenFalse(input) | ||
return whenFalseFn(input) | ||
} | ||
|
||
export const unless = curry(unlessFn) | ||
``` | ||
|
||
</details> | ||
|
@@ -17097,6 +17120,11 @@ test('curried', () => { | |
const safeIncCurried = unless(isNil)(inc) | ||
expect(safeIncCurried(null)).toBeNull() | ||
}) | ||
|
||
test('with 3 inputs', () => { | ||
let result = unless(x => x.startsWith('/'), x=> x.concat('/'), '/api') | ||
expect(result).toBe('/api') | ||
}) | ||
``` | ||
|
||
</details> | ||
|
@@ -18502,9 +18530,16 @@ describe('R.zipWith', () => { | |
|
||
## ❯ CHANGELOG | ||
|
||
9.1.2 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
selfrefactor
Author
Owner
|
||
|
||
- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728) | ||
|
||
- Fix implementation of `R.unless` function - https://github.com/selfrefactor/rambda/pull/726 | ||
|
||
9.1.1 | ||
|
||
- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725 | ||
|
||
- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720 | ||
|
||
9.1.0 | ||
|
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
@selfrefactor: Thanks. I think the changelog version numbering does not match the npm release here ;-)