rambda 10.0.0 → 10.1.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/index.d.ts CHANGED
@@ -206,6 +206,11 @@ export function append<T>(el: T): (list: readonly T[]) => T[];
206
206
  */
207
207
  export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T)=> Ordering;
208
208
 
209
+ /**
210
+ * It helps to make sure that input is from specific type. Similar to `R.convertToType`, but it actually checks the type of the input value. If `fn` input returns falsy value, then the function will throw an error.
211
+ */
212
+ export function assertType<T, U extends T>(fn: (x: T) => x is U) : (x: T) => U;
213
+
209
214
  /**
210
215
  * It returns `true` if all each property in `conditions` returns `true` when applied to corresponding property in `input` object.
211
216
  */
@@ -235,6 +240,12 @@ export function complement<T extends any[]>(predicate: (...args: T) => unknown):
235
240
  export function concat<T>(x: T[]): (y: T[]) => T[];
236
241
  export function concat(x: string): (y: string) => string;
237
242
 
243
+ /**
244
+ * It helps to convert a value to a specific type.
245
+ * It is useful when you have to overcome TypeScript's type inference.
246
+ */
247
+ export function convertToType<T>(x: unknown) : T;
248
+
238
249
  /**
239
250
  * It counts how many times `predicate` function returns `true`, when supplied with iteration of `list`.
240
251
  */
@@ -1094,10 +1105,7 @@ export function permutations<T>(list: T[]): T[][];
1094
1105
  * String annotation of `propsToPick` is one of the differences between `Rambda` and `Ramda`.
1095
1106
  */
1096
1107
  export function pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
1097
- export function pick<
1098
- S extends string,
1099
- K extends PickStringToPickPath<K>
1100
- >(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
1108
+ export function pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
1101
1109
 
1102
1110
  /**
1103
1111
  * It performs left-to-right function composition, where first argument is the input for the chain of functions.
@@ -2160,7 +2168,7 @@ export function unless<T>(predicate: (x: T) => boolean, whenFalseFn: (x: T) => T
2160
2168
  /**
2161
2169
  * It takes an object and a property name. The method will return a list of objects, where each object is a shallow copy of the input object, but with the property array unwound.
2162
2170
  */
2163
- export function unwind<S extends string>(prop: S): <T>(obj: T) => MergeTypes<Omit<T, S> & { [K in S]: T[S][number] }>;
2171
+ export function unwind<S extends string>(prop: S): <T extends Record<S, readonly any[]>>(obj: T) => Array<MergeTypes<Omit<T, S> & { [K in S]: T[S][number] }>>;
2164
2172
 
2165
2173
  /**
2166
2174
  * It returns a copy of `list` with updated element at `index` with `newValue`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rambda",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "scripts": {
5
5
  "out": "yarn populatedocs && yarn populatereadme && yarn build && yarn create-docsify",
6
6
  "build": "yarn build:main && yarn build:web && yarn build:esm",
@@ -10,6 +10,7 @@
10
10
  "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
11
11
  "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
12
12
  "lint": "cd source && run lint:folder > lint-output.txt",
13
+ "lint:typings": "tsc",
13
14
  "test:file": "node scripts/tasks/run/run-test.js",
14
15
  "test:ci": "vitest run",
15
16
  "test": "vitest run --watch -u",
@@ -27,7 +28,7 @@
27
28
  "type": "module",
28
29
  "exports": {
29
30
  "require": {
30
- "types": "./index.d.ts",
31
+ "types": "./index.d.cts",
31
32
  "default": "./dist/rambda.cjs"
32
33
  },
33
34
  "types": "./index.d.ts",
@@ -39,17 +40,18 @@
39
40
  "devDependencies": {
40
41
  "@definitelytyped/dtslint": "0.0.182",
41
42
  "@types/mocha": "10.0.10",
42
- "@vitest/coverage-v8": "3.1.0-beta.2",
43
+ "@types/node": "22.14.1",
44
+ "@vitest/coverage-v8": "3.1.1",
43
45
  "helpers-fn": "2.0.0",
44
46
  "lodash": "4.17.21",
45
- "radashi": "^12.4.0",
47
+ "radashi": "13.0.0-beta.ffa4778",
46
48
  "rambdax": "11.3.1",
47
49
  "ramda": "0.30.1",
48
- "remeda": "2.21.2",
49
- "rollup": "4.36.0",
50
+ "remeda": "2.21.3",
51
+ "rollup": "4.40.0",
50
52
  "types-ramda": "0.30.1",
51
- "typescript": "5.9.0-dev.20250321",
52
- "vitest": "3.1.0-beta.2"
53
+ "typescript": "5.9.0-dev.20250418",
54
+ "vitest": "3.1.1"
53
55
  },
54
56
  "jest": {
55
57
  "testEnvironment": "node",
@@ -93,9 +95,10 @@
93
95
  "src",
94
96
  "CHANGELOG.md",
95
97
  "index.d.ts",
98
+ "index.d.cts",
96
99
  "rambda.js"
97
100
  ],
98
101
  "sideEffects": false,
99
102
  "umd": "./dist/rambda.umd.js",
100
- "types": "./index.d.ts"
103
+ "types": "./index.d.cts"
101
104
  }
package/rambda.js CHANGED
@@ -7,10 +7,12 @@ export * from './src/any.js'
7
7
  export * from './src/anyPass.js'
8
8
  export * from './src/append.js'
9
9
  export * from './src/ascend.js'
10
+ export * from './src/assertType.js'
10
11
  export * from './src/checkObjectWithSpec.js'
11
12
  export * from './src/compact.js'
12
13
  export * from './src/complement.js'
13
14
  export * from './src/concat.js'
15
+ export * from './src/convertToType.js'
14
16
  export * from './src/count.js'
15
17
  export * from './src/countBy.js'
16
18
  export * from './src/createObjectFromKeys.js'
@@ -0,0 +1,8 @@
1
+ export function assertType(fn) {
2
+ return (x) => {
3
+ if (fn(x)) {
4
+ return x
5
+ }
6
+ throw new Error('type assertion failed in R.assertType')
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ export function convertToType(x) {
2
+ return x
3
+ }