1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.geojsonhint = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | var rightHandRule = require('./rhr');
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function hint(gj, options) {
|
16 |
|
17 | var errors = [];
|
18 | var precisionWarningCount = 0;
|
19 | var maxPrecisionWarnings = 10;
|
20 | var maxPrecision = 6;
|
21 |
|
22 | function root(_) {
|
23 |
|
24 | if ((!options || options.noDuplicateMembers !== false) &&
|
25 | _.__duplicateProperties__) {
|
26 | errors.push({
|
27 | message: 'An object contained duplicate members, making parsing ambigous: ' + _.__duplicateProperties__.join(', '),
|
28 | line: _.__line__
|
29 | });
|
30 | }
|
31 |
|
32 | if (requiredProperty(_, 'type', 'string')) {
|
33 | return;
|
34 | }
|
35 |
|
36 | if (!types[_.type]) {
|
37 | var expectedType = typesLower[_.type.toLowerCase()];
|
38 | if (expectedType !== undefined) {
|
39 | errors.push({
|
40 | message: 'Expected ' + expectedType + ' but got ' + _.type + ' (case sensitive)',
|
41 | line: _.__line__
|
42 | });
|
43 | } else {
|
44 | errors.push({
|
45 | message: 'The type ' + _.type + ' is unknown',
|
46 | line: _.__line__
|
47 | });
|
48 | }
|
49 | } else if (_) {
|
50 | types[_.type](_);
|
51 | }
|
52 | }
|
53 |
|
54 | function everyIs(_, type) {
|
55 |
|
56 | return _.every(function(x) {
|
57 | return x !== null && typeof x === type;
|
58 | });
|
59 | }
|
60 |
|
61 | function requiredProperty(_, name, type) {
|
62 | if (typeof _[name] === 'undefined') {
|
63 | return errors.push({
|
64 | message: '"' + name + '" member required',
|
65 | line: _.__line__
|
66 | });
|
67 | } else if (type === 'array') {
|
68 | if (!Array.isArray(_[name])) {
|
69 | return errors.push({
|
70 | message: '"' + name +
|
71 | '" member should be an array, but is an ' +
|
72 | (typeof _[name]) + ' instead',
|
73 | line: _.__line__
|
74 | });
|
75 | }
|
76 | } else if (type === 'object' && _[name] && _[name].constructor.name !== 'Object') {
|
77 | return errors.push({
|
78 | message: '"' + name +
|
79 | '" member should be ' + (type) +
|
80 | ', but is an ' + (_[name].constructor.name) + ' instead',
|
81 | line: _.__line__
|
82 | });
|
83 | } else if (type && typeof _[name] !== type) {
|
84 | return errors.push({
|
85 | message: '"' + name +
|
86 | '" member should be ' + (type) +
|
87 | ', but is an ' + (typeof _[name]) + ' instead',
|
88 | line: _.__line__
|
89 | });
|
90 | }
|
91 | }
|
92 |
|
93 |
|
94 | function FeatureCollection(featureCollection) {
|
95 | crs(featureCollection);
|
96 | bbox(featureCollection);
|
97 | if (featureCollection.properties !== undefined) {
|
98 | errors.push({
|
99 | message: 'FeatureCollection object cannot contain a "properties" member',
|
100 | line: featureCollection.__line__
|
101 | });
|
102 | }
|
103 | if (featureCollection.coordinates !== undefined) {
|
104 | errors.push({
|
105 | message: 'FeatureCollection object cannot contain a "coordinates" member',
|
106 | line: featureCollection.__line__
|
107 | });
|
108 | }
|
109 | if (!requiredProperty(featureCollection, 'features', 'array')) {
|
110 | if (!everyIs(featureCollection.features, 'object')) {
|
111 | return errors.push({
|
112 | message: 'Every feature must be an object',
|
113 | line: featureCollection.__line__
|
114 | });
|
115 | }
|
116 | featureCollection.features.forEach(Feature);
|
117 | }
|
118 | }
|
119 |
|
120 |
|
121 | function position(_, line) {
|
122 | if (!Array.isArray(_)) {
|
123 | return errors.push({
|
124 | message: 'position should be an array, is a ' + (typeof _) +
|
125 | ' instead',
|
126 | line: _.__line__ || line
|
127 | });
|
128 | }
|
129 | if (_.length < 2) {
|
130 | return errors.push({
|
131 | message: 'position must have 2 or more elements',
|
132 | line: _.__line__ || line
|
133 | });
|
134 | }
|
135 | if (_.length > 3) {
|
136 | return errors.push({
|
137 | message: 'position should not have more than 3 elements',
|
138 | line: _.__line__ || line
|
139 | });
|
140 | }
|
141 | if (!everyIs(_, 'number')) {
|
142 | return errors.push({
|
143 | message: 'each element in a position must be a number',
|
144 | line: _.__line__ || line
|
145 | });
|
146 | }
|
147 |
|
148 | if (options && options.precisionWarning) {
|
149 | if (precisionWarningCount === maxPrecisionWarnings) {
|
150 | precisionWarningCount += 1;
|
151 | return errors.push({
|
152 | message: 'truncated warnings: we\'ve encountered coordinate precision warning ' + maxPrecisionWarnings + ' times, no more warnings will be reported',
|
153 | level: 'message',
|
154 | line: _.__line__ || line
|
155 | });
|
156 | } else if (precisionWarningCount < maxPrecisionWarnings) {
|
157 | _.forEach(function(num) {
|
158 | var precision = 0;
|
159 | var decimalStr = String(num).split('.')[1];
|
160 | if (decimalStr !== undefined)
|
161 | precision = decimalStr.length;
|
162 | if (precision > maxPrecision) {
|
163 | precisionWarningCount += 1;
|
164 | return errors.push({
|
165 | message: 'precision of coordinates should be reduced',
|
166 | level: 'message',
|
167 | line: _.__line__ || line
|
168 | });
|
169 | }
|
170 | });
|
171 | }
|
172 | }
|
173 | }
|
174 |
|
175 | function positionArray(coords, type, depth, line) {
|
176 | if (line === undefined && coords.__line__ !== undefined) {
|
177 | line = coords.__line__;
|
178 | }
|
179 | if (depth === 0) {
|
180 | return position(coords, line);
|
181 | }
|
182 | if (depth === 1 && type) {
|
183 | if (type === 'LinearRing') {
|
184 | if (!Array.isArray(coords[coords.length - 1])) {
|
185 | errors.push({
|
186 | message: 'a number was found where a coordinate array should have been found: this needs to be nested more deeply',
|
187 | line: line
|
188 | });
|
189 | return true;
|
190 | }
|
191 | if (coords.length < 4) {
|
192 | errors.push({
|
193 | message: 'a LinearRing of coordinates needs to have four or more positions',
|
194 | line: line
|
195 | });
|
196 | }
|
197 | if (coords.length &&
|
198 | (coords[coords.length - 1].length !== coords[0].length ||
|
199 | !coords[coords.length - 1].every(function(pos, index) {
|
200 | return coords[0][index] === pos;
|
201 | }))) {
|
202 | errors.push({
|
203 | message: 'the first and last positions in a LinearRing of coordinates must be the same',
|
204 | line: line
|
205 | });
|
206 | return true;
|
207 | }
|
208 | } else if (type === 'Line' && coords.length < 2) {
|
209 | return errors.push({
|
210 | message: 'a line needs to have two or more coordinates to be valid',
|
211 | line: line
|
212 | });
|
213 | }
|
214 | }
|
215 | if (!Array.isArray(coords)) {
|
216 | errors.push({
|
217 | message: 'a number was found where a coordinate array should have been found: this needs to be nested more deeply',
|
218 | line: line
|
219 | });
|
220 | } else {
|
221 | var results = coords.map(function(c) {
|
222 | return positionArray(c, type, depth - 1, c.__line__ || line);
|
223 | });
|
224 | return results.some(function(r) {
|
225 | return r;
|
226 | });
|
227 | }
|
228 | }
|
229 |
|
230 | function crs(_) {
|
231 | if (!_.crs) return;
|
232 | var defaultCRSName = 'urn:ogc:def:crs:OGC:1.3:CRS84';
|
233 | if (typeof _.crs === 'object' && _.crs.properties && _.crs.properties.name === defaultCRSName) {
|
234 | errors.push({
|
235 | message: 'old-style crs member is not recommended, this object is equivalent to the default and should be removed',
|
236 | line: _.__line__
|
237 | });
|
238 | } else {
|
239 | errors.push({
|
240 | message: 'old-style crs member is not recommended',
|
241 | line: _.__line__
|
242 | });
|
243 | }
|
244 | }
|
245 |
|
246 | function bbox(_) {
|
247 | if (!_.bbox) {
|
248 | return;
|
249 | }
|
250 | if (Array.isArray(_.bbox)) {
|
251 | if (!everyIs(_.bbox, 'number')) {
|
252 | errors.push({
|
253 | message: 'each element in a bbox member must be a number',
|
254 | line: _.bbox.__line__
|
255 | });
|
256 | }
|
257 | if (!(_.bbox.length === 4 || _.bbox.length === 6)) {
|
258 | errors.push({
|
259 | message: 'bbox must contain 4 elements (for 2D) or 6 elements (for 3D)',
|
260 | line: _.bbox.__line__
|
261 | });
|
262 | }
|
263 | return errors.length;
|
264 | }
|
265 | errors.push({
|
266 | message: 'bbox member must be an array of numbers, but is a ' + (typeof _.bbox),
|
267 | line: _.__line__
|
268 | });
|
269 | }
|
270 |
|
271 | function geometrySemantics(geom) {
|
272 | if (geom.properties !== undefined) {
|
273 | errors.push({
|
274 | message: 'geometry object cannot contain a "properties" member',
|
275 | line: geom.__line__
|
276 | });
|
277 | }
|
278 | if (geom.geometry !== undefined) {
|
279 | errors.push({
|
280 | message: 'geometry object cannot contain a "geometry" member',
|
281 | line: geom.__line__
|
282 | });
|
283 | }
|
284 | if (geom.features !== undefined) {
|
285 | errors.push({
|
286 | message: 'geometry object cannot contain a "features" member',
|
287 | line: geom.__line__
|
288 | });
|
289 | }
|
290 | }
|
291 |
|
292 |
|
293 | function Point(point) {
|
294 | crs(point);
|
295 | bbox(point);
|
296 | geometrySemantics(point);
|
297 | if (!requiredProperty(point, 'coordinates', 'array')) {
|
298 | position(point.coordinates);
|
299 | }
|
300 | }
|
301 |
|
302 |
|
303 | function Polygon(polygon) {
|
304 | crs(polygon);
|
305 | bbox(polygon);
|
306 | if (!requiredProperty(polygon, 'coordinates', 'array')) {
|
307 | if (!positionArray(polygon.coordinates, 'LinearRing', 2)) {
|
308 | rightHandRule(polygon, errors);
|
309 | }
|
310 | }
|
311 | }
|
312 |
|
313 |
|
314 | function MultiPolygon(multiPolygon) {
|
315 | crs(multiPolygon);
|
316 | bbox(multiPolygon);
|
317 | if (!requiredProperty(multiPolygon, 'coordinates', 'array')) {
|
318 | if (!positionArray(multiPolygon.coordinates, 'LinearRing', 3)) {
|
319 | rightHandRule(multiPolygon, errors);
|
320 | }
|
321 | }
|
322 | }
|
323 |
|
324 |
|
325 | function LineString(lineString) {
|
326 | crs(lineString);
|
327 | bbox(lineString);
|
328 | if (!requiredProperty(lineString, 'coordinates', 'array')) {
|
329 | positionArray(lineString.coordinates, 'Line', 1);
|
330 | }
|
331 | }
|
332 |
|
333 |
|
334 | function MultiLineString(multiLineString) {
|
335 | crs(multiLineString);
|
336 | bbox(multiLineString);
|
337 | if (!requiredProperty(multiLineString, 'coordinates', 'array')) {
|
338 | positionArray(multiLineString.coordinates, 'Line', 2);
|
339 | }
|
340 | }
|
341 |
|
342 |
|
343 | function MultiPoint(multiPoint) {
|
344 | crs(multiPoint);
|
345 | bbox(multiPoint);
|
346 | if (!requiredProperty(multiPoint, 'coordinates', 'array')) {
|
347 | positionArray(multiPoint.coordinates, '', 1);
|
348 | }
|
349 | }
|
350 |
|
351 | function GeometryCollection(geometryCollection) {
|
352 | crs(geometryCollection);
|
353 | bbox(geometryCollection);
|
354 | if (!requiredProperty(geometryCollection, 'geometries', 'array')) {
|
355 | if (!everyIs(geometryCollection.geometries, 'object')) {
|
356 | errors.push({
|
357 | message: 'The geometries array in a GeometryCollection must contain only geometry objects',
|
358 | line: geometryCollection.__line__
|
359 | });
|
360 | }
|
361 | if (geometryCollection.geometries.length === 1) {
|
362 | errors.push({
|
363 | message: 'GeometryCollection with a single geometry should be avoided in favor of single part or a single object of multi-part type',
|
364 | line: geometryCollection.geometries.__line__
|
365 | });
|
366 | }
|
367 | geometryCollection.geometries.forEach(function(geometry) {
|
368 | if (geometry) {
|
369 | if (geometry.type === 'GeometryCollection') {
|
370 | errors.push({
|
371 | message: 'GeometryCollection should avoid nested geometry collections',
|
372 | line: geometryCollection.geometries.__line__
|
373 | });
|
374 | }
|
375 | root(geometry);
|
376 | }
|
377 | });
|
378 | }
|
379 | }
|
380 |
|
381 | function Feature(feature) {
|
382 | crs(feature);
|
383 | bbox(feature);
|
384 |
|
385 | if (feature.id !== undefined &&
|
386 | typeof feature.id !== 'string' &&
|
387 | typeof feature.id !== 'number') {
|
388 | errors.push({
|
389 | message: 'Feature "id" member must have a string or number value',
|
390 | line: feature.__line__
|
391 | });
|
392 | }
|
393 | if (feature.features !== undefined) {
|
394 | errors.push({
|
395 | message: 'Feature object cannot contain a "features" member',
|
396 | line: feature.__line__
|
397 | });
|
398 | }
|
399 | if (feature.coordinates !== undefined) {
|
400 | errors.push({
|
401 | message: 'Feature object cannot contain a "coordinates" member',
|
402 | line: feature.__line__
|
403 | });
|
404 | }
|
405 | if (feature.type !== 'Feature') {
|
406 | errors.push({
|
407 | message: 'GeoJSON features must have a type=feature member',
|
408 | line: feature.__line__
|
409 | });
|
410 | }
|
411 | requiredProperty(feature, 'properties', 'object');
|
412 | if (!requiredProperty(feature, 'geometry', 'object')) {
|
413 |
|
414 |
|
415 | if (feature.geometry) root(feature.geometry);
|
416 | }
|
417 | }
|
418 |
|
419 | var types = {
|
420 | Point: Point,
|
421 | Feature: Feature,
|
422 | MultiPoint: MultiPoint,
|
423 | LineString: LineString,
|
424 | MultiLineString: MultiLineString,
|
425 | FeatureCollection: FeatureCollection,
|
426 | GeometryCollection: GeometryCollection,
|
427 | Polygon: Polygon,
|
428 | MultiPolygon: MultiPolygon
|
429 | };
|
430 |
|
431 | var typesLower = Object.keys(types).reduce(function(prev, curr) {
|
432 | prev[curr.toLowerCase()] = curr;
|
433 | return prev;
|
434 | }, {});
|
435 |
|
436 | if (typeof gj !== 'object' ||
|
437 | gj === null ||
|
438 | gj === undefined) {
|
439 | errors.push({
|
440 | message: 'The root of a GeoJSON object must be an object.',
|
441 | line: 0
|
442 | });
|
443 | return errors;
|
444 | }
|
445 |
|
446 | root(gj);
|
447 |
|
448 | errors.forEach(function(err) {
|
449 | if ({}.hasOwnProperty.call(err, 'line') && err.line === undefined) {
|
450 | delete err.line;
|
451 | }
|
452 | });
|
453 |
|
454 | return errors;
|
455 | }
|
456 |
|
457 | module.exports.hint = hint;
|
458 |
|
459 | },{"./rhr":2}],2:[function(require,module,exports){
|
460 | function rad(x) {
|
461 | return x * Math.PI / 180;
|
462 | }
|
463 |
|
464 | function isRingClockwise (coords) {
|
465 | var area = 0;
|
466 | if (coords.length > 2) {
|
467 | var p1, p2;
|
468 | for (var i = 0; i < coords.length - 1; i++) {
|
469 | p1 = coords[i];
|
470 | p2 = coords[i + 1];
|
471 | area += rad(p2[0] - p1[0]) * (2 + Math.sin(rad(p1[1])) + Math.sin(rad(p2[1])));
|
472 | }
|
473 | }
|
474 |
|
475 | return area >= 0;
|
476 | }
|
477 |
|
478 | function isPolyRHR (coords) {
|
479 | if (coords && coords.length > 0) {
|
480 | if (isRingClockwise(coords[0]))
|
481 | return false;
|
482 | var interiorCoords = coords.slice(1, coords.length);
|
483 | if (!interiorCoords.every(isRingClockwise))
|
484 | return false;
|
485 | }
|
486 | return true;
|
487 | }
|
488 |
|
489 | function rightHandRule (geometry) {
|
490 | if (geometry.type === 'Polygon') {
|
491 | return isPolyRHR(geometry.coordinates);
|
492 | } else if (geometry.type === 'MultiPolygon') {
|
493 | return geometry.coordinates.every(isPolyRHR);
|
494 | }
|
495 | }
|
496 |
|
497 | module.exports = function validateRightHandRule(geometry, errors) {
|
498 | if (!rightHandRule(geometry)) {
|
499 | errors.push({
|
500 | message: 'Polygons and MultiPolygons should follow the right-hand rule',
|
501 | level: 'message',
|
502 | line: geometry.__line__
|
503 | });
|
504 | }
|
505 | };
|
506 |
|
507 | },{}],3:[function(require,module,exports){
|
508 |
|
509 | },{}],4:[function(require,module,exports){
|
510 | (function (process){
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 | function normalizeArray(parts, allowAboveRoot) {
|
537 |
|
538 | var up = 0;
|
539 | for (var i = parts.length - 1; i >= 0; i--) {
|
540 | var last = parts[i];
|
541 | if (last === '.') {
|
542 | parts.splice(i, 1);
|
543 | } else if (last === '..') {
|
544 | parts.splice(i, 1);
|
545 | up++;
|
546 | } else if (up) {
|
547 | parts.splice(i, 1);
|
548 | up--;
|
549 | }
|
550 | }
|
551 |
|
552 |
|
553 | if (allowAboveRoot) {
|
554 | for (; up--; up) {
|
555 | parts.unshift('..');
|
556 | }
|
557 | }
|
558 |
|
559 | return parts;
|
560 | }
|
561 |
|
562 |
|
563 |
|
564 | var splitPathRe =
|
565 | /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
566 | var splitPath = function(filename) {
|
567 | return splitPathRe.exec(filename).slice(1);
|
568 | };
|
569 |
|
570 |
|
571 |
|
572 | exports.resolve = function() {
|
573 | var resolvedPath = '',
|
574 | resolvedAbsolute = false;
|
575 |
|
576 | for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
577 | var path = (i >= 0) ? arguments[i] : process.cwd();
|
578 |
|
579 |
|
580 | if (typeof path !== 'string') {
|
581 | throw new TypeError('Arguments to path.resolve must be strings');
|
582 | } else if (!path) {
|
583 | continue;
|
584 | }
|
585 |
|
586 | resolvedPath = path + '/' + resolvedPath;
|
587 | resolvedAbsolute = path.charAt(0) === '/';
|
588 | }
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 | resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
595 | return !!p;
|
596 | }), !resolvedAbsolute).join('/');
|
597 |
|
598 | return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
599 | };
|
600 |
|
601 |
|
602 |
|
603 | exports.normalize = function(path) {
|
604 | var isAbsolute = exports.isAbsolute(path),
|
605 | trailingSlash = substr(path, -1) === '/';
|
606 |
|
607 |
|
608 | path = normalizeArray(filter(path.split('/'), function(p) {
|
609 | return !!p;
|
610 | }), !isAbsolute).join('/');
|
611 |
|
612 | if (!path && !isAbsolute) {
|
613 | path = '.';
|
614 | }
|
615 | if (path && trailingSlash) {
|
616 | path += '/';
|
617 | }
|
618 |
|
619 | return (isAbsolute ? '/' : '') + path;
|
620 | };
|
621 |
|
622 |
|
623 | exports.isAbsolute = function(path) {
|
624 | return path.charAt(0) === '/';
|
625 | };
|
626 |
|
627 |
|
628 | exports.join = function() {
|
629 | var paths = Array.prototype.slice.call(arguments, 0);
|
630 | return exports.normalize(filter(paths, function(p, index) {
|
631 | if (typeof p !== 'string') {
|
632 | throw new TypeError('Arguments to path.join must be strings');
|
633 | }
|
634 | return p;
|
635 | }).join('/'));
|
636 | };
|
637 |
|
638 |
|
639 |
|
640 |
|
641 | exports.relative = function(from, to) {
|
642 | from = exports.resolve(from).substr(1);
|
643 | to = exports.resolve(to).substr(1);
|
644 |
|
645 | function trim(arr) {
|
646 | var start = 0;
|
647 | for (; start < arr.length; start++) {
|
648 | if (arr[start] !== '') break;
|
649 | }
|
650 |
|
651 | var end = arr.length - 1;
|
652 | for (; end >= 0; end--) {
|
653 | if (arr[end] !== '') break;
|
654 | }
|
655 |
|
656 | if (start > end) return [];
|
657 | return arr.slice(start, end - start + 1);
|
658 | }
|
659 |
|
660 | var fromParts = trim(from.split('/'));
|
661 | var toParts = trim(to.split('/'));
|
662 |
|
663 | var length = Math.min(fromParts.length, toParts.length);
|
664 | var samePartsLength = length;
|
665 | for (var i = 0; i < length; i++) {
|
666 | if (fromParts[i] !== toParts[i]) {
|
667 | samePartsLength = i;
|
668 | break;
|
669 | }
|
670 | }
|
671 |
|
672 | var outputParts = [];
|
673 | for (var i = samePartsLength; i < fromParts.length; i++) {
|
674 | outputParts.push('..');
|
675 | }
|
676 |
|
677 | outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
678 |
|
679 | return outputParts.join('/');
|
680 | };
|
681 |
|
682 | exports.sep = '/';
|
683 | exports.delimiter = ':';
|
684 |
|
685 | exports.dirname = function(path) {
|
686 | var result = splitPath(path),
|
687 | root = result[0],
|
688 | dir = result[1];
|
689 |
|
690 | if (!root && !dir) {
|
691 |
|
692 | return '.';
|
693 | }
|
694 |
|
695 | if (dir) {
|
696 |
|
697 | dir = dir.substr(0, dir.length - 1);
|
698 | }
|
699 |
|
700 | return root + dir;
|
701 | };
|
702 |
|
703 |
|
704 | exports.basename = function(path, ext) {
|
705 | var f = splitPath(path)[2];
|
706 |
|
707 | if (ext && f.substr(-1 * ext.length) === ext) {
|
708 | f = f.substr(0, f.length - ext.length);
|
709 | }
|
710 | return f;
|
711 | };
|
712 |
|
713 |
|
714 | exports.extname = function(path) {
|
715 | return splitPath(path)[3];
|
716 | };
|
717 |
|
718 | function filter (xs, f) {
|
719 | if (xs.filter) return xs.filter(f);
|
720 | var res = [];
|
721 | for (var i = 0; i < xs.length; i++) {
|
722 | if (f(xs[i], i, xs)) res.push(xs[i]);
|
723 | }
|
724 | return res;
|
725 | }
|
726 |
|
727 |
|
728 | var substr = 'ab'.substr(-1) === 'b'
|
729 | ? function (str, start, len) { return str.substr(start, len) }
|
730 | : function (str, start, len) {
|
731 | if (start < 0) start = str.length + start;
|
732 | return str.substr(start, len);
|
733 | }
|
734 | ;
|
735 |
|
736 | }).call(this,require('_process'))
|
737 | },{"_process":5}],5:[function(require,module,exports){
|
738 |
|
739 | var process = module.exports = {};
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 | var cachedSetTimeout;
|
747 | var cachedClearTimeout;
|
748 |
|
749 | (function () {
|
750 | try {
|
751 | cachedSetTimeout = setTimeout;
|
752 | } catch (e) {
|
753 | cachedSetTimeout = function () {
|
754 | throw new Error('setTimeout is not defined');
|
755 | }
|
756 | }
|
757 | try {
|
758 | cachedClearTimeout = clearTimeout;
|
759 | } catch (e) {
|
760 | cachedClearTimeout = function () {
|
761 | throw new Error('clearTimeout is not defined');
|
762 | }
|
763 | }
|
764 | } ())
|
765 | function runTimeout(fun) {
|
766 | if (cachedSetTimeout === setTimeout) {
|
767 |
|
768 | return setTimeout(fun, 0);
|
769 | }
|
770 | try {
|
771 |
|
772 | return cachedSetTimeout(fun, 0);
|
773 | } catch(e){
|
774 | try {
|
775 |
|
776 | return cachedSetTimeout.call(null, fun, 0);
|
777 | } catch(e){
|
778 |
|
779 | return cachedSetTimeout.call(this, fun, 0);
|
780 | }
|
781 | }
|
782 |
|
783 |
|
784 | }
|
785 | function runClearTimeout(marker) {
|
786 | if (cachedClearTimeout === clearTimeout) {
|
787 |
|
788 | return clearTimeout(marker);
|
789 | }
|
790 | try {
|
791 |
|
792 | return cachedClearTimeout(marker);
|
793 | } catch (e){
|
794 | try {
|
795 |
|
796 | return cachedClearTimeout.call(null, marker);
|
797 | } catch (e){
|
798 |
|
799 |
|
800 | return cachedClearTimeout.call(this, marker);
|
801 | }
|
802 | }
|
803 |
|
804 |
|
805 |
|
806 | }
|
807 | var queue = [];
|
808 | var draining = false;
|
809 | var currentQueue;
|
810 | var queueIndex = -1;
|
811 |
|
812 | function cleanUpNextTick() {
|
813 | if (!draining || !currentQueue) {
|
814 | return;
|
815 | }
|
816 | draining = false;
|
817 | if (currentQueue.length) {
|
818 | queue = currentQueue.concat(queue);
|
819 | } else {
|
820 | queueIndex = -1;
|
821 | }
|
822 | if (queue.length) {
|
823 | drainQueue();
|
824 | }
|
825 | }
|
826 |
|
827 | function drainQueue() {
|
828 | if (draining) {
|
829 | return;
|
830 | }
|
831 | var timeout = runTimeout(cleanUpNextTick);
|
832 | draining = true;
|
833 |
|
834 | var len = queue.length;
|
835 | while(len) {
|
836 | currentQueue = queue;
|
837 | queue = [];
|
838 | while (++queueIndex < len) {
|
839 | if (currentQueue) {
|
840 | currentQueue[queueIndex].run();
|
841 | }
|
842 | }
|
843 | queueIndex = -1;
|
844 | len = queue.length;
|
845 | }
|
846 | currentQueue = null;
|
847 | draining = false;
|
848 | runClearTimeout(timeout);
|
849 | }
|
850 |
|
851 | process.nextTick = function (fun) {
|
852 | var args = new Array(arguments.length - 1);
|
853 | if (arguments.length > 1) {
|
854 | for (var i = 1; i < arguments.length; i++) {
|
855 | args[i - 1] = arguments[i];
|
856 | }
|
857 | }
|
858 | queue.push(new Item(fun, args));
|
859 | if (queue.length === 1 && !draining) {
|
860 | runTimeout(drainQueue);
|
861 | }
|
862 | };
|
863 |
|
864 |
|
865 | function Item(fun, array) {
|
866 | this.fun = fun;
|
867 | this.array = array;
|
868 | }
|
869 | Item.prototype.run = function () {
|
870 | this.fun.apply(null, this.array);
|
871 | };
|
872 | process.title = 'browser';
|
873 | process.browser = true;
|
874 | process.env = {};
|
875 | process.argv = [];
|
876 | process.version = '';
|
877 | process.versions = {};
|
878 |
|
879 | function noop() {}
|
880 |
|
881 | process.on = noop;
|
882 | process.addListener = noop;
|
883 | process.once = noop;
|
884 | process.off = noop;
|
885 | process.removeListener = noop;
|
886 | process.removeAllListeners = noop;
|
887 | process.emit = noop;
|
888 |
|
889 | process.binding = function (name) {
|
890 | throw new Error('process.binding is not supported');
|
891 | };
|
892 |
|
893 | process.cwd = function () { return '/' };
|
894 | process.chdir = function (dir) {
|
895 | throw new Error('process.chdir is not supported');
|
896 | };
|
897 | process.umask = function() { return 0; };
|
898 |
|
899 | },{}],6:[function(require,module,exports){
|
900 | (function (process){
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 | var jsonlint = (function(){
|
975 | var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,12],$V1=[1,13],$V2=[1,9],$V3=[1,10],$V4=[1,11],$V5=[1,14],$V6=[1,15],$V7=[14,18,22,24],$V8=[18,22],$V9=[22,24];
|
976 | var parser = {trace: function trace() { },
|
977 | yy: {},
|
978 | symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
|
979 | terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
|
980 | productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
|
981 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
982 |
|
983 |
|
984 | var $0 = $$.length - 1;
|
985 | switch (yystate) {
|
986 | case 1:
|
987 |
|
988 | this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
|
989 | .replace(/\\n/g,'\n')
|
990 | .replace(/\\r/g,'\r')
|
991 | .replace(/\\t/g,'\t')
|
992 | .replace(/\\v/g,'\v')
|
993 | .replace(/\\f/g,'\f')
|
994 | .replace(/\\b/g,'\b');
|
995 |
|
996 | break;
|
997 | case 2:
|
998 | this.$ = Number(yytext);
|
999 | break;
|
1000 | case 3:
|
1001 | this.$ = null;
|
1002 | break;
|
1003 | case 4:
|
1004 | this.$ = true;
|
1005 | break;
|
1006 | case 5:
|
1007 | this.$ = false;
|
1008 | break;
|
1009 | case 6:
|
1010 | return this.$ = $$[$0-1];
|
1011 | break;
|
1012 | case 13:
|
1013 | this.$ = {}; Object.defineProperty(this.$, '__line__', {
|
1014 | value: this._$.first_line,
|
1015 | enumerable: false
|
1016 | })
|
1017 | break;
|
1018 | case 14: case 19:
|
1019 | this.$ = $$[$0-1]; Object.defineProperty(this.$, '__line__', {
|
1020 | value: this._$.first_line,
|
1021 | enumerable: false
|
1022 | })
|
1023 | break;
|
1024 | case 15:
|
1025 | this.$ = [$$[$0-2], $$[$0]];
|
1026 | break;
|
1027 | case 16:
|
1028 | this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
|
1029 | break;
|
1030 | case 17:
|
1031 |
|
1032 | this.$ = $$[$0-2];
|
1033 | if ($$[$0-2][$$[$0][0]] !== undefined) {
|
1034 | if (!this.$.__duplicateProperties__) {
|
1035 | Object.defineProperty(this.$, '__duplicateProperties__', {
|
1036 | value: [],
|
1037 | enumerable: false
|
1038 | });
|
1039 | }
|
1040 | this.$.__duplicateProperties__.push($$[$0][0]);
|
1041 | }
|
1042 | $$[$0-2][$$[$0][0]] = $$[$0][1];
|
1043 |
|
1044 | break;
|
1045 | case 18:
|
1046 | this.$ = []; Object.defineProperty(this.$, '__line__', {
|
1047 | value: this._$.first_line,
|
1048 | enumerable: false
|
1049 | })
|
1050 | break;
|
1051 | case 20:
|
1052 | this.$ = [$$[$0]];
|
1053 | break;
|
1054 | case 21:
|
1055 | this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
|
1056 | break;
|
1057 | }
|
1058 | },
|
1059 | table: [{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,12:1,13:2,15:7,16:8,17:$V5,23:$V6},{1:[3]},{14:[1,16]},o($V7,[2,7]),o($V7,[2,8]),o($V7,[2,9]),o($V7,[2,10]),o($V7,[2,11]),o($V7,[2,12]),o($V7,[2,3]),o($V7,[2,4]),o($V7,[2,5]),o([14,18,21,22,24],[2,1]),o($V7,[2,2]),{3:20,4:$V0,18:[1,17],19:18,20:19},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:23,15:7,16:8,17:$V5,23:$V6,24:[1,21],25:22},{1:[2,6]},o($V7,[2,13]),{18:[1,24],22:[1,25]},o($V8,[2,16]),{21:[1,26]},o($V7,[2,18]),{22:[1,28],24:[1,27]},o($V9,[2,20]),o($V7,[2,14]),{3:20,4:$V0,20:29},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:30,15:7,16:8,17:$V5,23:$V6},o($V7,[2,19]),{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:31,15:7,16:8,17:$V5,23:$V6},o($V8,[2,17]),o($V8,[2,15]),o($V9,[2,21])],
|
1060 | defaultActions: {16:[2,6]},
|
1061 | parseError: function parseError(str, hash) {
|
1062 | if (hash.recoverable) {
|
1063 | this.trace(str);
|
1064 | } else {
|
1065 | function _parseError (msg, hash) {
|
1066 | this.message = msg;
|
1067 | this.hash = hash;
|
1068 | }
|
1069 | _parseError.prototype = Error;
|
1070 |
|
1071 | throw new _parseError(str, hash);
|
1072 | }
|
1073 | },
|
1074 | parse: function parse(input) {
|
1075 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
1076 | var args = lstack.slice.call(arguments, 1);
|
1077 | var lexer = Object.create(this.lexer);
|
1078 | var sharedState = { yy: {} };
|
1079 | for (var k in this.yy) {
|
1080 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
1081 | sharedState.yy[k] = this.yy[k];
|
1082 | }
|
1083 | }
|
1084 | lexer.setInput(input, sharedState.yy);
|
1085 | sharedState.yy.lexer = lexer;
|
1086 | sharedState.yy.parser = this;
|
1087 | if (typeof lexer.yylloc == 'undefined') {
|
1088 | lexer.yylloc = {};
|
1089 | }
|
1090 | var yyloc = lexer.yylloc;
|
1091 | lstack.push(yyloc);
|
1092 | var ranges = lexer.options && lexer.options.ranges;
|
1093 | if (typeof sharedState.yy.parseError === 'function') {
|
1094 | this.parseError = sharedState.yy.parseError;
|
1095 | } else {
|
1096 | this.parseError = Object.getPrototypeOf(this).parseError;
|
1097 | }
|
1098 | function popStack(n) {
|
1099 | stack.length = stack.length - 2 * n;
|
1100 | vstack.length = vstack.length - n;
|
1101 | lstack.length = lstack.length - n;
|
1102 | }
|
1103 | _token_stack:
|
1104 | var lex = function () {
|
1105 | var token;
|
1106 | token = lexer.lex() || EOF;
|
1107 | if (typeof token !== 'number') {
|
1108 | token = self.symbols_[token] || token;
|
1109 | }
|
1110 | return token;
|
1111 | };
|
1112 | var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
1113 | while (true) {
|
1114 | state = stack[stack.length - 1];
|
1115 | if (this.defaultActions[state]) {
|
1116 | action = this.defaultActions[state];
|
1117 | } else {
|
1118 | if (symbol === null || typeof symbol == 'undefined') {
|
1119 | symbol = lex();
|
1120 | }
|
1121 | action = table[state] && table[state][symbol];
|
1122 | }
|
1123 | if (typeof action === 'undefined' || !action.length || !action[0]) {
|
1124 | var errStr = '';
|
1125 | expected = [];
|
1126 | for (p in table[state]) {
|
1127 | if (this.terminals_[p] && p > TERROR) {
|
1128 | expected.push('\'' + this.terminals_[p] + '\'');
|
1129 | }
|
1130 | }
|
1131 | if (lexer.showPosition) {
|
1132 | errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
1133 | } else {
|
1134 | errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
1135 | }
|
1136 | this.parseError(errStr, {
|
1137 | text: lexer.match,
|
1138 | token: this.terminals_[symbol] || symbol,
|
1139 | line: lexer.yylineno,
|
1140 | loc: yyloc,
|
1141 | expected: expected
|
1142 | });
|
1143 | }
|
1144 | if (action[0] instanceof Array && action.length > 1) {
|
1145 | throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
1146 | }
|
1147 | switch (action[0]) {
|
1148 | case 1:
|
1149 | stack.push(symbol);
|
1150 | vstack.push(lexer.yytext);
|
1151 | lstack.push(lexer.yylloc);
|
1152 | stack.push(action[1]);
|
1153 | symbol = null;
|
1154 | if (!preErrorSymbol) {
|
1155 | yyleng = lexer.yyleng;
|
1156 | yytext = lexer.yytext;
|
1157 | yylineno = lexer.yylineno;
|
1158 | yyloc = lexer.yylloc;
|
1159 | if (recovering > 0) {
|
1160 | recovering--;
|
1161 | }
|
1162 | } else {
|
1163 | symbol = preErrorSymbol;
|
1164 | preErrorSymbol = null;
|
1165 | }
|
1166 | break;
|
1167 | case 2:
|
1168 | len = this.productions_[action[1]][1];
|
1169 | yyval.$ = vstack[vstack.length - len];
|
1170 | yyval._$ = {
|
1171 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
1172 | last_line: lstack[lstack.length - 1].last_line,
|
1173 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
1174 | last_column: lstack[lstack.length - 1].last_column
|
1175 | };
|
1176 | if (ranges) {
|
1177 | yyval._$.range = [
|
1178 | lstack[lstack.length - (len || 1)].range[0],
|
1179 | lstack[lstack.length - 1].range[1]
|
1180 | ];
|
1181 | }
|
1182 | r = this.performAction.apply(yyval, [
|
1183 | yytext,
|
1184 | yyleng,
|
1185 | yylineno,
|
1186 | sharedState.yy,
|
1187 | action[1],
|
1188 | vstack,
|
1189 | lstack
|
1190 | ].concat(args));
|
1191 | if (typeof r !== 'undefined') {
|
1192 | return r;
|
1193 | }
|
1194 | if (len) {
|
1195 | stack = stack.slice(0, -1 * len * 2);
|
1196 | vstack = vstack.slice(0, -1 * len);
|
1197 | lstack = lstack.slice(0, -1 * len);
|
1198 | }
|
1199 | stack.push(this.productions_[action[1]][0]);
|
1200 | vstack.push(yyval.$);
|
1201 | lstack.push(yyval._$);
|
1202 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
1203 | stack.push(newState);
|
1204 | break;
|
1205 | case 3:
|
1206 | return true;
|
1207 | }
|
1208 | }
|
1209 | return true;
|
1210 | }};
|
1211 |
|
1212 | var lexer = (function(){
|
1213 | var lexer = ({
|
1214 |
|
1215 | EOF:1,
|
1216 |
|
1217 | parseError:function parseError(str, hash) {
|
1218 | if (this.yy.parser) {
|
1219 | this.yy.parser.parseError(str, hash);
|
1220 | } else {
|
1221 | throw new Error(str);
|
1222 | }
|
1223 | },
|
1224 |
|
1225 |
|
1226 | setInput:function (input, yy) {
|
1227 | this.yy = yy || this.yy || {};
|
1228 | this._input = input;
|
1229 | this._more = this._backtrack = this.done = false;
|
1230 | this.yylineno = this.yyleng = 0;
|
1231 | this.yytext = this.matched = this.match = '';
|
1232 | this.conditionStack = ['INITIAL'];
|
1233 | this.yylloc = {
|
1234 | first_line: 1,
|
1235 | first_column: 0,
|
1236 | last_line: 1,
|
1237 | last_column: 0
|
1238 | };
|
1239 | if (this.options.ranges) {
|
1240 | this.yylloc.range = [0,0];
|
1241 | }
|
1242 | this.offset = 0;
|
1243 | return this;
|
1244 | },
|
1245 |
|
1246 |
|
1247 | input:function () {
|
1248 | var ch = this._input[0];
|
1249 | this.yytext += ch;
|
1250 | this.yyleng++;
|
1251 | this.offset++;
|
1252 | this.match += ch;
|
1253 | this.matched += ch;
|
1254 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
1255 | if (lines) {
|
1256 | this.yylineno++;
|
1257 | this.yylloc.last_line++;
|
1258 | } else {
|
1259 | this.yylloc.last_column++;
|
1260 | }
|
1261 | if (this.options.ranges) {
|
1262 | this.yylloc.range[1]++;
|
1263 | }
|
1264 |
|
1265 | this._input = this._input.slice(1);
|
1266 | return ch;
|
1267 | },
|
1268 |
|
1269 |
|
1270 | unput:function (ch) {
|
1271 | var len = ch.length;
|
1272 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
1273 |
|
1274 | this._input = ch + this._input;
|
1275 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
1276 |
|
1277 | this.offset -= len;
|
1278 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
1279 | this.match = this.match.substr(0, this.match.length - 1);
|
1280 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
1281 |
|
1282 | if (lines.length - 1) {
|
1283 | this.yylineno -= lines.length - 1;
|
1284 | }
|
1285 | var r = this.yylloc.range;
|
1286 |
|
1287 | this.yylloc = {
|
1288 | first_line: this.yylloc.first_line,
|
1289 | last_line: this.yylineno + 1,
|
1290 | first_column: this.yylloc.first_column,
|
1291 | last_column: lines ?
|
1292 | (lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
1293 | + oldLines[oldLines.length - lines.length].length - lines[0].length :
|
1294 | this.yylloc.first_column - len
|
1295 | };
|
1296 |
|
1297 | if (this.options.ranges) {
|
1298 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
1299 | }
|
1300 | this.yyleng = this.yytext.length;
|
1301 | return this;
|
1302 | },
|
1303 |
|
1304 |
|
1305 | more:function () {
|
1306 | this._more = true;
|
1307 | return this;
|
1308 | },
|
1309 |
|
1310 |
|
1311 | reject:function () {
|
1312 | if (this.options.backtrack_lexer) {
|
1313 | this._backtrack = true;
|
1314 | } else {
|
1315 | return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
1316 | text: "",
|
1317 | token: null,
|
1318 | line: this.yylineno
|
1319 | });
|
1320 |
|
1321 | }
|
1322 | return this;
|
1323 | },
|
1324 |
|
1325 |
|
1326 | less:function (n) {
|
1327 | this.unput(this.match.slice(n));
|
1328 | },
|
1329 |
|
1330 |
|
1331 | pastInput:function () {
|
1332 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
1333 | return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
1334 | },
|
1335 |
|
1336 |
|
1337 | upcomingInput:function () {
|
1338 | var next = this.match;
|
1339 | if (next.length < 20) {
|
1340 | next += this._input.substr(0, 20-next.length);
|
1341 | }
|
1342 | return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
1343 | },
|
1344 |
|
1345 |
|
1346 | showPosition:function () {
|
1347 | var pre = this.pastInput();
|
1348 | var c = new Array(pre.length + 1).join("-");
|
1349 | return pre + this.upcomingInput() + "\n" + c + "^";
|
1350 | },
|
1351 |
|
1352 |
|
1353 | test_match:function (match, indexed_rule) {
|
1354 | var token,
|
1355 | lines,
|
1356 | backup;
|
1357 |
|
1358 | if (this.options.backtrack_lexer) {
|
1359 |
|
1360 | backup = {
|
1361 | yylineno: this.yylineno,
|
1362 | yylloc: {
|
1363 | first_line: this.yylloc.first_line,
|
1364 | last_line: this.last_line,
|
1365 | first_column: this.yylloc.first_column,
|
1366 | last_column: this.yylloc.last_column
|
1367 | },
|
1368 | yytext: this.yytext,
|
1369 | match: this.match,
|
1370 | matches: this.matches,
|
1371 | matched: this.matched,
|
1372 | yyleng: this.yyleng,
|
1373 | offset: this.offset,
|
1374 | _more: this._more,
|
1375 | _input: this._input,
|
1376 | yy: this.yy,
|
1377 | conditionStack: this.conditionStack.slice(0),
|
1378 | done: this.done
|
1379 | };
|
1380 | if (this.options.ranges) {
|
1381 | backup.yylloc.range = this.yylloc.range.slice(0);
|
1382 | }
|
1383 | }
|
1384 |
|
1385 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
1386 | if (lines) {
|
1387 | this.yylineno += lines.length;
|
1388 | }
|
1389 | this.yylloc = {
|
1390 | first_line: this.yylloc.last_line,
|
1391 | last_line: this.yylineno + 1,
|
1392 | first_column: this.yylloc.last_column,
|
1393 | last_column: lines ?
|
1394 | lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
1395 | this.yylloc.last_column + match[0].length
|
1396 | };
|
1397 | this.yytext += match[0];
|
1398 | this.match += match[0];
|
1399 | this.matches = match;
|
1400 | this.yyleng = this.yytext.length;
|
1401 | if (this.options.ranges) {
|
1402 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
1403 | }
|
1404 | this._more = false;
|
1405 | this._backtrack = false;
|
1406 | this._input = this._input.slice(match[0].length);
|
1407 | this.matched += match[0];
|
1408 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
1409 | if (this.done && this._input) {
|
1410 | this.done = false;
|
1411 | }
|
1412 | if (token) {
|
1413 | return token;
|
1414 | } else if (this._backtrack) {
|
1415 |
|
1416 | for (var k in backup) {
|
1417 | this[k] = backup[k];
|
1418 | }
|
1419 | return false;
|
1420 | }
|
1421 | return false;
|
1422 | },
|
1423 |
|
1424 |
|
1425 | next:function () {
|
1426 | if (this.done) {
|
1427 | return this.EOF;
|
1428 | }
|
1429 | if (!this._input) {
|
1430 | this.done = true;
|
1431 | }
|
1432 |
|
1433 | var token,
|
1434 | match,
|
1435 | tempMatch,
|
1436 | index;
|
1437 | if (!this._more) {
|
1438 | this.yytext = '';
|
1439 | this.match = '';
|
1440 | }
|
1441 | var rules = this._currentRules();
|
1442 | for (var i = 0; i < rules.length; i++) {
|
1443 | tempMatch = this._input.match(this.rules[rules[i]]);
|
1444 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
1445 | match = tempMatch;
|
1446 | index = i;
|
1447 | if (this.options.backtrack_lexer) {
|
1448 | token = this.test_match(tempMatch, rules[i]);
|
1449 | if (token !== false) {
|
1450 | return token;
|
1451 | } else if (this._backtrack) {
|
1452 | match = false;
|
1453 | continue;
|
1454 | } else {
|
1455 |
|
1456 | return false;
|
1457 | }
|
1458 | } else if (!this.options.flex) {
|
1459 | break;
|
1460 | }
|
1461 | }
|
1462 | }
|
1463 | if (match) {
|
1464 | token = this.test_match(match, rules[index]);
|
1465 | if (token !== false) {
|
1466 | return token;
|
1467 | }
|
1468 |
|
1469 | return false;
|
1470 | }
|
1471 | if (this._input === "") {
|
1472 | return this.EOF;
|
1473 | } else {
|
1474 | return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
1475 | text: "",
|
1476 | token: null,
|
1477 | line: this.yylineno
|
1478 | });
|
1479 | }
|
1480 | },
|
1481 |
|
1482 |
|
1483 | lex:function lex() {
|
1484 | var r = this.next();
|
1485 | if (r) {
|
1486 | return r;
|
1487 | } else {
|
1488 | return this.lex();
|
1489 | }
|
1490 | },
|
1491 |
|
1492 |
|
1493 | begin:function begin(condition) {
|
1494 | this.conditionStack.push(condition);
|
1495 | },
|
1496 |
|
1497 |
|
1498 | popState:function popState() {
|
1499 | var n = this.conditionStack.length - 1;
|
1500 | if (n > 0) {
|
1501 | return this.conditionStack.pop();
|
1502 | } else {
|
1503 | return this.conditionStack[0];
|
1504 | }
|
1505 | },
|
1506 |
|
1507 |
|
1508 | _currentRules:function _currentRules() {
|
1509 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
1510 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
1511 | } else {
|
1512 | return this.conditions["INITIAL"].rules;
|
1513 | }
|
1514 | },
|
1515 |
|
1516 |
|
1517 | topState:function topState(n) {
|
1518 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
1519 | if (n >= 0) {
|
1520 | return this.conditionStack[n];
|
1521 | } else {
|
1522 | return "INITIAL";
|
1523 | }
|
1524 | },
|
1525 |
|
1526 |
|
1527 | pushState:function pushState(condition) {
|
1528 | this.begin(condition);
|
1529 | },
|
1530 |
|
1531 |
|
1532 | stateStackSize:function stateStackSize() {
|
1533 | return this.conditionStack.length;
|
1534 | },
|
1535 | options: {},
|
1536 | performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
1537 | var YYSTATE=YY_START;
|
1538 | switch($avoiding_name_collisions) {
|
1539 | case 0:
|
1540 | break;
|
1541 | case 1:return 6
|
1542 | break;
|
1543 | case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
|
1544 | break;
|
1545 | case 3:return 17
|
1546 | break;
|
1547 | case 4:return 18
|
1548 | break;
|
1549 | case 5:return 23
|
1550 | break;
|
1551 | case 6:return 24
|
1552 | break;
|
1553 | case 7:return 22
|
1554 | break;
|
1555 | case 8:return 21
|
1556 | break;
|
1557 | case 9:return 10
|
1558 | break;
|
1559 | case 10:return 11
|
1560 | break;
|
1561 | case 11:return 8
|
1562 | break;
|
1563 | case 12:return 14
|
1564 | break;
|
1565 | case 13:return 'INVALID'
|
1566 | break;
|
1567 | }
|
1568 | },
|
1569 | rules: [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt\/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],
|
1570 | conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}}
|
1571 | });
|
1572 | return lexer;
|
1573 | })();
|
1574 | parser.lexer = lexer;
|
1575 | function Parser () {
|
1576 | this.yy = {};
|
1577 | }
|
1578 | Parser.prototype = parser;parser.Parser = Parser;
|
1579 | return new Parser;
|
1580 | })();
|
1581 |
|
1582 |
|
1583 | if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
1584 | exports.parser = jsonlint;
|
1585 | exports.Parser = jsonlint.Parser;
|
1586 | exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); };
|
1587 | exports.main = function commonjsMain(args) {
|
1588 | if (!args[1]) {
|
1589 | console.log('Usage: '+args[0]+' FILE');
|
1590 | process.exit(1);
|
1591 | }
|
1592 | var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
1593 | return exports.parser.parse(source);
|
1594 | };
|
1595 | if (typeof module !== 'undefined' && require.main === module) {
|
1596 | exports.main(process.argv.slice(1));
|
1597 | }
|
1598 | }
|
1599 | }).call(this,require('_process'))
|
1600 | },{"_process":5,"fs":3,"path":4}],7:[function(require,module,exports){
|
1601 | var jsonlint = require('jsonlint-lines'),
|
1602 | geojsonHintObject = require('./object');
|
1603 |
|
1604 |
|
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 | function hint(str, options) {
|
1616 |
|
1617 | var gj, errors = [];
|
1618 |
|
1619 | if (typeof str === 'object') {
|
1620 | gj = str;
|
1621 | } else if (typeof str === 'string') {
|
1622 | try {
|
1623 | gj = jsonlint.parse(str);
|
1624 | } catch(e) {
|
1625 | var match = e.message.match(/line (\d+)/);
|
1626 | var lineNumber = parseInt(match[1], 10);
|
1627 | return [{
|
1628 | line: lineNumber - 1,
|
1629 | message: e.message,
|
1630 | error: e
|
1631 | }];
|
1632 | }
|
1633 | } else {
|
1634 | return [{
|
1635 | message: 'Expected string or object as input',
|
1636 | line: 0
|
1637 | }];
|
1638 | }
|
1639 |
|
1640 | errors = errors.concat(geojsonHintObject.hint(gj, options));
|
1641 |
|
1642 | return errors;
|
1643 | }
|
1644 |
|
1645 | module.exports.hint = hint;
|
1646 |
|
1647 | },{"./object":1,"jsonlint-lines":6}]},{},[7])(7)
|
1648 | }); |
\ | No newline at end of file |