Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gucciogucci/contented

Package Overview
Dependencies
Maintainers
4
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gucciogucci/contented - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

dist/oneOf.d.ts

1

dist/index.d.ts

@@ -10,2 +10,3 @@ export * from './always';

export * from './object';
export * from './oneOf';
export * from './permissiveArrayOf';

@@ -12,0 +13,0 @@ export * from './satisfy';

@@ -23,2 +23,3 @@ "use strict";

__exportStar(require("./object"), exports);
__exportStar(require("./oneOf"), exports);
__exportStar(require("./permissiveArrayOf"), exports);

@@ -25,0 +26,0 @@ __exportStar(require("./satisfy"), exports);

2

dist/Type.d.ts

@@ -16,3 +16,3 @@ import { ContentedError } from './ContentedError';

export declare type ErrorType<T> = T extends Type<any, infer E> ? E : never;
declare type OrErrors<E, F> = EnumerateErrors<StripJoint<E>, StripJoint<F>> extends never ? never : Joint<EnumerateErrors<StripJoint<E>, StripJoint<F>>>;
export declare type OrErrors<E, F> = EnumerateErrors<StripJoint<E>, StripJoint<F>> extends never ? never : Joint<EnumerateErrors<StripJoint<E>, StripJoint<F>>>;
declare type EnumerateErrors<E, F> = E extends never ? never : F extends never ? never : E extends unknown[] ? F extends unknown[] ? [...E, ...F] : [...E, F] : F extends unknown[] ? [E, ...F] : [E, F];

@@ -19,0 +19,0 @@ declare type StripJoint<T> = T extends Joint<infer U> ? U : T;

{
"name": "@gucciogucci/contented",
"description": "A library to coerce values at run-time.",
"version": "3.0.0",
"version": "3.1.0",
"author": "Gucci <npm@gucci.com>",

@@ -6,0 +6,0 @@ "license": "LGPL-3.0-only",

@@ -41,2 +41,3 @@ <div align="center">

- [`T1.or(T2)`](#t1ort2)
- [`oneOf(...Ts)`](#oneofts)
- [Errors](#errors)

@@ -378,2 +379,26 @@ - [`InvalidCoercion`](#invalidcoercion)

#### `oneOf(...Ts)`
Repeated applications of `T1.or(T2)` may produce a significant amount of syntactic noise. By contrast, `oneOf` may produce better results in situations where more than two or three alternatives are needed.
```typescript
import { oneOf, match, coerceTo } from '@gucciogucci/contented';
const abc = oneOf(match('a'), match('b'), match('c')); // the same as match('a').or(match('b')).or(match('c'))
coerceTo(abc, 'a');
// 'a'
coerceTo(abc, 'd');
/* Joint {
errors: [
InvalidCoercion { expected: 'a', got: 'd' },
InvalidCoercion { expected: 'b', got: 'd' },
InvalidCoercion { expected: 'c', got: 'd' }
]
}
*/
```
### Errors

@@ -380,0 +405,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc