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/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
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
+
while (counter < iterable.length){
|
|
24
|
+
toReturn.push(iterable[ counter++ ])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return isArray ? toReturn : toReturn.join('')
|
|
26
28
|
}
|
package/src/isPromise.js
CHANGED
package/src/mergeWith.js
CHANGED
package/src/path.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createPath } from './_internals/createPath.js'
|
|
2
2
|
|
|
3
|
-
export function
|
|
4
|
-
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
5
|
-
|
|
6
|
-
if (obj === null || obj === undefined){
|
|
7
|
-
return undefined
|
|
8
|
-
}
|
|
3
|
+
export function pathFn(pathInput, obj){
|
|
9
4
|
let willReturn = obj
|
|
10
5
|
let counter = 0
|
|
11
6
|
|
|
@@ -23,3 +18,13 @@ export function path(pathInput, obj){
|
|
|
23
18
|
|
|
24
19
|
return willReturn
|
|
25
20
|
}
|
|
21
|
+
|
|
22
|
+
export function path(pathInput, obj){
|
|
23
|
+
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
24
|
+
|
|
25
|
+
if (obj === null || obj === undefined){
|
|
26
|
+
return undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return pathFn(pathInput, obj)
|
|
30
|
+
}
|
package/src/propEq.js
CHANGED
package/src/reduce.js
CHANGED
package/src/reverse.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export function reverse(listOrString){
|
|
2
|
-
if (typeof listOrString === 'string'){
|
|
3
|
-
return listOrString.split('').reverse()
|
|
4
|
-
.join('')
|
|
1
|
+
export function reverse(listOrString) {
|
|
2
|
+
if (typeof listOrString === 'string') {
|
|
3
|
+
return listOrString.split('').reverse().join('')
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
const clone = listOrString.slice()
|
package/src/set.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {always} from './always.js'
|
|
2
|
+
import {curry} from './curry.js'
|
|
3
|
+
import {over} from './over.js'
|
|
4
4
|
|
|
5
|
-
function setFn(
|
|
6
|
-
lens, replacer, x
|
|
7
|
-
){
|
|
8
|
-
return over(
|
|
9
|
-
lens, always(replacer), x
|
|
10
|
-
)
|
|
5
|
+
function setFn(lens, replacer, x) {
|
|
6
|
+
return over(lens, always(replacer), x)
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
export const set = curry(setFn)
|
package/src/startsWith.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { equals } from './equals.js'
|
|
3
3
|
|
|
4
|
-
export function startsWith(
|
|
4
|
+
export function startsWith(question, iterable){
|
|
5
5
|
if (arguments.length === 1)
|
|
6
|
-
return _iterable => startsWith(
|
|
6
|
+
return _iterable => startsWith(question, _iterable)
|
|
7
7
|
|
|
8
8
|
if (typeof iterable === 'string'){
|
|
9
|
-
return iterable.startsWith(
|
|
9
|
+
return iterable.startsWith(question)
|
|
10
10
|
}
|
|
11
|
-
if (!isArray(
|
|
11
|
+
if (!isArray(question)) return false
|
|
12
12
|
|
|
13
13
|
let correct = true
|
|
14
|
-
const filtered =
|
|
14
|
+
const filtered = question.filter((x, index) => {
|
|
15
15
|
if (!correct) return false
|
|
16
16
|
const result = equals(x, iterable[ index ])
|
|
17
17
|
if (!result) correct = false
|
|
@@ -19,5 +19,5 @@ export function startsWith(target, iterable){
|
|
|
19
19
|
return result
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
return filtered.length ===
|
|
22
|
+
return filtered.length === question.length
|
|
23
23
|
}
|
package/src/takeLastWhile.js
CHANGED
|
@@ -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
|
-
|
|
8
|
+
|
|
9
9
|
const toReturn = []
|
|
10
10
|
let counter = input.length
|
|
11
11
|
|
|
12
|
-
while (
|
|
13
|
-
counter
|
|
14
|
-
if (predicate(
|
|
15
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 ?
|
|
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
|
|
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
|
-
|
|
12
|
-
})
|
|
9
|
+
return list.filter(item => set.checkUniqueness(fn(item)))
|
|
13
10
|
}
|