New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

skemata

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skemata - npm Package Compare versions

Comparing version

to
0.1.2

3

lib/index.js
'use strict';
const sysUtil = require('util');
const v = require('./types');

@@ -9,3 +10,3 @@ const t = {v};

if (r.type === 'simple') {
return `expected: ${r.expType}, got: ${r.acType} (${r.val})`;
return `expected: ${r.expType}, got: ${r.acType} (${sysUtil.format(r.val)})`;
}

@@ -12,0 +13,0 @@ };

@@ -116,2 +116,14 @@ 'use strict';

const _mergeObjectOf = (v1, v2, opts) => {
const deepUndefault = val => {
if (val.human === 'object' && val._props && val._props.elSchema && val._props.elSchema.human === 'object') {
const blank = v.objects({}, v.object({}));
return _mergeObjectOf(val, blank, opts);
} else if (val.human === 'object' && val._props && val._props.schema) {
const blank = v.object({});
return _mergeObjectOf(val, blank, opts);
} else {
return val.undefault();
}
};
const uniq = ary => Array.from(new Set(ary));

@@ -148,4 +160,5 @@ if (v1.human === 'object' && v2.human === 'object' && v1._props.schema && v2._props.schema) {

let val = key in schema1 ? schema1[key] : schema2[key];
if (opts && opts.ignoreFirstDefaults && key in schema1) {
val = val.undefault();
val = deepUndefault(val);
}

@@ -156,2 +169,7 @@ mergedSchema[key] = val;

return v.object(mergedSchema);
} else if (v1.human === 'object' && v2.human === 'object' && v1._props.elSchema && v2._props.elSchema) {
const elSchema1 = v1._props.elSchema;
const elSchema2 = v2._props.elSchema;
const mergedElSchema = _mergeObjectOf(elSchema1, elSchema2, opts);
return v.objects(v1._props.props, mergedElSchema);
}

@@ -163,3 +181,3 @@ throw new Error("can't merge");

const specifics = props && props.specifics || {};
return obj => {
const fn = obj => {
const rs = Object.keys(obj).map(key => {

@@ -197,2 +215,4 @@ const val = obj[key];

};
fn._props = {props, elSchema};
return fn;
};

@@ -199,0 +219,0 @@

{
"name": "skemata",
"version": "0.1.1",
"version": "0.1.2",
"description": "An object structure and type validation library",

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