rambda 7.2.1 → 7.3.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1597 -1458
  3. package/dist/rambda.js +82 -68
  4. package/dist/rambda.mjs +81 -69
  5. package/dist/rambda.umd.js +1 -1
  6. package/immutable.d.ts +15 -1
  7. package/index.d.ts +15 -1
  8. package/package.json +16 -13
  9. package/src/_internals/constants.js +1 -0
  10. package/src/_internals/isArray.js +1 -0
  11. package/src/_internals/isFalsy.js +2 -2
  12. package/src/_internals/isInteger.js +5 -0
  13. package/src/_internals/isIterable.js +5 -0
  14. package/src/_internals/isObject.js +1 -1
  15. package/src/_internals/isTruthy.js +2 -2
  16. package/src/_internals/keys.js +1 -0
  17. package/src/_internals/{_objectIs.js → objectIs.js} +2 -2
  18. package/src/applySpec.js +3 -3
  19. package/src/assocPath.js +7 -7
  20. package/src/clone.js +2 -2
  21. package/src/count.js +2 -2
  22. package/src/dropLastWhile.js +2 -2
  23. package/src/dropRepeats.js +2 -2
  24. package/src/dropRepeatsWith.js +2 -2
  25. package/src/dropWhile.js +2 -2
  26. package/src/endsWith.js +2 -2
  27. package/src/equals.js +3 -3
  28. package/src/evolve.js +1 -1
  29. package/src/filter.js +2 -2
  30. package/src/flatten.js +2 -2
  31. package/src/forEach.js +6 -6
  32. package/src/groupWith.js +2 -2
  33. package/src/identical.js +2 -2
  34. package/src/includes.js +2 -2
  35. package/src/isPromise.js +1 -1
  36. package/src/length.js +2 -2
  37. package/src/map.js +7 -7
  38. package/src/mathMod.js +2 -2
  39. package/src/merge.js +1 -1
  40. package/src/mergeDeepRight.js +2 -1
  41. package/src/mergeRight.js +2 -1
  42. package/src/modify.js +23 -0
  43. package/src/modifyPath.js +2 -2
  44. package/src/partialObject.js +1 -11
  45. package/src/partition.js +2 -2
  46. package/src/props.js +2 -2
  47. package/src/reduce.js +2 -3
  48. package/src/splitAt.js +2 -2
  49. package/src/startsWith.js +2 -2
  50. package/src/takeLastWhile.js +2 -2
  51. package/src/takeWhile.js +2 -2
  52. package/src/times.js +2 -1
  53. package/src/transpose.js +2 -2
  54. package/src/unwind.js +4 -3
  55. package/src/update.js +1 -1
  56. package/src/where.js +1 -0
  57. package/src/_internals/_isArray.js +0 -1
  58. package/src/_internals/_isInteger.js +0 -5
  59. package/src/_internals/_keys.js +0 -1
package/immutable.d.ts CHANGED
@@ -133,6 +133,8 @@ type ApplyDiffAdd = {readonly op:'add', readonly path: string, readonly value: a
133
133
  type ApplyDiffRemove = {readonly op:'remove', readonly path: string};
134
134
  type ApplyDiffRule = ApplyDiffUpdate | ApplyDiffAdd | ApplyDiffRemove;
135
135
 
136
+ type Resolved<T> = {readonly status: 'fulfilled', readonly value: T} | {readonly status: 'rejected', readonly reason: string|Error}
137
+
136
138
 
137
139
  /**
138
140
  * It adds `a` and `b`.
@@ -156,6 +158,7 @@ export function all<T>(predicate: (x: T) => boolean): (list: readonly T[]) => bo
156
158
  * It returns `true`, if all functions of `predicates` return `true`, when `input` is their argument.
157
159
  */
158
160
  export function allPass<T>(predicates: readonly ((x: T) => boolean)[]): (input: T) => boolean;
161
+ export function allPass<T>(predicates: readonly ((...inputs: readonly T[]) => boolean)[]): (...inputs: readonly T[]) => boolean;
159
162
 
160
163
  /**
161
164
  * It returns function that always returns `x`.
@@ -184,6 +187,7 @@ export function any<T>(predicate: (x: T) => boolean): (list: readonly T[]) => bo
184
187
  * It accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`.
185
188
  */
186
189
  export function anyPass<T>(predicates: readonly ((x: T) => boolean)[]): (input: T) => boolean;
190
+ export function anyPass<T>(predicates: readonly ((...inputs: readonly T[]) => boolean)[]): (...inputs: readonly T[]) => boolean;
187
191
 
188
192
  /**
189
193
  * It adds element `x` at the end of `list`.
@@ -602,7 +606,7 @@ export function init<T extends readonly unknown[]>(input: T): T extends readonly
602
606
  export function init(input: string): string;
603
607
 
604
608
  /**
605
- * It loops throw `listA` and `listB` and returns the intersection of the two according to `R.equals`.
609
+ * It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
606
610
  */
607
611
  export function intersection<T>(listA: readonly T[], listB: readonly T[]): readonly T[];
608
612
  export function intersection<T>(listA: readonly T[]): (listB: readonly T[]) => readonly T[];
@@ -1554,3 +1558,13 @@ export function uniqBy<T, U>(fn: (a: T) => U): (list: readonly T[]) => readonly
1554
1558
  export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown, object: Record<string, unknown>): T;
1555
1559
  export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown): (object: Record<string, unknown>) => T;
1556
1560
  export function modifyPath<T extends Record<string, unknown>>(path: Path): (fn: (x: any) => unknown) => (object: Record<string, unknown>) => T;
1561
+
1562
+ export function modify<T extends object, K extends keyof T, P>(
1563
+ prop: K,
1564
+ fn: (a: T[K]) => P,
1565
+ obj: T,
1566
+ ): Omit<T, K> & Record<K, P>;
1567
+ export function modify<K extends string, A, P>(
1568
+ prop: K,
1569
+ fn: (a: A) => P,
1570
+ ): <T extends Record<K, A>>(target: T) => Omit<T, K> & Record<K, P>;
package/index.d.ts CHANGED
@@ -133,6 +133,8 @@ type ApplyDiffAdd = {op:'add', path: string, value: any};
133
133
  type ApplyDiffRemove = {op:'remove', path: string};
134
134
  type ApplyDiffRule = ApplyDiffUpdate | ApplyDiffAdd | ApplyDiffRemove;
135
135
 
136
+ type Resolved<T> = {status: 'fulfilled', value: T} | {status: 'rejected', reason: string|Error}
137
+
136
138
 
137
139
  /**
138
140
  * It adds `a` and `b`.
@@ -156,6 +158,7 @@ export function all<T>(predicate: (x: T) => boolean): (list: T[]) => boolean;
156
158
  * It returns `true`, if all functions of `predicates` return `true`, when `input` is their argument.
157
159
  */
158
160
  export function allPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
161
+ export function allPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;
159
162
 
160
163
  /**
161
164
  * It returns function that always returns `x`.
@@ -184,6 +187,7 @@ export function any<T>(predicate: (x: T) => boolean): (list: T[]) => boolean;
184
187
  * It accepts list of `predicates` and returns a function. This function with its `input` will return `true`, if any of `predicates` returns `true` for this `input`.
185
188
  */
186
189
  export function anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
190
+ export function anyPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;
187
191
 
188
192
  /**
189
193
  * It adds element `x` at the end of `list`.
@@ -602,7 +606,7 @@ export function init<T extends unknown[]>(input: T): T extends readonly [...infe
602
606
  export function init(input: string): string;
603
607
 
604
608
  /**
605
- * It loops throw `listA` and `listB` and returns the intersection of the two according to `R.equals`.
609
+ * It loops through `listA` and `listB` and returns the intersection of the two according to `R.equals`.
606
610
  */
607
611
  export function intersection<T>(listA: T[], listB: T[]): T[];
608
612
  export function intersection<T>(listA: T[]): (listB: T[]) => T[];
@@ -1554,3 +1558,13 @@ export function uniqBy<T, U>(fn: (a: T) => U): (list: T[]) => T[];
1554
1558
  export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown, object: Record<string, unknown>): T;
1555
1559
  export function modifyPath<T extends Record<string, unknown>>(path: Path, fn: (x: any) => unknown): (object: Record<string, unknown>) => T;
1556
1560
  export function modifyPath<T extends Record<string, unknown>>(path: Path): (fn: (x: any) => unknown) => (object: Record<string, unknown>) => T;
1561
+
1562
+ export function modify<T extends object, K extends keyof T, P>(
1563
+ prop: K,
1564
+ fn: (a: T[K]) => P,
1565
+ obj: T,
1566
+ ): Omit<T, K> & Record<K, P>;
1567
+ export function modify<K extends string, A, P>(
1568
+ prop: K,
1569
+ fn: (a: A) => P,
1570
+ ): <T extends Record<K, A>>(target: T) => Omit<T, K> & Record<K, P>;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "7.2.1",
3
+ "version": "7.3.0",
4
4
  "scripts": {
5
+ "publishx": "node files/publish",
5
6
  "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
6
7
  "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
7
8
  "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
@@ -24,20 +25,22 @@
24
25
  "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.js",
25
26
  "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
26
27
  "new": "cd ../rambda-scripts && yarn new",
27
- "test:all": "jest source -u --bail=false",
28
- "test": "jest -o --watch",
29
- "cover:spec": "jest source --coverage --no-cache -w 1",
30
- "cover": "yarn typings && yarn cover:spec",
28
+ "run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
29
+ "consume-typings:clone": "cd .. && git clone --depth 1 https://github.com/selfrefactor/rambda-scripts.git rambda-scripts-clone",
30
+ "consume-typings:execute": "cd ../rambda-scripts-clone/scripts/consume-typings && yarn start",
31
+ "consume-typings": "yarn consume-typings:clone && yarn consume-typings:execute",
32
+ "test:consume-typings": "jest source/_consumeTypings.test.js",
33
+ "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
34
+ "test:all": "jest source/*.spec.js -u --bail=false",
35
+ "test": "jest -o -u --watch",
36
+ "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
31
37
  "build:step": "yarn populatedocs && yarn populatereadme && yarn build:main",
32
- "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
33
- "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
34
- "benchmark:single": "cd ../rambda-scripts && METHOD=uniqWith RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
35
38
  "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
36
- "benchmark": "yarn build:step && yarn benchmark:single",
37
- "typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
39
+ "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
40
+ "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
41
+ "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
38
42
  "d:rambda-scripts": "cd ../rambda-scripts && run d",
39
- "d": "yarn out && yarn lint && run d && yarn d:rambda-scripts",
40
- "fix": "mkdir $HOME/.dts/perf -p"
43
+ "d": "yarn out && yarn lint && run d && yarn d:rambda-scripts"
41
44
  },
42
45
  "dependencies": {},
43
46
  "devDependencies": {
@@ -69,7 +72,7 @@
69
72
  },
70
73
  "jest": {
71
74
  "testEnvironment": "node",
72
- "testRegex": ".*\\.spec\\.js$",
75
+ "testRegex": ".*\\.(spec|test)\\.js$",
73
76
  "setupFilesAfterEnv": [
74
77
  "./files/testSetup.js"
75
78
  ],
@@ -0,0 +1 @@
1
+ export const INCORRECT_ITERABLE_INPUT = 'Incorrect iterable input'
@@ -0,0 +1 @@
1
+ export const { isArray } = Array
@@ -1,8 +1,8 @@
1
1
  import { type } from '../type.js'
2
- import { _isArray } from './_isArray.js'
2
+ import { isArray } from './isArray.js'
3
3
 
4
4
  export function isFalsy(x){
5
- if (_isArray(x)){
5
+ if (isArray(x)){
6
6
  return x.length === 0
7
7
  }
8
8
  if (type(x) === 'Object'){
@@ -0,0 +1,5 @@
1
+ function _isInteger(n){
2
+ return n << 0 === n
3
+ }
4
+
5
+ export const isInteger = Number.isInteger || _isInteger
@@ -0,0 +1,5 @@
1
+ import { type } from '../type.js'
2
+
3
+ export function isIterable(input){
4
+ return Array.isArray(input) || type(input) === 'Object'
5
+ }
@@ -1,5 +1,5 @@
1
1
  import { type } from '../type.js'
2
2
 
3
- export function _isObject(input){
3
+ export function isObject(input){
4
4
  return type(input) === 'Object'
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import { type } from '../type.js'
2
- import { _isArray } from './_isArray.js'
2
+ import { isArray } from './isArray.js'
3
3
 
4
4
  export function isTruthy(x){
5
- if (_isArray(x)){
5
+ if (isArray(x)){
6
6
  return x.length > 0
7
7
  }
8
8
  if (type(x) === 'Object'){
@@ -0,0 +1 @@
1
+ export const { keys } = Object
@@ -1,4 +1,4 @@
1
- export function _objectIs(a, b){
1
+ function _objectIs(a, b){
2
2
  if (a === b){
3
3
  return a !== 0 || 1 / a === 1 / b
4
4
  }
@@ -6,4 +6,4 @@ export function _objectIs(a, b){
6
6
  return a !== a && b !== b
7
7
  }
8
8
 
9
- export default Object.is || _objectIs
9
+ export const objectIs = Object.is || _objectIs
package/src/applySpec.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  // recursively traverse the given spec object to find the highest arity function
4
4
  export function __findHighestArity(spec, max = 0){
@@ -74,13 +74,13 @@ function __applySpecWithArity(
74
74
  )
75
75
 
76
76
  // handle spec as Array
77
- if (_isArray(spec)){
77
+ if (isArray(spec)){
78
78
  const ret = []
79
79
  let i = 0
80
80
  const l = spec.length
81
81
  for (; i < l; i++){
82
82
  // handle recursive spec inside array
83
- if (typeof spec[ i ] === 'object' || _isArray(spec[ i ])){
83
+ if (typeof spec[ i ] === 'object' || isArray(spec[ i ])){
84
84
  ret[ i ] = __applySpecWithArity(
85
85
  spec[ i ], arity, cache
86
86
  )
package/src/assocPath.js CHANGED
@@ -1,6 +1,6 @@
1
- import { _isArray } from './_internals/_isArray.js'
2
- import { _isInteger } from './_internals/_isInteger.js'
3
1
  import { cloneList } from './_internals/cloneList.js'
2
+ import { isArray } from './_internals/isArray.js'
3
+ import { isInteger } from './_internals/isInteger.js'
4
4
  import { assoc } from './assoc.js'
5
5
  import { curry } from './curry.js'
6
6
 
@@ -9,7 +9,7 @@ function assocPathFn(
9
9
  ){
10
10
  const pathArrValue =
11
11
  typeof path === 'string' ?
12
- path.split('.').map(x => _isInteger(Number(x)) ? Number(x) : x) :
12
+ path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
13
13
  path
14
14
  if (pathArrValue.length === 0){
15
15
  return newValue
@@ -22,8 +22,8 @@ function assocPathFn(
22
22
  input === null ||
23
23
  !input.hasOwnProperty(index)
24
24
 
25
- const nextinput = condition ?
26
- _isInteger(pathArrValue[ 1 ]) ?
25
+ const nextInput = condition ?
26
+ isInteger(pathArrValue[ 1 ]) ?
27
27
  [] :
28
28
  {} :
29
29
  input[ index ]
@@ -31,11 +31,11 @@ function assocPathFn(
31
31
  newValue = assocPathFn(
32
32
  Array.prototype.slice.call(pathArrValue, 1),
33
33
  newValue,
34
- nextinput
34
+ nextInput
35
35
  )
36
36
  }
37
37
 
38
- if (_isInteger(index) && _isArray(input)){
38
+ if (isInteger(index) && isArray(input)){
39
39
  const arr = cloneList(input)
40
40
  arr[ index ] = newValue
41
41
 
package/src/clone.js CHANGED
@@ -1,7 +1,7 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function clone(input){
4
- const out = _isArray(input) ? Array(input.length) : {}
4
+ const out = isArray(input) ? Array(input.length) : {}
5
5
  if (input && input.getTime) return new Date(input.getTime())
6
6
 
7
7
  for (const key in input){
package/src/count.js CHANGED
@@ -1,10 +1,10 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function count(predicate, list){
4
4
  if (arguments.length === 1){
5
5
  return _list => count(predicate, _list)
6
6
  }
7
- if (!_isArray(list)) return 0
7
+ if (!isArray(list)) return 0
8
8
 
9
9
  return list.filter(x => predicate(x)).length
10
10
  }
@@ -1,11 +1,11 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray as isArrayMethod } from './_internals/isArray.js'
2
2
 
3
3
  export function dropLastWhile(predicate, iterable){
4
4
  if (arguments.length === 1){
5
5
  return _iterable => dropLastWhile(predicate, _iterable)
6
6
  }
7
7
  if (iterable.length === 0) return iterable
8
- const isArray = _isArray(iterable)
8
+ const isArray = isArrayMethod(iterable)
9
9
 
10
10
  if (typeof predicate !== 'function'){
11
11
  throw new Error(`'predicate' is from wrong type ${ typeof predicate }`)
@@ -1,8 +1,8 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
  import { equals } from './equals.js'
3
3
 
4
4
  export function dropRepeats(list){
5
- if (!_isArray(list)){
5
+ if (!isArray(list)){
6
6
  throw new Error(`${ list } is not a list`)
7
7
  }
8
8
 
@@ -1,11 +1,11 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function dropRepeatsWith(predicate, list){
4
4
  if (arguments.length === 1){
5
5
  return _iterable => dropRepeatsWith(predicate, _iterable)
6
6
  }
7
7
 
8
- if (!_isArray(list)){
8
+ if (!isArray(list)){
9
9
  throw new Error(`${ list } is not a list`)
10
10
  }
11
11
 
package/src/dropWhile.js CHANGED
@@ -1,10 +1,10 @@
1
- import { _isArray } from '../src/_internals/_isArray.js'
1
+ import { isArray as isArrayMethod } from './_internals/isArray.js'
2
2
 
3
3
  export function dropWhile(predicate, iterable){
4
4
  if (arguments.length === 1){
5
5
  return _iterable => dropWhile(predicate, _iterable)
6
6
  }
7
- const isArray = _isArray(iterable)
7
+ const isArray = isArrayMethod(iterable)
8
8
  if (!isArray && typeof iterable !== 'string'){
9
9
  throw new Error('`iterable` is neither list nor a string')
10
10
  }
package/src/endsWith.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
  import { equals } from './equals.js'
3
3
 
4
4
  export function endsWith(target, iterable){
@@ -7,7 +7,7 @@ export function endsWith(target, iterable){
7
7
  if (typeof iterable === 'string'){
8
8
  return iterable.endsWith(target)
9
9
  }
10
- if (!_isArray(target)) return false
10
+ if (!isArray(target)) return false
11
11
 
12
12
  const diff = iterable.length - target.length
13
13
  let correct = true
package/src/equals.js CHANGED
@@ -1,8 +1,8 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
  import { type } from './type.js'
3
3
 
4
4
  export function _lastIndexOf(valueToFind, list){
5
- if (!_isArray(list)){
5
+ if (!isArray(list)){
6
6
  throw new Error(`Cannot read property 'indexOf' of ${ list }`)
7
7
  }
8
8
  const typeOfValue = type(valueToFind)
@@ -23,7 +23,7 @@ export function _lastIndexOf(valueToFind, list){
23
23
  }
24
24
 
25
25
  export function _indexOf(valueToFind, list){
26
- if (!_isArray(list)){
26
+ if (!isArray(list)){
27
27
  throw new Error(`Cannot read property 'indexOf' of ${ list }`)
28
28
  }
29
29
  const typeOfValue = type(valueToFind)
package/src/evolve.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
  import { mapArray, mapObject } from './map.js'
3
3
  import { type } from './type.js'
4
4
 
package/src/filter.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function filterObject(predicate, obj){
4
4
  const willReturn = {}
@@ -42,7 +42,7 @@ export function filter(predicate, iterable){
42
42
  throw new Error('Incorrect iterable input')
43
43
  }
44
44
 
45
- if (_isArray(iterable)) return filterArray(
45
+ if (isArray(iterable)) return filterArray(
46
46
  predicate, iterable, false
47
47
  )
48
48
 
package/src/flatten.js CHANGED
@@ -1,10 +1,10 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function flatten(list, input){
4
4
  const willReturn = input === undefined ? [] : input
5
5
 
6
6
  for (let i = 0; i < list.length; i++){
7
- if (_isArray(list[ i ])){
7
+ if (isArray(list[ i ])){
8
8
  flatten(list[ i ], willReturn)
9
9
  } else {
10
10
  willReturn.push(list[ i ])
package/src/forEach.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _isArray } from './_internals/_isArray.js'
2
- import { _keys } from './_internals/_keys.js'
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { keys } from './_internals/keys.js'
3
3
 
4
4
  export function forEach(fn, list){
5
5
  if (arguments.length === 1) return _list => forEach(fn, _list)
@@ -8,7 +8,7 @@ export function forEach(fn, list){
8
8
  return
9
9
  }
10
10
 
11
- if (_isArray(list)){
11
+ if (isArray(list)){
12
12
  let index = 0
13
13
  const len = list.length
14
14
 
@@ -18,11 +18,11 @@ export function forEach(fn, list){
18
18
  }
19
19
  } else {
20
20
  let index = 0
21
- const keys = _keys(list)
22
- const len = keys.length
21
+ const listKeys = keys(list)
22
+ const len = listKeys.length
23
23
 
24
24
  while (index < len){
25
- const key = keys[ index ]
25
+ const key = listKeys[ index ]
26
26
  fn(
27
27
  list[ key ], key, list
28
28
  )
package/src/groupWith.js CHANGED
@@ -1,8 +1,8 @@
1
- import { _isArray } from './_internals/_isArray.js'
2
1
  import { cloneList } from './_internals/cloneList.js'
2
+ import { isArray } from './_internals/isArray.js'
3
3
 
4
4
  export function groupWith(compareFn, list){
5
- if (!_isArray(list)) throw new TypeError('list.reduce is not a function')
5
+ if (!isArray(list)) throw new TypeError('list.reduce is not a function')
6
6
 
7
7
  const clone = cloneList(list)
8
8
 
package/src/identical.js CHANGED
@@ -1,7 +1,7 @@
1
- import _objectIs from './_internals/_objectIs.js'
1
+ import { objectIs } from './_internals/objectIs.js'
2
2
 
3
3
  export function identical(a, b){
4
4
  if (arguments.length === 1) return _b => identical(a, _b)
5
5
 
6
- return _objectIs(a, b)
6
+ return objectIs(a, b)
7
7
  }
package/src/includes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
  import { _indexOf } from './equals.js'
3
3
 
4
4
  export function includes(valueToFind, iterable){
@@ -10,7 +10,7 @@ export function includes(valueToFind, iterable){
10
10
  if (!iterable){
11
11
  throw new TypeError(`Cannot read property \'indexOf\' of ${ iterable }`)
12
12
  }
13
- if (!_isArray(iterable)) return false
13
+ if (!isArray(iterable)) return false
14
14
 
15
15
  return _indexOf(valueToFind, iterable) > -1
16
16
  }
package/src/isPromise.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type } from './type.js'
2
2
 
3
3
  export function isPromise(x){
4
- return [ 'Async', 'Promise' ].includes(type(x))
4
+ return 'Promise' === type(x)
5
5
  }
package/src/length.js CHANGED
@@ -1,7 +1,7 @@
1
- import { _isArray } from './_internals/_isArray.js'
1
+ import { isArray } from './_internals/isArray.js'
2
2
 
3
3
  export function length(x){
4
- if (_isArray(x)) return x.length
4
+ if (isArray(x)) return x.length
5
5
  if (typeof x === 'string') return x.length
6
6
 
7
7
  return NaN
package/src/map.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _isArray } from './_internals/_isArray.js'
2
- import { _keys } from './_internals/_keys.js'
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { keys } from './_internals/keys.js'
3
3
 
4
4
  export function mapArray(
5
5
  fn, list, isIndexed = false
@@ -21,12 +21,12 @@ export function mapObject(fn, obj){
21
21
  return _obj => mapObject(fn, _obj)
22
22
  }
23
23
  let index = 0
24
- const keys = _keys(obj)
25
- const len = keys.length
24
+ const objKeys = keys(obj)
25
+ const len = objKeys.length
26
26
  const willReturn = {}
27
27
 
28
28
  while (index < len){
29
- const key = keys[ index ]
29
+ const key = objKeys[ index ]
30
30
  willReturn[ key ] = fn(
31
31
  obj[ key ], key, obj
32
32
  )
@@ -41,10 +41,10 @@ export const mapObjIndexed = mapObject
41
41
  export function map(fn, iterable){
42
42
  if (arguments.length === 1) return _iterable => map(fn, _iterable)
43
43
  if (!iterable){
44
- throw new Error('Incorrect iterable input')
44
+ throw new Error(INCORRECT_ITERABLE_INPUT)
45
45
  }
46
46
 
47
- if (_isArray(iterable)) return mapArray(fn, iterable)
47
+ if (isArray(iterable)) return mapArray(fn, iterable)
48
48
 
49
49
  return mapObject(fn, iterable)
50
50
  }
package/src/mathMod.js CHANGED
@@ -1,8 +1,8 @@
1
- import _isInteger from './_internals/_isInteger.js'
1
+ import { isInteger } from './_internals/isInteger.js'
2
2
 
3
3
  export function mathMod(x, y){
4
4
  if (arguments.length === 1) return _y => mathMod(x, _y)
5
- if (!_isInteger(x) || !_isInteger(y) || y < 1) return NaN
5
+ if (!isInteger(x) || !isInteger(y) || y < 1) return NaN
6
6
 
7
7
  return (x % y + y) % y
8
8
  }
package/src/merge.js CHANGED
@@ -1 +1 @@
1
- export {mergeRight as merge} from './mergeRight.js'
1
+ export { mergeRight as merge } from './mergeRight.js'
@@ -1,3 +1,4 @@
1
+ import { clone } from './clone.js'
1
2
  import { type } from './type.js'
2
3
 
3
4
  export function mergeDeepRight(target, source){
@@ -5,7 +6,7 @@ export function mergeDeepRight(target, source){
5
6
  return sourceHolder => mergeDeepRight(target, sourceHolder)
6
7
  }
7
8
 
8
- const willReturn = JSON.parse(JSON.stringify(target))
9
+ const willReturn = clone(target)
9
10
 
10
11
  Object.keys(source).forEach(key => {
11
12
  if (type(source[ key ]) === 'Object'){
package/src/mergeRight.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export function mergeRight(target, newProps){
2
- if (arguments.length === 1) return _newProps => mergeRight(target, _newProps)
2
+ if (arguments.length === 1)
3
+ return _newProps => mergeRight(target, _newProps)
3
4
 
4
5
  return Object.assign(
5
6
  {}, target || {}, newProps || {}
package/src/modify.js ADDED
@@ -0,0 +1,23 @@
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { isIterable } from './_internals/isIterable.js'
3
+ import { curry } from './curry.js'
4
+ import { updateFn } from './update.js'
5
+
6
+ function modifyFn(
7
+ property, fn, iterable
8
+ ){
9
+ if (!isIterable(iterable)) return iterable
10
+ if (iterable[ property ] === undefined) return iterable
11
+ if (isArray(iterable)){
12
+ return updateFn(
13
+ property, fn(iterable[ property ]), iterable
14
+ )
15
+ }
16
+
17
+ return {
18
+ ...iterable,
19
+ [ property ] : fn(iterable[ property ]),
20
+ }
21
+ }
22
+
23
+ export const modify = curry(modifyFn)
package/src/modifyPath.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _isArray } from './_internals/_isArray.js'
2
1
  import { createPath } from './_internals/createPath.js'
2
+ import { isArray } from './_internals/isArray.js'
3
3
  import { assoc } from './assoc.js'
4
4
  import { curry } from './curry.js'
5
5
  import { path as pathModule } from './path.js'
@@ -11,7 +11,7 @@ export function modifyPathFn(
11
11
  if (path.length === 1){
12
12
  return {
13
13
  ...object,
14
- [ path[0] ] : fn(object[ path[0] ]),
14
+ [ path[ 0 ] ] : fn(object[ path[ 0 ] ]),
15
15
  }
16
16
  }
17
17
  if (pathModule(path, object) === undefined) return object