rambda 7.4.0 → 8.0.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/CHANGELOG.md +31 -0
- package/README.md +99 -28
- package/dist/rambda.js +81 -56
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +46 -8
- package/index.d.ts +46 -8
- package/package.json +38 -60
- package/rambda.js +1 -1
- package/src/dropLastWhile.js +9 -8
- package/src/dropWhile.js +12 -10
- package/src/isPromise.js +1 -1
- package/src/mergeWith.js +3 -1
- package/src/path.js +11 -6
- package/src/propEq.js +1 -1
- package/src/reduce.js +3 -0
- package/src/reverse.js +3 -4
- package/src/set.js +5 -9
- package/src/startsWith.js +6 -6
- package/src/takeLastWhile.js +6 -7
- package/src/takeWhile.js +9 -10
- package/src/uniqBy.js +4 -7
- package/src/unnest.js +9 -0
- package/dist/rambda.mjs +0 -2193
- package/src/nop.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
8.0.0
|
|
2
|
+
|
|
3
|
+
- handle falsy values in merge methods - https://github.com/ramda/ramda/pull/3222
|
|
4
|
+
|
|
5
|
+
- `R.head`/`R.last` don't return `undefined` for non-empty arrays
|
|
6
|
+
|
|
7
|
+
- `R.type` supports dates in TS definition - `Rambda` already did support dates in JS.
|
|
8
|
+
|
|
9
|
+
- Improve typings of `R.endsWith/startsWith` with regard to `string` input. - [PR #622](https://github.com/selfrefactor/rambda/pull/622)
|
|
10
|
+
|
|
11
|
+
- Handle list as falsy value in `R.reduce` - [Ramda MR](https://github.com/ramda/ramda/pull/2997/files)
|
|
12
|
+
|
|
13
|
+
- `R.nop` is removed - it will be moved to `Rambdax` as `R.noop`
|
|
14
|
+
|
|
15
|
+
- `R.includes` is no longer using string literal in Typescript definitions
|
|
16
|
+
|
|
17
|
+
> Reason for breaking change - synchronize with Ramda `0.29.0` release:
|
|
18
|
+
|
|
19
|
+
- change order of `R.propEq` - [Ramda MR](https://github.com/ramda/ramda/pull/2938/files)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
7.5.0
|
|
23
|
+
|
|
24
|
+
- IMPORTANT: Remove `export` property in `package.json` in order to allow `Rambda` support for projects with `"type": "module"` in `package.json` - [Issue #667](https://github.com/selfrefactor/rambda/issues/657)
|
|
25
|
+
|
|
26
|
+
- Add `R.unnest` - [Rambdax issue 89](https://github.com/selfrefactor/rambdax/issues/89)
|
|
27
|
+
|
|
28
|
+
- `R.uniq` is not using `R.equals` as Ramda does - [Issue #88](https://github.com/selfrefactor/rambdax/issues/88)
|
|
29
|
+
|
|
30
|
+
- Fix `R.path(['non','existing','path'], obj)` TS definition as 7.4.0 release caused TS errors - [Issue #668](https://github.com/selfrefactor/rambda/issues/668)
|
|
31
|
+
|
|
1
32
|
7.4.0
|
|
2
33
|
|
|
3
34
|
- Synchronize with `@types/ramda` - `R.prop`, `R.path`, `R.pickAll`
|
package/README.md
CHANGED
|
@@ -61,12 +61,6 @@ R.add(1)('foo') // => will trigger warning in VSCode
|
|
|
61
61
|
Ramda.add(1)('foo') // => will not trigger warning in VSCode
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
### Smaller size
|
|
65
|
-
|
|
66
|
-
The size of a library affects not only the build bundle size but also the dev bundle size and build time. This is important advantage, expecially for big projects.
|
|
67
|
-
|
|
68
|
-
<!-- ### Tree-shaking -->
|
|
69
|
-
|
|
70
64
|
### Dot notation for `R.path`, `R.paths`, `R.assocPath` and `R.lensPath`
|
|
71
65
|
|
|
72
66
|
Standard usage of `R.path` is `R.path(['a', 'b'], {a: {b: 1} })`.
|
|
@@ -102,11 +96,12 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
102
96
|
|
|
103
97
|
<details>
|
|
104
98
|
<summary>
|
|
105
|
-
Click to see the full list of
|
|
99
|
+
Click to see the full list of 80 Ramda methods not implemented in Rambda
|
|
106
100
|
</summary>
|
|
107
101
|
|
|
108
102
|
- __
|
|
109
103
|
- addIndex
|
|
104
|
+
- addIndexRight
|
|
110
105
|
- ap
|
|
111
106
|
- aperture
|
|
112
107
|
- applyTo
|
|
@@ -121,6 +116,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
121
116
|
- descend
|
|
122
117
|
- differenceWith
|
|
123
118
|
- dissocPath
|
|
119
|
+
- dropRepeatsBy
|
|
124
120
|
- empty
|
|
125
121
|
- eqBy
|
|
126
122
|
- forEachObjIndexed
|
|
@@ -134,6 +130,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
134
130
|
- invert
|
|
135
131
|
- invertObj
|
|
136
132
|
- invoker
|
|
133
|
+
- isNotNil
|
|
137
134
|
- keysIn
|
|
138
135
|
- lift
|
|
139
136
|
- liftN
|
|
@@ -166,6 +163,7 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
166
163
|
- sequence
|
|
167
164
|
- sortWith
|
|
168
165
|
- splitWhenever
|
|
166
|
+
- swap
|
|
169
167
|
- symmetricDifferenceWith
|
|
170
168
|
- andThen
|
|
171
169
|
- toPairsIn
|
|
@@ -175,7 +173,6 @@ Closing the issue is usually accompanied by publishing a new patch version of `R
|
|
|
175
173
|
- uncurryN
|
|
176
174
|
- unfold
|
|
177
175
|
- unionWith
|
|
178
|
-
- unnest
|
|
179
176
|
- until
|
|
180
177
|
- useWith
|
|
181
178
|
- valuesIn
|
|
@@ -240,7 +237,7 @@ There are methods which are benchmarked only with `Ramda` and `Rambda`(i.e. no `
|
|
|
240
237
|
|
|
241
238
|
Note that some of these methods, are called with and without curring. This is done in order to give more detailed performance feedback.
|
|
242
239
|
|
|
243
|
-
The benchmarks results are produced from latest versions of *Rambda*, *Lodash*(4.17.21) and *Ramda*(0.
|
|
240
|
+
The benchmarks results are produced from latest versions of *Rambda*, *Lodash*(4.17.21) and *Ramda*(0.29.0).
|
|
244
241
|
|
|
245
242
|
</summary>
|
|
246
243
|
|
|
@@ -316,6 +313,8 @@ method | Rambda | Ramda | Lodash
|
|
|
316
313
|
|
|
317
314
|
## ❯ Used by
|
|
318
315
|
|
|
316
|
+
- [ESLint plugin Mocha](https://www.npmjs.com/package/eslint-plugin-mocha)
|
|
317
|
+
|
|
319
318
|
- [WatermelonDB](https://github.com/Nozbe/WatermelonDB)
|
|
320
319
|
|
|
321
320
|
- [Walmart Canada](https://www.walmart.ca) reported by [w-b-dev](https://github.com/w-b-dev)
|
|
@@ -2623,7 +2622,7 @@ It returns the uniq set of all elements in the first list `a` not contained in t
|
|
|
2623
2622
|
|
|
2624
2623
|
`R.equals` is used to determine equality.
|
|
2625
2624
|
|
|
2626
|
-
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20a%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20b%20%3D%20%5B%203%2C%204%2C%205%2C%206%20%5D%0A%0Aconst%20result%20%3D%
|
|
2625
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20a%20%3D%20%5B%201%2C%202%2C%203%2C%204%20%5D%0Aconst%20b%20%3D%20%5B%203%2C%204%2C%205%2C%206%20%5D%0A%0Aconst%20result%20%3D%20R.difference(a%2C%20b)%0A%2F%2F%20%3D%3E%20%5B%201%2C%202%20%5D">Try this <strong>R.difference</strong> example in Rambda REPL</a>
|
|
2627
2626
|
|
|
2628
2627
|
<details>
|
|
2629
2628
|
|
|
@@ -8148,8 +8147,6 @@ export function mergeDeepRight(target, source){
|
|
|
8148
8147
|
<summary><strong>Tests</strong></summary>
|
|
8149
8148
|
|
|
8150
8149
|
```javascript
|
|
8151
|
-
import { mergeDeepRight as mergeDeepRightRamda } from 'ramda'
|
|
8152
|
-
|
|
8153
8150
|
import { mergeDeepRight } from './mergeDeepRight.js'
|
|
8154
8151
|
|
|
8155
8152
|
const student = {
|
|
@@ -8166,6 +8163,23 @@ const teacher = {
|
|
|
8166
8163
|
songs : { title : 'Remains the same' },
|
|
8167
8164
|
}
|
|
8168
8165
|
|
|
8166
|
+
test('when merging object with lists inside them', () => {
|
|
8167
|
+
const a = {
|
|
8168
|
+
a : [ 1, 2, 3 ],
|
|
8169
|
+
b : [ 4, 5, 6 ],
|
|
8170
|
+
}
|
|
8171
|
+
const b = {
|
|
8172
|
+
a : [ 7, 8, 9 ],
|
|
8173
|
+
b : [ 10, 11, 12 ],
|
|
8174
|
+
}
|
|
8175
|
+
const result = mergeDeepRight(a, b)
|
|
8176
|
+
const expected = {
|
|
8177
|
+
a : [ 7, 8, 9 ],
|
|
8178
|
+
b : [ 10, 11, 12 ],
|
|
8179
|
+
}
|
|
8180
|
+
expect(result).toEqual(expected)
|
|
8181
|
+
})
|
|
8182
|
+
|
|
8169
8183
|
test('happy', () => {
|
|
8170
8184
|
const result = mergeDeepRight(student, teacher)
|
|
8171
8185
|
const curryResult = mergeDeepRight(student)(teacher)
|
|
@@ -8390,7 +8404,7 @@ describe('R.mergeLeft', () => {
|
|
|
8390
8404
|
|
|
8391
8405
|
### mergeRight
|
|
8392
8406
|
|
|
8393
|
-
It creates a copy of `target` object with
|
|
8407
|
+
It creates a copy of `target` object with overwritten `newProps` properties. Previously known as `R.merge` but renamed after Ramda did the same.
|
|
8394
8408
|
|
|
8395
8409
|
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20target%20%3D%20%7B%20'foo'%3A%200%2C%20'bar'%3A%201%20%7D%0Aconst%20newProps%20%3D%20%7B%20'foo'%3A%207%20%7D%0A%0Aconst%20result%20%3D%20R.mergeRight(target%2C%20newProps)%0A%2F%2F%20%3D%3E%20%7B%20'foo'%3A%207%2C%20'bar'%3A%201%20%7D">Try this <strong>R.mergeRight</strong> example in Rambda REPL</a>
|
|
8396
8410
|
|
|
@@ -10330,6 +10344,7 @@ path<
|
|
|
10330
10344
|
path<T>(pathToSearch: string, obj: any): T | undefined;
|
|
10331
10345
|
path<T>(pathToSearch: string): (obj: any) => T | undefined;
|
|
10332
10346
|
path<T>(pathToSearch: RamdaPath): (obj: any) => T | undefined;
|
|
10347
|
+
path<T>(pathToSearch: RamdaPath, obj: any): T | undefined;
|
|
10333
10348
|
```
|
|
10334
10349
|
|
|
10335
10350
|
</details>
|
|
@@ -10445,12 +10460,31 @@ describe('R.path with list as path', () => {
|
|
|
10445
10460
|
test('shallow property', () => {
|
|
10446
10461
|
// $ExpectType number
|
|
10447
10462
|
path(['a'], {a: 1})
|
|
10448
|
-
|
|
10449
|
-
|
|
10463
|
+
|
|
10464
|
+
// $ExpectType unknown
|
|
10465
|
+
path(['b'], {a: 1})
|
|
10450
10466
|
})
|
|
10451
10467
|
test('deep property', () => {
|
|
10468
|
+
const testObject = {a: {b: {c: {d: {e: {f: 1}}}}}}
|
|
10469
|
+
const result = path(['a', 'b', 'c', 'd', 'e', 'f'], testObject)
|
|
10452
10470
|
// $ExpectType number
|
|
10453
|
-
|
|
10471
|
+
result
|
|
10472
|
+
const curriedResult = path(['a', 'b', 'c', 'd', 'e', 'f'])(testObject)
|
|
10473
|
+
// $ExpectType unknown
|
|
10474
|
+
curriedResult
|
|
10475
|
+
})
|
|
10476
|
+
test('issue #668 - path is not correct', () => {
|
|
10477
|
+
const object = {
|
|
10478
|
+
is: {
|
|
10479
|
+
a: 'path',
|
|
10480
|
+
},
|
|
10481
|
+
}
|
|
10482
|
+
const result = path(['is', 'not', 'a'], object)
|
|
10483
|
+
// $ExpectType unknown
|
|
10484
|
+
result
|
|
10485
|
+
const curriedResult = path(['is', 'not', 'a'])(object)
|
|
10486
|
+
// $ExpectType unknown
|
|
10487
|
+
curriedResult
|
|
10454
10488
|
})
|
|
10455
10489
|
})
|
|
10456
10490
|
```
|
|
@@ -10885,7 +10919,7 @@ It returns a partial copy of an `input` containing only `propsToPick` properties
|
|
|
10885
10919
|
|
|
10886
10920
|
`input` can be either an object or an array.
|
|
10887
10921
|
|
|
10888
|
-
String
|
|
10922
|
+
String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
|
|
10889
10923
|
|
|
10890
10924
|
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20obj%20%3D%20%7B%0A%20%20a%20%3A%201%2C%0A%20%20b%20%3A%20false%2C%0A%20%20foo%3A%20'cherry'%0A%7D%0Aconst%20list%20%3D%20%5B1%2C%202%2C%203%2C%204%5D%0Aconst%20propsToPick%20%3D%20'a%2Cfoo'%0Aconst%20propsToPickList%20%3D%20%5B'a'%2C%20'foo'%5D%0A%0Aconst%20result%20%3D%20%5B%0A%20%20R.pick(propsToPick%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick(propsToPickList%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick('a%2Cbar'%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick('bar'%2C%20Record%3Cstring%2C%20unknown%3E)%2C%0A%20%20R.pick(%5B0%2C%203%2C%205%5D%2C%20list)%2C%0A%20%20R.pick('0%2C3%2C5'%2C%20list)%2C%0A%5D%0A%0Aconst%20expected%20%3D%20%5B%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%2C%20foo%3A%20'cherry'%7D%2C%0A%20%20%7Ba%3A1%7D%2C%0A%20%20%7B%7D%2C%0A%20%20%7B0%3A%201%2C%203%3A%204%7D%2C%0A%20%20%7B0%3A%201%2C%203%3A%204%7D%2C%0A%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.pick</strong> example in Rambda REPL</a>
|
|
10891
10925
|
|
|
@@ -14362,17 +14396,16 @@ export function takeLastWhile(predicate, input){
|
|
|
14362
14396
|
return _input => takeLastWhile(predicate, _input)
|
|
14363
14397
|
}
|
|
14364
14398
|
if (input.length === 0) return input
|
|
14365
|
-
|
|
14399
|
+
|
|
14366
14400
|
const toReturn = []
|
|
14367
14401
|
let counter = input.length
|
|
14368
14402
|
|
|
14369
|
-
while (
|
|
14370
|
-
counter
|
|
14371
|
-
if (predicate(
|
|
14372
|
-
|
|
14373
|
-
} else if (!found){
|
|
14374
|
-
toReturn.push(input[ counter ])
|
|
14403
|
+
while (counter){
|
|
14404
|
+
const item = input[ --counter ]
|
|
14405
|
+
if (!predicate(item)){
|
|
14406
|
+
break
|
|
14375
14407
|
}
|
|
14408
|
+
toReturn.push(item)
|
|
14376
14409
|
}
|
|
14377
14410
|
|
|
14378
14411
|
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')
|
|
@@ -14398,13 +14431,13 @@ test('happy', () => {
|
|
|
14398
14431
|
})
|
|
14399
14432
|
|
|
14400
14433
|
test('predicate is always true', () => {
|
|
14401
|
-
const predicate =
|
|
14434
|
+
const predicate = () => true
|
|
14402
14435
|
const result = takeLastWhile(predicate)(list)
|
|
14403
14436
|
expect(result).toEqual(list)
|
|
14404
14437
|
})
|
|
14405
14438
|
|
|
14406
14439
|
test('predicate is always false', () => {
|
|
14407
|
-
const predicate =
|
|
14440
|
+
const predicate = () => false
|
|
14408
14441
|
const result = takeLastWhile(predicate, list)
|
|
14409
14442
|
expect(result).toEqual([])
|
|
14410
14443
|
})
|
|
@@ -14470,7 +14503,7 @@ tap<T>(fn: (x: T) => void, input: T): T
|
|
|
14470
14503
|
|
|
14471
14504
|
It applies function `fn` to input `x` and returns `x`.
|
|
14472
14505
|
|
|
14473
|
-
One use case is
|
|
14506
|
+
One use case is debugging in the middle of `R.compose`.
|
|
14474
14507
|
|
|
14475
14508
|
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20list%20%3D%20%5B1%2C%202%2C%203%5D%0A%0AR.compose(%0A%20%20R.map(x%20%3D%3E%20x%20*%202)%0A%20%20R.tap(console.log)%2C%0A%20%20R.filter(x%20%3D%3E%20x%20%3E%201)%0A)(list)%0A%2F%2F%20%3D%3E%20%602%60%20and%20%603%60%20will%20be%20logged">Try this <strong>R.tap</strong> example in Rambda REPL</a>
|
|
14476
14509
|
|
|
@@ -15516,7 +15549,11 @@ describe('R.uniq', () => {
|
|
|
15516
15549
|
|
|
15517
15550
|
### uniqBy
|
|
15518
15551
|
|
|
15519
|
-
|
|
15552
|
+
It applies uniqueness to input list based on function that defines what to be used for comparison between elements.
|
|
15553
|
+
|
|
15554
|
+
`R.equals` is used to determine equality.
|
|
15555
|
+
|
|
15556
|
+
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20list%20%3D%20%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%2C%20%7Ba%3A1%7D%5D%0Aconst%20result%20%3D%20R.uniqBy(x%20%3D%3E%20x%2C%20list)%0A%0A%2F%2F%20%3D%3E%20%5B%7Ba%3A1%7D%2C%20%7Ba%3A2%7D%5D">Try this <strong>R.uniqBy</strong> example in Rambda REPL</a>
|
|
15520
15557
|
|
|
15521
15558
|
[](#uniqBy)
|
|
15522
15559
|
|
|
@@ -15792,6 +15829,10 @@ describe('R.unless - curried', () => {
|
|
|
15792
15829
|
|
|
15793
15830
|
[](#unless)
|
|
15794
15831
|
|
|
15832
|
+
### unnest
|
|
15833
|
+
|
|
15834
|
+
[](#unnest)
|
|
15835
|
+
|
|
15795
15836
|
### unwind
|
|
15796
15837
|
|
|
15797
15838
|
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20obj%20%3D%20%7B%0A%20%20a%3A%201%2C%0A%20%20b%3A%20%5B2%2C%203%5D%2C%0A%7D%0Aconst%20result%20%3D%20unwind('b'%2C%20Record%3Cstring%2C%20unknown%3E)%0Aconst%20expected%20%3D%20%5B%7Ba%3A1%2C%20b%3A2%7D%2C%20%7Ba%3A1%2C%20b%3A3%7D%5D%0A%2F%2F%20%3D%3E%20%60result%60%20is%20equal%20to%20%60expected%60">Try this <strong>R.unwind</strong> example in Rambda REPL</a>
|
|
@@ -17009,6 +17050,36 @@ describe('R.zipWith', () => {
|
|
|
17009
17050
|
|
|
17010
17051
|
## ❯ CHANGELOG
|
|
17011
17052
|
|
|
17053
|
+
8.0.0
|
|
17054
|
+
|
|
17055
|
+
- handle falsy values in merge methods - https://github.com/ramda/ramda/pull/3222
|
|
17056
|
+
|
|
17057
|
+
- `R.head`/`R.last` don't return `undefined` for non-empty arrays
|
|
17058
|
+
|
|
17059
|
+
- `R.type` supports dates in TS definition - `Rambda` already did support dates in JS.
|
|
17060
|
+
|
|
17061
|
+
- Improve typings of `R.endsWith/startsWith` with regard to `string` input. - [PR #622](https://github.com/selfrefactor/rambda/pull/622)
|
|
17062
|
+
|
|
17063
|
+
- Handle list as falsy value in `R.reduce` - [Ramda MR](https://github.com/ramda/ramda/pull/2997/files)
|
|
17064
|
+
|
|
17065
|
+
- `R.nop` is removed - it will be moved to `Rambdax` as `R.noop`
|
|
17066
|
+
|
|
17067
|
+
- `R.includes` is no longer using string literal in Typescript definitions
|
|
17068
|
+
|
|
17069
|
+
> Reason for breaking change - synchronize with Ramda `0.29.0` release:
|
|
17070
|
+
|
|
17071
|
+
- change order of `R.propEq` - [Ramda MR](https://github.com/ramda/ramda/pull/2938/files)
|
|
17072
|
+
|
|
17073
|
+
7.5.0
|
|
17074
|
+
|
|
17075
|
+
- IMPORTANT: Remove `export` property in `package.json` in order to allow `Rambda` support for projects with `"type": "module"` in `package.json` - [Issue #667](https://github.com/selfrefactor/rambda/issues/657)
|
|
17076
|
+
|
|
17077
|
+
- Add `R.unnest` - [Rambdax issue 89](https://github.com/selfrefactor/rambdax/issues/89)
|
|
17078
|
+
|
|
17079
|
+
- `R.uniq` is not using `R.equals` as Ramda does - [Issue #88](https://github.com/selfrefactor/rambdax/issues/88)
|
|
17080
|
+
|
|
17081
|
+
- Fix `R.path(['non','existing','path'], obj)` TS definition as 7.4.0 release caused TS errors - [Issue #668](https://github.com/selfrefactor/rambda/issues/668)
|
|
17082
|
+
|
|
17012
17083
|
7.4.0
|
|
17013
17084
|
|
|
17014
17085
|
- Synchronize with `@types/ramda` - `R.prop`, `R.path`, `R.pickAll`
|
package/dist/rambda.js
CHANGED
|
@@ -324,6 +324,9 @@ class ReduceStopper {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
function reduceFn(reducer, acc, list) {
|
|
327
|
+
if (list == null) {
|
|
328
|
+
return acc;
|
|
329
|
+
}
|
|
327
330
|
if (!isArray(list)) {
|
|
328
331
|
throw new TypeError('reduce: list must be array or iterable');
|
|
329
332
|
}
|
|
@@ -764,18 +767,18 @@ function dropLastWhile(predicate, iterable) {
|
|
|
764
767
|
if (!isArray$1 && typeof iterable !== 'string') {
|
|
765
768
|
throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
|
|
766
769
|
}
|
|
767
|
-
let found = false;
|
|
768
770
|
const toReturn = [];
|
|
769
771
|
let counter = iterable.length;
|
|
770
|
-
while (counter
|
|
771
|
-
counter
|
|
772
|
-
if (!
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
} else if (found) {
|
|
776
|
-
toReturn.push(iterable[counter]);
|
|
772
|
+
while (counter) {
|
|
773
|
+
const item = iterable[--counter];
|
|
774
|
+
if (!predicate(item)) {
|
|
775
|
+
toReturn.push(item);
|
|
776
|
+
break;
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
|
+
while (counter) {
|
|
780
|
+
toReturn.push(iterable[--counter]);
|
|
781
|
+
}
|
|
779
782
|
return isArray$1 ? toReturn.reverse() : toReturn.reverse().join('');
|
|
780
783
|
}
|
|
781
784
|
|
|
@@ -822,18 +825,19 @@ function dropWhile(predicate, iterable) {
|
|
|
822
825
|
if (!isArray$1 && typeof iterable !== 'string') {
|
|
823
826
|
throw new Error('`iterable` is neither list nor a string');
|
|
824
827
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
if (
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if (!flag) flag = true;
|
|
833
|
-
holder.push(iterable[counter]);
|
|
828
|
+
const toReturn = [];
|
|
829
|
+
let counter = 0;
|
|
830
|
+
while (counter < iterable.length) {
|
|
831
|
+
const item = iterable[counter++];
|
|
832
|
+
if (!predicate(item)) {
|
|
833
|
+
toReturn.push(item);
|
|
834
|
+
break;
|
|
834
835
|
}
|
|
835
836
|
}
|
|
836
|
-
|
|
837
|
+
while (counter < iterable.length) {
|
|
838
|
+
toReturn.push(iterable[counter++]);
|
|
839
|
+
}
|
|
840
|
+
return isArray$1 ? toReturn : toReturn.join('');
|
|
837
841
|
}
|
|
838
842
|
|
|
839
843
|
function either(firstPredicate, secondPredicate) {
|
|
@@ -1108,11 +1112,7 @@ function createPath(path, delimiter = '.') {
|
|
|
1108
1112
|
return typeof path === 'string' ? path.split(delimiter) : path;
|
|
1109
1113
|
}
|
|
1110
1114
|
|
|
1111
|
-
function
|
|
1112
|
-
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
1113
|
-
if (obj === null || obj === undefined) {
|
|
1114
|
-
return undefined;
|
|
1115
|
-
}
|
|
1115
|
+
function pathFn(pathInput, obj) {
|
|
1116
1116
|
let willReturn = obj;
|
|
1117
1117
|
let counter = 0;
|
|
1118
1118
|
const pathArrValue = createPath(pathInput);
|
|
@@ -1126,6 +1126,13 @@ function path(pathInput, obj) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
return willReturn;
|
|
1128
1128
|
}
|
|
1129
|
+
function path(pathInput, obj) {
|
|
1130
|
+
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
1131
|
+
if (obj === null || obj === undefined) {
|
|
1132
|
+
return undefined;
|
|
1133
|
+
}
|
|
1134
|
+
return pathFn(pathInput, obj);
|
|
1135
|
+
}
|
|
1129
1136
|
|
|
1130
1137
|
function hasPath(pathInput, obj) {
|
|
1131
1138
|
if (arguments.length === 1) {
|
|
@@ -1403,7 +1410,9 @@ function mergeLeft(x, y) {
|
|
|
1403
1410
|
return mergeRight(y, x);
|
|
1404
1411
|
}
|
|
1405
1412
|
|
|
1406
|
-
function mergeWithFn(mergeFn,
|
|
1413
|
+
function mergeWithFn(mergeFn, aInput, bInput) {
|
|
1414
|
+
const a = aInput !== null && aInput !== void 0 ? aInput : {};
|
|
1415
|
+
const b = bInput !== null && bInput !== void 0 ? bInput : {};
|
|
1407
1416
|
const willReturn = {};
|
|
1408
1417
|
Object.keys(a).forEach(key => {
|
|
1409
1418
|
if (b[key] === undefined) {
|
|
@@ -1456,6 +1465,7 @@ function _objectSpread2(target) {
|
|
|
1456
1465
|
return target;
|
|
1457
1466
|
}
|
|
1458
1467
|
function _defineProperty(obj, key, value) {
|
|
1468
|
+
key = _toPropertyKey(key);
|
|
1459
1469
|
if (key in obj) {
|
|
1460
1470
|
Object.defineProperty(obj, key, {
|
|
1461
1471
|
value: value,
|
|
@@ -1468,6 +1478,20 @@ function _defineProperty(obj, key, value) {
|
|
|
1468
1478
|
}
|
|
1469
1479
|
return obj;
|
|
1470
1480
|
}
|
|
1481
|
+
function _toPrimitive(input, hint) {
|
|
1482
|
+
if (typeof input !== "object" || input === null) return input;
|
|
1483
|
+
var prim = input[Symbol.toPrimitive];
|
|
1484
|
+
if (prim !== undefined) {
|
|
1485
|
+
var res = prim.call(input, hint || "default");
|
|
1486
|
+
if (typeof res !== "object") return res;
|
|
1487
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1488
|
+
}
|
|
1489
|
+
return (hint === "string" ? String : Number)(input);
|
|
1490
|
+
}
|
|
1491
|
+
function _toPropertyKey(arg) {
|
|
1492
|
+
var key = _toPrimitive(arg, "string");
|
|
1493
|
+
return typeof key === "symbol" ? key : String(key);
|
|
1494
|
+
}
|
|
1471
1495
|
|
|
1472
1496
|
function isIterable(input) {
|
|
1473
1497
|
return Array.isArray(input) || type(input) === 'Object';
|
|
@@ -1535,8 +1559,6 @@ function none(predicate, list) {
|
|
|
1535
1559
|
return true;
|
|
1536
1560
|
}
|
|
1537
1561
|
|
|
1538
|
-
function nop() {}
|
|
1539
|
-
|
|
1540
1562
|
function not(input) {
|
|
1541
1563
|
return !input;
|
|
1542
1564
|
}
|
|
@@ -1730,7 +1752,7 @@ function prepend(x, input) {
|
|
|
1730
1752
|
|
|
1731
1753
|
const product = reduce(multiply, 1);
|
|
1732
1754
|
|
|
1733
|
-
function propEqFn(
|
|
1755
|
+
function propEqFn(valueToMatch, propToFind, obj) {
|
|
1734
1756
|
if (!obj) return false;
|
|
1735
1757
|
return equals(valueToMatch, prop(propToFind, obj));
|
|
1736
1758
|
}
|
|
@@ -1892,20 +1914,20 @@ function splitWhen(predicate, input) {
|
|
|
1892
1914
|
return [preFound, postFound];
|
|
1893
1915
|
}
|
|
1894
1916
|
|
|
1895
|
-
function startsWith(
|
|
1896
|
-
if (arguments.length === 1) return _iterable => startsWith(
|
|
1917
|
+
function startsWith(question, iterable) {
|
|
1918
|
+
if (arguments.length === 1) return _iterable => startsWith(question, _iterable);
|
|
1897
1919
|
if (typeof iterable === 'string') {
|
|
1898
|
-
return iterable.startsWith(
|
|
1920
|
+
return iterable.startsWith(question);
|
|
1899
1921
|
}
|
|
1900
|
-
if (!isArray(
|
|
1922
|
+
if (!isArray(question)) return false;
|
|
1901
1923
|
let correct = true;
|
|
1902
|
-
const filtered =
|
|
1924
|
+
const filtered = question.filter((x, index) => {
|
|
1903
1925
|
if (!correct) return false;
|
|
1904
1926
|
const result = equals(x, iterable[index]);
|
|
1905
1927
|
if (!result) correct = false;
|
|
1906
1928
|
return result;
|
|
1907
1929
|
});
|
|
1908
|
-
return filtered.length ===
|
|
1930
|
+
return filtered.length === question.length;
|
|
1909
1931
|
}
|
|
1910
1932
|
|
|
1911
1933
|
function subtract(a, b) {
|
|
@@ -1939,16 +1961,14 @@ function takeLastWhile(predicate, input) {
|
|
|
1939
1961
|
return _input => takeLastWhile(predicate, _input);
|
|
1940
1962
|
}
|
|
1941
1963
|
if (input.length === 0) return input;
|
|
1942
|
-
let found = false;
|
|
1943
1964
|
const toReturn = [];
|
|
1944
1965
|
let counter = input.length;
|
|
1945
|
-
while (
|
|
1946
|
-
counter
|
|
1947
|
-
if (predicate(
|
|
1948
|
-
|
|
1949
|
-
} else if (!found) {
|
|
1950
|
-
toReturn.push(input[counter]);
|
|
1966
|
+
while (counter) {
|
|
1967
|
+
const item = input[--counter];
|
|
1968
|
+
if (!predicate(item)) {
|
|
1969
|
+
break;
|
|
1951
1970
|
}
|
|
1971
|
+
toReturn.push(item);
|
|
1952
1972
|
}
|
|
1953
1973
|
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');
|
|
1954
1974
|
}
|
|
@@ -1961,17 +1981,16 @@ function takeWhile(predicate, iterable) {
|
|
|
1961
1981
|
if (!isArray$1 && typeof iterable !== 'string') {
|
|
1962
1982
|
throw new Error('`iterable` is neither list nor a string');
|
|
1963
1983
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
if (!predicate(
|
|
1969
|
-
|
|
1970
|
-
} else if (flag) {
|
|
1971
|
-
holder.push(iterable[counter]);
|
|
1984
|
+
const toReturn = [];
|
|
1985
|
+
let counter = 0;
|
|
1986
|
+
while (counter < iterable.length) {
|
|
1987
|
+
const item = iterable[counter++];
|
|
1988
|
+
if (!predicate(item)) {
|
|
1989
|
+
break;
|
|
1972
1990
|
}
|
|
1991
|
+
toReturn.push(item);
|
|
1973
1992
|
}
|
|
1974
|
-
return isArray$1 ?
|
|
1993
|
+
return isArray$1 ? toReturn : toReturn.join('');
|
|
1975
1994
|
}
|
|
1976
1995
|
|
|
1977
1996
|
function tap(fn, x) {
|
|
@@ -2057,12 +2076,8 @@ function uniqBy(fn, list) {
|
|
|
2057
2076
|
if (arguments.length === 1) {
|
|
2058
2077
|
return _list => uniqBy(fn, _list);
|
|
2059
2078
|
}
|
|
2060
|
-
const set = new
|
|
2061
|
-
return list.filter(item =>
|
|
2062
|
-
if (set.has(fn(item))) return false;
|
|
2063
|
-
set.add(fn(item));
|
|
2064
|
-
return true;
|
|
2065
|
-
});
|
|
2079
|
+
const set = new _Set();
|
|
2080
|
+
return list.filter(item => set.checkUniqueness(fn(item)));
|
|
2066
2081
|
}
|
|
2067
2082
|
|
|
2068
2083
|
function includesWith(predicate, target, list) {
|
|
@@ -2096,6 +2111,15 @@ function unless(predicate, whenFalse) {
|
|
|
2096
2111
|
return input => predicate(input) ? input : whenFalse(input);
|
|
2097
2112
|
}
|
|
2098
2113
|
|
|
2114
|
+
function unnest(list) {
|
|
2115
|
+
return list.reduce((acc, item) => {
|
|
2116
|
+
if (Array.isArray(item)) {
|
|
2117
|
+
return [...acc, ...item];
|
|
2118
|
+
}
|
|
2119
|
+
return [...acc, item];
|
|
2120
|
+
}, []);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2099
2123
|
function unwind(property, obj) {
|
|
2100
2124
|
if (arguments.length === 1) {
|
|
2101
2125
|
return _obj => unwind(property, _obj);
|
|
@@ -2315,7 +2339,6 @@ exports.move = move;
|
|
|
2315
2339
|
exports.multiply = multiply;
|
|
2316
2340
|
exports.negate = negate;
|
|
2317
2341
|
exports.none = none;
|
|
2318
|
-
exports.nop = nop;
|
|
2319
2342
|
exports.not = not;
|
|
2320
2343
|
exports.nth = nth;
|
|
2321
2344
|
exports.objOf = objOf;
|
|
@@ -2332,6 +2355,7 @@ exports.partitionArray = partitionArray;
|
|
|
2332
2355
|
exports.partitionObject = partitionObject;
|
|
2333
2356
|
exports.path = path;
|
|
2334
2357
|
exports.pathEq = pathEq;
|
|
2358
|
+
exports.pathFn = pathFn;
|
|
2335
2359
|
exports.pathOr = pathOr;
|
|
2336
2360
|
exports.paths = paths;
|
|
2337
2361
|
exports.pick = pick;
|
|
@@ -2388,6 +2412,7 @@ exports.uniq = uniq;
|
|
|
2388
2412
|
exports.uniqBy = uniqBy;
|
|
2389
2413
|
exports.uniqWith = uniqWith;
|
|
2390
2414
|
exports.unless = unless;
|
|
2415
|
+
exports.unnest = unnest;
|
|
2391
2416
|
exports.unwind = unwind;
|
|
2392
2417
|
exports.update = update;
|
|
2393
2418
|
exports.updateFn = updateFn;
|