swagger-mock-parser
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -59,25 +59,3 @@ 'use strict'; | ||
value: function getParser(node) { | ||
if (!Array.prototype.find) { | ||
Array.prototype.find = function (predicate) { | ||
if (this === null) { | ||
throw new TypeError('Array.prototype.find called on null or undefined'); | ||
} | ||
if (typeof predicate !== 'function') { | ||
throw new TypeError('predicate must be a function'); | ||
} | ||
var list = Object(this); | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
var value; | ||
for (var i = 0; i < length; i++) { | ||
value = list[i]; | ||
if (predicate.call(thisArg, value, i, list)) { | ||
return value; | ||
} | ||
} | ||
return undefined; | ||
}; | ||
} | ||
var parser = this.parsers.find(function (p) { | ||
var parser = this.findParser(function (p) { | ||
return p.canParse(node); | ||
@@ -96,2 +74,21 @@ }); | ||
}, { | ||
key: 'findParser', | ||
value: function findParser(predicate) { | ||
if (typeof predicate !== 'function') { | ||
throw new TypeError('predicate must be a function'); | ||
} | ||
var list = this.parsers; | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
var value; | ||
for (var i = 0; i < length; i++) { | ||
value = list[i]; | ||
if (predicate.call(thisArg, value, i, list)) { | ||
return value; | ||
} | ||
} | ||
return undefined; | ||
} | ||
}, { | ||
key: 'parsers', | ||
@@ -98,0 +95,0 @@ get: function get() { |
{ | ||
"name": "swagger-mock-parser", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "use chance.js to parse definition schema to mock data", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -29,26 +29,4 @@ import StringParser from './Parsers/StringParser' | ||
getParser(node) { | ||
if (!Array.prototype.find) { | ||
Array.prototype.find = function (predicate) { | ||
if (this === null) { | ||
throw new TypeError('Array.prototype.find called on null or undefined'); | ||
} | ||
if (typeof predicate !== 'function') { | ||
throw new TypeError('predicate must be a function'); | ||
} | ||
var list = Object(this); | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
var value; | ||
let parser = this.findParser(p => p.canParse(node)); | ||
for (var i = 0; i < length; i++) { | ||
value = list[i]; | ||
if (predicate.call(thisArg, value, i, list)) { | ||
return value; | ||
} | ||
} | ||
return undefined; | ||
}; | ||
} | ||
let parser = this.parsers.find(p => p.canParse(node)); | ||
if (!parser) | ||
@@ -63,2 +41,20 @@ throw new Error(`Can't handle ${node.type || 'Unknown'} type.`); | ||
} | ||
findParser(predicate){ | ||
if (typeof predicate !== 'function') { | ||
throw new TypeError('predicate must be a function'); | ||
} | ||
var list = this.parsers; | ||
var length = list.length >>> 0; | ||
var thisArg = arguments[1]; | ||
var value; | ||
for (var i = 0; i < length; i++) { | ||
value = list[i]; | ||
if (predicate.call(thisArg, value, i, list)) { | ||
return value; | ||
} | ||
} | ||
return undefined; | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34483
750