Skip to content

Commit

Permalink
fix: view.or typings
Browse files Browse the repository at this point in the history
  • Loading branch information
selfrefactor committed Apr 24, 2024
1 parent 6849666 commit db20844
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18530,7 +18530,7 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.1.2
9.2.0

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

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
9.1.2
9.2.0

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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17220,7 +17220,7 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.1.2
9.2.0

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

Expand Down
28 changes: 14 additions & 14 deletions dist/rambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,20 @@ function _objectSpread2(e) {
}
return e;
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Expand All @@ -869,20 +883,6 @@ function _defineProperty(obj, key, value) {
}
return obj;
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}

function compare(a, b) {
return String(a) === String(b);
Expand Down
2 changes: 1 addition & 1 deletion dist/rambda.umd.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions files/NEXT_VERSION_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
viewor
lenssatisfies
lensor
---
run immutable script
---
warning package.json: No license field
Expand Down
5 changes: 2 additions & 3 deletions files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7789,9 +7789,8 @@ Notes: Idea for this method comes from `@meltwater/phi` library

*/
// @SINGLE_MARKER
export function viewOr<Input, Output>(fallback: Output, lens: Lens, input: Input): Output;
export function viewOr<Input, Output>(fallback: Output, lens: Lens): (input: Input) => Output;
export function viewOr<Input, Output>(fallback: Output): (lens: Lens) => (input: Input) => Output;
export function viewOr<Input, Output>(fallback: Output, lens: Lens<Input, Output>, input: Input): Output;
export function viewOr<Input, Output>(fallback: Output, lens: Lens<Input, Output>): (input: Input) => Output;

/*
Method: sortByPath
Expand Down
26 changes: 17 additions & 9 deletions source/viewOr-spec.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import {viewOr, lensProp} from 'rambda'

const input = {a: 1}
const input = {a: 1, b:2}
interface Input {
a: number,
b?: number,
b: number,
}
const lens = lensProp<Input, 'b'>('b')

describe('R.viewOr', () => {
it('require explicit types', () => {
const result = viewOr<Input, number>(4, lens, input)
describe('R.viewOr - no explicit types', () => {
it('no curried inputs', () => {
const result = viewOr(4, lens, input)

result // $ExpectType number
})
it('curry 1', () => {
const result = viewOr<Input, number>(4, lens)(input)
it('curried inputs', () => {
const result = viewOr(4, lens)(input)

result // $ExpectType number
})
it('curry 2', () => {
const result = viewOr<Input, number>(4)(lens)(input)
})

describe('R.viewOr - explicit types', () => {
it('no curried inputs', () => {
const result = viewOr<Input, number>(4, lens, input)

result // $ExpectType number
})
it('curried inputs', () => {
const result = viewOr<Input, number>(4, lens)(input)

result // $ExpectType number
})
Expand Down

0 comments on commit db20844

Please sign in to comment.