@railway-ts/pipelines 0.1.24 → 0.1.26

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/README.md CHANGED
@@ -29,12 +29,14 @@ Each layer works independently. Combine them when it makes sense.
29
29
 
30
30
  Fully tree-shakable:
31
31
 
32
- - `result` -- 582 B
33
- - `option` -- 402 B
32
+ - `result` -- 631 B
33
+ - `option` -- 406 B
34
34
  - `composition` -- 233 B
35
- - `schema` -- ~3 kB
35
+ - `schema` -- 3.51 kB
36
36
 
37
- **~4.2 kB total** (minified + brotli)
37
+ **~4.8 kB total** (minified + brotli)
38
+
39
+ See how it compares at [schemabenchmarks.dev](https://schemabenchmarks.dev) — smallest bundle size of all benchmarked libraries.
38
40
 
39
41
  ## Install
40
42
 
@@ -266,6 +266,22 @@ function refineAtAsync(targetPath, predicate, message) {
266
266
  return ok(value);
267
267
  };
268
268
  }
269
+ function when(predicate, thenValidator, elseValidator) {
270
+ return (value, path = []) => {
271
+ if (predicate(value)) {
272
+ return thenValidator(value, path);
273
+ }
274
+ return elseValidator ? elseValidator(value, path) : ok(value);
275
+ };
276
+ }
277
+ function whenAsync(predicate, thenValidator, elseValidator) {
278
+ return async (value, path = []) => {
279
+ if (predicate(value)) {
280
+ return thenValidator(value, path);
281
+ }
282
+ return elseValidator ? elseValidator(value, path) : ok(value);
283
+ };
284
+ }
269
285
 
270
286
  // src/schema/string.ts
271
287
  function string(message = "Must be a string") {
@@ -1147,5 +1163,7 @@ exports.url = url;
1147
1163
  exports.uuid = uuid;
1148
1164
  exports.validate = validate;
1149
1165
  exports.validateAndFormatResult = validateAndFormatResult;
1166
+ exports.when = when;
1167
+ exports.whenAsync = whenAsync;
1150
1168
  //# sourceMappingURL=index.cjs.map
1151
1169
  //# sourceMappingURL=index.cjs.map