catharsis
Advanced tools
Comparing version 0.7.0 to 0.7.1
{ | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"name": "catharsis", | ||
@@ -4,0 +4,0 @@ "description": "A JavaScript parser for Google Closure Compiler and JSDoc type expressions.", |
@@ -19,34 +19,28 @@ # Catharsis # | ||
var catharsis = require('catharsis'); | ||
```js | ||
var catharsis = require('catharsis'); | ||
var type; | ||
var jsdocType; | ||
var parsedType; | ||
var parsedJsdocType; | ||
// Google Closure Compiler parsing | ||
var type = '!Object'; | ||
var parsedType; | ||
try { | ||
parsedType = catharsis.parse(type); // {"type":"NameExpression,"name":"Object","nullable":false} | ||
} catch(e) { | ||
console.error('unable to parse %s: %s', type, e); | ||
} | ||
// Google Closure Compiler parsing | ||
try { | ||
type = '!Object'; | ||
parsedType = catharsis.parse(type); | ||
console.log('%j', parsedType); // {"type":"NameExpression,"name":"Object","nullable":false} | ||
} | ||
catch(e) { | ||
console.error('unable to parse %s: %s', type, e); | ||
} | ||
// JSDoc-style type expressions enabled | ||
var jsdocType = 'string[]'; // Closure Compiler expects Array.<string> | ||
var parsedJsdocType; | ||
try { | ||
parsedJsdocType = catharsis.parse(jsdocType, {jsdoc: true}); | ||
} catch (e) { | ||
console.error('unable to parse %s: %s', jsdocType, e); | ||
} | ||
// JSDoc-style type expressions enabled | ||
try { | ||
jsdocType = 'string[]'; // Closure Compiler expects Array.<string> | ||
parsedJsdocType = catharsis.parse(jsdocType, {jsdoc: true}); | ||
} | ||
catch (e) { | ||
console.error('unable to parse %s: %s', jsdocType, e); | ||
} | ||
catharsis.stringify(parsedType); // !Object | ||
catharsis.stringify(parsedJsdocType); // string[] | ||
catharsis.stringify(parsedJsdocType, {restringify: true}); // Array.<string> | ||
``` | ||
console.log(catharsis.stringify(parsedType)); // !Object | ||
console.log(catharsis.stringify(parsedJsdocType)); // string[] | ||
console.log(catharsis.stringify(parsedJsdocType, // Array.<string> | ||
{restringify: true})); | ||
See the `test/specs/` directory for more examples of Catharsis' parse results. | ||
@@ -149,2 +143,4 @@ | ||
+ 0.7.1 (April 2014): In record types, property names that begin with a keyword (for example, | ||
`undefinedHTML`) are now parsed correctly when JSDoc-style type expressions are enabled. | ||
+ 0.7.0 (October 2013): | ||
@@ -151,0 +147,0 @@ + Repeatable type expressions other than name expressions (for example, `...function()`) are now |
Sorry, the diff of this file is too big to display
187967
236