rambda 7.4.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export type Iterator<T, U> = (x: T) => U;
7
7
  export type ObjectIterator<T, U> = (x: T, prop: string, inputObj: Dictionary<T>) => U;
8
8
  type Ord = number | string | boolean | Date;
9
9
  type Path = string | (number | string)[];
10
- type RamdaPath = (number | string)[];
10
+ export type RamdaPath = (number | string)[];
11
11
  type Predicate<T> = (x: T) => boolean;
12
12
  export type IndexedPredicate<T> = (x: T, i: number) => boolean;
13
13
  export type ObjectPredicate<T> = (x: T, prop: string, inputObj: Dictionary<T>) => boolean;
@@ -848,7 +848,7 @@ export function mergeLeft<Output>(newProps: object, target: object): Output;
848
848
  export function mergeLeft<Output>(newProps: object): (target: object) => Output;
849
849
 
850
850
  /**
851
- * It creates a copy of `target` object with overidden `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
851
+ * It creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
852
852
  */
853
853
  export function mergeRight<A, B>(target: A, newProps: B): A & B
854
854
  export function mergeRight<Output>(target: any): (newProps: any) => Output;
@@ -1076,6 +1076,7 @@ export function path<
1076
1076
  export function path<T>(pathToSearch: string, obj: any): T | undefined;
1077
1077
  export function path<T>(pathToSearch: string): (obj: any) => T | undefined;
1078
1078
  export function path<T>(pathToSearch: RamdaPath): (obj: any) => T | undefined;
1079
+ export function path<T>(pathToSearch: RamdaPath, obj: any): T | undefined;
1079
1080
 
1080
1081
  /**
1081
1082
  * It returns `true` if `pathToSearch` of `input` object is equal to `target` value.
@@ -1108,7 +1109,7 @@ export function paths<T>(pathsToSearch: Path[]): (obj: any) => (T | undefined)[]
1108
1109
  *
1109
1110
  * `input` can be either an object or an array.
1110
1111
  *
1111
- * String anotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1112
+ * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1112
1113
  */
1113
1114
  export function pick<T, K extends string | number | symbol>(propsToPick: K[], input: T): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
1114
1115
  export function pick<K extends string | number | symbol>(propsToPick: K[]): <T>(input: T) => Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
@@ -1427,7 +1428,7 @@ export function takeWhile<T>(fn: Predicate<T>): (iterable: T[]) => T[];
1427
1428
  /**
1428
1429
  * It applies function `fn` to input `x` and returns `x`.
1429
1430
  *
1430
- * One use case is debuging in the middle of `R.compose`.
1431
+ * One use case is debugging in the middle of `R.compose`.
1431
1432
  */
1432
1433
  export function tap<T>(fn: (x: T) => void, input: T): T;
1433
1434
  export function tap<T>(fn: (x: T) => void): (input: T) => T;
@@ -1511,6 +1512,11 @@ export function union<T>(x: T[]): (y: T[]) => T[];
1511
1512
  */
1512
1513
  export function uniq<T>(list: T[]): T[];
1513
1514
 
1515
+ /**
1516
+ * It applies uniqueness to input list based on function that defines what to be used for comparison between elements.
1517
+ *
1518
+ * `R.equals` is used to determine equality.
1519
+ */
1514
1520
  export function uniqBy<T, U>(fn: (a: T) => U, list: T[]): T[];
1515
1521
  export function uniqBy<T, U>(fn: (a: T) => U): (list: T[]) => T[];
1516
1522
 
@@ -1534,6 +1540,9 @@ export function unless<T, U>(predicate: (x: T) => boolean, whenFalseFn: (x: T) =
1534
1540
  export function unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T, x: T): T;
1535
1541
  export function unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T): (x: T) => T;
1536
1542
 
1543
+ export function unnest(list: unknown[]): unknown[];
1544
+ export function unnest<T>(list: unknown[]): T;
1545
+
1537
1546
  export function unwind<T, U>(prop: keyof T, obj: T): U[];
1538
1547
  export function unwind<T, U>(prop: keyof T): (obj: T) => U[];
1539
1548
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "7.4.0",
3
+ "version": "7.5.0",
4
4
  "scripts": {
5
5
  "publishx": "node files/publish",
6
6
  "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
@@ -14,6 +14,7 @@
14
14
  "github": "cd ../rambda-scripts && yarn github",
15
15
  "fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
16
16
  "immutable": "cd ../rambda-scripts && yarn immutable:rambda",
17
+ "immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
17
18
  "usedby": "cd ../rambda-scripts && yarn usedby",
18
19
  "lint:all": "cd ../rambda-scripts && yarn lint",
19
20
  "lint:staged": "cd ../rambda-scripts && yarn lint:staged",
@@ -30,7 +31,6 @@
30
31
  "consume-typings": "yarn consume-typings:clone && yarn consume-typings:execute",
31
32
  "test:consume-typings": "jest source/_consumeTypings.test.js",
32
33
  "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
33
- "t": "yarn test:typings",
34
34
  "test:all": "jest source/*.spec.js -u --bail=false",
35
35
  "test": "jest -o -u --watch",
36
36
  "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
@@ -52,7 +52,7 @@
52
52
  "@rollup/plugin-node-resolve": "15.0.1",
53
53
  "@rollup/plugin-replace": "5.0.1",
54
54
  "@types/jest": "29.2.2",
55
- "@types/ramda": "0.28.18",
55
+ "@types/ramda": "0.28.23",
56
56
  "combinate": "1.1.11",
57
57
  "cross-env": "7.0.3",
58
58
  "dtslint": "4.2.1",
@@ -63,7 +63,6 @@
63
63
  "lodash": "4.17.21",
64
64
  "rambdax": "8.1.0",
65
65
  "ramda": "0.28.0",
66
- "remeda": "1.2.0",
67
66
  "rollup": "3.2.5",
68
67
  "rollup-plugin-cleanup": "3.2.1",
69
68
  "rollup-plugin-sourcemaps": "0.6.3",
@@ -85,12 +84,13 @@
85
84
  "files": [
86
85
  "dist",
87
86
  "src",
87
+ "esm",
88
+ "mjs",
88
89
  "README.md",
89
90
  "CHANGELOG.md",
90
91
  "index.d.ts",
91
92
  "immutable.d.ts",
92
93
  "rambda.js",
93
- "rambda.js",
94
94
  "immutable.js"
95
95
  ],
96
96
  "repository": {
@@ -105,20 +105,6 @@
105
105
  "umd": "./dist/rambda.umd.js",
106
106
  "module": "./rambda.js",
107
107
  "types": "./index.d.ts",
108
- "exports": {
109
- ".": {
110
- "import": "./rambda.js",
111
- "require": "./dist/rambda.js",
112
- "default": "./dist/rambda.js",
113
- "types": "./index.d.ts"
114
- },
115
- "./immutable": {
116
- "import": "./immutable.js",
117
- "require": "./immutable.js",
118
- "default": "./immutable.js",
119
- "types": "./immutable.d.ts"
120
- }
121
- },
122
108
  "keywords": [
123
109
  "ramda",
124
110
  "fp",
package/rambda.js CHANGED
@@ -1,6 +1,4 @@
1
1
  /// <reference types="./index.d.ts" />
2
- export * from './src/F.js'
3
- export * from './src/T.js'
4
2
  export * from './src/add.js'
5
3
  export * from './src/adjust.js'
6
4
  export * from './src/all.js'
@@ -44,6 +42,7 @@ export * from './src/endsWith.js'
44
42
  export * from './src/eqProps.js'
45
43
  export * from './src/equals.js'
46
44
  export * from './src/evolve.js'
45
+ export * from './src/F.js'
47
46
  export * from './src/filter.js'
48
47
  export * from './src/find.js'
49
48
  export * from './src/findIndex.js'
@@ -130,8 +129,8 @@ export * from './src/prop.js'
130
129
  export * from './src/propEq.js'
131
130
  export * from './src/propIs.js'
132
131
  export * from './src/propOr.js'
133
- export * from './src/propSatisfies.js'
134
132
  export * from './src/props.js'
133
+ export * from './src/propSatisfies.js'
135
134
  export * from './src/range.js'
136
135
  export * from './src/reduce.js'
137
136
  export * from './src/reject.js'
@@ -150,6 +149,7 @@ export * from './src/startsWith.js'
150
149
  export * from './src/subtract.js'
151
150
  export * from './src/sum.js'
152
151
  export * from './src/symmetricDifference.js'
152
+ export * from './src/T.js'
153
153
  export * from './src/tail.js'
154
154
  export * from './src/take.js'
155
155
  export * from './src/takeLast.js'
@@ -172,6 +172,7 @@ export * from './src/uniq.js'
172
172
  export * from './src/uniqBy.js'
173
173
  export * from './src/uniqWith.js'
174
174
  export * from './src/unless.js'
175
+ export * from './src/unnest.js'
175
176
  export * from './src/unwind.js'
176
177
  export * from './src/update.js'
177
178
  export * from './src/values.js'
@@ -14,19 +14,20 @@ export function dropLastWhile(predicate, iterable){
14
14
  throw new Error(`'iterable' is from wrong type ${ typeof iterable }`)
15
15
  }
16
16
 
17
- let found = false
18
17
  const toReturn = []
19
18
  let counter = iterable.length
20
19
 
21
- while (counter > 0){
22
- counter--
23
- if (!found && predicate(iterable[ counter ]) === false){
24
- found = true
25
- toReturn.push(iterable[ counter ])
26
- } else if (found){
27
- toReturn.push(iterable[ counter ])
20
+ while (counter){
21
+ const item = iterable[ --counter ]
22
+ if (!predicate(item)){
23
+ toReturn.push(item)
24
+ break
28
25
  }
29
26
  }
30
27
 
28
+ while (counter){
29
+ toReturn.push(iterable[ --counter ])
30
+ }
31
+
31
32
  return isArray ? toReturn.reverse() : toReturn.reverse().join('')
32
33
  }
package/src/dropWhile.js CHANGED
@@ -8,19 +8,21 @@ export function dropWhile(predicate, iterable){
8
8
  if (!isArray && typeof iterable !== 'string'){
9
9
  throw new Error('`iterable` is neither list nor a string')
10
10
  }
11
- let flag = false
12
- const holder = []
13
- let counter = -1
14
11
 
15
- while (counter++ < iterable.length - 1){
16
- if (flag){
17
- holder.push(iterable[ counter ])
18
- } else if (!predicate(iterable[ counter ])){
19
- if (!flag) flag = true
12
+ const toReturn = []
13
+ let counter = 0
20
14
 
21
- holder.push(iterable[ counter ])
15
+ while (counter < iterable.length){
16
+ const item = iterable[ counter++ ]
17
+ if (!predicate(item)){
18
+ toReturn.push(item)
19
+ break
22
20
  }
23
21
  }
24
22
 
25
- return isArray ? holder : holder.join('')
23
+ while (counter < iterable.length){
24
+ toReturn.push(iterable[ counter++ ])
25
+ }
26
+
27
+ return isArray ? toReturn : toReturn.join('')
26
28
  }
@@ -5,17 +5,16 @@ export function takeLastWhile(predicate, input){
5
5
  return _input => takeLastWhile(predicate, _input)
6
6
  }
7
7
  if (input.length === 0) return input
8
- let found = false
8
+
9
9
  const toReturn = []
10
10
  let counter = input.length
11
11
 
12
- while (!found || counter === 0){
13
- counter--
14
- if (predicate(input[ counter ]) === false){
15
- found = true
16
- } else if (!found){
17
- toReturn.push(input[ counter ])
12
+ while (counter){
13
+ const item = input[ --counter ]
14
+ if (!predicate(item)){
15
+ break
18
16
  }
17
+ toReturn.push(item)
19
18
  }
20
19
 
21
20
  return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')
package/src/takeWhile.js CHANGED
@@ -8,18 +8,17 @@ export function takeWhile(predicate, iterable){
8
8
  if (!isArray && typeof iterable !== 'string'){
9
9
  throw new Error('`iterable` is neither list nor a string')
10
10
  }
11
- let flag = true
12
- const holder = []
13
- let counter = -1
14
11
 
15
- while (counter++ < iterable.length - 1){
16
- if (!predicate(iterable[ counter ])){
17
- if (flag) flag = false
18
- } else if (flag){
19
- holder.push(iterable[ counter ])
12
+ const toReturn = []
13
+ let counter = 0
14
+
15
+ while (counter < iterable.length){
16
+ const item = iterable[ counter++ ]
17
+ if (!predicate(item)){
18
+ break
20
19
  }
20
+ toReturn.push(item)
21
21
  }
22
- holder
23
22
 
24
- return isArray ? holder : holder.join('')
23
+ return isArray ? toReturn : toReturn.join('')
25
24
  }
package/src/uniqBy.js CHANGED
@@ -1,13 +1,10 @@
1
+ import { _Set } from '../src/_internals/set.js'
2
+
1
3
  export function uniqBy(fn, list){
2
4
  if (arguments.length === 1){
3
5
  return _list => uniqBy(fn, _list)
4
6
  }
5
- const set = new Set()
6
-
7
- return list.filter(item => {
8
- if (set.has(fn(item))) return false
9
- set.add(fn(item))
7
+ const set = new _Set()
10
8
 
11
- return true
12
- })
9
+ return list.filter(item => set.checkUniqueness(fn(item)))
13
10
  }
package/src/unnest.js ADDED
@@ -0,0 +1,9 @@
1
+ export function unnest(list){
2
+ return list.reduce((acc, item) => {
3
+ if (Array.isArray(item)){
4
+ return [ ...acc, ...item ]
5
+ }
6
+
7
+ return [ ...acc, item ]
8
+ }, [])
9
+ }