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

funtypes

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funtypes - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/types/Enum.d.ts

12

.size-snapshot.json
{
"index.js": {
"bundled": 39193,
"minified": 17023,
"gzipped": 4692
"bundled": 39778,
"minified": 17298,
"gzipped": 4767
},
"index.mjs": {
"bundled": 38608,
"minified": 16506,
"gzipped": 4565,
"bundled": 39178,
"minified": 16768,
"gzipped": 4637,
"treeshaked": {

@@ -12,0 +12,0 @@ "rollup": {

@@ -12,2 +12,3 @@ export { AsyncContract } from './asynccontract';

export { Dictionary } from './types/dictionary';
export { Enum } from './types/Enum';
export { Function } from './types/function';

@@ -14,0 +15,0 @@ export { InstanceOf } from './types/instanceof';

@@ -525,2 +525,22 @@ 'use strict';

function Enum(name, e) {
const values = Object.values(e);
const enumValues = new Set(values.some(v => typeof v === 'number') ? values.filter(v => typeof v === 'number') : values);
return create(value => {
if (enumValues.has(value)) {
return { success: true, value: value };
}
else {
return {
success: false,
message: `Expected ${name}, but was '${value}'`,
};
}
}, {
tag: 'enum',
enumObject: e,
show: () => name,
});
}
/**

@@ -1101,2 +1121,3 @@ * Construct a runtype for functions.

exports.Dictionary = Dictionary;
exports.Enum = Enum;
exports.Function = Function;

@@ -1103,0 +1124,0 @@ exports.Guard = Guard;

{
"name": "funtypes",
"version": "2.0.0",
"version": "2.1.0",
"description": "Runtime validation for static types",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -14,2 +14,3 @@ export { AsyncContract } from './asynccontract';

export { Dictionary } from './types/dictionary';
export { Enum } from './types/Enum';
export { Function } from './types/function';

@@ -16,0 +17,0 @@ export { InstanceOf } from './types/instanceof';

Sorry, the diff of this file is not supported yet

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