rambda 10.0.0-alpha.0 → 10.0.0-beta.3

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 (76) hide show
  1. package/CHANGELOG.md +125 -16
  2. package/README.md +8035 -3592
  3. package/dist/{rambda.esm.js → rambda.cjs} +800 -385
  4. package/dist/rambda.js +673 -486
  5. package/dist/rambda.umd.js +701 -388
  6. package/immutable.d.ts +896 -345
  7. package/index.d.ts +896 -345
  8. package/package.json +22 -15
  9. package/rambda.js +23 -2
  10. package/src/addProp.js +3 -0
  11. package/src/addPropToObjects.js +14 -0
  12. package/src/append.js +5 -5
  13. package/src/ascend.js +16 -0
  14. package/src/compact.js +12 -0
  15. package/src/concat.js +1 -1
  16. package/src/count.js +7 -7
  17. package/src/countBy.js +12 -12
  18. package/src/createObjectFromKeys.js +10 -0
  19. package/src/defaultTo.js +2 -6
  20. package/src/descend.js +10 -0
  21. package/src/drop.js +2 -6
  22. package/src/dropLast.js +1 -3
  23. package/src/eqProps.js +1 -2
  24. package/src/equals.js +2 -2
  25. package/src/evolve.js +2 -23
  26. package/src/filter.js +14 -14
  27. package/src/find.js +10 -10
  28. package/src/findIndex.js +9 -9
  29. package/src/findLast.js +8 -8
  30. package/src/findLastIndex.js +8 -8
  31. package/src/findNth.js +16 -0
  32. package/src/flattenObject.js +76 -0
  33. package/src/groupBy.js +14 -13
  34. package/src/includes.js +12 -13
  35. package/src/interpolate.js +29 -0
  36. package/src/intersection.js +1 -1
  37. package/src/intersperse.js +12 -12
  38. package/src/join.js +1 -1
  39. package/src/map.js +13 -9
  40. package/src/mapAsync.js +3 -3
  41. package/src/mapKeys.js +11 -0
  42. package/src/mapObjectAsync.js +9 -9
  43. package/src/mapParallelAsync.js +3 -0
  44. package/src/match.js +5 -5
  45. package/src/{replaceItemAtIndex.js → modifyItemAtIndex.js} +1 -1
  46. package/src/modifyProp.js +20 -0
  47. package/src/objectIncludes.js +12 -0
  48. package/src/partition.js +13 -37
  49. package/src/partitionObject.js +15 -0
  50. package/src/path.js +24 -26
  51. package/src/pathSatisfies.js +5 -0
  52. package/src/permutations.js +40 -0
  53. package/src/pipeAsync.js +7 -6
  54. package/src/pluck.js +9 -9
  55. package/src/prepend.js +1 -1
  56. package/src/propOr.js +1 -1
  57. package/src/propSatisfies.js +1 -3
  58. package/src/range.js +29 -13
  59. package/src/reject.js +1 -1
  60. package/src/rejectObject.js +13 -0
  61. package/src/shuffle.js +13 -0
  62. package/src/sort.js +1 -1
  63. package/src/sortBy.js +20 -9
  64. package/src/sortByDescending.js +5 -0
  65. package/src/sortByPath.js +6 -0
  66. package/src/sortByPathDescending.js +6 -0
  67. package/src/sortObject.js +15 -0
  68. package/src/sortWith.js +8 -8
  69. package/src/split.js +2 -2
  70. package/src/splitEvery.js +11 -11
  71. package/src/takeLastWhile.js +18 -18
  72. package/src/tap.js +4 -4
  73. package/src/test.js +1 -1
  74. package/src/uniqBy.js +4 -4
  75. package/src/uniqWith.js +10 -10
  76. package/src/modifyPath.js +0 -30
package/package.json CHANGED
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "10.0.0-alpha.0",
3
+ "version": "10.0.0-beta.3",
4
4
  "scripts": {
5
5
  "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build && yarn create-docsify",
6
6
  "build": "yarn build:main && yarn build:web && yarn build:esm",
7
- "build:main": "rollup rambda.js --file dist/rambda.js --format cjs",
8
- "build:esm": "rollup rambda.js --file dist/rambda.esm.js --format es",
7
+ "build:main": "rollup rambda.js --file dist/rambda.cjs --format cjs",
8
+ "build:esm": "rollup rambda.js --file dist/rambda.js --format es",
9
9
  "build:web": "rollup rambda.js --file dist/rambda.umd.js --format umd --name \"R\"",
10
- "immutable": "cd ../rambda-scripts && yarn immutable:rambda",
10
+ "immutable": "cd ../rambda-scripts && yarn immutable",
11
11
  "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
12
12
  "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
13
13
  "lint": "cd source && run lint:folder > lint-output.txt",
14
14
  "test:file": "node scripts/tasks/run/run-test.js",
15
15
  "test:ci": "vitest run",
16
16
  "test": "vitest run --watch -u",
17
- "x": "vitest run --watch source/and.spec.js",
18
- "test:cover": "vitest run --coverage",
19
17
  "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
20
18
  "create-docsify": "cd ../rambda-scripts && yarn create-docsify",
21
19
  "deps": "run dep:next",
@@ -27,20 +25,32 @@
27
25
  "depFn": [
28
26
  "@definitelytyped/dtslint"
29
27
  ],
28
+ "type": "module",
29
+ "exports": {
30
+ "require": {
31
+ "types": "./index.d.ts",
32
+ "default": "./dist/rambda.cjs"
33
+ },
34
+ "types": "./index.d.ts",
35
+ "default": "./dist/rambda.js"
36
+ },
37
+ "main": "dist/rambda.cjs",
38
+ "module": "dist/rambda.js",
30
39
  "dependencies": {},
31
40
  "devDependencies": {
32
41
  "@definitelytyped/dtslint": "0.0.182",
33
42
  "@types/mocha": "10.0.10",
34
- "@vitest/coverage-v8": "^3.0.5",
43
+ "@vitest/coverage-v8": "3.1.0-beta.2",
35
44
  "helpers-fn": "2.0.0",
36
45
  "lodash": "4.17.21",
46
+ "radashi": "^12.4.0",
37
47
  "rambdax": "11.3.1",
38
48
  "ramda": "0.30.1",
39
- "remeda": "^2.21.0",
40
- "rollup": "4.34.4",
49
+ "remeda": "2.21.2",
50
+ "rollup": "4.36.0",
41
51
  "types-ramda": "0.30.1",
42
- "typescript": "5.8.0-dev.20250206",
43
- "vitest": "3.0.5"
52
+ "typescript": "5.9.0-dev.20250321",
53
+ "vitest": "3.1.0-beta.2"
44
54
  },
45
55
  "jest": {
46
56
  "testEnvironment": "node",
@@ -68,13 +78,12 @@
68
78
  "generics",
69
79
  "lodash",
70
80
  "ramda",
81
+ "remeda",
71
82
  "stdlib",
72
83
  "toolkit",
73
84
  "ts",
74
85
  "types",
75
86
  "typescript",
76
- "underscore",
77
- "util",
78
87
  "utilities",
79
88
  "utility",
80
89
  "utils"
@@ -90,8 +99,6 @@
90
99
  "immutable.js"
91
100
  ],
92
101
  "sideEffects": false,
93
- "main": "./dist/rambda.js",
94
102
  "umd": "./dist/rambda.umd.js",
95
- "module": "./rambda.js",
96
103
  "types": "./index.d.ts"
97
104
  }
package/rambda.js CHANGED
@@ -1,15 +1,21 @@
1
1
  /// <reference types="./index.d.ts" />
2
+ export * from './src/addProp.js'
3
+ export * from './src/addPropToObjects.js'
2
4
  export * from './src/all.js'
3
5
  export * from './src/allPass.js'
4
6
  export * from './src/any.js'
5
7
  export * from './src/anyPass.js'
6
8
  export * from './src/append.js'
9
+ export * from './src/ascend.js'
7
10
  export * from './src/checkObjectWithSpec.js'
11
+ export * from './src/compact.js'
8
12
  export * from './src/complement.js'
9
13
  export * from './src/concat.js'
10
14
  export * from './src/count.js'
11
15
  export * from './src/countBy.js'
16
+ export * from './src/createObjectFromKeys.js'
12
17
  export * from './src/defaultTo.js'
18
+ export * from './src/descend.js'
13
19
  export * from './src/drop.js'
14
20
  export * from './src/dropLast.js'
15
21
  export * from './src/dropLastWhile.js'
@@ -25,14 +31,17 @@ export * from './src/find.js'
25
31
  export * from './src/findIndex.js'
26
32
  export * from './src/findLast.js'
27
33
  export * from './src/findLastIndex.js'
34
+ export * from './src/findNth.js'
28
35
  export * from './src/flatMap.js'
29
36
  export * from './src/flatten.js'
37
+ export * from './src/flattenObject.js'
30
38
  export * from './src/groupBy.js'
31
39
  export * from './src/head.js'
32
40
  export * from './src/includes.js'
33
41
  export * from './src/indexOf.js'
34
42
  export * from './src/init.js'
35
43
  export * from './src/innerJoin.js'
44
+ export * from './src/interpolate.js'
36
45
  export * from './src/intersection.js'
37
46
  export * from './src/intersperse.js'
38
47
  export * from './src/join.js'
@@ -40,19 +49,26 @@ export * from './src/last.js'
40
49
  export * from './src/lastIndexOf.js'
41
50
  export * from './src/map.js'
42
51
  export * from './src/mapAsync.js'
52
+ export * from './src/mapKeys.js'
43
53
  export * from './src/mapObject.js'
44
54
  export * from './src/mapObjectAsync.js'
55
+ export * from './src/mapParallelAsync.js'
45
56
  export * from './src/match.js'
46
57
  export * from './src/maxBy.js'
47
58
  export * from './src/merge.js'
48
59
  export * from './src/mergeTypes.js'
49
60
  export * from './src/minBy.js'
50
- export * from './src/modifyPath.js'
61
+ export * from './src/modifyItemAtIndex.js'
62
+ export * from './src/modifyProp.js'
51
63
  export * from './src/none.js'
52
64
  export * from './src/objOf.js'
65
+ export * from './src/objectIncludes.js'
53
66
  export * from './src/omit.js'
54
67
  export * from './src/partition.js'
68
+ export * from './src/partitionObject.js'
55
69
  export * from './src/path.js'
70
+ export * from './src/pathSatisfies.js'
71
+ export * from './src/permutations.js'
56
72
  export * from './src/pick.js'
57
73
  export * from './src/pipe.js'
58
74
  export * from './src/pipeAsync.js'
@@ -65,10 +81,15 @@ export * from './src/propSatisfies.js'
65
81
  export * from './src/range.js'
66
82
  export * from './src/reduce.js'
67
83
  export * from './src/reject.js'
84
+ export * from './src/rejectObject.js'
68
85
  export * from './src/replace.js'
69
- export * from './src/replaceItemAtIndex.js'
86
+ export * from './src/shuffle.js'
70
87
  export * from './src/sort.js'
71
88
  export * from './src/sortBy.js'
89
+ export * from './src/sortByDescending.js'
90
+ export * from './src/sortByPath.js'
91
+ export * from './src/sortByPathDescending.js'
92
+ export * from './src/sortObject.js'
72
93
  export * from './src/sortWith.js'
73
94
  export * from './src/split.js'
74
95
  export * from './src/splitEvery.js'
package/src/addProp.js ADDED
@@ -0,0 +1,3 @@
1
+ export function addProp(key, value) {
2
+ return obj => ({ ...obj, [key]: value })
3
+ }
@@ -0,0 +1,14 @@
1
+ import { mapFn } from './map.js'
2
+
3
+ export function addPropToObjects (
4
+ property,
5
+ fn
6
+ ){
7
+ return listOfObjects => mapFn(
8
+ (obj) => ({
9
+ ...(obj),
10
+ [property]: fn(obj)
11
+ }),
12
+ listOfObjects
13
+ )
14
+ }
package/src/append.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
2
 
3
3
  export function append(x) {
4
- return list=> {
5
- const clone = cloneList(list)
6
- clone.push(x)
4
+ return list => {
5
+ const clone = cloneList(list)
6
+ clone.push(x)
7
7
 
8
- return clone
9
- }
8
+ return clone
9
+ }
10
10
  }
package/src/ascend.js ADDED
@@ -0,0 +1,16 @@
1
+ export function createCompareFunction(a, b, winner, loser) {
2
+ if (a === b) {
3
+ return 0
4
+ }
5
+
6
+ return a < b ? winner : loser
7
+ }
8
+
9
+ export function ascend(getFunction) {
10
+ return (a, b) => {
11
+ const aValue = getFunction(a)
12
+ const bValue = getFunction(b)
13
+
14
+ return createCompareFunction(aValue, bValue, -1, 1)
15
+ }
16
+ }
package/src/compact.js ADDED
@@ -0,0 +1,12 @@
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { reject } from './reject.js'
3
+ import { rejectObject } from './rejectObject.js'
4
+
5
+ const isNullOrUndefined = x => x === null || x === undefined
6
+
7
+ export function compact(input){
8
+ if(isArray(input)){
9
+ return reject(isNullOrUndefined)(input)
10
+ }
11
+ return rejectObject(isNullOrUndefined)(input)
12
+ }
package/src/concat.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export function concat(x) {
2
- return y => typeof x === 'string' ? `${x}${y}` : [...x, ...y]
2
+ return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
3
3
  }
package/src/count.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
2
 
3
- export function count(predicate, ) {
4
- return list => {
5
- if (!isArray(list)) {
6
- return 0
7
- }
3
+ export function count(predicate) {
4
+ return list => {
5
+ if (!isArray(list)) {
6
+ return 0
7
+ }
8
8
 
9
- return list.filter(x => predicate(x)).length
10
- }
9
+ return list.filter(x => predicate(x)).length
10
+ }
11
11
  }
package/src/countBy.js CHANGED
@@ -1,16 +1,16 @@
1
1
  export function countBy(fn) {
2
- return list => {
3
- const willReturn = {}
2
+ return list => {
3
+ const willReturn = {}
4
4
 
5
- list.forEach(item => {
6
- const key = fn(item)
7
- if (!willReturn[key]) {
8
- willReturn[key] = 1
9
- } else {
10
- willReturn[key]++
11
- }
12
- })
5
+ list.forEach(item => {
6
+ const key = fn(item)
7
+ if (!willReturn[key]) {
8
+ willReturn[key] = 1
9
+ } else {
10
+ willReturn[key]++
11
+ }
12
+ })
13
13
 
14
- return willReturn
15
- }
14
+ return willReturn
15
+ }
16
16
  }
@@ -0,0 +1,10 @@
1
+ export function createObjectFromKeys(keys) {
2
+ return fn => {
3
+ const result = {}
4
+ keys.forEach((key, index) => {
5
+ result[key] = fn(key, index)
6
+ })
7
+
8
+ return result
9
+ }
10
+ }
package/src/defaultTo.js CHANGED
@@ -2,10 +2,6 @@ function isFalsy(input) {
2
2
  return input === undefined || input === null || Number.isNaN(input) === true
3
3
  }
4
4
 
5
- export function defaultTo(defaultArgument, input) {
6
- if (arguments.length === 1) {
7
- return _input => defaultTo(defaultArgument, _input)
8
- }
9
-
10
- return isFalsy(input) ? defaultArgument : input
5
+ export function defaultTo(defaultArgument) {
6
+ return input => isFalsy(input) ? defaultArgument : input
11
7
  }
package/src/descend.js ADDED
@@ -0,0 +1,10 @@
1
+ import { createCompareFunction } from './ascend.js'
2
+
3
+ export function descend(getFunction) {
4
+ return (a, b) => {
5
+ const aValue = getFunction(a)
6
+ const bValue = getFunction(b)
7
+
8
+ return createCompareFunction(aValue, bValue, 1, -1)
9
+ }
10
+ }
package/src/drop.js CHANGED
@@ -1,7 +1,3 @@
1
- export function drop(howManyToDrop, listOrString) {
2
- if (arguments.length === 1) {
3
- return _list => drop(howManyToDrop, _list)
4
- }
5
-
6
- return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0)
1
+ export function drop(howManyToDrop, ) {
2
+ return list => list.slice(howManyToDrop > 0 ? howManyToDrop : 0)
7
3
  }
package/src/dropLast.js CHANGED
@@ -1,5 +1,3 @@
1
1
  export function dropLast(numberItems) {
2
- return list => numberItems > 0
3
- ? list.slice(0, -numberItems)
4
- : list.slice()
2
+ return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
5
3
  }
package/src/eqProps.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { equalsFn } from './equals.js'
2
- import { prop } from './prop.js'
3
2
 
4
3
  export function eqProps(property, objA) {
5
- return objB => equalsFn(prop(property)(objA), prop(property)(objB))
4
+ return objB => equalsFn( objA[property], objB[property] )
6
5
  }
package/src/equals.js CHANGED
@@ -98,7 +98,7 @@ function parseRegex(maybeRegex) {
98
98
  }
99
99
 
100
100
  export function equalsFn(a, b) {
101
- if (Object.is(a, b)) {
101
+ if (Object.is(a, b)) {
102
102
  return true
103
103
  }
104
104
 
@@ -207,5 +207,5 @@ export function equalsFn(a, b) {
207
207
  return false
208
208
  }
209
209
  export function equals(a) {
210
- return b => equalsFn(a, b)
210
+ return b => equalsFn(a, b)
211
211
  }
package/src/evolve.js CHANGED
@@ -1,27 +1,6 @@
1
1
  import { mapObject } from './mapObject.js'
2
2
  import { type } from './type.js'
3
3
 
4
- export function evolveFn(rules, obj) {
5
- return mapObject((x, prop) => {
6
- if (type(x) === 'Object') {
7
- const typeRule = type(rules[prop])
8
- if (typeRule === 'Function') {
9
- return rules[prop](x)
10
- }
11
- if (typeRule === 'Object') {
12
- return evolveFn(rules[prop], x)
13
- }
14
-
15
- return x
16
- }
17
- if (type(rules[prop]) === 'Function') {
18
- return rules[prop](x)
19
- }
20
-
21
- return x
22
- })(obj)
23
- }
24
-
25
4
  export function evolve(rules) {
26
- return obj => evolveFn(rules, obj)
27
- }
5
+ return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
6
+ }
package/src/filter.js CHANGED
@@ -1,20 +1,20 @@
1
1
  export function filter(predicate) {
2
- return list => {
3
- if (!list) {
4
- throw new Error('Incorrect iterable input')
5
- }
6
- let index = 0
7
- const len = list.length
8
- const willReturn = []
2
+ return list => {
3
+ if (!list) {
4
+ throw new Error('Incorrect iterable input')
5
+ }
6
+ let index = 0
7
+ const len = list.length
8
+ const willReturn = []
9
+
10
+ while (index < len) {
11
+ if (predicate(list[index], index)) {
12
+ willReturn.push(list[index])
13
+ }
9
14
 
10
- while (index < len) {
11
- if (predicate(list[index], index)) {
12
- willReturn.push(list[index])
15
+ index++
13
16
  }
14
17
 
15
- index++
18
+ return willReturn
16
19
  }
17
-
18
- return willReturn
19
- }
20
20
  }
package/src/find.js CHANGED
@@ -1,15 +1,15 @@
1
1
  export function find(predicate) {
2
- return list => {
3
- let index = 0
4
- const len = list.length
2
+ return list => {
3
+ let index = 0
4
+ const len = list.length
5
5
 
6
- while (index < len) {
7
- const x = list[index]
8
- if (predicate(x)) {
9
- return x
10
- }
6
+ while (index < len) {
7
+ const x = list[index]
8
+ if (predicate(x)) {
9
+ return x
10
+ }
11
11
 
12
- index++
12
+ index++
13
+ }
13
14
  }
14
15
  }
15
- }
package/src/findIndex.js CHANGED
@@ -1,14 +1,14 @@
1
1
  export function findIndex(predicate) {
2
- return list => {
3
- const len = list.length
4
- let index = -1
2
+ return list => {
3
+ const len = list.length
4
+ let index = -1
5
5
 
6
- while (++index < len) {
7
- if (predicate(list[index])) {
8
- return index
6
+ while (++index < len) {
7
+ if (predicate(list[index])) {
8
+ return index
9
+ }
9
10
  }
10
- }
11
11
 
12
- return -1
13
- }
12
+ return -1
13
+ }
14
14
  }
package/src/findLast.js CHANGED
@@ -1,13 +1,13 @@
1
1
  export function findLast(predicate) {
2
- return list => {
3
- let index = list.length
2
+ return list => {
3
+ let index = list.length
4
4
 
5
- while (--index >= 0) {
6
- if (predicate(list[index])) {
7
- return list[index]
5
+ while (--index >= 0) {
6
+ if (predicate(list[index])) {
7
+ return list[index]
8
+ }
8
9
  }
9
- }
10
10
 
11
- return undefined
12
- }
11
+ return undefined
12
+ }
13
13
  }
@@ -1,13 +1,13 @@
1
1
  export function findLastIndex(fn) {
2
- return list => {
3
- let index = list.length
2
+ return list => {
3
+ let index = list.length
4
4
 
5
- while (--index >= 0) {
6
- if (fn(list[index])) {
7
- return index
5
+ while (--index >= 0) {
6
+ if (fn(list[index])) {
7
+ return index
8
+ }
8
9
  }
9
- }
10
10
 
11
- return -1
12
- }
11
+ return -1
12
+ }
13
13
  }
package/src/findNth.js ADDED
@@ -0,0 +1,16 @@
1
+ export function findNth(predicate, nth) {
2
+ return list => {
3
+ let index = 0
4
+ const len = list.length
5
+
6
+ while (index < len) {
7
+ const x = list[index]
8
+ if (predicate(x)) {
9
+ if (nth === 0) return x
10
+ nth--
11
+ }
12
+
13
+ index++
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,76 @@
1
+ import { type } from './type.js'
2
+
3
+ export function flattenObjectHelper(obj, accumulator = []){
4
+ const willReturn = {}
5
+ Object.keys(obj).forEach(key => {
6
+ const typeIs = type(obj[ key ])
7
+ if (typeIs === 'Object'){
8
+ const [ flatResultValue, flatResultPath ] = flattenObjectHelper(obj[ key ],
9
+ [ ...accumulator, key ])
10
+ willReturn[ flatResultPath.join('.') ] = flatResultValue
11
+
12
+ return
13
+ } else if (accumulator.length > 0){
14
+ const finalKey = [ ...accumulator, key ].join('.')
15
+ willReturn[ finalKey ] = obj[ key ]
16
+
17
+ return
18
+ }
19
+ willReturn[ key ] = obj[ key ]
20
+ })
21
+ if (accumulator.length > 0) return [ willReturn, accumulator ]
22
+
23
+ return willReturn
24
+ }
25
+
26
+ export function transformFlatObject(obj){
27
+ const willReturn = {}
28
+
29
+ const transformFlatObjectFn = objLocal => {
30
+ const willReturnLocal = {}
31
+ Object.keys(objLocal).forEach(key => {
32
+ const typeIs = type(objLocal[ key ])
33
+ if (typeIs === 'Object'){
34
+ transformFlatObjectFn(objLocal[ key ])
35
+
36
+ return
37
+ }
38
+ willReturnLocal[ key ] = objLocal[ key ]
39
+ willReturn[ key ] = objLocal[ key ]
40
+ })
41
+
42
+ return willReturnLocal
43
+ }
44
+
45
+ Object.keys(obj).forEach(key => {
46
+ const typeIs = type(obj[ key ])
47
+ if (typeIs === 'Object'){
48
+ transformFlatObjectFn(obj[ key ], key)
49
+
50
+ return
51
+ }
52
+ willReturn[ key ] = obj[ key ]
53
+ })
54
+
55
+ return willReturn
56
+ }
57
+
58
+ export function flattenObject(obj){
59
+ const willReturn = {}
60
+
61
+ Object.keys(obj).forEach(key => {
62
+ const typeIs = type(obj[ key ])
63
+ if (typeIs === 'Object'){
64
+ const flatObject = flattenObjectHelper(obj[ key ])
65
+ const transformed = transformFlatObject(flatObject)
66
+
67
+ Object.keys(transformed).forEach(keyTransformed => {
68
+ willReturn[ `${ key }.${ keyTransformed }` ] = transformed[ keyTransformed ]
69
+ })
70
+ } else {
71
+ willReturn[ key ] = obj[ key ]
72
+ }
73
+ })
74
+
75
+ return willReturn
76
+ }
package/src/groupBy.js CHANGED
@@ -1,19 +1,20 @@
1
- export function groupBy(groupFn, list) {
2
- if (arguments.length === 1) {
3
- return _list => groupBy(groupFn, _list)
4
- }
1
+ export function groupByFallback(groupFn, list) {
2
+ const result = {}
3
+ for (let i = 0; i < list.length; i++) {
4
+ const item = list[i]
5
+ const key = groupFn(item)
5
6
 
6
- const result = {}
7
- for (let i = 0; i < list.length; i++) {
8
- const item = list[i]
9
- const key = groupFn(item)
7
+ if (!result[key]) {
8
+ result[key] = []
9
+ }
10
10
 
11
- if (!result[key]) {
12
- result[key] = []
11
+ result[key].push(item)
13
12
  }
14
13
 
15
- result[key].push(item)
16
- }
14
+ return result
15
+ }
16
+
17
17
 
18
- return result
18
+ export function groupBy(groupFn) {
19
+ return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
19
20
  }