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

@cloudflare/util-en-garde

Package Overview
Dependencies
Maintainers
31
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/util-en-garde - npm Package Compare versions

Comparing version 6.4.4 to 7.0.0

22

CHANGELOG.md

@@ -6,2 +6,24 @@ # Change Log

# [7.0.0](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-en-garde@6.4.4...@cloudflare/util-en-garde@7.0.0) (2020-02-10)
### Bug Fixes
* **util-en-garde:** TSX-163 Remove empty tuple types ([c7b8320](http://stash.cfops.it:7999/fe/stratus/commits/c7b8320))
### Features
* **util-en-garde:** TSX-163 Add emptyArray codec ([230bd4d](http://stash.cfops.it:7999/fe/stratus/commits/230bd4d))
### BREAKING CHANGES
* **util-en-garde:** Any consumer of eg.tuple trying to use an empty array should switch to
eg.emptyArray as eg.tuple will no longer accept an empty array.
## [6.4.4](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/util-en-garde@6.4.0...@cloudflare/util-en-garde@6.4.4) (2020-02-02)

@@ -8,0 +30,0 @@

3

dist/index.d.ts

@@ -135,4 +135,5 @@ import * as t from 'io-ts';

keyOf: <C_2 extends ObjectCodec<any>>(codec: C_2) => Codec<t.LiteralType<Extract<keyof C_2["props"], string>>>;
emptyArray: Codec<t.Type<[], [], unknown>>;
object: <P extends t.Props>(p: P, name?: string | undefined) => ObjectCodec<P>;
tuple: <Codecs extends never[] | [t.Any, ...t.Any[]]>(codecs: Codecs, name?: string | undefined) => Codec<t.TupleC<Exclude<Codecs, never[]>>>;
tuple: <Codecs extends [t.Any, ...t.Any[]]>(codecs: Codecs, name?: string | undefined) => Codec<t.TupleC<Codecs>>;
intersection: <Codecs_1 extends [t.Any, t.Any, ...t.Any[]]>(codecs: Codecs_1, name?: string | undefined) => Codec<t.IntersectionC<Codecs_1>>;

@@ -139,0 +140,0 @@ brand: <Name extends string, BaseCodec extends Codec<any>>(name: Name, base: BaseCodec, predicate: (value: BaseCodec["_A"]) => boolean) => Codec<t.BrandC<BaseCodec, { [N in Name]: symbol; }>>;

@@ -210,2 +210,4 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

},
// Unfortunately tuple type inference does not work with our HOC wrapper.
// so we need to explicitly define this here.
tuple: function tuple(codecs, name) {

@@ -243,2 +245,7 @@ return new Codec(t.tuple(codecs, name));

};
var isEmptyArray = function isEmptyArray(value) {
return Array.isArray(value) && value.length === 0;
};
var helpers = {

@@ -297,3 +304,8 @@ /**

return new Codec(t.never);
}
},
// io-ts doesn't support creating an empty tuple or an array of type never
// so we're creating a custom codec to reprepsent this.
emptyArray: new Codec(new t.Type('[]', isEmptyArray, function (value, context) {
return isEmptyArray(value) ? t.success(value) : t.failure(value, context);
}, t.identity))
};

@@ -300,0 +312,0 @@ export var eg = _objectSpread({}, primitiveCodecs, higherOrderCodecs, helpers); // re-export io-ts lib

@@ -156,2 +156,4 @@ "use strict";

},
// Unfortunately tuple type inference does not work with our HOC wrapper.
// so we need to explicitly define this here.
tuple: function tuple(codecs, name) {

@@ -189,2 +191,7 @@ return new Codec(t.tuple(codecs, name));

};
var isEmptyArray = function isEmptyArray(value) {
return Array.isArray(value) && value.length === 0;
};
var helpers = {

@@ -243,3 +250,8 @@ /**

return new Codec(t.never);
}
},
// io-ts doesn't support creating an empty tuple or an array of type never
// so we're creating a custom codec to reprepsent this.
emptyArray: new Codec(new t.Type('[]', isEmptyArray, function (value, context) {
return isEmptyArray(value) ? t.success(value) : t.failure(value, context);
}, t.identity))
};

@@ -246,0 +258,0 @@

{
"name": "@cloudflare/util-en-garde",
"description": "",
"version": "6.4.4",
"version": "7.0.0",
"types": "./dist/index.d.ts",

@@ -29,3 +29,3 @@ "main": "lib/index.js",

},
"gitHead": "8d0306d0234211b5ebadd5d08d2ac6200fbb472f"
"gitHead": "1cd295356c692cbf55d7fa131bd8ff96d849b8c5"
}

@@ -168,4 +168,2 @@ import * as t from 'io-ts';

type NonEmpty<T extends any[]> = Exclude<T, never[]>;
const higherOrderCodecs = {

@@ -176,7 +174,8 @@ // Using a special type for object which enables optional keys

tuple: <Codecs extends never[] | [IoTsCodec, ...IoTsCodec[]]>(
// Unfortunately tuple type inference does not work with our HOC wrapper.
// so we need to explicitly define this here.
tuple: <Codecs extends [IoTsCodec, ...IoTsCodec[]]>(
codecs: Codecs,
name?: string
): Codec<t.TupleC<NonEmpty<Codecs>>> =>
new Codec(t.tuple(codecs as any, name) as any),
): Codec<t.TupleC<Codecs>> => new Codec(t.tuple(codecs as any, name) as any),

@@ -228,2 +227,5 @@ intersection: <Codecs extends [IoTsCodec, IoTsCodec, ...IoTsCodec[]]>(

const isEmptyArray = (value: unknown): value is [] =>
Array.isArray(value) && value.length === 0;
const helpers = {

@@ -294,3 +296,15 @@ /**

return new Codec(t.never as any) as any;
}
},
// io-ts doesn't support creating an empty tuple or an array of type never
// so we're creating a custom codec to reprepsent this.
emptyArray: new Codec(
new t.Type<[], []>(
'[]',
isEmptyArray,
(value, context) =>
isEmptyArray(value) ? t.success(value) : t.failure(value, context),
t.identity
)
)
};

@@ -297,0 +311,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