graphql-tag
Advanced tools
Comparing version 0.1.13 to 0.1.14
36
index.js
@@ -5,2 +5,36 @@ var parse = require('./parser').parse; | ||
function stripLoc(doc) { | ||
var docType = Object.prototype.toString.call(doc); | ||
if (docType === '[object Array]') { | ||
return doc.map(stripLoc); | ||
} | ||
if (docType !== '[object Object]') { | ||
throw new Error('Unexpected input.'); | ||
} | ||
if (doc.loc) { | ||
delete doc.loc; | ||
} | ||
var keys = Object.keys(doc); | ||
var key; | ||
var value; | ||
var valueType; | ||
for (key in keys) { | ||
if (keys.hasOwnProperty(key)) { | ||
value = doc[keys[key]]; | ||
valueType = Object.prototype.toString.call(value); | ||
if (valueType === '[object Object]' || valueType === '[object Array]') { | ||
doc[keys[key]] = stripLoc(value); | ||
} | ||
} | ||
} | ||
return doc; | ||
} | ||
function parseDocument(doc) { | ||
@@ -17,2 +51,4 @@ if (cache[doc]) { | ||
parsed = stripLoc(parsed); | ||
cache[doc] = parsed; | ||
@@ -19,0 +55,0 @@ |
{ | ||
"name": "graphql-tag", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "A JavaScript template literal tag that parses GraphQL queries", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"compile": "webpack", | ||
"test": "mocha --require babel-register" | ||
"test": "mocha" | ||
}, | ||
@@ -27,3 +27,2 @@ "repository": { | ||
"graphql": "^0.6.0", | ||
"lodash": "^4.13.1", | ||
"mocha": "^2.5.3", | ||
@@ -30,0 +29,0 @@ "webpack": "^1.13.1" |
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
185583
6
5308