rambda 7.0.3 → 7.1.2

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.
Files changed (201) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +3542 -2693
  3. package/dist/rambda.js +282 -76
  4. package/dist/rambda.mjs +268 -76
  5. package/dist/rambda.umd.js +1 -1
  6. package/immutable.d.ts +91 -10
  7. package/index.d.ts +91 -10
  8. package/package.json +119 -119
  9. package/src/F.js +1 -1
  10. package/src/T.js +1 -1
  11. package/src/_internals/_isInteger.js +1 -1
  12. package/src/_internals/_keys.js +0 -1
  13. package/src/_internals/_objectIs.js +2 -7
  14. package/src/_internals/baseSlice.js +8 -6
  15. package/src/_internals/cloneList.js +1 -3
  16. package/src/_internals/createPath.js +3 -0
  17. package/src/_internals/isFalsy.js +5 -5
  18. package/src/_internals/isObject.js +2 -2
  19. package/src/_internals/isTruthy.js +5 -5
  20. package/src/_internals/set.js +19 -13
  21. package/src/add.js +1 -1
  22. package/src/adjust.js +6 -4
  23. package/src/all.js +3 -3
  24. package/src/allPass.js +3 -3
  25. package/src/always.js +2 -2
  26. package/src/and.js +1 -1
  27. package/src/any.js +3 -3
  28. package/src/anyPass.js +3 -3
  29. package/src/append.js +2 -2
  30. package/src/apply.js +2 -2
  31. package/src/applySpec.js +59 -33
  32. package/src/assoc.js +7 -3
  33. package/src/assocPath.js +25 -21
  34. package/src/bind.js +3 -3
  35. package/src/both.js +1 -1
  36. package/src/chain.js +2 -2
  37. package/src/clamp.js +6 -6
  38. package/src/clone.js +10 -10
  39. package/src/complement.js +1 -1
  40. package/src/compose.js +5 -14
  41. package/src/concat.js +2 -2
  42. package/src/cond.js +3 -3
  43. package/src/converge.js +11 -11
  44. package/src/count.js +10 -0
  45. package/src/countBy.js +17 -0
  46. package/src/curry.js +2 -2
  47. package/src/curryN.js +81 -61
  48. package/src/defaultTo.js +3 -3
  49. package/src/difference.js +3 -3
  50. package/src/dissoc.js +4 -4
  51. package/src/divide.js +1 -1
  52. package/src/drop.js +1 -1
  53. package/src/dropLast.js +5 -5
  54. package/src/dropLastWhile.js +12 -12
  55. package/src/dropRepeats.js +6 -6
  56. package/src/dropRepeatsWith.js +7 -7
  57. package/src/dropWhile.js +9 -9
  58. package/src/either.js +2 -2
  59. package/src/endsWith.js +6 -5
  60. package/src/eqProps.js +6 -4
  61. package/src/equals.js +64 -65
  62. package/src/evolve.js +21 -23
  63. package/src/filter.js +21 -15
  64. package/src/find.js +4 -4
  65. package/src/findIndex.js +3 -3
  66. package/src/findLast.js +4 -4
  67. package/src/findLastIndex.js +3 -3
  68. package/src/flatten.js +6 -6
  69. package/src/flip.js +15 -11
  70. package/src/forEach.js +12 -10
  71. package/src/fromPairs.js +2 -2
  72. package/src/groupBy.js +6 -6
  73. package/src/groupWith.js +12 -10
  74. package/src/has.js +1 -1
  75. package/src/hasPath.js +3 -3
  76. package/src/head.js +3 -3
  77. package/src/identical.js +2 -2
  78. package/src/identity.js +1 -1
  79. package/src/ifElse.js +5 -3
  80. package/src/includes.js +6 -6
  81. package/src/indexBy.js +11 -11
  82. package/src/indexOf.js +3 -3
  83. package/src/init.js +7 -3
  84. package/src/intersection.js +3 -3
  85. package/src/intersperse.js +5 -5
  86. package/src/is.js +2 -2
  87. package/src/isEmpty.js +5 -5
  88. package/src/isNil.js +1 -1
  89. package/src/isPromise.js +3 -3
  90. package/src/join.js +1 -1
  91. package/src/juxt.js +3 -0
  92. package/src/keys.js +1 -1
  93. package/src/last.js +4 -4
  94. package/src/lastIndexOf.js +3 -3
  95. package/src/length.js +2 -2
  96. package/src/lens.js +3 -3
  97. package/src/lensIndex.js +4 -4
  98. package/src/lensPath.js +4 -4
  99. package/src/lensProp.js +4 -4
  100. package/src/map.js +15 -11
  101. package/src/match.js +1 -1
  102. package/src/mathMod.js +3 -3
  103. package/src/max.js +1 -1
  104. package/src/maxBy.js +4 -2
  105. package/src/maybe.js +4 -2
  106. package/src/mean.js +2 -2
  107. package/src/median.js +10 -12
  108. package/src/merge.js +1 -5
  109. package/src/mergeAll.js +4 -4
  110. package/src/mergeDeepRight.js +8 -8
  111. package/src/mergeLeft.js +3 -3
  112. package/src/mergeRight.js +7 -0
  113. package/src/mergeWith.js +29 -0
  114. package/src/min.js +1 -1
  115. package/src/minBy.js +4 -2
  116. package/src/modulo.js +1 -1
  117. package/src/move.js +8 -6
  118. package/src/multiply.js +1 -1
  119. package/src/negate.js +1 -1
  120. package/src/none.js +3 -3
  121. package/src/not.js +1 -1
  122. package/src/nth.js +6 -6
  123. package/src/objOf.js +3 -5
  124. package/src/of.js +2 -2
  125. package/src/omit.js +8 -8
  126. package/src/on.js +16 -0
  127. package/src/once.js +6 -6
  128. package/src/or.js +1 -1
  129. package/src/over.js +5 -3
  130. package/src/partial.js +3 -3
  131. package/src/partialObject.js +15 -0
  132. package/src/partition.js +18 -16
  133. package/src/path.js +9 -8
  134. package/src/pathEq.js +6 -4
  135. package/src/pathOr.js +6 -4
  136. package/src/paths.js +3 -3
  137. package/src/pick.js +8 -8
  138. package/src/pickAll.js +9 -9
  139. package/src/pipe.js +85 -13
  140. package/src/pluck.js +4 -4
  141. package/src/prepend.js +3 -3
  142. package/src/product.js +2 -2
  143. package/src/prop.js +2 -2
  144. package/src/propEq.js +5 -3
  145. package/src/propIs.js +6 -4
  146. package/src/propOr.js +6 -4
  147. package/src/propSatisfies.js +10 -0
  148. package/src/props.js +6 -6
  149. package/src/range.js +4 -4
  150. package/src/reduce.js +11 -7
  151. package/src/reject.js +2 -2
  152. package/src/repeat.js +2 -2
  153. package/src/replace.js +4 -2
  154. package/src/reverse.js +4 -3
  155. package/src/set.js +9 -5
  156. package/src/slice.js +4 -2
  157. package/src/sort.js +2 -2
  158. package/src/sortBy.js +2 -2
  159. package/src/split.js +1 -1
  160. package/src/splitAt.js +9 -9
  161. package/src/splitEvery.js +6 -8
  162. package/src/splitWhen.js +10 -10
  163. package/src/startsWith.js +6 -5
  164. package/src/subtract.js +1 -1
  165. package/src/sum.js +1 -1
  166. package/src/symmetricDifference.js +7 -9
  167. package/src/tail.js +2 -2
  168. package/src/take.js +5 -3
  169. package/src/takeLast.js +5 -3
  170. package/src/takeLastWhile.js +7 -7
  171. package/src/takeWhile.js +8 -8
  172. package/src/tap.js +1 -1
  173. package/src/test.js +3 -5
  174. package/src/times.js +4 -4
  175. package/src/toLower.js +1 -1
  176. package/src/toPairs.js +1 -1
  177. package/src/toString.js +1 -1
  178. package/src/toUpper.js +1 -1
  179. package/src/transpose.js +3 -4
  180. package/src/trim.js +1 -1
  181. package/src/tryCatch.js +7 -5
  182. package/src/type.js +5 -5
  183. package/src/unapply.js +2 -2
  184. package/src/union.js +3 -3
  185. package/src/uniq.js +3 -3
  186. package/src/uniqWith.js +12 -8
  187. package/src/unless.js +3 -3
  188. package/src/unwind.js +15 -0
  189. package/src/update.js +8 -4
  190. package/src/values.js +2 -2
  191. package/src/view.js +2 -2
  192. package/src/when.js +4 -2
  193. package/src/where.js +5 -5
  194. package/src/whereAny.js +12 -0
  195. package/src/whereEq.js +7 -9
  196. package/src/without.js +4 -4
  197. package/src/xor.js +2 -2
  198. package/src/zip.js +3 -3
  199. package/src/zipObj.js +6 -4
  200. package/src/zipWith.js +6 -6
  201. package/src/isFunction.js +0 -5
package/src/median.js CHANGED
@@ -1,19 +1,17 @@
1
- import {mean} from './mean'
1
+ import { mean } from './mean.js'
2
2
 
3
- export function median(list) {
3
+ export function median(list){
4
4
  const len = list.length
5
5
  if (len === 0) return NaN
6
- const width = 2 - (len % 2)
6
+ const width = 2 - len % 2
7
7
  const idx = (len - width) / 2
8
8
 
9
- return mean(
10
- Array.prototype.slice
11
- .call(list, 0)
12
- .sort((a, b) => {
13
- if (a === b) return 0
9
+ return mean(Array.prototype.slice
10
+ .call(list, 0)
11
+ .sort((a, b) => {
12
+ if (a === b) return 0
14
13
 
15
- return a < b ? -1 : 1
16
- })
17
- .slice(idx, idx + width)
18
- )
14
+ return a < b ? -1 : 1
15
+ })
16
+ .slice(idx, idx + width))
19
17
  }
package/src/merge.js CHANGED
@@ -1,5 +1 @@
1
- export function merge(target, newProps) {
2
- if (arguments.length === 1) return _newProps => merge(target, _newProps)
3
-
4
- return Object.assign({}, target || {}, newProps || {})
5
- }
1
+ export {mergeRight as merge} from './mergeRight.js'
package/src/mergeAll.js CHANGED
@@ -1,10 +1,10 @@
1
- import {map} from './map'
2
- import {merge} from './merge'
1
+ import { map } from './map.js'
2
+ import { mergeRight } from './mergeRight.js'
3
3
 
4
- export function mergeAll(arr) {
4
+ export function mergeAll(arr){
5
5
  let willReturn = {}
6
6
  map(val => {
7
- willReturn = merge(willReturn, val)
7
+ willReturn = mergeRight(willReturn, val)
8
8
  }, arr)
9
9
 
10
10
  return willReturn
@@ -1,21 +1,21 @@
1
- import {type} from './type'
1
+ import { type } from './type.js'
2
2
 
3
- export function mergeDeepRight(target, source) {
4
- if (arguments.length === 1) {
3
+ export function mergeDeepRight(target, source){
4
+ if (arguments.length === 1){
5
5
  return sourceHolder => mergeDeepRight(target, sourceHolder)
6
6
  }
7
7
 
8
8
  const willReturn = JSON.parse(JSON.stringify(target))
9
9
 
10
10
  Object.keys(source).forEach(key => {
11
- if (type(source[key]) === 'Object') {
12
- if (type(target[key]) === 'Object') {
13
- willReturn[key] = mergeDeepRight(target[key], source[key])
11
+ if (type(source[ key ]) === 'Object'){
12
+ if (type(target[ key ]) === 'Object'){
13
+ willReturn[ key ] = mergeDeepRight(target[ key ], source[ key ])
14
14
  } else {
15
- willReturn[key] = source[key]
15
+ willReturn[ key ] = source[ key ]
16
16
  }
17
17
  } else {
18
- willReturn[key] = source[key]
18
+ willReturn[ key ] = source[ key ]
19
19
  }
20
20
  })
21
21
 
package/src/mergeLeft.js CHANGED
@@ -1,7 +1,7 @@
1
- import {merge} from './merge'
1
+ import { mergeRight } from './mergeRight.js'
2
2
 
3
- export function mergeLeft(x, y) {
3
+ export function mergeLeft(x, y){
4
4
  if (arguments.length === 1) return _y => mergeLeft(x, _y)
5
5
 
6
- return merge(y, x)
6
+ return mergeRight(y, x)
7
7
  }
@@ -0,0 +1,7 @@
1
+ export function mergeRight(target, newProps){
2
+ if (arguments.length === 1) return _newProps => mergeRight(target, _newProps)
3
+
4
+ return Object.assign(
5
+ {}, target || {}, newProps || {}
6
+ )
7
+ }
@@ -0,0 +1,29 @@
1
+ import { curry } from './curry.js'
2
+
3
+ function mergeWithFn(
4
+ mergeFn, a, b
5
+ ){
6
+ const willReturn = {}
7
+
8
+ Object.keys(a).forEach(key => {
9
+ if (b[ key ] === undefined){
10
+ willReturn[ key ] = a[ key ]
11
+ } else {
12
+ willReturn[ key ] = mergeFn(a[ key ], b[ key ])
13
+ }
14
+ })
15
+
16
+ Object.keys(b).forEach(key => {
17
+ if (willReturn[ key ] !== undefined) return
18
+
19
+ if (a[ key ] === undefined){
20
+ willReturn[ key ] = b[ key ]
21
+ } else {
22
+ willReturn[ key ] = mergeFn(a[ key ], b[ key ])
23
+ }
24
+ })
25
+
26
+ return willReturn
27
+ }
28
+
29
+ export const mergeWith = curry(mergeWithFn)
package/src/min.js CHANGED
@@ -1,4 +1,4 @@
1
- export function min(x, y) {
1
+ export function min(x, y){
2
2
  if (arguments.length === 1) return _y => min(x, _y)
3
3
 
4
4
  return y < x ? y : x
package/src/minBy.js CHANGED
@@ -1,6 +1,8 @@
1
- import {curry} from './curry'
1
+ import { curry } from './curry.js'
2
2
 
3
- export function minByFn(compareFn, x, y) {
3
+ export function minByFn(
4
+ compareFn, x, y
5
+ ){
4
6
  return compareFn(y) < compareFn(x) ? y : x
5
7
  }
6
8
 
package/src/modulo.js CHANGED
@@ -1,4 +1,4 @@
1
- export function modulo(x, y) {
1
+ export function modulo(x, y){
2
2
  if (arguments.length === 1) return _y => modulo(x, _y)
3
3
 
4
4
  return x % y
package/src/move.js CHANGED
@@ -1,15 +1,17 @@
1
- import {curry} from './curry'
2
- import {cloneList} from './_internals/cloneList'
1
+ import { cloneList } from './_internals/cloneList.js'
2
+ import { curry } from './curry.js'
3
3
 
4
- function moveFn(fromIndex, toIndex, list) {
5
- if (fromIndex < 0 || toIndex < 0) {
4
+ function moveFn(
5
+ fromIndex, toIndex, list
6
+ ){
7
+ if (fromIndex < 0 || toIndex < 0){
6
8
  throw new Error('Rambda.move does not support negative indexes')
7
9
  }
8
10
  if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list
9
11
 
10
12
  const clone = cloneList(list)
11
- clone[fromIndex] = list[toIndex]
12
- clone[toIndex] = list[fromIndex]
13
+ clone[ fromIndex ] = list[ toIndex ]
14
+ clone[ toIndex ] = list[ fromIndex ]
13
15
 
14
16
  return clone
15
17
  }
package/src/multiply.js CHANGED
@@ -1,4 +1,4 @@
1
- export function multiply(x, y) {
1
+ export function multiply(x, y){
2
2
  if (arguments.length === 1) return _y => multiply(x, _y)
3
3
 
4
4
  return x * y
package/src/negate.js CHANGED
@@ -1,3 +1,3 @@
1
- export function negate(x) {
1
+ export function negate(x){
2
2
  return -x
3
3
  }
package/src/none.js CHANGED
@@ -1,8 +1,8 @@
1
- export function none(predicate, list) {
1
+ export function none(predicate, list){
2
2
  if (arguments.length === 1) return _list => none(predicate, _list)
3
3
 
4
- for (let i = 0; i < list.length; i++) {
5
- if (predicate(list[i])) return false
4
+ for (let i = 0; i < list.length; i++){
5
+ if (predicate(list[ i ])) return false
6
6
  }
7
7
 
8
8
  return true
package/src/not.js CHANGED
@@ -1,3 +1,3 @@
1
- export function not(input) {
1
+ export function not(input){
2
2
  return !input
3
3
  }
package/src/nth.js CHANGED
@@ -1,9 +1,9 @@
1
- export function nth(index, list) {
2
- if (arguments.length === 1) return _list => nth(index, _list)
1
+ export function nth(index, input){
2
+ if (arguments.length === 1) return _input => nth(index, _input)
3
3
 
4
- const idx = index < 0 ? list.length + index : index
4
+ const idx = index < 0 ? input.length + index : index
5
5
 
6
- return Object.prototype.toString.call(list) === '[object String]'
7
- ? list.charAt(idx)
8
- : list[idx]
6
+ return Object.prototype.toString.call(input) === '[object String]' ?
7
+ input.charAt(idx) :
8
+ input[ idx ]
9
9
  }
package/src/objOf.js CHANGED
@@ -1,9 +1,7 @@
1
- export function objOf(key, value) {
2
- if (arguments.length === 1) {
1
+ export function objOf(key, value){
2
+ if (arguments.length === 1){
3
3
  return _value => objOf(key, _value)
4
4
  }
5
5
 
6
- return {
7
- [key]: value,
8
- }
6
+ return { [ key ] : value }
9
7
  }
package/src/of.js CHANGED
@@ -1,3 +1,3 @@
1
- export function of(value) {
2
- return [value]
1
+ export function of(value){
2
+ return [ value ]
3
3
  }
package/src/omit.js CHANGED
@@ -1,18 +1,18 @@
1
- export function omit(propsToOmit, obj) {
1
+ import { createPath } from './_internals/createPath.js'
2
+
3
+ export function omit(propsToOmit, obj){
2
4
  if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)
3
5
 
4
- if (obj === null || obj === undefined) {
6
+ if (obj === null || obj === undefined){
5
7
  return undefined
6
8
  }
7
9
 
8
- const propsToOmitValue =
9
- typeof propsToOmit === 'string' ? propsToOmit.split(',') : propsToOmit
10
-
10
+ const propsToOmitValue = createPath(propsToOmit, ',')
11
11
  const willReturn = {}
12
12
 
13
- for (const key in obj) {
14
- if (!propsToOmitValue.includes(key)) {
15
- willReturn[key] = obj[key]
13
+ for (const key in obj){
14
+ if (!propsToOmitValue.includes(key)){
15
+ willReturn[ key ] = obj[ key ]
16
16
  }
17
17
  }
18
18
 
package/src/on.js ADDED
@@ -0,0 +1,16 @@
1
+ export function on(
2
+ binaryFn, unaryFn, a, b
3
+ ){
4
+ if (arguments.length === 3){
5
+ return _b => on(
6
+ binaryFn, unaryFn, a, _b
7
+ )
8
+ }
9
+ if (arguments.length === 2){
10
+ return (_a, _b) => on(
11
+ binaryFn, unaryFn, _a, _b
12
+ )
13
+ }
14
+
15
+ return binaryFn(unaryFn(a), unaryFn(b))
16
+ }
package/src/once.js CHANGED
@@ -1,10 +1,10 @@
1
- import {curry} from './curry'
1
+ import { curry } from './curry.js'
2
2
 
3
- function onceFn(fn, context) {
3
+ function onceFn(fn, context){
4
4
  let result
5
5
 
6
- return function () {
7
- if (fn) {
6
+ return function (){
7
+ if (fn){
8
8
  result = fn.apply(context || this, arguments)
9
9
  fn = null
10
10
  }
@@ -13,8 +13,8 @@ function onceFn(fn, context) {
13
13
  }
14
14
  }
15
15
 
16
- export function once(fn, context) {
17
- if (arguments.length === 1) {
16
+ export function once(fn, context){
17
+ if (arguments.length === 1){
18
18
  const wrap = onceFn(fn, context)
19
19
 
20
20
  return curry(wrap)
package/src/or.js CHANGED
@@ -1,4 +1,4 @@
1
- export function or(a, b) {
1
+ export function or(a, b){
2
2
  if (arguments.length === 1) return _b => or(a, _b)
3
3
 
4
4
  return a || b
package/src/over.js CHANGED
@@ -1,11 +1,13 @@
1
- import {curry} from './curry'
1
+ import { curry } from './curry.js'
2
2
 
3
3
  const Identity = x => ({
4
4
  x,
5
- map: fn => Identity(fn(x)),
5
+ map : fn => Identity(fn(x)),
6
6
  })
7
7
 
8
- function overFn(lens, fn, object) {
8
+ function overFn(
9
+ lens, fn, object
10
+ ){
9
11
  return lens(x => Identity(fn(x)))(object).x
10
12
  }
11
13
 
package/src/partial.js CHANGED
@@ -1,11 +1,11 @@
1
- export function partial(fn, ...args) {
1
+ export function partial(fn, ...args){
2
2
  const len = fn.length
3
3
 
4
4
  return (...rest) => {
5
- if (args.length + rest.length >= len) {
5
+ if (args.length + rest.length >= len){
6
6
  return fn(...args, ...rest)
7
7
  }
8
8
 
9
- return partial(fn, ...[...args, ...rest])
9
+ return partial(fn, ...[ ...args, ...rest ])
10
10
  }
11
11
  }
@@ -0,0 +1,15 @@
1
+ import { mergeDeepRight } from './mergeDeepRight.js'
2
+ import { type } from './type.js'
3
+
4
+ export function partialObject(fn, input){
5
+ return rest => {
6
+ if (type(fn) === 'Async'){
7
+ return new Promise((resolve, reject) => {
8
+ fn(mergeDeepRight(rest, input)).then(resolve)
9
+ .catch(reject)
10
+ })
11
+ }
12
+
13
+ return fn(mergeDeepRight(rest, input))
14
+ }
15
+ }
package/src/partition.js CHANGED
@@ -1,39 +1,41 @@
1
- import {_isArray} from './_internals/_isArray'
1
+ import { _isArray } from './_internals/_isArray.js'
2
2
 
3
- export function partitionObject(predicate, iterable) {
3
+ export function partitionObject(predicate, iterable){
4
4
  const yes = {}
5
5
  const no = {}
6
- Object.entries(iterable).forEach(([prop, value]) => {
7
- if (predicate(value, prop)) {
8
- yes[prop] = value
6
+ Object.entries(iterable).forEach(([ prop, value ]) => {
7
+ if (predicate(value, prop)){
8
+ yes[ prop ] = value
9
9
  } else {
10
- no[prop] = value
10
+ no[ prop ] = value
11
11
  }
12
12
  })
13
13
 
14
- return [yes, no]
14
+ return [ yes, no ]
15
15
  }
16
16
 
17
- export function partitionArray(predicate, list, indexed = false) {
17
+ export function partitionArray(
18
+ predicate, list, indexed = false
19
+ ){
18
20
  const yes = []
19
21
  const no = []
20
22
  let counter = -1
21
23
 
22
- while (counter++ < list.length - 1) {
24
+ while (counter++ < list.length - 1){
23
25
  if (
24
- indexed ? predicate(list[counter], counter) : predicate(list[counter])
25
- ) {
26
- yes.push(list[counter])
26
+ indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
27
+ ){
28
+ yes.push(list[ counter ])
27
29
  } else {
28
- no.push(list[counter])
30
+ no.push(list[ counter ])
29
31
  }
30
32
  }
31
33
 
32
- return [yes, no]
34
+ return [ yes, no ]
33
35
  }
34
36
 
35
- export function partition(predicate, iterable) {
36
- if (arguments.length === 1) {
37
+ export function partition(predicate, iterable){
38
+ if (arguments.length === 1){
37
39
  return listHolder => partition(predicate, listHolder)
38
40
  }
39
41
  if (!_isArray(iterable)) return partitionObject(predicate, iterable)
package/src/path.js CHANGED
@@ -1,22 +1,23 @@
1
- export function path(pathInput, obj) {
1
+ import { createPath } from './_internals/createPath.js'
2
+
3
+ export function path(pathInput, obj){
2
4
  if (arguments.length === 1) return _obj => path(pathInput, _obj)
3
5
 
4
- if (obj === null || obj === undefined) {
6
+ if (obj === null || obj === undefined){
5
7
  return undefined
6
8
  }
7
9
  let willReturn = obj
8
10
  let counter = 0
9
11
 
10
- const pathArrValue =
11
- typeof pathInput === 'string' ? pathInput.split('.') : pathInput
12
+ const pathArrValue = createPath(pathInput)
12
13
 
13
- while (counter < pathArrValue.length) {
14
- if (willReturn === null || willReturn === undefined) {
14
+ while (counter < pathArrValue.length){
15
+ if (willReturn === null || willReturn === undefined){
15
16
  return undefined
16
17
  }
17
- if (willReturn[pathArrValue[counter]] === null) return undefined
18
+ if (willReturn[ pathArrValue[ counter ] ] === null) return undefined
18
19
 
19
- willReturn = willReturn[pathArrValue[counter]]
20
+ willReturn = willReturn[ pathArrValue[ counter ] ]
20
21
  counter++
21
22
  }
22
23
 
package/src/pathEq.js CHANGED
@@ -1,8 +1,10 @@
1
- import {curry} from './curry'
2
- import {equals} from './equals'
3
- import {path} from './path'
1
+ import { curry } from './curry.js'
2
+ import { equals } from './equals.js'
3
+ import { path } from './path.js'
4
4
 
5
- function pathEqFn(pathToSearch, target, input) {
5
+ function pathEqFn(
6
+ pathToSearch, target, input
7
+ ){
6
8
  return equals(path(pathToSearch, input), target)
7
9
  }
8
10
 
package/src/pathOr.js CHANGED
@@ -1,8 +1,10 @@
1
- import {curry} from './curry'
2
- import {defaultTo} from './defaultTo'
3
- import {path} from './path'
1
+ import { curry } from './curry.js'
2
+ import { defaultTo } from './defaultTo.js'
3
+ import { path } from './path.js'
4
4
 
5
- function pathOrFn(defaultValue, pathInput, obj) {
5
+ function pathOrFn(
6
+ defaultValue, pathInput, obj
7
+ ){
6
8
  return defaultTo(defaultValue, path(pathInput, obj))
7
9
  }
8
10
 
package/src/paths.js CHANGED
@@ -1,7 +1,7 @@
1
- import {path} from './path'
1
+ import { path } from './path.js'
2
2
 
3
- export function paths(pathsToSearch, obj) {
4
- if (arguments.length === 1) {
3
+ export function paths(pathsToSearch, obj){
4
+ if (arguments.length === 1){
5
5
  return _obj => paths(pathsToSearch, _obj)
6
6
  }
7
7
 
package/src/pick.js CHANGED
@@ -1,18 +1,18 @@
1
- export function pick(propsToPick, input) {
1
+ import { createPath } from './_internals/createPath.js'
2
+
3
+ export function pick(propsToPick, input){
2
4
  if (arguments.length === 1) return _input => pick(propsToPick, _input)
3
5
 
4
- if (input === null || input === undefined) {
6
+ if (input === null || input === undefined){
5
7
  return undefined
6
8
  }
7
- const keys =
8
- typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick
9
-
9
+ const keys = createPath(propsToPick, ',')
10
10
  const willReturn = {}
11
11
  let counter = 0
12
12
 
13
- while (counter < keys.length) {
14
- if (keys[counter] in input) {
15
- willReturn[keys[counter]] = input[keys[counter]]
13
+ while (counter < keys.length){
14
+ if (keys[ counter ] in input){
15
+ willReturn[ keys[ counter ] ] = input[ keys[ counter ] ]
16
16
  }
17
17
  counter++
18
18
  }
package/src/pickAll.js CHANGED
@@ -1,20 +1,20 @@
1
- export function pickAll(propsToPick, obj) {
1
+ import { createPath } from './_internals/createPath.js'
2
+
3
+ export function pickAll(propsToPick, obj){
2
4
  if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj)
3
5
 
4
- if (obj === null || obj === undefined) {
6
+ if (obj === null || obj === undefined){
5
7
  return undefined
6
8
  }
7
- const keysValue =
8
- typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick
9
-
9
+ const keysValue = createPath(propsToPick, ',')
10
10
  const willReturn = {}
11
11
  let counter = 0
12
12
 
13
- while (counter < keysValue.length) {
14
- if (keysValue[counter] in obj) {
15
- willReturn[keysValue[counter]] = obj[keysValue[counter]]
13
+ while (counter < keysValue.length){
14
+ if (keysValue[ counter ] in obj){
15
+ willReturn[ keysValue[ counter ] ] = obj[ keysValue[ counter ] ]
16
16
  } else {
17
- willReturn[keysValue[counter]] = undefined
17
+ willReturn[ keysValue[ counter ] ] = undefined
18
18
  }
19
19
  counter++
20
20
  }