@@ -2028,11 +2028,11 @@ difference<T>(x: T[]): (y: T[]) => T[];
20282028import { filter } from ' ./filter.js'
20292029import { 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
97859785It 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 [];
97999800range(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) {
98319828import { range } from ' ./range.js'
98329829
98339830test(' 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
98769874rangeDescending(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'
99089904test(' 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
139251392010.3.5
1392613921
0 commit comments