rambda 8.4.0 → 8.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "8.4.0",
3
+ "version": "8.6.0",
4
4
  "scripts": {
5
5
  "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
6
6
  "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
@@ -32,35 +32,36 @@
32
32
  "test:all": "jest source/*.spec.js -u --bail=false",
33
33
  "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
34
34
  "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
35
+ "ts": "yarn test:typings",
35
36
  "usedby": "cd ../rambda-scripts && yarn usedby",
36
37
  "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
37
38
  },
38
39
  "dependencies": {},
39
40
  "devDependencies": {
40
- "@babel/core": "7.21.8",
41
+ "@babel/core": "7.23.3",
41
42
  "@babel/plugin-proposal-object-rest-spread": "7.20.7",
42
- "@babel/preset-env": "7.21.5",
43
+ "@babel/preset-env": "7.23.3",
43
44
  "@definitelytyped/dtslint": "0.0.176",
44
- "@rollup/plugin-babel": "6.0.3",
45
- "@rollup/plugin-commonjs": "25.0.0",
46
- "@rollup/plugin-node-resolve": "15.0.2",
47
- "@rollup/plugin-replace": "5.0.2",
48
- "@types/jest": "29.5.1",
45
+ "@rollup/plugin-babel": "6.0.4",
46
+ "@rollup/plugin-commonjs": "25.0.7",
47
+ "@rollup/plugin-node-resolve": "15.2.3",
48
+ "@rollup/plugin-replace": "5.0.5",
49
+ "@types/jest": "29.5.8",
49
50
  "combinate": "1.1.11",
50
51
  "cross-env": "7.0.3",
51
- "fast-check": "^3.11.0",
52
+ "fast-check": "3.13.2",
52
53
  "helpers-fn": "1.8.1",
53
54
  "is-ci": "3.0.1",
54
- "jest": "29.5.0",
55
- "jest-extended": "3.2.4",
55
+ "jest": "29.7.0",
56
+ "jest-extended": "4.0.2",
56
57
  "lodash": "4.17.21",
57
- "rambdax": "9.1.1",
58
- "ramda": "0.29.0",
59
- "rollup": "3.22.0",
58
+ "rambdax": "10.0.0",
59
+ "ramda": "0.29.1",
60
+ "rollup": "4.4.1",
60
61
  "rollup-plugin-cleanup": "3.2.1",
61
62
  "rollup-plugin-sourcemaps": "0.6.3",
62
63
  "rollup-plugin-uglify": "6.0.4",
63
- "types-ramda": "0.29.2",
64
+ "types-ramda": "0.29.6",
64
65
  "typescript": "5.2.2"
65
66
  },
66
67
  "jest": {
package/rambda.js CHANGED
@@ -1,6 +1,4 @@
1
1
  /// <reference types="./index.d.ts" />
2
- export * from './src/F.js'
3
- export * from './src/T.js'
4
2
  export * from './src/add.js'
5
3
  export * from './src/addIndex.js'
6
4
  export * from './src/addIndexRight.js'
@@ -51,13 +49,17 @@ export * from './src/drop.js'
51
49
  export * from './src/dropLast.js'
52
50
  export * from './src/dropLastWhile.js'
53
51
  export * from './src/dropRepeats.js'
52
+ export * from './src/dropRepeatsBy.js'
54
53
  export * from './src/dropRepeatsWith.js'
55
54
  export * from './src/dropWhile.js'
56
55
  export * from './src/either.js'
56
+ export * from './src/empty.js'
57
57
  export * from './src/endsWith.js'
58
+ export * from './src/eqBy.js'
58
59
  export * from './src/eqProps.js'
59
60
  export * from './src/equals.js'
60
61
  export * from './src/evolve.js'
62
+ export * from './src/F.js'
61
63
  export * from './src/filter.js'
62
64
  export * from './src/find.js'
63
65
  export * from './src/findIndex.js'
@@ -143,8 +145,8 @@ export * from './src/prop.js'
143
145
  export * from './src/propEq.js'
144
146
  export * from './src/propIs.js'
145
147
  export * from './src/propOr.js'
146
- export * from './src/propSatisfies.js'
147
148
  export * from './src/props.js'
149
+ export * from './src/propSatisfies.js'
148
150
  export * from './src/range.js'
149
151
  export * from './src/reduce.js'
150
152
  export * from './src/reject.js'
@@ -164,6 +166,7 @@ export * from './src/startsWith.js'
164
166
  export * from './src/subtract.js'
165
167
  export * from './src/sum.js'
166
168
  export * from './src/symmetricDifference.js'
169
+ export * from './src/T.js'
167
170
  export * from './src/tail.js'
168
171
  export * from './src/take.js'
169
172
  export * from './src/takeLast.js'
@@ -0,0 +1,21 @@
1
+ import { equals } from './equals.js'
2
+
3
+ export function dropRepeatsBy(fn, list){
4
+ if (arguments.length === 1) return _list => dropRepeatsBy(fn, _list)
5
+
6
+ let lastEvaluated = null
7
+
8
+ return list.slice().filter(item => {
9
+ if (lastEvaluated === null){
10
+ lastEvaluated = fn(item)
11
+
12
+ return true
13
+ }
14
+ const evaluatedResult = fn(item)
15
+ if (equals(lastEvaluated, evaluatedResult)) return false
16
+
17
+ lastEvaluated = evaluatedResult
18
+
19
+ return true
20
+ })
21
+ }
package/src/empty.js ADDED
@@ -0,0 +1,15 @@
1
+ import { type } from './type.js'
2
+
3
+ export function empty(list){
4
+ if (typeof list === 'string') return ''
5
+
6
+ if (Array.isArray(list)){
7
+ const { name } = list.constructor
8
+ if (name === 'Uint8Array') return Uint8Array.from('')
9
+
10
+ if (name === 'Float32Array') return new Float32Array([])
11
+
12
+ return []
13
+ }
14
+ if (type(list) === 'Object') return {}
15
+ }
package/src/eqBy.js ADDED
@@ -0,0 +1,10 @@
1
+ import { curry } from './curry.js'
2
+ import { equals } from './equals.js'
3
+
4
+ export function eqByFn(
5
+ fn, a, b
6
+ ){
7
+ return equals(fn(a), fn(b))
8
+ }
9
+
10
+ export const eqBy = curry(eqByFn)
package/src/forEach.js CHANGED
@@ -1,34 +1,44 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
2
  import { keys } from './_internals/keys.js'
3
3
 
4
- export function forEach(fn, list){
5
- if (arguments.length === 1) return _list => forEach(fn, _list)
4
+ export function forEachObjIndexedFn(fn, obj){
5
+ let index = 0
6
+ const listKeys = keys(obj)
7
+ const len = listKeys.length
6
8
 
7
- if (list === undefined){
8
- return
9
+ while (index < len){
10
+ const key = listKeys[ index ]
11
+ fn(
12
+ obj[ key ], key, obj
13
+ )
14
+ index++
9
15
  }
10
16
 
11
- if (isArray(list)){
12
- let index = 0
13
- const len = list.length
17
+ return obj
18
+ }
14
19
 
15
- while (index < len){
16
- fn(list[ index ])
17
- index++
18
- }
19
- } else {
20
+ export function forEachObjIndexed(fn, list){
21
+ if (arguments.length === 1) return _list => forEachObjIndexed(fn, _list)
22
+
23
+ if (list === undefined) return
24
+
25
+ return forEachObjIndexedFn(fn, list)
26
+ }
27
+
28
+ export function forEach(fn, iterable){
29
+ if (arguments.length === 1) return _list => forEach(fn, _list)
30
+
31
+ if (iterable === undefined) return
32
+
33
+ if (isArray(iterable)){
20
34
  let index = 0
21
- const listKeys = keys(list)
22
- const len = listKeys.length
35
+ const len = iterable.length
23
36
 
24
37
  while (index < len){
25
- const key = listKeys[ index ]
26
- fn(
27
- list[ key ], key, list
28
- )
38
+ fn(iterable[ index ])
29
39
  index++
30
40
  }
31
- }
41
+ } else return forEachObjIndexedFn(fn, iterable)
32
42
 
33
- return list
43
+ return iterable
34
44
  }
package/src/mergeWith.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { curry } from './curry.js'
2
2
 
3
- function mergeWithFn(
3
+ export function mergeWithFn(
4
4
  mergeFn, aInput, bInput
5
5
  ){
6
6
  const a = aInput ?? {}
@@ -8,21 +8,15 @@ function mergeWithFn(
8
8
  const willReturn = {}
9
9
 
10
10
  Object.keys(a).forEach(key => {
11
- if (b[ key ] === undefined){
12
- willReturn[ key ] = a[ key ]
13
- } else {
14
- willReturn[ key ] = mergeFn(a[ key ], b[ key ])
15
- }
11
+ if (b[ key ] === undefined) willReturn[ key ] = a[ key ]
12
+ else willReturn[ key ] = mergeFn(a[ key ], b[ key ])
16
13
  })
17
14
 
18
15
  Object.keys(b).forEach(key => {
19
16
  if (willReturn[ key ] !== undefined) return
20
17
 
21
- if (a[ key ] === undefined){
22
- willReturn[ key ] = b[ key ]
23
- } else {
24
- willReturn[ key ] = mergeFn(a[ key ], b[ key ])
25
- }
18
+ if (a[ key ] === undefined) willReturn[ key ] = b[ key ]
19
+ else willReturn[ key ] = mergeFn(a[ key ], b[ key ])
26
20
  })
27
21
 
28
22
  return willReturn