Skip to content

Commit 5938627

Browse files
committed
chore@small
1 parent 001a3b9 commit 5938627

18 files changed

Lines changed: 159 additions & 198 deletions

CHANGELOG.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010

1111
- Add `R.symmetricDifference`
1212

13-
- Add `R.rangeDescending` as now `R.range` works only in ascending order.
13+
- Add `R.difference`
1414

1515
- `R.range` now works similar to Ruby's `Range` - both start and end values are inclusive.
1616

17-
- Change several functions to be used directly without currying. It relates when there is confusion which is the input that is coming from the pipe:
17+
- Add `R.rangeDescending` as now `R.range` works only in ascending order.
1818

19-
- R.range - it accepts one or two arguments. If one argument is passed, it is considered as end value, and start is 0.
19+
- `R.range` - it accepts one or two arguments. If one argument is passed, it is considered as end value, and start is 0.
2020

2121
- R.rangeDescending - it accepts one or two arguments. If one argument is passed, it is considered as start value, and end is 0.
22-
23-
- R.difference(new method)
2422

2523
10.3.5
2624

README.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,11 +2028,11 @@ difference<T>(x: T[]): (y: T[]) => T[];
20282028
import { filter } from './filter.js'
20292029
import { includes } from './includes.js'
20302030

2031-
export function difference(x, y) {
2032-
return [
2031+
export function difference(x) {
2032+
return y => ([
20332033
...filter(value => !includes(value)(y))(x),
20342034
...filter(value => !includes(value)(x))(y),
2035-
]
2035+
])
20362036
}
20372037
```
20382038
@@ -9779,7 +9779,7 @@ describe('R.propSatisfies', () => {
97799779
97809780
```typescript
97819781

9782-
range(startInclusive: number, endInclusive: number) : number[]
9782+
range(endInclusive: number) : number[]
97839783
```
97849784
97859785
It returns list of numbers between `startInclusive` to `endInclusive` markers.
@@ -9796,6 +9796,7 @@ It returns list of numbers between `startInclusive` to `endInclusive` markers.
97969796
<summary>All TypeScript definitions</summary>
97979797
97989798
```typescript
9799+
range(endInclusive: number) : number[];
97999800
range(startInclusive: number, endInclusive: number) : number[];
98009801
```
98019802
@@ -9806,18 +9807,14 @@ range(startInclusive: number, endInclusive: number) : number[];
98069807
<summary><strong>R.range</strong> source</summary>
98079808
98089809
```javascript
9809-
export function range(start, end) {
9810-
if (end === start) {
9811-
return []
9812-
}
9813-
const len = start - (end ?? 0)
9814-
const willReturn = Array(len)
9815-
9816-
for (let i = 0; i <= len; i++) {
9817-
willReturn[i] = start + i
9818-
}
9819-
9820-
return willReturn
9810+
export function range(a, b) {
9811+
const start = b === undefined ? 0 : a
9812+
const end = b === undefined ? a : b
9813+
if (end<= start) {
9814+
return []
9815+
}
9816+
const len = end - start
9817+
return Array.from({ length: len + 1 }, (_, i) => start + i)
98219818
}
98229819
```
98239820
@@ -9831,9 +9828,10 @@ export function range(start, end) {
98319828
import { range } from './range.js'
98329829

98339830
test('happy', () => {
9834-
expect(range(0)(5)).toEqual([0, 1, 2, 3, 4])
9835-
expect(range(7)(3)).toEqual([7, 6, 5, 4])
9836-
expect(range(5)(5)).toEqual([])
9831+
expect(range(5)).toEqual([0, 1, 2, 3, 4, 5])
9832+
expect(range(3,5)).toEqual([3, 4, 5])
9833+
expect(range(5,3)).toEqual([])
9834+
expect(range(0)).toEqual([])
98379835
})
98389836
```
98399837
@@ -9874,6 +9872,7 @@ It returns list of numbers between `endInclusive` to `startInclusive` markers.
98749872
98759873
```typescript
98769874
rangeDescending(startInclusive: number, endInclusive: number) : number[];
9875+
rangeDescending(endInclusive: number) : number[];
98779876
```
98789877
98799878
</details>
@@ -9883,16 +9882,13 @@ rangeDescending(startInclusive: number, endInclusive: number) : number[];
98839882
<summary><strong>R.rangeDescending</strong> source</summary>
98849883
98859884
```javascript
9886-
export function rangeDescending(start, end) {
9887-
const len = start - (end ?? 0)
9888-
if(!(len >0)) return []
9889-
const willReturn = Array(len)
9890-
9891-
for (let i = 0; i <= len; i++) {
9892-
willReturn[i] = start - i
9885+
export function rangeDescending(start, b) {
9886+
const end = b === undefined ? 0 : b
9887+
if (start <= end) {
9888+
return []
98939889
}
9894-
9895-
return willReturn
9890+
const len = start - end
9891+
return Array.from({ length: len + 1 }, (_, i) => start - i)
98969892
}
98979893
```
98989894
@@ -9908,6 +9904,7 @@ import { rangeDescending } from './rangeDescending.js'
99089904
test('happy', () => {
99099905
expect(rangeDescending(5)).toEqual([5, 4, 3, 2, 1, 0])
99109906
expect(rangeDescending(7,3)).toEqual([7, 6, 5, 4,3])
9907+
expect(rangeDescending(5, 7)).toEqual([])
99119908
expect(rangeDescending(5, 5)).toEqual([])
99129909
})
99139910
```
@@ -13910,17 +13907,15 @@ describe('R.zipWith', () => {
1391013907
1391113908
- Add `R.symmetricDifference`
1391213909
13913-
- Add `R.rangeDescending` as now `R.range` works only in ascending order.
13910+
- Add `R.difference`
1391413911
1391513912
- `R.range` now works similar to Ruby's `Range` - both start and end values are inclusive.
1391613913
13917-
- Change several functions to be used directly without currying. It relates when there is confusion which is the input that is coming from the pipe:
13914+
- Add `R.rangeDescending` as now `R.range` works only in ascending order.
1391813915
13919-
- R.range - it accepts one or two arguments. If one argument is passed, it is considered as end value, and start is 0.
13916+
- `R.range` - it accepts one or two arguments. If one argument is passed, it is considered as end value, and start is 0.
1392013917
1392113918
- R.rangeDescending - it accepts one or two arguments. If one argument is passed, it is considered as start value, and end is 0.
13922-
13923-
- R.difference(new method)
1392413919
1392513920
10.3.5
1392613921

dist/rambda.cjs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,11 @@ function includes(valueToFind) {
497497
}
498498
}
499499

500-
function difference(x, y) {
501-
return [
500+
function difference(x) {
501+
return y => ([
502502
...filter(value => !includes(value)(y))(x),
503503
...filter(value => !includes(value)(x))(y),
504-
]
504+
])
505505
}
506506

507507
function drop(howManyToDrop, ) {
@@ -1514,30 +1514,23 @@ function propSatisfies(predicate, property) {
15141514
return obj => predicate(obj[property])
15151515
}
15161516

1517-
function range(start, end) {
1518-
if (end === start) {
1519-
return []
1520-
}
1521-
const len = start - (end ?? 0);
1522-
const willReturn = Array(len);
1523-
1524-
for (let i = 0; i <= len; i++) {
1525-
willReturn[i] = start + i;
1526-
}
1527-
1528-
return willReturn
1517+
function range(a, b) {
1518+
const start = b === undefined ? 0 : a;
1519+
const end = b === undefined ? a : b;
1520+
if (end<= start) {
1521+
return []
1522+
}
1523+
const len = end - start;
1524+
return Array.from({ length: len + 1 }, (_, i) => start + i)
15291525
}
15301526

1531-
function rangeDescending(start, end) {
1532-
const len = start - (end ?? 0);
1533-
if(!(len >0)) return []
1534-
const willReturn = Array(len);
1535-
1536-
for (let i = 0; i <= len; i++) {
1537-
willReturn[i] = start - i;
1527+
function rangeDescending(start, b) {
1528+
const end = b === undefined ? 0 : b;
1529+
if (start <= end) {
1530+
return []
15381531
}
1539-
1540-
return willReturn
1532+
const len = start - end;
1533+
return Array.from({ length: len + 1 }, (_, i) => start - i)
15411534
}
15421535

15431536
function replace(pattern, replacer) {

dist/rambda.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,11 @@ function includes(valueToFind) {
495495
}
496496
}
497497

498-
function difference(x, y) {
499-
return [
498+
function difference(x) {
499+
return y => ([
500500
...filter(value => !includes(value)(y))(x),
501501
...filter(value => !includes(value)(x))(y),
502-
]
502+
])
503503
}
504504

505505
function drop(howManyToDrop, ) {
@@ -1512,30 +1512,23 @@ function propSatisfies(predicate, property) {
15121512
return obj => predicate(obj[property])
15131513
}
15141514

1515-
function range(start, end) {
1516-
if (end === start) {
1517-
return []
1518-
}
1519-
const len = start - (end ?? 0);
1520-
const willReturn = Array(len);
1521-
1522-
for (let i = 0; i <= len; i++) {
1523-
willReturn[i] = start + i;
1524-
}
1525-
1526-
return willReturn
1515+
function range(a, b) {
1516+
const start = b === undefined ? 0 : a;
1517+
const end = b === undefined ? a : b;
1518+
if (end<= start) {
1519+
return []
1520+
}
1521+
const len = end - start;
1522+
return Array.from({ length: len + 1 }, (_, i) => start + i)
15271523
}
15281524

1529-
function rangeDescending(start, end) {
1530-
const len = start - (end ?? 0);
1531-
if(!(len >0)) return []
1532-
const willReturn = Array(len);
1533-
1534-
for (let i = 0; i <= len; i++) {
1535-
willReturn[i] = start - i;
1525+
function rangeDescending(start, b) {
1526+
const end = b === undefined ? 0 : b;
1527+
if (start <= end) {
1528+
return []
15361529
}
1537-
1538-
return willReturn
1530+
const len = start - end;
1531+
return Array.from({ length: len + 1 }, (_, i) => start - i)
15391532
}
15401533

15411534
function replace(pattern, replacer) {

dist/rambda.umd.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,11 @@
501501
}
502502
}
503503

504-
function difference(x, y) {
505-
return [
504+
function difference(x) {
505+
return y => ([
506506
...filter(value => !includes(value)(y))(x),
507507
...filter(value => !includes(value)(x))(y),
508-
]
508+
])
509509
}
510510

511511
function drop(howManyToDrop, ) {
@@ -1518,30 +1518,23 @@
15181518
return obj => predicate(obj[property])
15191519
}
15201520

1521-
function range(start, end) {
1522-
if (end === start) {
1523-
return []
1524-
}
1525-
const len = start - (end ?? 0);
1526-
const willReturn = Array(len);
1527-
1528-
for (let i = 0; i <= len; i++) {
1529-
willReturn[i] = start + i;
1530-
}
1531-
1532-
return willReturn
1521+
function range(a, b) {
1522+
const start = b === undefined ? 0 : a;
1523+
const end = b === undefined ? a : b;
1524+
if (end<= start) {
1525+
return []
1526+
}
1527+
const len = end - start;
1528+
return Array.from({ length: len + 1 }, (_, i) => start + i)
15331529
}
15341530

1535-
function rangeDescending(start, end) {
1536-
const len = start - (end ?? 0);
1537-
if(!(len >0)) return []
1538-
const willReturn = Array(len);
1539-
1540-
for (let i = 0; i <= len; i++) {
1541-
willReturn[i] = start - i;
1531+
function rangeDescending(start, b) {
1532+
const end = b === undefined ? 0 : b;
1533+
if (start <= end) {
1534+
return []
15421535
}
1543-
1544-
return willReturn
1536+
const len = start - end;
1537+
return Array.from({ length: len + 1 }, (_, i) => start - i)
15451538
}
15461539

15471540
function replace(pattern, replacer) {

0 commit comments

Comments
 (0)