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

superstruct

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superstruct - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

umd/index.d.ts

1

lib/index.d.ts

@@ -16,2 +16,1 @@ import { superstruct } from './superstruct';

export { isStruct, Struct } from './struct';
//# sourceMappingURL=index.d.ts.map

@@ -573,3 +573,3 @@ function _defineProperty(obj, key, value) {

*/
undefined: function undefined(value) {
undefined: function undefined$1(value) {
return kindOf(value) === 'undefined';

@@ -672,3 +672,4 @@ },

var createStruct = function createStruct(props) {
var ErrorConstructor = props.options.Error;
var struct = props.struct;
var Error = struct.Error;

@@ -704,3 +705,3 @@ var Struct = function Struct(value) {

if (failures) {
throw new ErrorConstructor(failures);
throw new Error(failures);
} else {

@@ -717,3 +718,3 @@ return result;

if (failures) {
return [new ErrorConstructor(failures)];
return [new Error(failures)];
} else {

@@ -746,5 +747,5 @@ return [undefined, result];

var createArray = function createArray(schema, defaults, options) {
var createArray = function createArray(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 1, "Array structs must be defined as an array with one element, but you passed: " + schema);
var Element = createShorthand(schema[0], undefined, options);
var Element = struct(schema[0], undefined);
var Struct = createStruct({

@@ -754,3 +755,3 @@ kind: 'array',

defaults: defaults,
options: options
struct: struct
});

@@ -795,3 +796,3 @@

var createDynamic = function createDynamic(schema, defaults, options) {
var createDynamic = function createDynamic(schema, defaults, struct) {
invariant(typeof schema === 'function', "Dynamic structs must be defined as a function, but you passed: " + schema);

@@ -802,3 +803,3 @@ var Dynamic = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -818,3 +819,3 @@

var createEnum = function createEnum(schema, defaults, options) {
var createEnum = function createEnum(schema, defaults, struct) {
invariant(Array.isArray(schema), "Enum structs must be defined as an array, but you passed: " + schema);

@@ -826,3 +827,3 @@

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'enum';

@@ -835,3 +836,3 @@ Struct.type = schema.map(function (s) {

var createFunction = function createFunction(schema, defaults, options) {
var createFunction = function createFunction(schema, defaults, struct) {
var Struct = createStruct({

@@ -841,3 +842,3 @@ kind: 'function',

defaults: defaults,
options: options
struct: struct
});

@@ -900,3 +901,3 @@

var createInstance = function createInstance(schema, defaults, options) {
var createInstance = function createInstance(schema, defaults, struct) {
invariant(typeof schema === 'function', "Instance structs must be defined as a function, but you passed: " + schema);

@@ -908,3 +909,3 @@

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'instance';

@@ -915,3 +916,3 @@ Struct.type = "instance<" + schema.name + ">";

var createInterface = function createInterface(schema, defaults, options) {
var createInterface = function createInterface(schema, defaults, struct) {
invariant(typeof schema === 'object', "Interface structs must be defined as an object, but you passed: " + schema);

@@ -921,3 +922,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -929,3 +930,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -966,6 +967,6 @@

var createIntersection = function createIntersection(schema, defaults, options) {
var createIntersection = function createIntersection(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Intersection structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
return struct(sch);
});

@@ -979,3 +980,3 @@ var type = Structs.map(function (s) {

defaults: defaults,
options: options
struct: struct
});

@@ -1002,5 +1003,5 @@

var struct = _ref;
var _struct = _ref;
var _struct$check = struct.check(value, branch, path),
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],

@@ -1026,3 +1027,3 @@ v = _struct$check[1];

var createLazy = function createLazy(schema, defaults, options) {
var createLazy = function createLazy(schema, defaults, struct) {
invariant(typeof schema === 'function', "Lazy structs must be defined as a function, but you passed: " + schema);

@@ -1033,3 +1034,3 @@ var Lazy = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -1045,3 +1046,3 @@

var createSize = function createSize(schema, defaults, options) {
var createSize = function createSize(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2 && schema.every(function (n) {

@@ -1057,3 +1058,3 @@ return typeof n === 'number';

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'size';

@@ -1064,3 +1065,3 @@ Struct.type = "size<" + min + "," + max + ">";

var createLiteral = function createLiteral(schema, defaults, options) {
var createLiteral = function createLiteral(schema, defaults, struct) {
var validator = function validator(value) {

@@ -1070,3 +1071,3 @@ return value === schema;

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'literal';

@@ -1077,3 +1078,3 @@ Struct.type = typeof schema === 'string' ? "\"" + schema + "\"" : "" + schema;

var createObject = function createObject(schema, defaults, options) {
var createObject = function createObject(schema, defaults, struct) {
invariant(typeof schema === 'object', "Object structs must be defined as an object, but you passed: " + schema);

@@ -1083,3 +1084,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -1091,3 +1092,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1167,3 +1168,3 @@

var createPartial = function createPartial(schema, defaults, options) {
var createPartial = function createPartial(schema, defaults, struct) {
invariant(typeof schema === 'object', "Partial structs must be defined as an object, but you passed: " + schema);

@@ -1173,3 +1174,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createUnion([schema[key], 'undefined'], undefined, options);
Props[key] = struct.union([schema[key], 'undefined']);
}

@@ -1181,3 +1182,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1256,3 +1257,3 @@

var createPick = function createPick(schema, defaults, options) {
var createPick = function createPick(schema, defaults, struct) {
invariant(typeof schema === 'object', "Pick structs must be defined as an object, but you passed: " + schema);

@@ -1262,3 +1263,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -1270,3 +1271,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1323,6 +1324,6 @@

var createRecord = function createRecord(schema, defaults, options) {
var createRecord = function createRecord(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2, "Record structs must be defined as an array with two elements, but you passed: " + schema);
var Key = createShorthand(schema[0], undefined, options);
var Value = createShorthand(schema[1], undefined, options);
var Key = struct(schema[0]);
var Value = struct(schema[1]);
var Struct = createStruct({

@@ -1332,3 +1333,3 @@ kind: 'record',

defaults: defaults,
options: options
struct: struct
});

@@ -1384,8 +1385,7 @@

var createScalar = function createScalar(schema, defaults, options) {
var createScalar = function createScalar(schema, defaults, struct) {
invariant(typeof schema === 'string', "Scalar structs must be defined as a string, but you passed: " + schema);
var types = options.types;
invariant(schema in types, "No struct validator function found for type \"" + schema + "\".");
var validator = types[schema];
var Struct = createFunction(validator, defaults, options);
var Types = struct.Types;
invariant(schema in Types, "No struct validator function found for type \"" + schema + "\".");
var Struct = struct(Types[schema], defaults);
Struct.kind = 'scalar';

@@ -1396,3 +1396,3 @@ Struct.type = schema;

var createShorthand = function createShorthand(schema, defaults, options) {
var createShorthand = function createShorthand(schema, defaults, struct) {
if (isStruct(schema)) {

@@ -1406,5 +1406,5 @@ return schema;

first = _schema[0];
return createArray([first], defaults, options);
return struct.array([first], defaults);
} else if (schema.length > 1) {
return createTuple(schema, defaults, options);
return struct.tuple(schema, defaults);
}

@@ -1414,7 +1414,7 @@ }

if (typeof schema === 'function') {
return createFunction(schema, defaults, options);
return struct.function(schema, defaults);
}
if (typeof schema === 'object') {
return createObject(schema, defaults, options);
return struct.object(schema, defaults);
}

@@ -1433,13 +1433,13 @@

var scalars = schema.split(/\s*\|\s*/g);
Struct = createUnion(scalars, defaults, options);
Struct = struct.union(scalars, defaults);
} else if (schema.includes('&')) {
var _scalars = schema.split(/\s*&\s*/g);
Struct = createIntersection(_scalars, defaults, options);
Struct = struct.intersection(_scalars, defaults);
} else {
Struct = createScalar(schema, defaults, options);
Struct = struct.scalar(schema, defaults);
}
if (optional) {
Struct = createUnion([Struct, 'undefined'], undefined, options);
Struct = struct.union([Struct, 'undefined'], undefined);
}

@@ -1453,6 +1453,6 @@

var createTuple = function createTuple(schema, defaults, options) {
var createTuple = function createTuple(schema, defaults, struct) {
invariant(Array.isArray(schema), "Tuple structs must be defined as an array, but you passed: " + schema);
var Elements = schema.map(function (s) {
return createShorthand(s, undefined, options);
return struct(s);
});

@@ -1465,3 +1465,3 @@ var Struct = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -1518,6 +1518,6 @@

var createUnion = function createUnion(schema, defaults, options) {
var createUnion = function createUnion(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Union structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
return struct(sch);
});

@@ -1531,3 +1531,3 @@ var type = Structs.map(function (s) {

defaults: defaults,
options: options
struct: struct
});

@@ -1552,5 +1552,5 @@

var struct = _ref;
var _struct = _ref;
var _struct$check = struct.check(value, branch, path),
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],

@@ -1584,83 +1584,80 @@ v = _struct$check[1];

var options = {
Error: settings.Error || StructError,
types: _objectSpread2({}, Types, {}, settings.types)
};
var struct = function struct(schema, defaults) {
return createShorthand(schema, defaults, options);
return createShorthand(schema, defaults, struct);
};
struct.array = function (schema, defaults) {
return createArray(schema, defaults, options);
return createArray(schema, defaults, struct);
};
struct.dynamic = function (schema, defaults) {
return createDynamic(schema, defaults, options);
return createDynamic(schema, defaults, struct);
};
struct.enum = function (schema, defaults) {
return createEnum(schema, defaults, options);
return createEnum(schema, defaults, struct);
};
struct.function = function (schema, defaults) {
return createFunction(schema, defaults, options);
return createFunction(schema, defaults, struct);
};
struct.instance = function (schema, defaults) {
return createInstance(schema, defaults, options);
return createInstance(schema, defaults, struct);
};
struct.interface = function (schema, defaults) {
return createInterface(schema, defaults, options);
return createInterface(schema, defaults, struct);
};
struct.intersection = function (schema, defaults) {
return createIntersection(schema, defaults, options);
return createIntersection(schema, defaults, struct);
};
struct.lazy = function (schema, defaults) {
return createLazy(schema, defaults, options);
return createLazy(schema, defaults, struct);
};
struct.literal = function (schema, defaults) {
return createLiteral(schema, defaults, options);
return createLiteral(schema, defaults, struct);
};
struct.object = function (schema, defaults) {
return createObject(schema, defaults, options);
return createObject(schema, defaults, struct);
};
struct.optional = function (schema, defaults) {
return createUnion([schema, 'undefined'], defaults, options);
return createUnion([schema, 'undefined'], defaults, struct);
};
struct.partial = function (schema, defaults) {
return createPartial(schema, defaults, options);
return createPartial(schema, defaults, struct);
};
struct.pick = function (schema, defaults) {
return createPick(schema, defaults, options);
return createPick(schema, defaults, struct);
};
struct.record = function (schema, defaults) {
return createRecord(schema, defaults, options);
return createRecord(schema, defaults, struct);
};
struct.scalar = function (schema, defaults) {
return createScalar(schema, defaults, options);
return createScalar(schema, defaults, struct);
};
struct.size = function (schema, defaults) {
return createSize(schema, defaults, options);
return createSize(schema, defaults, struct);
};
struct.tuple = function (schema, defaults) {
return createTuple(schema, defaults, options);
return createTuple(schema, defaults, struct);
};
struct.union = function (schema, defaults) {
return createUnion(schema, defaults, options);
return createUnion(schema, defaults, struct);
};
struct.Error = settings.error || StructError;
struct.Types = _objectSpread2({}, Types, {}, settings.types);
return struct;

@@ -1680,3 +1677,3 @@ };

export { struct, superstruct, StructError, Types, isStruct };
export { StructError, Types, isStruct, struct, superstruct };
//# sourceMappingURL=index.es.js.map

@@ -577,3 +577,3 @@ 'use strict';

*/
undefined: function undefined(value) {
undefined: function undefined$1(value) {
return kindOf(value) === 'undefined';

@@ -676,3 +676,4 @@ },

var createStruct = function createStruct(props) {
var ErrorConstructor = props.options.Error;
var struct = props.struct;
var Error = struct.Error;

@@ -708,3 +709,3 @@ var Struct = function Struct(value) {

if (failures) {
throw new ErrorConstructor(failures);
throw new Error(failures);
} else {

@@ -721,3 +722,3 @@ return result;

if (failures) {
return [new ErrorConstructor(failures)];
return [new Error(failures)];
} else {

@@ -750,5 +751,5 @@ return [undefined, result];

var createArray = function createArray(schema, defaults, options) {
var createArray = function createArray(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 1, "Array structs must be defined as an array with one element, but you passed: " + schema);
var Element = createShorthand(schema[0], undefined, options);
var Element = struct(schema[0], undefined);
var Struct = createStruct({

@@ -758,3 +759,3 @@ kind: 'array',

defaults: defaults,
options: options
struct: struct
});

@@ -799,3 +800,3 @@

var createDynamic = function createDynamic(schema, defaults, options) {
var createDynamic = function createDynamic(schema, defaults, struct) {
invariant(typeof schema === 'function', "Dynamic structs must be defined as a function, but you passed: " + schema);

@@ -806,3 +807,3 @@ var Dynamic = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -822,3 +823,3 @@

var createEnum = function createEnum(schema, defaults, options) {
var createEnum = function createEnum(schema, defaults, struct) {
invariant(Array.isArray(schema), "Enum structs must be defined as an array, but you passed: " + schema);

@@ -830,3 +831,3 @@

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'enum';

@@ -839,3 +840,3 @@ Struct.type = schema.map(function (s) {

var createFunction = function createFunction(schema, defaults, options) {
var createFunction = function createFunction(schema, defaults, struct) {
var Struct = createStruct({

@@ -845,3 +846,3 @@ kind: 'function',

defaults: defaults,
options: options
struct: struct
});

@@ -904,3 +905,3 @@

var createInstance = function createInstance(schema, defaults, options) {
var createInstance = function createInstance(schema, defaults, struct) {
invariant(typeof schema === 'function', "Instance structs must be defined as a function, but you passed: " + schema);

@@ -912,3 +913,3 @@

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'instance';

@@ -919,3 +920,3 @@ Struct.type = "instance<" + schema.name + ">";

var createInterface = function createInterface(schema, defaults, options) {
var createInterface = function createInterface(schema, defaults, struct) {
invariant(typeof schema === 'object', "Interface structs must be defined as an object, but you passed: " + schema);

@@ -925,3 +926,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -933,3 +934,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -970,6 +971,6 @@

var createIntersection = function createIntersection(schema, defaults, options) {
var createIntersection = function createIntersection(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Intersection structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
return struct(sch);
});

@@ -983,3 +984,3 @@ var type = Structs.map(function (s) {

defaults: defaults,
options: options
struct: struct
});

@@ -1006,5 +1007,5 @@

var struct = _ref;
var _struct = _ref;
var _struct$check = struct.check(value, branch, path),
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],

@@ -1030,3 +1031,3 @@ v = _struct$check[1];

var createLazy = function createLazy(schema, defaults, options) {
var createLazy = function createLazy(schema, defaults, struct) {
invariant(typeof schema === 'function', "Lazy structs must be defined as a function, but you passed: " + schema);

@@ -1037,3 +1038,3 @@ var Lazy = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -1049,3 +1050,3 @@

var createSize = function createSize(schema, defaults, options) {
var createSize = function createSize(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2 && schema.every(function (n) {

@@ -1061,3 +1062,3 @@ return typeof n === 'number';

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'size';

@@ -1068,3 +1069,3 @@ Struct.type = "size<" + min + "," + max + ">";

var createLiteral = function createLiteral(schema, defaults, options) {
var createLiteral = function createLiteral(schema, defaults, struct) {
var validator = function validator(value) {

@@ -1074,3 +1075,3 @@ return value === schema;

var Struct = createFunction(validator, defaults, options);
var Struct = struct(validator, defaults);
Struct.kind = 'literal';

@@ -1081,3 +1082,3 @@ Struct.type = typeof schema === 'string' ? "\"" + schema + "\"" : "" + schema;

var createObject = function createObject(schema, defaults, options) {
var createObject = function createObject(schema, defaults, struct) {
invariant(typeof schema === 'object', "Object structs must be defined as an object, but you passed: " + schema);

@@ -1087,3 +1088,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -1095,3 +1096,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1171,3 +1172,3 @@

var createPartial = function createPartial(schema, defaults, options) {
var createPartial = function createPartial(schema, defaults, struct) {
invariant(typeof schema === 'object', "Partial structs must be defined as an object, but you passed: " + schema);

@@ -1177,3 +1178,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createUnion([schema[key], 'undefined'], undefined, options);
Props[key] = struct.union([schema[key], 'undefined']);
}

@@ -1185,3 +1186,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1260,3 +1261,3 @@

var createPick = function createPick(schema, defaults, options) {
var createPick = function createPick(schema, defaults, struct) {
invariant(typeof schema === 'object', "Pick structs must be defined as an object, but you passed: " + schema);

@@ -1266,3 +1267,3 @@ var Props = {};

for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
Props[key] = struct(schema[key]);
}

@@ -1274,3 +1275,3 @@

defaults: defaults,
options: options
struct: struct
});

@@ -1327,6 +1328,6 @@

var createRecord = function createRecord(schema, defaults, options) {
var createRecord = function createRecord(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2, "Record structs must be defined as an array with two elements, but you passed: " + schema);
var Key = createShorthand(schema[0], undefined, options);
var Value = createShorthand(schema[1], undefined, options);
var Key = struct(schema[0]);
var Value = struct(schema[1]);
var Struct = createStruct({

@@ -1336,3 +1337,3 @@ kind: 'record',

defaults: defaults,
options: options
struct: struct
});

@@ -1388,8 +1389,7 @@

var createScalar = function createScalar(schema, defaults, options) {
var createScalar = function createScalar(schema, defaults, struct) {
invariant(typeof schema === 'string', "Scalar structs must be defined as a string, but you passed: " + schema);
var types = options.types;
invariant(schema in types, "No struct validator function found for type \"" + schema + "\".");
var validator = types[schema];
var Struct = createFunction(validator, defaults, options);
var Types = struct.Types;
invariant(schema in Types, "No struct validator function found for type \"" + schema + "\".");
var Struct = struct(Types[schema], defaults);
Struct.kind = 'scalar';

@@ -1400,3 +1400,3 @@ Struct.type = schema;

var createShorthand = function createShorthand(schema, defaults, options) {
var createShorthand = function createShorthand(schema, defaults, struct) {
if (isStruct(schema)) {

@@ -1410,5 +1410,5 @@ return schema;

first = _schema[0];
return createArray([first], defaults, options);
return struct.array([first], defaults);
} else if (schema.length > 1) {
return createTuple(schema, defaults, options);
return struct.tuple(schema, defaults);
}

@@ -1418,7 +1418,7 @@ }

if (typeof schema === 'function') {
return createFunction(schema, defaults, options);
return struct.function(schema, defaults);
}
if (typeof schema === 'object') {
return createObject(schema, defaults, options);
return struct.object(schema, defaults);
}

@@ -1437,13 +1437,13 @@

var scalars = schema.split(/\s*\|\s*/g);
Struct = createUnion(scalars, defaults, options);
Struct = struct.union(scalars, defaults);
} else if (schema.includes('&')) {
var _scalars = schema.split(/\s*&\s*/g);
Struct = createIntersection(_scalars, defaults, options);
Struct = struct.intersection(_scalars, defaults);
} else {
Struct = createScalar(schema, defaults, options);
Struct = struct.scalar(schema, defaults);
}
if (optional) {
Struct = createUnion([Struct, 'undefined'], undefined, options);
Struct = struct.union([Struct, 'undefined'], undefined);
}

@@ -1457,6 +1457,6 @@

var createTuple = function createTuple(schema, defaults, options) {
var createTuple = function createTuple(schema, defaults, struct) {
invariant(Array.isArray(schema), "Tuple structs must be defined as an array, but you passed: " + schema);
var Elements = schema.map(function (s) {
return createShorthand(s, undefined, options);
return struct(s);
});

@@ -1469,3 +1469,3 @@ var Struct = createStruct({

defaults: defaults,
options: options
struct: struct
});

@@ -1522,6 +1522,6 @@

var createUnion = function createUnion(schema, defaults, options) {
var createUnion = function createUnion(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Union structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
return struct(sch);
});

@@ -1535,3 +1535,3 @@ var type = Structs.map(function (s) {

defaults: defaults,
options: options
struct: struct
});

@@ -1556,5 +1556,5 @@

var struct = _ref;
var _struct = _ref;
var _struct$check = struct.check(value, branch, path),
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],

@@ -1588,83 +1588,80 @@ v = _struct$check[1];

var options = {
Error: settings.Error || StructError,
types: _objectSpread2({}, Types, {}, settings.types)
};
var struct = function struct(schema, defaults) {
return createShorthand(schema, defaults, options);
return createShorthand(schema, defaults, struct);
};
struct.array = function (schema, defaults) {
return createArray(schema, defaults, options);
return createArray(schema, defaults, struct);
};
struct.dynamic = function (schema, defaults) {
return createDynamic(schema, defaults, options);
return createDynamic(schema, defaults, struct);
};
struct.enum = function (schema, defaults) {
return createEnum(schema, defaults, options);
return createEnum(schema, defaults, struct);
};
struct.function = function (schema, defaults) {
return createFunction(schema, defaults, options);
return createFunction(schema, defaults, struct);
};
struct.instance = function (schema, defaults) {
return createInstance(schema, defaults, options);
return createInstance(schema, defaults, struct);
};
struct.interface = function (schema, defaults) {
return createInterface(schema, defaults, options);
return createInterface(schema, defaults, struct);
};
struct.intersection = function (schema, defaults) {
return createIntersection(schema, defaults, options);
return createIntersection(schema, defaults, struct);
};
struct.lazy = function (schema, defaults) {
return createLazy(schema, defaults, options);
return createLazy(schema, defaults, struct);
};
struct.literal = function (schema, defaults) {
return createLiteral(schema, defaults, options);
return createLiteral(schema, defaults, struct);
};
struct.object = function (schema, defaults) {
return createObject(schema, defaults, options);
return createObject(schema, defaults, struct);
};
struct.optional = function (schema, defaults) {
return createUnion([schema, 'undefined'], defaults, options);
return createUnion([schema, 'undefined'], defaults, struct);
};
struct.partial = function (schema, defaults) {
return createPartial(schema, defaults, options);
return createPartial(schema, defaults, struct);
};
struct.pick = function (schema, defaults) {
return createPick(schema, defaults, options);
return createPick(schema, defaults, struct);
};
struct.record = function (schema, defaults) {
return createRecord(schema, defaults, options);
return createRecord(schema, defaults, struct);
};
struct.scalar = function (schema, defaults) {
return createScalar(schema, defaults, options);
return createScalar(schema, defaults, struct);
};
struct.size = function (schema, defaults) {
return createSize(schema, defaults, options);
return createSize(schema, defaults, struct);
};
struct.tuple = function (schema, defaults) {
return createTuple(schema, defaults, options);
return createTuple(schema, defaults, struct);
};
struct.union = function (schema, defaults) {
return createUnion(schema, defaults, options);
return createUnion(schema, defaults, struct);
};
struct.Error = settings.error || StructError;
struct.Types = _objectSpread2({}, Types, {}, settings.types);
return struct;

@@ -1684,7 +1681,7 @@ };

exports.struct = struct;
exports.superstruct = superstruct;
exports.StructError = StructError;
exports.Types = Types;
exports.isStruct = isStruct;
exports.struct = struct;
exports.superstruct = superstruct;
//# sourceMappingURL=index.js.map

@@ -13,7 +13,5 @@ /**

value: any;
[key: string]: any;
constructor(failures: Failure[]);
}
export interface StructErrorConstructor {
new (failures: Failure[]): StructError;
}
/**

@@ -69,3 +67,6 @@ * `Path` arrays specify a nested value's location in a root object or array.

type: string | undefined;
/**
* Failures can also be augmented with any of your on custom properties.
*/
[key: string]: any;
};
//# sourceMappingURL=struct-error.d.ts.map

@@ -1,3 +0,3 @@

import { Failure, Branch, Path, StructErrorConstructor } from './struct-error';
import { Validator } from './types';
import { Failure, Branch, Path } from './struct-error';
import { Superstruct } from './superstruct';
/**

@@ -19,3 +19,3 @@ * A symbol to set on `Struct` objects to test them against later.

defaults: () => any;
options: StructOptions;
struct: Superstruct;
}) => Struct;

@@ -142,9 +142,1 @@ /**

}
/**
* `StructOptions` are passed in when creating a struct.
*/
export declare type StructOptions = {
types: Record<string, Validator>;
Error: StructErrorConstructor;
};
//# sourceMappingURL=struct.d.ts.map

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createArray: (schema: [any], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=array.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createArray: (schema: [any], defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createDynamic: (schema: (value: any, branch: any[], path: (string | number)[]) => Struct, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=dynamic.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createDynamic: (schema: (value: any, branch: any[], path: (string | number)[]) => Struct, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createEnum: (schema: any[], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=enum.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createEnum: (schema: any[], defaults: any, struct: Superstruct) => Struct;

@@ -1,4 +0,2 @@

import { Struct, StructOptions } from '../struct';
import { Validator } from '../types';
export declare const createFunction: (schema: Validator, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=function.d.ts.map
import { Struct, Superstruct, Validator } from '..';
export declare const createFunction: (schema: Validator, defaults: any, struct: Superstruct) => Struct;

@@ -19,2 +19,1 @@ export * from './array';

export * from './union';
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createInstance: (schema: any, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=instance.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createInstance: (schema: any, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createInterface: (schema: any, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=interface.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createInterface: (schema: any, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createIntersection: (schema: any[], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=intersection.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createIntersection: (schema: any[], defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createLazy: (schema: () => Struct, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=lazy.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createLazy: (schema: () => Struct, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createLiteral: (schema: any, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=literal.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createLiteral: (schema: any, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createObject: (schema: {}, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=object.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createObject: (schema: {}, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createPartial: (schema: {}, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=partial.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createPartial: (schema: {}, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createPick: (schema: {}, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=pick.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createPick: (schema: {}, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createRecord: (schema: [any, any], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=record.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createRecord: (schema: [any, any], defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createScalar: (schema: string, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=scalar.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createScalar: (schema: string, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createShorthand: (schema: any, defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=shorthand.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createShorthand: (schema: any, defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createSize: (schema: [number, number], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=size.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createSize: (schema: [number, number], defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createTuple: (schema: any[], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=tuple.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createTuple: (schema: any[], defaults: any, struct: Superstruct) => Struct;

@@ -1,3 +0,2 @@

import { Struct, StructOptions } from '../struct';
export declare const createUnion: (schema: any[], defaults: any, options: StructOptions) => Struct;
//# sourceMappingURL=union.d.ts.map
import { Struct, Superstruct } from '..';
export declare const createUnion: (schema: any[], defaults: any, struct: Superstruct) => Struct;
import { Validator } from './types';
import { Branch, Path, StructErrorConstructor } from './struct-error';
import { Branch, Failure, Path } from './struct-error';
import { Struct } from './struct';
/**
* `SuperstructSettings` are passed in when creating a `Superstruct` factory.
*/
export declare type SuperstructSettings = {
types: Record<string, Validator>;
error: {
new (failures: Failure[]): Error;
};
};
/**
* Create a struct singleton with settings that include your own domain-specific
* data `types`, and an optional custom `Error` class.
*/
export declare const superstruct: (settings?: {
types?: Record<string, Validator> | undefined;
Error?: StructErrorConstructor | undefined;
}) => Superstruct;
export declare const superstruct: (settings?: Partial<SuperstructSettings>) => Superstruct;
/**

@@ -109,3 +115,3 @@ * `Superstruct` factories create different kinds of [[Struct]] validators, and

*/
(schema: any, defaults: any): Struct;
(schema: any, defaults?: any): Struct;
/**

@@ -124,3 +130,3 @@ * Array structs validate that their input is an array with elements that

*/
array(schema: [any], defaults: any): Struct;
array(schema: [any], defaults?: any): Struct;
/**

@@ -137,3 +143,3 @@ * Dynamic structs are defined by a function that is passed the value being

*/
dynamic(schema: (value: any, branch: Branch, path: Path) => Struct, defaults: any): Struct;
dynamic(schema: (value: any, branch: Branch, path: Path) => Struct, defaults?: any): Struct;
/**

@@ -150,3 +156,3 @@ * Enum structs validate that their input is one of a set of values.

*/
enum(schema: any[], defaults: any): Struct;
enum(schema: any[], defaults?: any): Struct;
/**

@@ -164,3 +170,3 @@ * Function structs validate their input against a one-off validator function.

*/
function(schema: Validator, defaults: any): Struct;
function(schema: Validator, defaults?: any): Struct;
/**

@@ -175,3 +181,3 @@ * Instance structs validate that their input is an instance of a class.

*/
instance(schema: any, defaults: any): Struct;
instance(schema: any, defaults?: any): Struct;
/**

@@ -193,3 +199,3 @@ * Interface structs validate that their input matches an interface defined as

*/
interface(schema: any, defaults: any): Struct;
interface(schema: any, defaults?: any): Struct;
/**

@@ -210,3 +216,3 @@ * Intersection structs validate that their input matches **all** of a set of

*/
intersection(schema: any[], defaults: any): Struct;
intersection(schema: any[], defaults?: any): Struct;
/**

@@ -230,3 +236,3 @@ * Lazy structs allow you to initialize a struct lazily, only initializing it

*/
lazy(schema: () => Struct, defaults: any): Struct;
lazy(schema: () => Struct, defaults?: any): Struct;
/**

@@ -241,3 +247,3 @@ * Literal structs validate their input against a literal value.

*/
literal(schema: any, defaults: any): Struct;
literal(schema: any, defaults?: any): Struct;
/**

@@ -261,3 +267,3 @@ * Object structs validate that their input exactly matches an object defined

*/
object(schema: {}, defaults: any): Struct;
object(schema: {}, defaults?: any): Struct;
/**

@@ -276,3 +282,3 @@ * Optional structs validate that their input passes a specific struct, or

*/
optional(schema: any, defaults: any): Struct;
optional(schema: any, defaults?: any): Struct;
/**

@@ -296,3 +302,3 @@ * Partial structs validate that their input partially matches an object

*/
partial(schema: {}, defaults: any): Struct;
partial(schema: {}, defaults?: any): Struct;
/**

@@ -319,3 +325,3 @@ * Pick structs validate that their input exactly matches a subset of an

*/
pick(schema: {}, defaults: any): Struct;
pick(schema: {}, defaults?: any): Struct;
/**

@@ -337,3 +343,3 @@ * Record structs validate that their input is an object with keys that match

*/
record(schema: [any, any], defaults: any): Struct;
record(schema: [any, any], defaults?: any): Struct;
/**

@@ -351,3 +357,3 @@ * Scalar structs validate that their input passes the `Validator` function

*/
scalar(schema: string, defaults: any): Struct;
scalar(schema: string, defaults?: any): Struct;
/**

@@ -366,3 +372,3 @@ * Size structs validate their input has a certain length, by checking its

*/
size(schema: [number, number], defaults: any): Struct;
size(schema: [number, number], defaults?: any): Struct;
/**

@@ -378,3 +384,3 @@ * Tuple structs validate that their input exactly matches a tuple of values,

*/
tuple(schema: any[], defaults: any): Struct;
tuple(schema: any[], defaults?: any): Struct;
/**

@@ -393,4 +399,13 @@ * Union structs validate that their input matches **at least one** of a set

*/
union(schema: any[], defaults: any): Struct;
union(schema: any[], defaults?: any): Struct;
/**
* The class for errors thrown by `Structs`, defaults to [[StructError]].
*/
Error: {
new (failures: Failure[]): Error;
};
/**
* The set of data types that the factory knows.
*/
Types: Record<string, Validator>;
}
//# sourceMappingURL=superstruct.d.ts.map

@@ -234,2 +234,1 @@ import { Branch, Path, Failure } from './struct-error';

export declare type Validator = (value: any, branch: Branch, path: Path) => Partial<Failure>[] | Partial<Failure> | boolean;
//# sourceMappingURL=types.d.ts.map

@@ -5,3 +5,3 @@ {

"description": "A simple, expressive way to validate data in JavaScript.",
"version": "0.8.0",
"version": "0.8.1",
"license": "MIT",

@@ -18,24 +18,23 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git",

"dependencies": {
"@types/kind-of": "^6.0.0",
"kind-of": "^6.0.1",
"kind-of": "^6.0.2",
"rollup-plugin-terser": "^5.1.2",
"tiny-invariant": "^1.0.6"
},
"devDependencies": {
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/cli": "^7.6.3",
"@babel/core": "^7.6.3",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/preset-env": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"@babel/register": "^7.6.2",
"@gnd/typedoc": "^0.15.0-0",
"@typescript-eslint/eslint-plugin": "^2.3.2",
"@typescript-eslint/parser": "^2.3.2",
"@types/lodash": "^4.14.144",
"@types/mocha": "^5.2.7",
"@types/node": "^12.7.12",
"@typescript-eslint/eslint-plugin": "^2.3.3",
"@typescript-eslint/parser": "^2.3.3",
"babel-eslint": "^10.0.3",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-inline-environment-variables": "^0.2.0",
"babelify": "^8.0.0",
"browserify": "^14.5.0",
"envify": "^4.1.0",
"babel-plugin-dev-expression": "^0.2.2",
"eslint": "^6.5.1",

@@ -46,18 +45,17 @@ "eslint-config-prettier": "^6.4.0",

"is-email": "^1.0.0",
"is-url": "^1.2.2",
"is-url": "^1.2.4",
"is-uuid": "^1.0.2",
"lodash": "^4.17.4",
"lodash": "^4.17.15",
"mocha": "^4.0.1",
"prettier": "^1.18.2",
"rollup": "^0.52.0",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup": "^1.23.1",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.24.3",
"rollup-plugin-uglify": "^2.0.1",
"source-map-support": "^0.5.13",
"typescript": "^3.6.3",
"uglify-es": "^3.2.2"
"rollup-plugin-uglify": "^6.0.3",
"typescript": "^3.6.4",
"uglify-es": "^3.3.9"
},

@@ -67,7 +65,7 @@ "scripts": {

"build:cjs": "rollup --config ./config/rollup-cjs.js",
"build:docs": "typedoc ./src/index.ts && cp -f ./site/globals.html ./site/index.html",
"build:docs": "typedoc ./src/index.ts ./src/@types/*.ts && cp -f ./site/globals.html ./site/index.html",
"build:es": "rollup --config ./config/rollup.js",
"build:max": "rollup --config ./config/rollup-umd.js",
"build:min": "rollup --config ./config/rollup-umd-min.js",
"build:types": "tsc --emitDeclarationOnly --declarationMap",
"build:types": "tsc --emitDeclarationOnly --declarationMap --outDir ./lib",
"clean": "rm -rf ./{lib,umd,node_modules}",

@@ -78,8 +76,8 @@ "fix": "yarn fix:eslint && yarn fix:prettier",

"lint": "yarn lint:eslint && yarn lint:prettier",
"lint:eslint": "eslint '{src,test}/*'",
"lint:prettier": "prettier --list-different '{config,docs,examples,src,test}/**/*.{js,json}'",
"lint:eslint": "eslint '{src,test}/*.{js,ts}'",
"lint:prettier": "prettier --list-different '**/*.{js,json,ts}'",
"release": "yarn build && yarn lint && np",
"test": "yarn test:types && yarn test:mocha",
"test:mocha": "yarn build:cjs && mocha --require @babel/register --require source-map-support/register ./test/index.js",
"test:types": "tsc --noEmit",
"test:mocha": "yarn build:cjs && mocha --require ./test/register --require source-map-support/register ./test/index.ts",
"test:types": "yarn build:types && tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit",
"watch": "yarn build:cjs --watch"

@@ -86,0 +84,0 @@ },

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.Superstruct = {})));
}(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.Superstruct = {}));
}(this, function (exports) { 'use strict';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
return keys;
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
return target;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
return target;
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
return _setPrototypeOf(o, p);
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
_cache.set(Class, Wrapper);
}
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
return _construct.apply(null, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
return target;
}
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
return self;
}
var toString = Object.prototype.toString;
var kindOf = function kindOf(val) {
if (val === void 0) return 'undefined';
if (val === null) return 'null';
var type = typeof val;
if (type === 'boolean') return 'boolean';
if (type === 'string') return 'string';
if (type === 'number') return 'number';
if (type === 'symbol') return 'symbol';
if (type === 'function') {
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
if (isArray(val)) return 'array';
if (isBuffer(val)) return 'buffer';
if (isArguments(val)) return 'arguments';
if (isDate(val)) return 'date';
if (isError(val)) return 'error';
if (isRegexp(val)) return 'regexp';
_cache.set(Class, Wrapper);
switch (ctorName(val)) {
case 'Symbol': return 'symbol';
case 'Promise': return 'promise';
// Set, Map, WeakSet, WeakMap
case 'WeakMap': return 'weakmap';
case 'WeakSet': return 'weakset';
case 'Map': return 'map';
case 'Set': return 'set';
// 8-bit typed arrays
case 'Int8Array': return 'int8array';
case 'Uint8Array': return 'uint8array';
case 'Uint8ClampedArray': return 'uint8clampedarray';
// 16-bit typed arrays
case 'Int16Array': return 'int16array';
case 'Uint16Array': return 'uint16array';
// 32-bit typed arrays
case 'Int32Array': return 'int32array';
case 'Uint32Array': return 'uint32array';
case 'Float32Array': return 'float32array';
case 'Float64Array': return 'float64array';
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
if (isGeneratorObj(val)) {
return 'generator';
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
// Non-plain objects
type = toString.call(val);
switch (type) {
case '[object Object]': return 'object';
// iterators
case '[object Map Iterator]': return 'mapiterator';
case '[object Set Iterator]': return 'setiterator';
case '[object String Iterator]': return 'stringiterator';
case '[object Array Iterator]': return 'arrayiterator';
}
// other
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
};
return _wrapNativeSuper(Class);
}
function ctorName(val) {
return val.constructor ? val.constructor.name : null;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
function isArray(val) {
if (Array.isArray) return Array.isArray(val);
return val instanceof Array;
}
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
function isError(val) {
return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
}
return target;
}
function isDate(val) {
if (val instanceof Date) return true;
return typeof val.toDateString === 'function'
&& typeof val.getDate === 'function'
&& typeof val.setDate === 'function';
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
function isRegexp(val) {
if (val instanceof RegExp) return true;
return typeof val.flags === 'string'
&& typeof val.ignoreCase === 'boolean'
&& typeof val.multiline === 'boolean'
&& typeof val.global === 'boolean';
}
return self;
}
function isGeneratorFn(name, val) {
return ctorName(name) === 'GeneratorFunction';
}
var toString = Object.prototype.toString;
function isGeneratorObj(val) {
return typeof val.throw === 'function'
&& typeof val.return === 'function'
&& typeof val.next === 'function';
}
var kindOf = function kindOf(val) {
if (val === void 0) return 'undefined';
if (val === null) return 'null';
function isArguments(val) {
try {
if (typeof val.length === 'number' && typeof val.callee === 'function') {
return true;
}
} catch (err) {
if (err.message.indexOf('callee') !== -1) {
return true;
}
}
return false;
}
var type = typeof val;
if (type === 'boolean') return 'boolean';
if (type === 'string') return 'string';
if (type === 'number') return 'number';
if (type === 'symbol') return 'symbol';
if (type === 'function') {
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
/**
* If you need to support Safari 5-7 (8-10 yr-old browser),
* take a look at https://github.com/feross/is-buffer
*/
function isBuffer(val) {
if (val.constructor && typeof val.constructor.isBuffer === 'function') {
return val.constructor.isBuffer(val);
}
return false;
}
if (isArray(val)) return 'array';
if (isBuffer(val)) return 'buffer';
if (isArguments(val)) return 'arguments';
if (isDate(val)) return 'date';
if (isError(val)) return 'error';
if (isRegexp(val)) return 'regexp';
/**
* Superstruct ships by default with an unopinionated set of scalar types that
* express all of the data types that are built-in to JavaScript.
*/
switch (ctorName(val)) {
case 'Symbol': return 'symbol';
case 'Promise': return 'promise';
var Types = {
/**
* Matches any value other than `undefined`.
*
* ```js
* 'anything'
* true
* ```
*/
any: function any(value) {
return value !== undefined;
},
// Set, Map, WeakSet, WeakMap
case 'WeakMap': return 'weakmap';
case 'WeakSet': return 'weakset';
case 'Map': return 'map';
case 'Set': return 'set';
/**
* Matches an `arguments` object.
*
* ```js
* arguments
* ```
*/
arguments: function _arguments(value) {
return kindOf(value) === 'arguments';
},
// 8-bit typed arrays
case 'Int8Array': return 'int8array';
case 'Uint8Array': return 'uint8array';
case 'Uint8ClampedArray': return 'uint8clampedarray';
/**
* Matches an `Array`.
*
* ```js
* [1, 2, 3]
* ```
*/
array: function array(value) {
return kindOf(value) === 'array';
},
// 16-bit typed arrays
case 'Int16Array': return 'int16array';
case 'Uint16Array': return 'uint16array';
/**
* Matches a boolean.
*
* ```js
* true
* false
* ```
*/
boolean: function boolean(value) {
return kindOf(value) === 'boolean';
},
// 32-bit typed arrays
case 'Int32Array': return 'int32array';
case 'Uint32Array': return 'uint32array';
case 'Float32Array': return 'float32array';
case 'Float64Array': return 'float64array';
}
/**
* Matches a Node.js `Buffer`.
*
* ```js
* Buffer.from('string')
* ```
*/
buffer: function buffer(value) {
return kindOf(value) === 'buffer';
},
if (isGeneratorObj(val)) {
return 'generator';
}
/**
* Matches a **valid** `Date` object.
*
* ```js
* new Date()
* ```
*
* Note: Invalid `Date` objects that equal `NaN` are not matched.
*/
date: function date(value) {
return kindOf(value) === 'date' && !isNaN(value);
},
// Non-plain objects
type = toString.call(val);
switch (type) {
case '[object Object]': return 'object';
// iterators
case '[object Map Iterator]': return 'mapiterator';
case '[object Set Iterator]': return 'setiterator';
case '[object String Iterator]': return 'stringiterator';
case '[object Array Iterator]': return 'arrayiterator';
}
/**
* Matches an error object.
*
* ```js
* new Error()
* ```
*/
error: function error(value) {
return kindOf(value) === 'error';
},
// other
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
};
/**
* Matches a `Float32Array` object.
*/
float32array: function float32array(value) {
return kindOf(value) === 'float32array';
},
function ctorName(val) {
return val.constructor ? val.constructor.name : null;
}
/**
* Matches a `Float64Array` object.
*/
float64array: function float64array(value) {
return kindOf(value) === 'float64array';
},
function isArray(val) {
if (Array.isArray) return Array.isArray(val);
return val instanceof Array;
}
/**
* Matches a function.
*
* ```js
* () => {}
* function () {}
* ```
*/
function: function _function(value) {
return kindOf(value) === 'function';
},
function isError(val) {
return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
}
/**
* Matches a generator function.
*
* ```js
* function* () {}
* ```
*/
generatorfunction: function generatorfunction(value) {
return kindOf(value) === 'generatorfunction';
},
function isDate(val) {
if (val instanceof Date) return true;
return typeof val.toDateString === 'function'
&& typeof val.getDate === 'function'
&& typeof val.setDate === 'function';
}
/**
* Matches a `Int16Array` object.
*/
int16array: function int16array(value) {
return kindOf(value) === 'int16array';
},
function isRegexp(val) {
if (val instanceof RegExp) return true;
return typeof val.flags === 'string'
&& typeof val.ignoreCase === 'boolean'
&& typeof val.multiline === 'boolean'
&& typeof val.global === 'boolean';
}
/**
* Matches a `Int32Array` object.
*/
int32array: function int32array(value) {
return kindOf(value) === 'int32array';
},
function isGeneratorFn(name, val) {
return ctorName(name) === 'GeneratorFunction';
}
/**
* Matches a `Int8Array` object.
*/
int8array: function int8array(value) {
return kindOf(value) === 'int8array';
},
function isGeneratorObj(val) {
return typeof val.throw === 'function'
&& typeof val.return === 'function'
&& typeof val.next === 'function';
}
/**
* Matches a `Map` object.
*
* ```js
* new Map()
* ```
*/
map: function map(value) {
return kindOf(value) === 'map';
},
function isArguments(val) {
try {
if (typeof val.length === 'number' && typeof val.callee === 'function') {
return true;
}
} catch (err) {
if (err.message.indexOf('callee') !== -1) {
return true;
}
}
return false;
}
/**
* Matches the `null` literal value.
*
* ```js
* null
* ```
*/
null: function _null(value) {
return kindOf(value) === 'null';
},
/**
* If you need to support Safari 5-7 (8-10 yr-old browser),
* take a look at https://github.com/feross/is-buffer
*/
/**
* Matches a number.
*
* ```js
* 42
* ```
*/
number: function number(value) {
return kindOf(value) === 'number';
},
function isBuffer(val) {
if (val.constructor && typeof val.constructor.isBuffer === 'function') {
return val.constructor.isBuffer(val);
}
return false;
}
/**
* Matches a plain object.
*
* ```js
* { key: 'value' }
* { something: true }
* ```
*/
object: function object(value) {
return kindOf(value) === 'object';
},
/**
* Superstruct ships by default with an unopinionated set of scalar types that
* express all of the data types that are built-in to JavaScript.
*/
/**
* Matches a `Promise` object.
*
* ```js
* Promise.resolve()
* ```
*/
promise: function promise(value) {
return kindOf(value) === 'promise';
},
var Types = {
/**
* Matches any value other than `undefined`.
*
* ```js
* 'anything'
* true
* ```
*/
any: function any(value) {
return value !== undefined;
},
/**
* Matches a regular expression object.
*
* ```js
* /a-z/g
* ```
*/
regexp: function regexp(value) {
return kindOf(value) === 'regexp';
},
/**
* Matches an `arguments` object.
*
* ```js
* arguments
* ```
*/
arguments: function _arguments(value) {
return kindOf(value) === 'arguments';
},
/**
* Matches a `Set` object.
*
* ```js
* new Set()
* ```
*/
set: function set(value) {
return kindOf(value) === 'set';
},
/**
* Matches an `Array`.
*
* ```js
* [1, 2, 3]
* ```
*/
array: function array(value) {
return kindOf(value) === 'array';
},
/**
* Matches a string.
*
* ```js
* 'text'
* ```
*/
string: function string(value) {
return kindOf(value) === 'string';
},
/**
* Matches a boolean.
*
* ```js
* true
* false
* ```
*/
boolean: function boolean(value) {
return kindOf(value) === 'boolean';
},
/**
* Matches a `Symbol`.
*
* ```js
* Symbol()
* ```
*/
symbol: function symbol(value) {
return kindOf(value) === 'symbol';
},
/**
* Matches a Node.js `Buffer`.
*
* ```js
* Buffer.from('string')
* ```
*/
buffer: function buffer(value) {
return kindOf(value) === 'buffer';
},
/**
* Matches a `Uint16Array` object.
*/
uint16array: function uint16array(value) {
return kindOf(value) === 'uint16array';
},
/**
* Matches a **valid** `Date` object.
*
* ```js
* new Date()
* ```
*
* Note: Invalid `Date` objects that equal `NaN` are not matched.
*/
date: function date(value) {
return kindOf(value) === 'date' && !isNaN(value);
},
/**
* Matches a `Uint32Array` object.
*/
uint32array: function uint32array(value) {
return kindOf(value) === 'uint32array';
},
/**
* Matches an error object.
*
* ```js
* new Error()
* ```
*/
error: function error(value) {
return kindOf(value) === 'error';
},
/**
* Matches a `Uint8Array` object.
*/
uint8array: function uint8array(value) {
return kindOf(value) === 'uint8array';
},
/**
* Matches a `Float32Array` object.
*/
float32array: function float32array(value) {
return kindOf(value) === 'float32array';
},
/**
* Matches a `Uint8ClampedArray` object.
*/
uint8clampedarray: function uint8clampedarray(value) {
return kindOf(value) === 'uint8clampedarray';
},
/**
* Matches a `Float64Array` object.
*/
float64array: function float64array(value) {
return kindOf(value) === 'float64array';
},
/**
* Matches the `undefined` literal value.
*
* ```js
* undefined
* ```
*/
undefined: function undefined$1(value) {
return kindOf(value) === 'undefined';
},
/**
* Matches a function.
*
* ```js
* () => {}
* function () {}
* ```
*/
function: function _function(value) {
return kindOf(value) === 'function';
},
/**
* Matches a `WeakMap` object.
*
* ```js
* new WeakMap()
* ```
*/
weakmap: function weakmap(value) {
return kindOf(value) === 'weakmap';
},
/**
* Matches a generator function.
*
* ```js
* function* () {}
* ```
*/
generatorfunction: function generatorfunction(value) {
return kindOf(value) === 'generatorfunction';
},
/**
* Matches a `WeakSet` object.
*
* ```js
* new WeakSet()
* ```
*/
weakset: function weakset(value) {
return kindOf(value) === 'weakset';
}
};
/**
* Matches a `Int16Array` object.
*/
int16array: function int16array(value) {
return kindOf(value) === 'int16array';
},
var prefix = 'Invariant failed';
function invariant(condition, message) {
if (condition) {
return;
}
/**
* Matches a `Int32Array` object.
*/
int32array: function int32array(value) {
return kindOf(value) === 'int32array';
},
{
throw new Error(prefix + ": " + (message || ''));
}
}
/**
* Matches a `Int8Array` object.
* `StructError` objects are thrown (or returned) by Superstruct when its
* validation fails. The error represents the first error encountered during
* validation. But they also have an `error.failures` property that holds
* information for all of the failures encountered.
*/
int8array: function int8array(value) {
return kindOf(value) === 'int8array';
},
/**
* Matches a `Map` object.
*
* ```js
* new Map()
* ```
*/
map: function map(value) {
return kindOf(value) === 'map';
},
var StructError =
/*#__PURE__*/
function (_TypeError) {
_inheritsLoose(StructError, _TypeError);
/**
* Matches the `null` literal value.
*
* ```js
* null
* ```
*/
null: function _null(value) {
return kindOf(value) === 'null';
},
function StructError(failures) {
var _this;
/**
* Matches a number.
*
* ```js
* 42
* ```
*/
number: function number(value) {
return kindOf(value) === 'number';
},
invariant(failures.length > 0, "StructError requires being passed a failure, but received: " + failures);
var first = failures[0];
/**
* Matches a plain object.
*
* ```js
* { key: 'value' }
* { something: true }
* ```
*/
object: function object(value) {
return kindOf(value) === 'object';
},
var path = first.path,
value = first.value,
type = first.type,
branch = first.branch,
rest = _objectWithoutPropertiesLoose(first, ["path", "value", "type", "branch"]);
/**
* Matches a `Promise` object.
*
* ```js
* Promise.resolve()
* ```
*/
promise: function promise(value) {
return kindOf(value) === 'promise';
},
var message = "Expected a value of type `" + type + "`" + (path.length ? " for `" + path.join('.') + "`" : '') + " but received `" + JSON.stringify(value) + "`.";
_this = _TypeError.call(this, message) || this;
_this.type = type;
_this.value = value;
Object.assign(_assertThisInitialized(_this), rest);
_this.path = path;
_this.branch = branch;
_this.failures = failures;
_this.stack = new Error().stack;
_this.__proto__ = StructError.prototype;
return _this;
}
/**
* Matches a regular expression object.
*
* ```js
* /a-z/g
* ```
*/
regexp: function regexp(value) {
return kindOf(value) === 'regexp';
},
return StructError;
}(_wrapNativeSuper(TypeError));
/**
* Matches a `Set` object.
*
* ```js
* new Set()
* ```
* A symbol to set on `Struct` objects to test them against later.
*/
set: function set(value) {
return kindOf(value) === 'set';
},
var STRUCT = Symbol('STRUCT');
/**
* Matches a string.
*
* ```js
* 'text'
* ```
* Check if a value is a `Struct` object.
*/
string: function string(value) {
return kindOf(value) === 'string';
},
var isStruct = function isStruct(value) {
return typeof value === 'function' && value[STRUCT];
};
/**
* Matches a `Symbol`.
*
* ```js
* Symbol()
* ```
* This abstract `Struct` factory creates a generic struct that validates values
* against a `Validator` function.
*/
symbol: function symbol(value) {
return kindOf(value) === 'symbol';
},
/**
* Matches a `Uint16Array` object.
*/
uint16array: function uint16array(value) {
return kindOf(value) === 'uint16array';
},
var createStruct = function createStruct(props) {
var struct = props.struct;
var Error = struct.Error;
/**
* Matches a `Uint32Array` object.
*/
uint32array: function uint32array(value) {
return kindOf(value) === 'uint32array';
},
var Struct = function Struct(value) {
return Struct.assert(value);
}; // Set a hidden symbol property so that we can check it later to see if an
// object is a struct object.
/**
* Matches a `Uint8Array` object.
*/
uint8array: function uint8array(value) {
return kindOf(value) === 'uint8array';
},
/**
* Matches a `Uint8ClampedArray` object.
*/
uint8clampedarray: function uint8clampedarray(value) {
return kindOf(value) === 'uint8clampedarray';
},
Object.defineProperty(Struct, STRUCT, {
value: true
});
Struct.kind = props.kind;
Struct.type = props.type;
/**
* Matches the `undefined` literal value.
*
* ```js
* undefined
* ```
*/
undefined: function undefined(value) {
return kindOf(value) === 'undefined';
},
Struct.default = function () {
return typeof props.defaults === 'function' ? props.defaults() : props.defaults;
};
/**
* Matches a `WeakMap` object.
*
* ```js
* new WeakMap()
* ```
*/
weakmap: function weakmap(value) {
return kindOf(value) === 'weakmap';
},
Struct.test = function (value) {
var _Struct$check = Struct.check(value, [value], []),
failures = _Struct$check[0];
/**
* Matches a `WeakSet` object.
*
* ```js
* new WeakSet()
* ```
*/
weakset: function weakset(value) {
return kindOf(value) === 'weakset';
}
};
return !failures;
};
var isProduction = "development" === 'production';
var prefix = 'Invariant failed';
function invariant(condition, message) {
if (condition) {
return;
}
Struct.assert = function (value) {
var _Struct$check2 = Struct.check(value, [value], []),
failures = _Struct$check2[0],
result = _Struct$check2[1];
if (isProduction) {
throw new Error(prefix);
} else {
throw new Error(prefix + ": " + (message || ''));
}
}
if (failures) {
throw new Error(failures);
} else {
return result;
}
};
/**
* `StructError` objects are thrown (or returned) by Superstruct when its
* validation fails. The error represents the first error encountered during
* validation. But they also have an `error.failures` property that holds
* information for all of the failures encountered.
*/
Struct.validate = function (value) {
var _Struct$check3 = Struct.check(value, [value], []),
failures = _Struct$check3[0],
result = _Struct$check3[1];
var StructError =
/*#__PURE__*/
function (_TypeError) {
_inheritsLoose(StructError, _TypeError);
if (failures) {
return [new Error(failures)];
} else {
return [undefined, result];
}
};
function StructError(failures) {
var _this;
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
invariant(failures.length > 0, "StructError requires being passed a failure, but received: " + failures);
var first = failures[0];
var failures = [Struct.fail({
value: value,
branch: branch,
path: path
})];
return [failures];
};
var path = first.path,
value = first.value,
type = first.type,
branch = first.branch,
rest = _objectWithoutPropertiesLoose(first, ["path", "value", "type", "branch"]);
Struct.fail = function (obj) {
return _objectSpread2({}, obj, {
type: 'type' in obj ? obj.type : Struct.type
});
};
var message = "Expected a value of type `" + type + "`" + (path.length ? " for `" + path.join('.') + "`" : '') + " but received `" + JSON.stringify(value) + "`.";
_this = _TypeError.call(this, message) || this;
_this.type = type;
_this.value = value;
Object.assign(_assertThisInitialized(_this), rest);
_this.path = path;
_this.branch = branch;
_this.failures = failures;
_this.stack = new Error().stack;
_this.__proto__ = StructError.prototype;
return _this;
}
return Struct;
};
return StructError;
}(_wrapNativeSuper(TypeError));
var createArray = function createArray(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 1, "Array structs must be defined as an array with one element, but you passed: " + schema);
var Element = struct(schema[0], undefined);
var Struct = createStruct({
kind: 'array',
type: Element.type + "[]",
defaults: defaults,
struct: struct
});
/**
* A symbol to set on `Struct` objects to test them against later.
*/
var STRUCT = Symbol('STRUCT');
/**
* Check if a value is a `Struct` object.
*/
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var isStruct = function isStruct(value) {
return typeof value === 'function' && value[STRUCT];
};
/**
* This abstract `Struct` factory creates a generic struct that validates values
* against a `Validator` function.
*/
if (!Array.isArray(value)) {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var createStruct = function createStruct(props) {
var ErrorConstructor = props.options.Error;
var result = [];
var failures = [];
var Struct = function Struct(value) {
return Struct.assert(value);
}; // Set a hidden symbol property so that we can check it later to see if an
// object is a struct object.
for (var i = 0; i < value.length; i++) {
var v = value[i];
var _Element$check = Element.check(v, branch.concat(v), path.concat(i)),
efs = _Element$check[0],
er = _Element$check[1];
Object.defineProperty(Struct, STRUCT, {
value: true
});
Struct.kind = props.kind;
Struct.type = props.type;
if (efs) {
failures.push.apply(failures, efs);
continue;
}
Struct.default = function () {
return typeof props.defaults === 'function' ? props.defaults() : props.defaults;
};
result[i] = er;
}
Struct.test = function (value) {
var _Struct$check = Struct.check(value, [value], []),
failures = _Struct$check[0];
return failures.length ? [failures] : [undefined, result];
};
return !failures;
return Struct;
};
Struct.assert = function (value) {
var _Struct$check2 = Struct.check(value, [value], []),
failures = _Struct$check2[0],
result = _Struct$check2[1];
var createDynamic = function createDynamic(schema, defaults, struct) {
invariant(typeof schema === 'function', "Dynamic structs must be defined as a function, but you passed: " + schema);
var Dynamic = createStruct({
kind: 'dynamic',
type: "dynamic<\u2026>",
defaults: defaults,
struct: struct
});
if (failures) {
throw new ErrorConstructor(failures);
} else {
return result;
}
};
Dynamic.check = function (value, branch, path) {
if (value === void 0) {
value = Dynamic.default();
}
Struct.validate = function (value) {
var _Struct$check3 = Struct.check(value, [value], []),
failures = _Struct$check3[0],
result = _Struct$check3[1];
var Struct = schema(value, branch, path);
return Struct.check(value, branch, path);
};
if (failures) {
return [new ErrorConstructor(failures)];
} else {
return [undefined, result];
}
return Dynamic;
};
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var createEnum = function createEnum(schema, defaults, struct) {
invariant(Array.isArray(schema), "Enum structs must be defined as an array, but you passed: " + schema);
var failures = [Struct.fail({
value: value,
branch: branch,
path: path
})];
return [failures];
var validator = function validator(value) {
return schema.includes(value);
};
var Struct = struct(validator, defaults);
Struct.kind = 'enum';
Struct.type = schema.map(function (s) {
return typeof s === 'string' ? "\"" + s + "\"" : "" + s;
}).join(' | ');
return Struct;
};
Struct.fail = function (obj) {
return _objectSpread2({}, obj, {
type: 'type' in obj ? obj.type : Struct.type
var createFunction = function createFunction(schema, defaults, struct) {
var Struct = createStruct({
kind: 'function',
type: "function<\u2026>",
defaults: defaults,
struct: struct
});
};
return Struct;
};
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var createArray = function createArray(schema, defaults, options) {
invariant(Array.isArray(schema) && schema.length === 1, "Array structs must be defined as an array with one element, but you passed: " + schema);
var Element = createShorthand(schema[0], undefined, options);
var Struct = createStruct({
kind: 'array',
type: Element.type + "[]",
defaults: defaults,
options: options
});
var result = schema(value, branch, path);
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
if (result === true) {
return [undefined, value];
}
if (!Array.isArray(value)) {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var failures = [];
var result = [];
var failures = [];
if (result === false) {
failures.push(Struct.fail({
value: value,
branch: branch,
path: path
}));
} else if (Array.isArray(result) && result.length > 0) {
for (var _iterator = result, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
for (var i = 0; i < value.length; i++) {
var v = value[i];
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var _Element$check = Element.check(v, branch.concat(v), path.concat(i)),
efs = _Element$check[0],
er = _Element$check[1];
if (efs) {
failures.push.apply(failures, efs);
continue;
var r = _ref;
failures.push(Struct.fail(_objectSpread2({
value: value,
branch: branch,
path: path
}, r)));
}
} else if (typeof result === 'object') {
failures.push(Struct.fail(_objectSpread2({
value: value,
branch: branch,
path: path
}, result)));
} else {
invariant(false, "Validator functions must return a boolean, a failure object, or an array of failure objects, but you passed: " + result);
}
result[i] = er;
}
return [failures];
};
return failures.length ? [failures] : [undefined, result];
return Struct;
};
return Struct;
};
var createInstance = function createInstance(schema, defaults, struct) {
invariant(typeof schema === 'function', "Instance structs must be defined as a function, but you passed: " + schema);
var createDynamic = function createDynamic(schema, defaults, options) {
invariant(typeof schema === 'function', "Dynamic structs must be defined as a function, but you passed: " + schema);
var Dynamic = createStruct({
kind: 'dynamic',
type: "dynamic<\u2026>",
defaults: defaults,
options: options
});
var validator = function validator(value) {
return value instanceof schema;
};
Dynamic.check = function (value, branch, path) {
if (value === void 0) {
value = Dynamic.default();
var Struct = struct(validator, defaults);
Struct.kind = 'instance';
Struct.type = "instance<" + schema.name + ">";
return Struct;
};
var createInterface = function createInterface(schema, defaults, struct) {
invariant(typeof schema === 'object', "Interface structs must be defined as an object, but you passed: " + schema);
var Props = {};
for (var key in schema) {
Props[key] = struct(schema[key]);
}
var Struct = schema(value, branch, path);
return Struct.check(value, branch, path);
};
var Struct = createStruct({
kind: 'interface',
type: "interface<{" + Object.keys(schema).join() + "}>",
defaults: defaults,
struct: struct
});
return Dynamic;
};
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var createEnum = function createEnum(schema, defaults, options) {
invariant(Array.isArray(schema), "Enum structs must be defined as an array, but you passed: " + schema);
if (typeof value !== 'object' && typeof value !== 'function') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var validator = function validator(value) {
return schema.includes(value);
};
var failures = [];
var Struct = createFunction(validator, defaults, options);
Struct.kind = 'enum';
Struct.type = schema.map(function (s) {
return typeof s === 'string' ? "\"" + s + "\"" : "" + s;
}).join(' | ');
return Struct;
};
for (var k in Props) {
var Prop = Props[k];
var v = value[k];
var createFunction = function createFunction(schema, defaults, options) {
var Struct = createStruct({
kind: 'function',
type: "function<\u2026>",
defaults: defaults,
options: options
});
var _Prop$check = Prop.check(v, branch.concat(v), path.concat(k)),
pfs = _Prop$check[0];
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
if (pfs) {
failures.push.apply(failures, pfs);
}
}
var result = schema(value, branch, path);
return failures.length ? [failures] : [undefined, value];
};
if (result === true) {
return [undefined, value];
}
return Struct;
};
var failures = [];
var createIntersection = function createIntersection(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Intersection structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return struct(sch);
});
var type = Structs.map(function (s) {
return s.type;
}).join(' & ');
var Struct = createStruct({
kind: 'intersection',
type: type,
defaults: defaults,
struct: struct
});
if (result === false) {
failures.push(Struct.fail({
value: value,
branch: branch,
path: path
}));
} else if (Array.isArray(result) && result.length > 0) {
for (var _iterator = result, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var result = value;
for (var _iterator = Structs, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;

@@ -871,127 +987,97 @@

var r = _ref;
failures.push(Struct.fail(_objectSpread2({
value: value,
branch: branch,
path: path
}, r)));
}
} else if (typeof result === 'object') {
failures.push(Struct.fail(_objectSpread2({
value: value,
branch: branch,
path: path
}, result)));
} else {
invariant(false, "Validator functions must return a boolean, a failure object, or an array of failure objects, but you passed: " + result);
}
var _struct = _ref;
return [failures];
};
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],
v = _struct$check[1];
return Struct;
};
if (fs) {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
} else {
result = v;
}
}
var createInstance = function createInstance(schema, defaults, options) {
invariant(typeof schema === 'function', "Instance structs must be defined as a function, but you passed: " + schema);
return [undefined, result];
};
var validator = function validator(value) {
return value instanceof schema;
return Struct;
};
var Struct = createFunction(validator, defaults, options);
Struct.kind = 'instance';
Struct.type = "instance<" + schema.name + ">";
return Struct;
};
var createLazy = function createLazy(schema, defaults, struct) {
invariant(typeof schema === 'function', "Lazy structs must be defined as a function, but you passed: " + schema);
var Lazy = createStruct({
kind: 'lazy',
type: "lazy<\u2026>",
defaults: defaults,
struct: struct
});
var createInterface = function createInterface(schema, defaults, options) {
invariant(typeof schema === 'object', "Interface structs must be defined as an object, but you passed: " + schema);
var Props = {};
Lazy.check = function () {
Object.assign(Lazy, schema());
return Lazy.check.apply(Lazy, arguments);
};
for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
}
return Lazy;
};
var Struct = createStruct({
kind: 'interface',
type: "interface<{" + Object.keys(schema).join() + "}>",
defaults: defaults,
options: options
});
var createSize = function createSize(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2 && schema.every(function (n) {
return typeof n === 'number';
}), "Size structs must be defined as an array with two number elements, but you passed: " + schema);
var min = schema[0],
max = schema[1];
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var validator = function validator(value) {
return value != null && typeof value.length === 'number' && value.length >= min && value.length <= max;
};
if (typeof value !== 'object' && typeof value !== 'function') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var Struct = struct(validator, defaults);
Struct.kind = 'size';
Struct.type = "size<" + min + "," + max + ">";
return Struct;
};
var failures = [];
var createLiteral = function createLiteral(schema, defaults, struct) {
var validator = function validator(value) {
return value === schema;
};
for (var k in Props) {
var Prop = Props[k];
var v = value[k];
var _Prop$check = Prop.check(v, branch.concat(v), path.concat(k)),
pfs = _Prop$check[0];
if (pfs) {
failures.push.apply(failures, pfs);
}
}
return failures.length ? [failures] : [undefined, value];
var Struct = struct(validator, defaults);
Struct.kind = 'literal';
Struct.type = typeof schema === 'string' ? "\"" + schema + "\"" : "" + schema;
return Struct;
};
return Struct;
};
var createObject = function createObject(schema, defaults, struct) {
invariant(typeof schema === 'object', "Object structs must be defined as an object, but you passed: " + schema);
var Props = {};
var createIntersection = function createIntersection(schema, defaults, options) {
invariant(Array.isArray(schema) && schema.length !== 0, "Intersection structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
});
var type = Structs.map(function (s) {
return s.type;
}).join(' & ');
var Struct = createStruct({
kind: 'intersection',
type: type,
defaults: defaults,
options: options
});
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
for (var key in schema) {
Props[key] = struct(schema[key]);
}
var result = value;
var Struct = createStruct({
kind: 'object',
type: "{" + Object.keys(schema).join() + "}",
defaults: defaults,
struct: struct
});
for (var _iterator = Structs, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var struct = _ref;
var d = Struct.default();
var _struct$check = struct.check(value, branch, path),
fs = _struct$check[0],
v = _struct$check[1];
if (value === undefined) {
value = d;
}
if (fs) {
if (kindOf(value) !== 'object') {
return [[Struct.fail({

@@ -1002,438 +1088,435 @@ value: value,

})]];
} else {
result = v;
}
}
return [undefined, result];
};
var result = {};
var failures = [];
var keys = new Set(Object.keys(Props).concat(Object.keys(value)));
return Struct;
};
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
var createLazy = function createLazy(schema, defaults, options) {
invariant(typeof schema === 'function', "Lazy structs must be defined as a function, but you passed: " + schema);
var Lazy = createStruct({
kind: 'lazy',
type: "lazy<\u2026>",
defaults: defaults,
options: options
});
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
Lazy.check = function () {
Object.assign(Lazy, schema());
return Lazy.check.apply(Lazy, arguments);
};
var k = _ref;
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
return Lazy;
};
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
}
var createSize = function createSize(schema, defaults, options) {
invariant(Array.isArray(schema) && schema.length === 2 && schema.every(function (n) {
return typeof n === 'number';
}), "Size structs must be defined as an array with two number elements, but you passed: " + schema);
var min = schema[0],
max = schema[1];
if (!(k in Props)) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: value
}));
continue;
}
var validator = function validator(value) {
return value != null && typeof value.length === 'number' && value.length >= min && value.length <= max;
};
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
var Struct = createFunction(validator, defaults, options);
Struct.kind = 'size';
Struct.type = "size<" + min + "," + max + ">";
return Struct;
};
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
var createLiteral = function createLiteral(schema, defaults, options) {
var validator = function validator(value) {
return value === schema;
return failures.length ? [failures] : [undefined, result];
};
return Struct;
};
var Struct = createFunction(validator, defaults, options);
Struct.kind = 'literal';
Struct.type = typeof schema === 'string' ? "\"" + schema + "\"" : "" + schema;
return Struct;
};
var createPartial = function createPartial(schema, defaults, struct) {
invariant(typeof schema === 'object', "Partial structs must be defined as an object, but you passed: " + schema);
var Props = {};
var createObject = function createObject(schema, defaults, options) {
invariant(typeof schema === 'object', "Object structs must be defined as an object, but you passed: " + schema);
var Props = {};
for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
}
var Struct = createStruct({
kind: 'object',
type: "{" + Object.keys(schema).join() + "}",
defaults: defaults,
options: options
});
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
for (var key in schema) {
Props[key] = struct.union([schema[key], 'undefined']);
}
var d = Struct.default();
var Struct = createStruct({
kind: 'object',
type: "{" + Object.keys(schema).join() + "}",
defaults: defaults,
struct: struct
});
if (value === undefined) {
value = d;
}
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var result = {};
var failures = [];
var keys = new Set(Object.keys(Props).concat(Object.keys(value)));
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var k = _ref;
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
var d = Struct.default();
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
if (value === undefined) {
value = d;
}
if (!(k in Props)) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: value
}));
continue;
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
var result = {};
var failures = [];
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
for (var _iterator = value, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
return failures.length ? [failures] : [undefined, result];
};
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
return Struct;
};
var k = _ref;
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
var createPartial = function createPartial(schema, defaults, options) {
invariant(typeof schema === 'object', "Partial structs must be defined as an object, but you passed: " + schema);
var Props = {};
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
}
for (var key in schema) {
Props[key] = createUnion([schema[key], 'undefined'], undefined, options);
}
if (!(k in Props)) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: value
}));
continue;
}
var Struct = createStruct({
kind: 'object',
type: "{" + Object.keys(schema).join() + "}",
defaults: defaults,
options: options
});
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
var d = Struct.default();
return failures.length ? [failures] : [undefined, result];
};
if (value === undefined) {
value = d;
}
return Struct;
};
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
var createPick = function createPick(schema, defaults, struct) {
invariant(typeof schema === 'object', "Pick structs must be defined as an object, but you passed: " + schema);
var Props = {};
for (var key in schema) {
Props[key] = struct(schema[key]);
}
var result = {};
var failures = [];
var Struct = createStruct({
kind: 'pick',
type: "pick<{" + Object.keys(schema).join() + "}>",
defaults: defaults,
struct: struct
});
for (var _iterator = value, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var k = _ref;
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
var d = Struct.default();
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
if (value === undefined) {
value = d;
}
if (!(k in Props)) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: value
}));
continue;
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
var result = {};
var failures = [];
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
for (var k in Props) {
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
return failures.length ? [failures] : [undefined, result];
};
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
}
return Struct;
};
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
var createPick = function createPick(schema, defaults, options) {
invariant(typeof schema === 'object', "Pick structs must be defined as an object, but you passed: " + schema);
var Props = {};
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
for (var key in schema) {
Props[key] = createShorthand(schema[key], undefined, options);
}
return failures.length ? [failures] : [undefined, result];
};
var Struct = createStruct({
kind: 'pick',
type: "pick<{" + Object.keys(schema).join() + "}>",
defaults: defaults,
options: options
});
return Struct;
};
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var createRecord = function createRecord(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length === 2, "Record structs must be defined as an array with two elements, but you passed: " + schema);
var Key = struct(schema[0]);
var Value = struct(schema[1]);
var Struct = createStruct({
kind: 'record',
type: "record<" + Key.type + "," + Value.type + ">",
defaults: defaults,
struct: struct
});
var d = Struct.default();
Struct.check = function (value, branch, path) {
// Record structs have a special default handling behavior, where the defaults
// are for the entries themselves, not for the entire value. So we can't use
// JavaScript's built-in default handling here.
var defs = Struct.default();
value = defs ? _objectSpread2({}, defs, {}, value) : value;
if (value === undefined) {
value = d;
}
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
var result = {};
var failures = [];
var result = {};
var failures = [];
for (var k in value) {
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
for (var k in Props) {
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
var Prop = Props[k];
var _Key$check = Key.check(k, b, p),
kfs = _Key$check[0],
kr = _Key$check[1];
if (v === undefined && d != null && k in d) {
v = typeof d[k] === 'function' ? d[k](value, branch, path) : d[k];
if (kfs) {
failures.push.apply(failures, kfs);
} else {
var _Value$check = Value.check(v, b, p),
vfs = _Value$check[0],
vr = _Value$check[1];
if (vfs) {
failures.push.apply(failures, vfs);
} else {
result[kr] = vr;
}
}
}
var _Prop$check = Prop.check(v, b, p),
pfs = _Prop$check[0],
pr = _Prop$check[1];
return failures.length ? [failures] : [undefined, result];
};
if (pfs) {
failures.push.apply(failures, pfs);
} else if (pr !== undefined && k in Props) {
result[k] = pr;
}
}
return Struct;
};
return failures.length ? [failures] : [undefined, result];
var createScalar = function createScalar(schema, defaults, struct) {
invariant(typeof schema === 'string', "Scalar structs must be defined as a string, but you passed: " + schema);
var Types = struct.Types;
invariant(schema in Types, "No struct validator function found for type \"" + schema + "\".");
var Struct = struct(Types[schema], defaults);
Struct.kind = 'scalar';
Struct.type = schema;
return Struct;
};
return Struct;
};
var createShorthand = function createShorthand(schema, defaults, struct) {
if (isStruct(schema)) {
return schema;
}
var createRecord = function createRecord(schema, defaults, options) {
invariant(Array.isArray(schema) && schema.length === 2, "Record structs must be defined as an array with two elements, but you passed: " + schema);
var Key = createShorthand(schema[0], undefined, options);
var Value = createShorthand(schema[1], undefined, options);
var Struct = createStruct({
kind: 'record',
type: "record<" + Key.type + "," + Value.type + ">",
defaults: defaults,
options: options
});
if (Array.isArray(schema)) {
if (schema.length === 1) {
var _schema = schema,
first = _schema[0];
return struct.array([first], defaults);
} else if (schema.length > 1) {
return struct.tuple(schema, defaults);
}
}
Struct.check = function (value, branch, path) {
// Record structs have a special default handling behavior, where the defaults
// are for the entries themselves, not for the entire value. So we can't use
// JavaScript's built-in default handling here.
var defs = Struct.default();
value = defs ? _objectSpread2({}, defs, {}, value) : value;
if (typeof schema === 'function') {
return struct.function(schema, defaults);
}
if (kindOf(value) !== 'object') {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
if (typeof schema === 'object') {
return struct.object(schema, defaults);
}
var result = {};
var failures = [];
if (typeof schema === 'string') {
var optional = false;
var Struct;
for (var k in value) {
var v = value[k];
var p = path.concat(k);
var b = branch.concat(v);
if (schema.endsWith('?')) {
optional = true;
schema = schema.slice(0, -1);
}
var _Key$check = Key.check(k, b, p),
kfs = _Key$check[0],
kr = _Key$check[1];
if (schema.includes('|')) {
var scalars = schema.split(/\s*\|\s*/g);
Struct = struct.union(scalars, defaults);
} else if (schema.includes('&')) {
var _scalars = schema.split(/\s*&\s*/g);
if (kfs) {
failures.push.apply(failures, kfs);
Struct = struct.intersection(_scalars, defaults);
} else {
var _Value$check = Value.check(v, b, p),
vfs = _Value$check[0],
vr = _Value$check[1];
Struct = struct.scalar(schema, defaults);
}
if (vfs) {
failures.push.apply(failures, vfs);
} else {
result[kr] = vr;
}
if (optional) {
Struct = struct.union([Struct, 'undefined'], undefined);
}
return Struct;
}
return failures.length ? [failures] : [undefined, result];
throw new Error("A schema definition must be an object, array, string or function, but you passed: " + schema);
};
return Struct;
};
var createTuple = function createTuple(schema, defaults, struct) {
invariant(Array.isArray(schema), "Tuple structs must be defined as an array, but you passed: " + schema);
var Elements = schema.map(function (s) {
return struct(s);
});
var Struct = createStruct({
kind: 'tuple',
type: "[" + Elements.map(function (S) {
return S.type;
}).join() + "]",
defaults: defaults,
struct: struct
});
var createScalar = function createScalar(schema, defaults, options) {
invariant(typeof schema === 'string', "Scalar structs must be defined as a string, but you passed: " + schema);
var types = options.types;
invariant(schema in types, "No struct validator function found for type \"" + schema + "\".");
var validator = types[schema];
var Struct = createFunction(validator, defaults, options);
Struct.kind = 'scalar';
Struct.type = schema;
return Struct;
};
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var createShorthand = function createShorthand(schema, defaults, options) {
if (isStruct(schema)) {
return schema;
}
if (!Array.isArray(value)) {
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
}
if (Array.isArray(schema)) {
if (schema.length === 1) {
var _schema = schema,
first = _schema[0];
return createArray([first], defaults, options);
} else if (schema.length > 1) {
return createTuple(schema, defaults, options);
}
}
var result = [];
var failures = [];
var length = Math.max(value.length, Elements.length);
if (typeof schema === 'function') {
return createFunction(schema, defaults, options);
}
for (var i = 0; i < length; i++) {
var Element = Elements[i];
var v = value[i];
var p = path.concat(i);
var b = branch.concat(v);
if (typeof schema === 'object') {
return createObject(schema, defaults, options);
}
if (!Element) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: b
}));
} else {
var _Element$check = Element.check(v, b, p),
efs = _Element$check[0],
er = _Element$check[1];
if (typeof schema === 'string') {
var optional = false;
var Struct;
if (efs) {
failures.push.apply(failures, efs);
} else {
result[i] = er;
}
}
}
if (schema.endsWith('?')) {
optional = true;
schema = schema.slice(0, -1);
}
return failures.length ? [failures] : [undefined, result];
};
if (schema.includes('|')) {
var scalars = schema.split(/\s*\|\s*/g);
Struct = createUnion(scalars, defaults, options);
} else if (schema.includes('&')) {
var _scalars = schema.split(/\s*&\s*/g);
return Struct;
};
Struct = createIntersection(_scalars, defaults, options);
} else {
Struct = createScalar(schema, defaults, options);
}
var createUnion = function createUnion(schema, defaults, struct) {
invariant(Array.isArray(schema) && schema.length !== 0, "Union structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return struct(sch);
});
var type = Structs.map(function (s) {
return s.type;
}).join(' | ');
var Struct = createStruct({
kind: 'union',
type: type,
defaults: defaults,
struct: struct
});
if (optional) {
Struct = createUnion([Struct, 'undefined'], undefined, options);
}
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
return Struct;
}
for (var _iterator = Structs, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
throw new Error("A schema definition must be an object, array, string or function, but you passed: " + schema);
};
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var createTuple = function createTuple(schema, defaults, options) {
invariant(Array.isArray(schema), "Tuple structs must be defined as an array, but you passed: " + schema);
var Elements = schema.map(function (s) {
return createShorthand(s, undefined, options);
});
var Struct = createStruct({
kind: 'tuple',
type: "[" + Elements.map(function (S) {
return S.type;
}).join() + "]",
defaults: defaults,
options: options
});
var _struct = _ref;
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
}
var _struct$check = _struct.check(value, branch, path),
fs = _struct$check[0],
v = _struct$check[1];
if (!Array.isArray(value)) {
if (!fs) {
return [undefined, v];
}
}
return [[Struct.fail({

@@ -1444,206 +1527,117 @@ value: value,

})]];
}
};
var result = [];
var failures = [];
var length = Math.max(value.length, Elements.length);
for (var i = 0; i < length; i++) {
var Element = Elements[i];
var v = value[i];
var p = path.concat(i);
var b = branch.concat(v);
if (!Element) {
failures.push(Struct.fail({
type: undefined,
value: v,
path: p,
branch: b
}));
} else {
var _Element$check = Element.check(v, b, p),
efs = _Element$check[0],
er = _Element$check[1];
if (efs) {
failures.push.apply(failures, efs);
} else {
result[i] = er;
}
}
}
return failures.length ? [failures] : [undefined, result];
return Struct;
};
return Struct;
};
/**
* Create a struct singleton with settings that include your own domain-specific
* data `types`, and an optional custom `Error` class.
*/
var createUnion = function createUnion(schema, defaults, options) {
invariant(Array.isArray(schema) && schema.length !== 0, "Union structs must be defined as a non-empty array, but you passed: " + schema);
var Structs = schema.map(function (sch) {
return createShorthand(sch, undefined, options);
});
var type = Structs.map(function (s) {
return s.type;
}).join(' | ');
var Struct = createStruct({
kind: 'union',
type: type,
defaults: defaults,
options: options
});
Struct.check = function (value, branch, path) {
if (value === void 0) {
value = Struct.default();
var superstruct = function superstruct(settings) {
if (settings === void 0) {
settings = {};
}
for (var _iterator = Structs, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
var struct = function struct(schema, defaults) {
return createShorthand(schema, defaults, struct);
};
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
struct.array = function (schema, defaults) {
return createArray(schema, defaults, struct);
};
var struct = _ref;
struct.dynamic = function (schema, defaults) {
return createDynamic(schema, defaults, struct);
};
var _struct$check = struct.check(value, branch, path),
fs = _struct$check[0],
v = _struct$check[1];
struct.enum = function (schema, defaults) {
return createEnum(schema, defaults, struct);
};
if (!fs) {
return [undefined, v];
}
}
struct.function = function (schema, defaults) {
return createFunction(schema, defaults, struct);
};
return [[Struct.fail({
value: value,
branch: branch,
path: path
})]];
};
struct.instance = function (schema, defaults) {
return createInstance(schema, defaults, struct);
};
return Struct;
};
struct.interface = function (schema, defaults) {
return createInterface(schema, defaults, struct);
};
/**
* Create a struct singleton with settings that include your own domain-specific
* data `types`, and an optional custom `Error` class.
*/
struct.intersection = function (schema, defaults) {
return createIntersection(schema, defaults, struct);
};
var superstruct = function superstruct(settings) {
if (settings === void 0) {
settings = {};
}
struct.lazy = function (schema, defaults) {
return createLazy(schema, defaults, struct);
};
var options = {
Error: settings.Error || StructError,
types: _objectSpread2({}, Types, {}, settings.types)
};
struct.literal = function (schema, defaults) {
return createLiteral(schema, defaults, struct);
};
var struct = function struct(schema, defaults) {
return createShorthand(schema, defaults, options);
};
struct.object = function (schema, defaults) {
return createObject(schema, defaults, struct);
};
struct.array = function (schema, defaults) {
return createArray(schema, defaults, options);
};
struct.optional = function (schema, defaults) {
return createUnion([schema, 'undefined'], defaults, struct);
};
struct.dynamic = function (schema, defaults) {
return createDynamic(schema, defaults, options);
};
struct.partial = function (schema, defaults) {
return createPartial(schema, defaults, struct);
};
struct.enum = function (schema, defaults) {
return createEnum(schema, defaults, options);
};
struct.pick = function (schema, defaults) {
return createPick(schema, defaults, struct);
};
struct.function = function (schema, defaults) {
return createFunction(schema, defaults, options);
};
struct.record = function (schema, defaults) {
return createRecord(schema, defaults, struct);
};
struct.instance = function (schema, defaults) {
return createInstance(schema, defaults, options);
};
struct.scalar = function (schema, defaults) {
return createScalar(schema, defaults, struct);
};
struct.interface = function (schema, defaults) {
return createInterface(schema, defaults, options);
};
struct.size = function (schema, defaults) {
return createSize(schema, defaults, struct);
};
struct.intersection = function (schema, defaults) {
return createIntersection(schema, defaults, options);
};
struct.tuple = function (schema, defaults) {
return createTuple(schema, defaults, struct);
};
struct.lazy = function (schema, defaults) {
return createLazy(schema, defaults, options);
};
struct.union = function (schema, defaults) {
return createUnion(schema, defaults, struct);
};
struct.literal = function (schema, defaults) {
return createLiteral(schema, defaults, options);
struct.Error = settings.error || StructError;
struct.Types = _objectSpread2({}, Types, {}, settings.types);
return struct;
};
struct.object = function (schema, defaults) {
return createObject(schema, defaults, options);
};
/**
* The singleton instance of Superstruct that is exported by default, configured
* with types for all of the JavaScript built-in data types.
*
* You can use it if you don't need any custom types. However, if you do want to
* define custom types, use the [[superstruct]] factory to configure your own
* [[Superstruct]] instance.
*/
struct.optional = function (schema, defaults) {
return createUnion([schema, 'undefined'], defaults, options);
};
var struct = superstruct();
struct.partial = function (schema, defaults) {
return createPartial(schema, defaults, options);
};
exports.StructError = StructError;
exports.Types = Types;
exports.isStruct = isStruct;
exports.struct = struct;
exports.superstruct = superstruct;
struct.pick = function (schema, defaults) {
return createPick(schema, defaults, options);
};
Object.defineProperty(exports, '__esModule', { value: true });
struct.record = function (schema, defaults) {
return createRecord(schema, defaults, options);
};
struct.scalar = function (schema, defaults) {
return createScalar(schema, defaults, options);
};
struct.size = function (schema, defaults) {
return createSize(schema, defaults, options);
};
struct.tuple = function (schema, defaults) {
return createTuple(schema, defaults, options);
};
struct.union = function (schema, defaults) {
return createUnion(schema, defaults, options);
};
return struct;
};
/**
* The singleton instance of Superstruct that is exported by default, configured
* with types for all of the JavaScript built-in data types.
*
* You can use it if you don't need any custom types. However, if you do want to
* define custom types, use the [[superstruct]] factory to configure your own
* [[Superstruct]] instance.
*/
var struct = superstruct();
exports.struct = struct;
exports.superstruct = superstruct;
exports.StructError = StructError;
exports.Types = Types;
exports.isStruct = isStruct;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));

@@ -1,1 +0,1 @@

!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(r.Superstruct={})}(this,function(r){"use strict";function t(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function n(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),n.push.apply(n,e)}return n}function e(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(o,!0).forEach(function(n){t(r,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(o).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))})}return r}function o(r){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function i(r,t){return(i=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function u(r,t,n){return(u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(r){return!1}}()?Reflect.construct:function(r,t,n){var e=[null];e.push.apply(e,t);var o=new(Function.bind.apply(r,e));return n&&i(o,n.prototype),o}).apply(null,arguments)}function a(r){var t="function"==typeof Map?new Map:void 0;return(a=function(r){function n(){return u(r,arguments,o(this).constructor)}if(null===r||!function(r){return-1!==Function.toString.call(r).indexOf("[native code]")}(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,n)}return n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,r)})(r)}function c(r){return r.constructor?r.constructor.name:null}function f(r,t){if(!r)throw y?new Error(v):new Error(v+": "+(t||""))}var l=Object.prototype.toString,p=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var t=typeof r;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return function(r,t){return"GeneratorFunction"===c(r)}(r)?"generatorfunction":"function";if(function(r){return Array.isArray?Array.isArray(r):r instanceof Array}(r))return"array";if(function(r){return!(!r.constructor||"function"!=typeof r.constructor.isBuffer)&&r.constructor.isBuffer(r)}(r))return"buffer";if(function(r){try{if("number"==typeof r.length&&"function"==typeof r.callee)return!0}catch(r){if(-1!==r.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(r){return r instanceof Date||"function"==typeof r.toDateString&&"function"==typeof r.getDate&&"function"==typeof r.setDate}(r))return"date";if(function(r){return r instanceof Error||"string"==typeof r.message&&r.constructor&&"number"==typeof r.constructor.stackTraceLimit}(r))return"error";if(function(r){return r instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global}(r))return"regexp";switch(c(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(r){return"function"==typeof r.throw&&"function"==typeof r.return&&"function"==typeof r.next}(r))return"generator";switch(t=l.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")},s={any:function(r){return void 0!==r},arguments:function(r){return"arguments"===p(r)},array:function(r){return"array"===p(r)},boolean:function(r){return"boolean"===p(r)},buffer:function(r){return"buffer"===p(r)},date:function(r){return"date"===p(r)&&!isNaN(r)},error:function(r){return"error"===p(r)},float32array:function(r){return"float32array"===p(r)},float64array:function(r){return"float64array"===p(r)},function:function(r){return"function"===p(r)},generatorfunction:function(r){return"generatorfunction"===p(r)},int16array:function(r){return"int16array"===p(r)},int32array:function(r){return"int32array"===p(r)},int8array:function(r){return"int8array"===p(r)},map:function(r){return"map"===p(r)},null:function(r){return"null"===p(r)},number:function(r){return"number"===p(r)},object:function(r){return"object"===p(r)},promise:function(r){return"promise"===p(r)},regexp:function(r){return"regexp"===p(r)},set:function(r){return"set"===p(r)},string:function(r){return"string"===p(r)},symbol:function(r){return"symbol"===p(r)},uint16array:function(r){return"uint16array"===p(r)},uint32array:function(r){return"uint32array"===p(r)},uint8array:function(r){return"uint8array"===p(r)},uint8clampedarray:function(r){return"uint8clampedarray"===p(r)},undefined:function(r){return"undefined"===p(r)},weakmap:function(r){return"weakmap"===p(r)},weakset:function(r){return"weakset"===p(r)}},y=!0,v="Invariant failed",d=function(r){function t(n){var e;n.length>0||f(!1);var o=n[0],i=o.path,u=o.value,a=o.type,c=o.branch,l=function(r,t){if(null==r)return{};var n,e,o={},i=Object.keys(r);for(e=0;e<i.length;e++)n=i[e],t.indexOf(n)>=0||(o[n]=r[n]);return o}(o,["path","value","type","branch"]),p="Expected a value of type `"+a+"`"+(i.length?" for `"+i.join(".")+"`":"")+" but received `"+JSON.stringify(u)+"`.";return e=r.call(this,p)||this,e.type=a,e.value=u,Object.assign(function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(e),l),e.path=i,e.branch=c,e.failures=n,e.stack=(new Error).stack,e.__proto__=t.prototype,e}return function(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.__proto__=t}(t,r),t}(a(TypeError)),h=Symbol("STRUCT"),b=function(r){return"function"==typeof r&&r[h]},g=function(r){var t=r.options.Error,n=function r(t){return r.assert(t)};return Object.defineProperty(n,h,{value:!0}),n.kind=r.kind,n.type=r.type,n.default=function(){return"function"==typeof r.defaults?r.defaults():r.defaults},n.test=function(r){return!n.check(r,[r],[])[0]},n.assert=function(r){var e=n.check(r,[r],[]),o=e[0],i=e[1];if(o)throw new t(o);return i},n.validate=function(r){var e=n.check(r,[r],[]),o=e[0],i=e[1];return o?[new t(o)]:[void 0,i]},n.check=function(r,t,e){void 0===r&&(r=n.default());return[[n.fail({value:r,branch:t,path:e})]]},n.fail=function(r){return e({},r,{type:"type"in r?r.type:n.type})},n},k=function(r,t,n){Array.isArray(r)&&1===r.length||f(!1);var e=w(r[0],void 0,n),o=g({kind:"array",type:e.type+"[]",defaults:t,options:n});return o.check=function(r,t,n){if(void 0===r&&(r=o.default()),!Array.isArray(r))return[[o.fail({value:r,branch:t,path:n})]];for(var i=[],u=[],a=0;a<r.length;a++){var c=r[a],f=e.check(c,t.concat(c),n.concat(a)),l=f[0],p=f[1];l?u.push.apply(u,l):i[a]=p}return u.length?[u]:[void 0,i]},o},m=function(r,t,n){var o=g({kind:"function",type:"function<…>",defaults:t,options:n});return o.check=function(t,n,i){void 0===t&&(t=o.default());var u=r(t,n,i);if(!0===u)return[void 0,t];var a=[];if(!1===u)a.push(o.fail({value:t,branch:n,path:i}));else if(Array.isArray(u)&&u.length>0){var c=u,l=Array.isArray(c),p=0;for(c=l?c:c[Symbol.iterator]();;){var s;if(l){if(p>=c.length)break;s=c[p++]}else{if((p=c.next()).done)break;s=p.value}var y=s;a.push(o.fail(e({value:t,branch:n,path:i},y)))}}else"object"==typeof u?a.push(o.fail(e({value:t,branch:n,path:i},u))):f(!1);return[a]},o},j=function(r,t,n){Array.isArray(r)&&0!==r.length||f(!1);var e=r.map(function(r){return w(r,void 0,n)}),o=e.map(function(r){return r.type}).join(" & "),i=g({kind:"intersection",type:o,defaults:t,options:n});return i.check=function(r,t,n){void 0===r&&(r=i.default());var o=r,u=e,a=Array.isArray(u),c=0;for(u=a?u:u[Symbol.iterator]();;){var f;if(a){if(c>=u.length)break;f=u[c++]}else{if((c=u.next()).done)break;f=c.value}var l=f.check(r,t,n),p=l[0],s=l[1];if(p)return[[i.fail({value:r,branch:t,path:n})]];o=s}return[void 0,o]},i},A=function(r,t,n){"object"!=typeof r&&f(!1);var e={};for(var o in r)e[o]=w(r[o],void 0,n);var i=g({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,options:n});return i.check=function(r,t,n){void 0===r&&(r=i.default());var o=i.default();if(void 0===r&&(r=o),"object"!==p(r))return[[i.fail({value:r,branch:t,path:n})]];var u={},a=[],c=new Set(Object.keys(e).concat(Object.keys(r))),f=Array.isArray(c),l=0;for(c=f?c:c[Symbol.iterator]();;){var s;if(f){if(l>=c.length)break;s=c[l++]}else{if((l=c.next()).done)break;s=l.value}var y=s,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=o&&y in o&&(v="function"==typeof o[y]?o[y](r,t,n):o[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?a.push.apply(a,k):void 0!==m&&y in e&&(u[y]=m)}else a.push(i.fail({type:void 0,value:v,path:d,branch:r}))}return a.length?[a]:[void 0,u]},i},O=function(r,t,n){"string"!=typeof r&&f(!1);var e=n.types;r in e||f(!1);var o=e[r],i=m(o,t,n);return i.kind="scalar",i.type=r,i},w=function(r,t,n){if(b(r))return r;if(Array.isArray(r)){if(1===r.length){var e=r[0];return k([e],t,n)}if(r.length>1)return S(r,t,n)}if("function"==typeof r)return m(r,t,n);if("object"==typeof r)return A(r,t,n);if("string"==typeof r){var o,i=!1;if(r.endsWith("?")&&(i=!0,r=r.slice(0,-1)),r.includes("|")){var u=r.split(/\s*\|\s*/g);o=x(u,t,n)}else if(r.includes("&")){var a=r.split(/\s*&\s*/g);o=j(a,t,n)}else o=O(r,t,n);return i&&(o=x([o,"undefined"],void 0,n)),o}throw new Error("A schema definition must be an object, array, string or function, but you passed: "+r)},S=function(r,t,n){Array.isArray(r)||f(!1);var e=r.map(function(r){return w(r,void 0,n)}),o=g({kind:"tuple",type:"["+e.map(function(r){return r.type}).join()+"]",defaults:t,options:n});return o.check=function(r,t,n){if(void 0===r&&(r=o.default()),!Array.isArray(r))return[[o.fail({value:r,branch:t,path:n})]];for(var i=[],u=[],a=Math.max(r.length,e.length),c=0;c<a;c++){var f=e[c],l=r[c],p=n.concat(c),s=t.concat(l);if(f){var y=f.check(l,s,p),v=y[0],d=y[1];v?u.push.apply(u,v):i[c]=d}else u.push(o.fail({type:void 0,value:l,path:p,branch:s}))}return u.length?[u]:[void 0,i]},o},x=function(r,t,n){Array.isArray(r)&&0!==r.length||f(!1);var e=r.map(function(r){return w(r,void 0,n)}),o=e.map(function(r){return r.type}).join(" | "),i=g({kind:"union",type:o,defaults:t,options:n});return i.check=function(r,t,n){void 0===r&&(r=i.default());var o=e,u=Array.isArray(o),a=0;for(o=u?o:o[Symbol.iterator]();;){var c;if(u){if(a>=o.length)break;c=o[a++]}else{if((a=o.next()).done)break;c=a.value}var f=c.check(r,t,n),l=f[0],p=f[1];if(!l)return[void 0,p]}return[[i.fail({value:r,branch:t,path:n})]]},i},_=function(r){void 0===r&&(r={});var t={Error:r.Error||d,types:e({},s,{},r.types)},n=function(r,n){return w(r,n,t)};return n.array=function(r,n){return k(r,n,t)},n.dynamic=function(r,n){return function(r,t,n){"function"!=typeof r&&f(!1);var e=g({kind:"dynamic",type:"dynamic<…>",defaults:t,options:n});return e.check=function(t,n,o){return void 0===t&&(t=e.default()),r(t,n,o).check(t,n,o)},e}(r,n,t)},n.enum=function(r,n){return function(r,t,n){Array.isArray(r)||f(!1);var e=m(function(t){return r.includes(t)},t,n);return e.kind="enum",e.type=r.map(function(r){return"string"==typeof r?'"'+r+'"':""+r}).join(" | "),e}(r,n,t)},n.function=function(r,n){return m(r,n,t)},n.instance=function(r,n){return function(r,t,n){"function"!=typeof r&&f(!1);var e=m(function(t){return t instanceof r},t,n);return e.kind="instance",e.type="instance<"+r.name+">",e}(r,n,t)},n.interface=function(r,n){return function(r,t,n){"object"!=typeof r&&f(!1);var e={};for(var o in r)e[o]=w(r[o],void 0,n);var i=g({kind:"interface",type:"interface<{"+Object.keys(r).join()+"}>",defaults:t,options:n});return i.check=function(r,t,n){if(void 0===r&&(r=i.default()),"object"!=typeof r&&"function"!=typeof r)return[[i.fail({value:r,branch:t,path:n})]];var o=[];for(var u in e){var a=e[u],c=r[u],f=a.check(c,t.concat(c),n.concat(u))[0];f&&o.push.apply(o,f)}return o.length?[o]:[void 0,r]},i}(r,n,t)},n.intersection=function(r,n){return j(r,n,t)},n.lazy=function(r,n){return function(r,t,n){"function"!=typeof r&&f(!1);var e=g({kind:"lazy",type:"lazy<…>",defaults:t,options:n});return e.check=function(){return Object.assign(e,r()),e.check.apply(e,arguments)},e}(r,n,t)},n.literal=function(r,n){return function(r,t,n){var e=m(function(t){return t===r},t,n);return e.kind="literal",e.type="string"==typeof r?'"'+r+'"':""+r,e}(r,n,t)},n.object=function(r,n){return A(r,n,t)},n.optional=function(r,n){return x([r,"undefined"],n,t)},n.partial=function(r,n){return function(r,t,n){"object"!=typeof r&&f(!1);var e={};for(var o in r)e[o]=x([r[o],"undefined"],void 0,n);var i=g({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,options:n});return i.check=function(r,t,n){void 0===r&&(r=i.default());var o=i.default();if(void 0===r&&(r=o),"object"!==p(r))return[[i.fail({value:r,branch:t,path:n})]];var u={},a=[],c=r,f=Array.isArray(c),l=0;for(c=f?c:c[Symbol.iterator]();;){var s;if(f){if(l>=c.length)break;s=c[l++]}else{if((l=c.next()).done)break;s=l.value}var y=s,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=o&&y in o&&(v="function"==typeof o[y]?o[y](r,t,n):o[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?a.push.apply(a,k):void 0!==m&&y in e&&(u[y]=m)}else a.push(i.fail({type:void 0,value:v,path:d,branch:r}))}return a.length?[a]:[void 0,u]},i}(r,n,t)},n.pick=function(r,n){return function(r,t,n){"object"!=typeof r&&f(!1);var e={};for(var o in r)e[o]=w(r[o],void 0,n);var i=g({kind:"pick",type:"pick<{"+Object.keys(r).join()+"}>",defaults:t,options:n});return i.check=function(r,t,n){void 0===r&&(r=i.default());var o=i.default();if(void 0===r&&(r=o),"object"!==p(r))return[[i.fail({value:r,branch:t,path:n})]];var u={},a=[];for(var c in e){var f=r[c],l=n.concat(c),s=t.concat(f),y=e[c];void 0===f&&null!=o&&c in o&&(f="function"==typeof o[c]?o[c](r,t,n):o[c]);var v=y.check(f,s,l),d=v[0],h=v[1];d?a.push.apply(a,d):void 0!==h&&c in e&&(u[c]=h)}return a.length?[a]:[void 0,u]},i}(r,n,t)},n.record=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length||f(!1);var o=w(r[0],void 0,n),i=w(r[1],void 0,n),u=g({kind:"record",type:"record<"+o.type+","+i.type+">",defaults:t,options:n});return u.check=function(r,t,n){var a=u.default();if(r=a?e({},a,{},r):r,"object"!==p(r))return[[u.fail({value:r,branch:t,path:n})]];var c={},f=[];for(var l in r){var s=r[l],y=n.concat(l),v=t.concat(s),d=o.check(l,v,y),h=d[0],b=d[1];if(h)f.push.apply(f,h);else{var g=i.check(s,v,y),k=g[0],m=g[1];k?f.push.apply(f,k):c[b]=m}}return f.length?[f]:[void 0,c]},u}(r,n,t)},n.scalar=function(r,n){return O(r,n,t)},n.size=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length&&r.every(function(r){return"number"==typeof r})||f(!1);var e=r[0],o=r[1],i=m(function(r){return null!=r&&"number"==typeof r.length&&r.length>=e&&r.length<=o},t,n);return i.kind="size",i.type="size<"+e+","+o+">",i}(r,n,t)},n.tuple=function(r,n){return S(r,n,t)},n.union=function(r,n){return x(r,n,t)},n},P=_();r.struct=P,r.superstruct=_,r.StructError=d,r.Types=s,r.isStruct=b,Object.defineProperty(r,"__esModule",{value:!0})});
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r=r||self).Superstruct={})}(this,(function(r){"use strict";function t(r,t,n){return t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n,r}function n(r,t){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);t&&(e=e.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.push.apply(n,e)}return n}function e(r){for(var e=1;e<arguments.length;e++){var u=null!=arguments[e]?arguments[e]:{};e%2?n(u,!0).forEach((function(n){t(r,n,u[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(u)):n(u).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(u,t))}))}return r}function u(r){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function a(r,t){return(a=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function i(r,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(r){return!1}}()?Reflect.construct:function(r,t,n){var e=[null];e.push.apply(e,t);var u=new(Function.bind.apply(r,e));return n&&a(u,n.prototype),u}).apply(null,arguments)}function o(r){var t="function"==typeof Map?new Map:void 0;return(o=function(r){if(null===r||(n=r,-1===Function.toString.call(n).indexOf("[native code]")))return r;var n;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return i(r,arguments,u(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a(e,r)})(r)}var c=Object.prototype.toString,f=function(r){if(void 0===r)return"undefined";if(null===r)return"null";var t=typeof r;if("boolean"===t)return"boolean";if("string"===t)return"string";if("number"===t)return"number";if("symbol"===t)return"symbol";if("function"===t)return"GeneratorFunction"===l(r)?"generatorfunction":"function";if(function(r){return Array.isArray?Array.isArray(r):r instanceof Array}(r))return"array";if(function(r){if(r.constructor&&"function"==typeof r.constructor.isBuffer)return r.constructor.isBuffer(r);return!1}(r))return"buffer";if(function(r){try{if("number"==typeof r.length&&"function"==typeof r.callee)return!0}catch(r){if(-1!==r.message.indexOf("callee"))return!0}return!1}(r))return"arguments";if(function(r){return r instanceof Date||"function"==typeof r.toDateString&&"function"==typeof r.getDate&&"function"==typeof r.setDate}(r))return"date";if(function(r){return r instanceof Error||"string"==typeof r.message&&r.constructor&&"number"==typeof r.constructor.stackTraceLimit}(r))return"error";if(function(r){return r instanceof RegExp||"string"==typeof r.flags&&"boolean"==typeof r.ignoreCase&&"boolean"==typeof r.multiline&&"boolean"==typeof r.global}(r))return"regexp";switch(l(r)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(r){return"function"==typeof r.throw&&"function"==typeof r.return&&"function"==typeof r.next}(r))return"generator";switch(t=c.call(r)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function l(r){return r.constructor?r.constructor.name:null}var s={any:function(r){return void 0!==r},arguments:function(r){return"arguments"===f(r)},array:function(r){return"array"===f(r)},boolean:function(r){return"boolean"===f(r)},buffer:function(r){return"buffer"===f(r)},date:function(r){return"date"===f(r)&&!isNaN(r)},error:function(r){return"error"===f(r)},float32array:function(r){return"float32array"===f(r)},float64array:function(r){return"float64array"===f(r)},function:function(r){return"function"===f(r)},generatorfunction:function(r){return"generatorfunction"===f(r)},int16array:function(r){return"int16array"===f(r)},int32array:function(r){return"int32array"===f(r)},int8array:function(r){return"int8array"===f(r)},map:function(r){return"map"===f(r)},null:function(r){return"null"===f(r)},number:function(r){return"number"===f(r)},object:function(r){return"object"===f(r)},promise:function(r){return"promise"===f(r)},regexp:function(r){return"regexp"===f(r)},set:function(r){return"set"===f(r)},string:function(r){return"string"===f(r)},symbol:function(r){return"symbol"===f(r)},uint16array:function(r){return"uint16array"===f(r)},uint32array:function(r){return"uint32array"===f(r)},uint8array:function(r){return"uint8array"===f(r)},uint8clampedarray:function(r){return"uint8clampedarray"===f(r)},undefined:function(r){return"undefined"===f(r)},weakmap:function(r){return"weakmap"===f(r)},weakset:function(r){return"weakset"===f(r)}},p="Invariant failed";function y(r,t){if(!r)throw new Error(p)}var v=function(r){var t,n;function e(t){var n;t.length>0||y(!1);var u=t[0],a=u.path,i=u.value,o=u.type,c=u.branch,f=function(r,t){if(null==r)return{};var n,e,u={},a=Object.keys(r);for(e=0;e<a.length;e++)n=a[e],t.indexOf(n)>=0||(u[n]=r[n]);return u}(u,["path","value","type","branch"]),l="Expected a value of type `"+o+"`"+(a.length?" for `"+a.join(".")+"`":"")+" but received `"+JSON.stringify(i)+"`.";return(n=r.call(this,l)||this).type=o,n.value=i,Object.assign(function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(n),f),n.path=a,n.branch=c,n.failures=t,n.stack=(new Error).stack,n.__proto__=e.prototype,n}return n=r,(t=e).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,e}(o(TypeError)),d=Symbol("STRUCT"),h=function(r){return"function"==typeof r&&r[d]},b=function(r){var t=r.struct.Error,n=function r(t){return r.assert(t)};return Object.defineProperty(n,d,{value:!0}),n.kind=r.kind,n.type=r.type,n.default=function(){return"function"==typeof r.defaults?r.defaults():r.defaults},n.test=function(r){return!n.check(r,[r],[])[0]},n.assert=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];if(u)throw new t(u);return a},n.validate=function(r){var e=n.check(r,[r],[]),u=e[0],a=e[1];return u?[new t(u)]:[void 0,a]},n.check=function(r,t,e){return void 0===r&&(r=n.default()),[[n.fail({value:r,branch:t,path:e})]]},n.fail=function(r){return e({},r,{type:"type"in r?r.type:n.type})},n},g=function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" | "),a=b({kind:"union",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=e,i=Array.isArray(u),o=0;for(u=i?u:u[Symbol.iterator]();;){var c;if(i){if(o>=u.length)break;c=u[o++]}else{if((o=u.next()).done)break;c=o.value}var f=c.check(r,t,n),l=f[0],s=f[1];if(!l)return[void 0,s]}return[[a.fail({value:r,branch:t,path:n})]]},a},k=function(r){void 0===r&&(r={});var t=function r(t,n){return function(r,t,n){if(h(r))return r;if(Array.isArray(r)){if(1===r.length){var e=r[0];return n.array([e],t)}if(r.length>1)return n.tuple(r,t)}if("function"==typeof r)return n.function(r,t);if("object"==typeof r)return n.object(r,t);if("string"==typeof r){var u,a=!1;if(r.endsWith("?")&&(a=!0,r=r.slice(0,-1)),r.includes("|")){var i=r.split(/\s*\|\s*/g);u=n.union(i,t)}else if(r.includes("&")){var o=r.split(/\s*&\s*/g);u=n.intersection(o,t)}else u=n.scalar(r,t);return a&&(u=n.union([u,"undefined"],void 0)),u}throw new Error("A schema definition must be an object, array, string or function, but you passed: "+r)}(t,n,r)};return t.array=function(r,n){return function(r,t,n){Array.isArray(r)&&1===r.length||y(!1);var e=n(r[0],void 0),u=b({kind:"array",type:e.type+"[]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=0;o<r.length;o++){var c=r[o],f=e.check(c,t.concat(c),n.concat(o)),l=f[0],s=f[1];l?i.push.apply(i,l):a[o]=s}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.dynamic=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"dynamic",type:"dynamic<…>",defaults:t,struct:n});return e.check=function(t,n,u){return void 0===t&&(t=e.default()),r(t,n,u).check(t,n,u)},e}(r,n,t)},t.enum=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=n((function(t){return r.includes(t)}),t);return e.kind="enum",e.type=r.map((function(r){return"string"==typeof r?'"'+r+'"':""+r})).join(" | "),e}(r,n,t)},t.function=function(r,n){return function(r,t,n){var u=b({kind:"function",type:"function<…>",defaults:t,struct:n});return u.check=function(t,n,a){void 0===t&&(t=u.default());var i=r(t,n,a);if(!0===i)return[void 0,t];var o=[];if(!1===i)o.push(u.fail({value:t,branch:n,path:a}));else if(Array.isArray(i)&&i.length>0){var c=i,f=Array.isArray(c),l=0;for(c=f?c:c[Symbol.iterator]();;){var s;if(f){if(l>=c.length)break;s=c[l++]}else{if((l=c.next()).done)break;s=l.value}var p=s;o.push(u.fail(e({value:t,branch:n,path:a},p)))}}else"object"==typeof i?o.push(u.fail(e({value:t,branch:n,path:a},i))):y(!1);return[o]},u}(r,n,t)},t.instance=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=n((function(t){return t instanceof r}),t);return e.kind="instance",e.type="instance<"+r.name+">",e}(r,n,t)},t.interface=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"interface",type:"interface<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){if(void 0===r&&(r=a.default()),"object"!=typeof r&&"function"!=typeof r)return[[a.fail({value:r,branch:t,path:n})]];var u=[];for(var i in e){var o=e[i],c=r[i],f=o.check(c,t.concat(c),n.concat(i))[0];f&&u.push.apply(u,f)}return u.length?[u]:[void 0,r]},a}(r,n,t)},t.intersection=function(r,n){return function(r,t,n){Array.isArray(r)&&0!==r.length||y(!1);var e=r.map((function(r){return n(r)})),u=e.map((function(r){return r.type})).join(" & "),a=b({kind:"intersection",type:u,defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=r,i=e,o=Array.isArray(i),c=0;for(i=o?i:i[Symbol.iterator]();;){var f;if(o){if(c>=i.length)break;f=i[c++]}else{if((c=i.next()).done)break;f=c.value}var l=f.check(r,t,n),s=l[0],p=l[1];if(s)return[[a.fail({value:r,branch:t,path:n})]];u=p}return[void 0,u]},a}(r,n,t)},t.lazy=function(r,n){return function(r,t,n){"function"!=typeof r&&y(!1);var e=b({kind:"lazy",type:"lazy<…>",defaults:t,struct:n});return e.check=function(){return Object.assign(e,r()),e.check.apply(e,arguments)},e}(r,n,t)},t.literal=function(r,n){return function(r,t,n){var e=n((function(t){return t===r}),t);return e.kind="literal",e.type="string"==typeof r?'"'+r+'"':""+r,e}(r,n,t)},t.object=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=new Set(Object.keys(e).concat(Object.keys(r))),l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.optional=function(r,n){return g([r,"undefined"],n,t)},t.partial=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n.union([r[u],"undefined"]);var a=b({kind:"object",type:"{"+Object.keys(r).join()+"}",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[],c=r,l=Array.isArray(c),s=0;for(c=l?c:c[Symbol.iterator]();;){var p;if(l){if(s>=c.length)break;p=c[s++]}else{if((s=c.next()).done)break;p=s.value}var y=p,v=r[y],d=n.concat(y),h=t.concat(v),b=e[y];if(void 0===v&&null!=u&&y in u&&(v="function"==typeof u[y]?u[y](r,t,n):u[y]),y in e){var g=b.check(v,h,d),k=g[0],m=g[1];k?o.push.apply(o,k):void 0!==m&&y in e&&(i[y]=m)}else o.push(a.fail({type:void 0,value:v,path:d,branch:r}))}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.pick=function(r,n){return function(r,t,n){"object"!=typeof r&&y(!1);var e={};for(var u in r)e[u]=n(r[u]);var a=b({kind:"pick",type:"pick<{"+Object.keys(r).join()+"}>",defaults:t,struct:n});return a.check=function(r,t,n){void 0===r&&(r=a.default());var u=a.default();if(void 0===r&&(r=u),"object"!==f(r))return[[a.fail({value:r,branch:t,path:n})]];var i={},o=[];for(var c in e){var l=r[c],s=n.concat(c),p=t.concat(l),y=e[c];void 0===l&&null!=u&&c in u&&(l="function"==typeof u[c]?u[c](r,t,n):u[c]);var v=y.check(l,p,s),d=v[0],h=v[1];d?o.push.apply(o,d):void 0!==h&&c in e&&(i[c]=h)}return o.length?[o]:[void 0,i]},a}(r,n,t)},t.record=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length||y(!1);var u=n(r[0]),a=n(r[1]),i=b({kind:"record",type:"record<"+u.type+","+a.type+">",defaults:t,struct:n});return i.check=function(r,t,n){var o=i.default();if(r=o?e({},o,{},r):r,"object"!==f(r))return[[i.fail({value:r,branch:t,path:n})]];var c={},l=[];for(var s in r){var p=r[s],y=n.concat(s),v=t.concat(p),d=u.check(s,v,y),h=d[0],b=d[1];if(h)l.push.apply(l,h);else{var g=a.check(p,v,y),k=g[0],m=g[1];k?l.push.apply(l,k):c[b]=m}}return l.length?[l]:[void 0,c]},i}(r,n,t)},t.scalar=function(r,n){return function(r,t,n){"string"!=typeof r&&y(!1);var e=n.Types;r in e||y(!1);var u=n(e[r],t);return u.kind="scalar",u.type=r,u}(r,n,t)},t.size=function(r,n){return function(r,t,n){Array.isArray(r)&&2===r.length&&r.every((function(r){return"number"==typeof r}))||y(!1);var e=r[0],u=r[1],a=n((function(r){return null!=r&&"number"==typeof r.length&&r.length>=e&&r.length<=u}),t);return a.kind="size",a.type="size<"+e+","+u+">",a}(r,n,t)},t.tuple=function(r,n){return function(r,t,n){Array.isArray(r)||y(!1);var e=r.map((function(r){return n(r)})),u=b({kind:"tuple",type:"["+e.map((function(r){return r.type})).join()+"]",defaults:t,struct:n});return u.check=function(r,t,n){if(void 0===r&&(r=u.default()),!Array.isArray(r))return[[u.fail({value:r,branch:t,path:n})]];for(var a=[],i=[],o=Math.max(r.length,e.length),c=0;c<o;c++){var f=e[c],l=r[c],s=n.concat(c),p=t.concat(l);if(f){var y=f.check(l,p,s),v=y[0],d=y[1];v?i.push.apply(i,v):a[c]=d}else i.push(u.fail({type:void 0,value:l,path:s,branch:p}))}return i.length?[i]:[void 0,a]},u}(r,n,t)},t.union=function(r,n){return g(r,n,t)},t.Error=r.error||v,t.Types=e({},s,{},r.types),t},m=k();r.StructError=v,r.Types=s,r.isStruct=h,r.struct=m,r.superstruct=k,Object.defineProperty(r,"__esModule",{value:!0})}));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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