Skip to content

Commit

Permalink
prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
Deyan Totev committed Mar 31, 2024
1 parent e075a00 commit 7fb3959
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 20 deletions.
32 changes: 28 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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
})
})
```

Expand Down Expand Up @@ -17071,7 +17090,7 @@ export function unless(predicate, whenFalse){
if (arguments.length === 1){
return _whenFalse => unless(predicate, _whenFalse)
}

return input => predicate(input) ? input : whenFalse(input)
}
```
Expand Down Expand Up @@ -18502,9 +18521,14 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.1.1
9.2.0

- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)

- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725

9.1.1

- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720

9.1.0
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
9.1.1
9.2.0

- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)

- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725

9.1.1

- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720

9.1.0
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9607,7 +9607,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.
Expand All @@ -9619,7 +9619,7 @@ It returns a function, which invokes only once `fn` function.
<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>
Expand Down Expand Up @@ -9688,6 +9688,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>
Expand All @@ -9708,6 +9719,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
})
})
```

Expand Down Expand Up @@ -15880,7 +15899,7 @@ export function unless(predicate, whenFalse){
if (arguments.length === 1){
return _whenFalse => unless(predicate, _whenFalse)
}

return input => predicate(input) ? input : whenFalse(input)
}
```
Expand Down Expand Up @@ -17192,9 +17211,14 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.1.1
9.2.0

- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)

- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725

9.1.1

- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720

9.1.0
Expand Down
32 changes: 28 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9607,7 +9607,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.
Expand All @@ -9619,7 +9619,7 @@ It returns a function, which invokes only once `fn` function.
<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>
Expand Down Expand Up @@ -9688,6 +9688,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>
Expand All @@ -9708,6 +9719,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
})
})
```

Expand Down Expand Up @@ -15880,7 +15899,7 @@ export function unless(predicate, whenFalse){
if (arguments.length === 1){
return _whenFalse => unless(predicate, _whenFalse)
}

return input => predicate(input) ? input : whenFalse(input)
}
```
Expand Down Expand Up @@ -17192,9 +17211,14 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.1.1
9.2.0

- `R.once` TS type definition miss to context argument and its type - [Issue #728](https://github.com/selfrefactor/rambda/issues/728)

- Faster R.equals with Object.is short circuit - https://github.com/selfrefactor/rambda/pull/725

9.1.1

- Fix R.cond transform is unary - https://github.com/selfrefactor/rambda/issues/720

9.1.0
Expand Down
2 changes: 1 addition & 1 deletion files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,7 @@ Notes:
*/
// @SINGLE_MARKER
export function once<T extends AnyFunction>(func: T): T;
export function once<T extends AnyFunction, C = unknown>(fn: T, context?: C): T;

/*
Method: omit
Expand Down
2 changes: 1 addition & 1 deletion immutable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ export function on<T, U, R>(binaryFn: (a: U, b: U) => R, unaryFn: (value: T) =>
/**
* It returns a function, which invokes only once `fn` function.
*/
export function once<T extends AnyFunction>(func: T): T;
export function once<T extends AnyFunction, C = unknown>(fn: T, context?: C): T;

/**
* Logical OR
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ export function on<T, U, R>(binaryFn: (a: U, b: U) => R, unaryFn: (value: T) =>
/**
* It returns a function, which invokes only once `fn` function.
*/
export function once<T extends AnyFunction>(func: T): T;
export function once<T extends AnyFunction, C = unknown>(fn: T, context?: C): T;

/**
* Logical OR
Expand Down
8 changes: 8 additions & 0 deletions source/once-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ 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
})
})
11 changes: 11 additions & 0 deletions source/once.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ 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')
})
4 changes: 2 additions & 2 deletions source/unless.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export function unless(predicate, whenFalse){
if (arguments.length === 1){
return _whenFalse => unless(predicate, _whenFalse)
}

return input => predicate(input) ? input : whenFalse(input)
}
}
4 changes: 2 additions & 2 deletions src/unless.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export function unless(predicate, whenFalse){
if (arguments.length === 1){
return _whenFalse => unless(predicate, _whenFalse)
}

return input => predicate(input) ? input : whenFalse(input)
}
}

0 comments on commit 7fb3959

Please sign in to comment.