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

duh-core

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duh-core - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

40

lib/validate-schema.js

@@ -6,2 +6,39 @@ 'use strict';

const padder = (res, row) => {
row.map((e, i) => {
if (typeof res[i] !== 'number') {
res[i] = 0;
}
res[i] = Math.max(res[i], e.toString().length);
});
return res;
};
const hfmt = [
{head: '\u001b[4m', tail: '\u001b[0m '},
{head: '\u001b[4m', tail: '\u001b[0m '},
{head: '\u001b[4m', tail: '\u001b[0m '}
];
const bfmt = [
{head: '\u001b[33;1m', tail: '\u001b[0m '},
{head: '\u001b[34;1m', tail: '\u001b[0m '},
{head: '\u001b[37;1m', tail: '\u001b[0m '}
];
const formatter = (fmt, widths) =>
(res, col, i) =>
res + fmt[i].head + col.toString().padEnd(widths[i]) + fmt[i].tail;
const logger = errors => {
const errora = errors.map(err => [err.dataPath, err.schemaPath, err.message]);
const widths = errora.reduce(padder, []);
return [
'DUH document does not match schema:',
['data path', 'schema path', 'message'].reduce(formatter(hfmt, widths), ''),
errora.map(row => row.reduce(formatter(bfmt, widths), '')).join('\n')
].join('\n');
};
module.exports = duh => new Promise((resolve, reject) => {

@@ -15,4 +52,5 @@ const ajv = new Ajv;

} else {
reject(validate.errors);
// reject(validate.errors);
reject(logger(validate.errors));
}
});

2

package.json
{
"name": "duh-core",
"version": "0.6.0",
"version": "0.6.1",
"description": "DUH core",

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

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