Socket
Socket
Sign inDemoInstall

grunt-tv4

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-tv4 - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

68

lib/runner.js

@@ -6,6 +6,15 @@ // Bulk validation core: composites with tv4, miniwrite, ministyle and loaders

function nextTick(call) {
//lame setImmediate
setTimeout(call, 1);
//lame setImmediate shimable
if (typeof setImmediate === 'function') {
setImmediate(call);
}
else if (process && typeof process.nextTick === 'function') {
process.nextTick(call);
}
else {
setTimeout(call, 1);
}
}
// for-each async style
function forAsync(items, iter, callback) {

@@ -96,3 +105,3 @@ var keys = Object.keys(items);

var context = {};
context.tv4 = tv4.freshApi();
context.tv4 = (options.fresh ? tv4.freshApi() : tv4);
context.options = {};

@@ -105,7 +114,9 @@

// main validation method
context.validate = function (objects, callback) {
// retunr value
var job = {
context: context,
total: objects.length,
objects: objects,
objects: objects, //TODO rename objects to values
success: true,

@@ -129,2 +140,3 @@ error: null,

}
// loop all objects
forAsync(job.objects, function (object, index, callback) {

@@ -172,7 +184,23 @@ validateObject(job, object, callback);

function loadSchemaList(job, uris, callback) {
uris = uris.filter(function (value) {
return !!value;
});
if (uris.length === 0) {
nextTick(function () {
callback();
});
return;
}
var sweep = function () {
if (uris.length === 0) {
return callback();
nextTick(callback);
return;
}
forAsync(uris, function (uri, i, callback) {
if (!uri) {
out.writeln('> ' + style.error('cannot load') + ' "' + tweakURI(uri) + '"');
callback();
}
out.writeln('> ' + style.accent('load') + ' + ' + tweakURI(uri));

@@ -222,2 +250,14 @@

// test for bad fragment pointer fall-through
if (!object.result.missing.every(function (value) {
return (value !== '');
})) {
job.failed.push(object);
out.writeln('> ' + style.error('empty missing-schema url detected') + ' (this likely casued by a bad fragment pointer)');
return callback();
}
out.writeln('> ' + style.accent('auto') + ' ! validation missing ' + object.result.missing.length + ' urls:');
out.writeln('> "' + object.result.missing.join('"\n> "') + '"');
// auto load missing (if loading has an error we'll bail way back)

@@ -303,3 +343,3 @@ loadSchemaList(job, object.result.missing, function (err) {

}
out.writeln('> ' + style.accent('load') + ' > ' + tweakURI(object.root));
out.writeln('> ' + style.accent('root') + ' > ' + tweakURI(object.root));

@@ -315,11 +355,9 @@ loader.load(object.root, job.context.options, function (err, schema) {

}
if (isURL(object.root)) {
object.schema = schema;
job.context.tv4.addSchema(object.root, schema);
object.schema = schema;
job.context.tv4.addSchema(object.root, schema);
if (object.schema.id) {
job.context.tv4.addSchema(object.schema);
}
else {
object.schema = schema;
//TODO use object.root? as id? (no, not uri: file:// uris are catched above)
job.context.tv4.addSchema((object.schema.id || ''), object.schema);
}
startLoading(job, object, callback);

@@ -329,3 +367,3 @@ });

default:
callback(new Error('dont know how to load: ' + object.root));
callback(new Error('don\'t know how to load: ' + object.root));
return;

@@ -332,0 +370,0 @@ }

{
"name": "grunt-tv4",
"description": "Validate values against json-schema v4",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/Bartvds/grunt-tv4",

@@ -6,0 +6,0 @@ "author": {

@@ -154,3 +154,3 @@ # grunt-tv4

myCallback: {
// alternately pass a function() to returns a collection of values (array or object)
// alternately pass a function() to return a collection of values (array or object)
values: function() {

@@ -169,7 +169,7 @@ return {

* 0.3.0 - Big intenral rewrite:
* 0.3.0 - Big internal rewrite:
* Added `.values` option.
* Extracted reporting to [tv4-reporter](https://github.com/Bartvds/tv4-reporter), [miniwrite](https://github.com/Bartvds/miniwrite) and [miniwrite](https://github.com/Bartvds/ministyle).
* Extracted reporting to [tv4-reporter](https://github.com/Bartvds/tv4-reporter), [miniwrite](https://github.com/Bartvds/miniwrite) and [ministyle](https://github.com/Bartvds/ministyle).
* Moved loader logic to own stand-alone module (for later extraction)
* Extracted test running logic to own module (for layer extraction)
* Extracted test-running logic to own module (for later extraction)
* 0.2.1 - Added support to report subErrors (for anyOf/oneOf)

@@ -176,0 +176,0 @@ * 0.2.0 - Updated to follow the Grunt conventions.

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