mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-26 01:43:06 +03:00
45 lines
13 KiB
JSON
45 lines
13 KiB
JSON
|
{
|
||
|
"version": "0.5.6",
|
||
|
"name": "catharsis",
|
||
|
"description": "A JavaScript parser for Google Closure Compiler and JSDoc type expressions.",
|
||
|
"author": {
|
||
|
"name": "Jeff Williams",
|
||
|
"email": "jeffrey.l.williams@gmail.com"
|
||
|
},
|
||
|
"repository": {
|
||
|
"type": "git",
|
||
|
"url": "https://github.com/hegemonic/catharsis"
|
||
|
},
|
||
|
"bugs": "https://github.com/hegemonic/catharsis/issues",
|
||
|
"main": "catharsis.js",
|
||
|
"devDependencies": {
|
||
|
"mocha": "1.6.0",
|
||
|
"pegjs": "git+ssh://git@github.com:dmajda/pegjs.git#76cc5d55",
|
||
|
"should": "1.2.2",
|
||
|
"uglify-js": "2.2.5",
|
||
|
"underscore": "1.4.4"
|
||
|
},
|
||
|
"engines": {
|
||
|
"node": ">= 0.6"
|
||
|
},
|
||
|
"scripts": {
|
||
|
"build": "pegjs ./lib/parser.pegjs",
|
||
|
"prepublish": "pegjs ./lib/parser.pegjs; uglifyjs ./lib/parser.js -o ./lib/parser.js",
|
||
|
"test": "mocha"
|
||
|
},
|
||
|
"licenses": [
|
||
|
{
|
||
|
"type": "MIT",
|
||
|
"url": "http://github.com/hegemonic/catharsis/raw/master/LICENSE"
|
||
|
}
|
||
|
],
|
||
|
"readme": "# Catharsis #\n\nA JavaScript parser for\n[Google Closure Compiler](https://developers.google.com/closure/compiler/docs/js-for-compiler#types)\nand [JSDoc](https://github.com/jsdoc3/jsdoc) type expressions.\n\nCatharsis is designed to be:\n\n+ **Accurate**. Catharsis is based on a [PEG.js](http://pegjs.majda.cz/) grammar that's designed to\nhandle any valid type expression. It uses a [Mocha](http://visionmedia.github.com/mocha/) test suite\nto verify the parser's accuracy.\n+ **Fast**. Parse results are cached, so the parser is invoked only when necessary.\n+ **Flexible**. Catharsis can convert parse results back into type expressions. In addition, it can\nparse [JSDoc](https://github.com/jsdoc3/jsdoc)-style type expressions.\n\n\n## Example ##\n\n\tvar catharsis = require('catharsis');\n\n var type;\n var jsdocType;\n var parsedType;\n var parsedJsdocType;\n\n // Google Closure Compiler parsing\n try {\n type = '!Object';\n parsedType = catharsis.parse(type);\n console.log('%j', parsedType); // {\"type\":\"NameExpression,\"name\":\"Object\",\"nullable\":false}\n }\n catch(e) {\n console.error('unable to parse %s: %s', type, e);\n }\n\n // JSDoc-style type expressions enabled\n try {\n jsdocType = 'string[]'; // Closure Compiler expects Array.<string>\n parsedJsdocType = catharsis.parse(jsdocType, {jsdoc: true});\n }\n catch (e) {\n console.error('unable to parse %s: %s', jsdocType, e);\n }\n\n console.log(catharsis.stringify(parsedType)); // !Object\n console.log(catharsis.stringify(parsedJsdocType)); // string[]\n console.log(catharsis.stringify(parsedJsdocType, // Array.<string>\n {restringify: true}));\n\n\nSee the `test/specs/` directory for more examples of Catharsis' parse results.\n\n\n## Methods ##\n\n### parse(typeExpression, options) ###\nParse `typeExpression`, and return the parse results. Throws an error if the type expression cannot\nbe parsed.\n\nWhen called without options, Catharsis attempts to parse type expressions in the same way as\nClosure Compiler. When the `jsdoc` option is enabled, Catharsis can also parse several kinds of\ntype expressions that are permitted in [JSDoc](https://github.com/jsdoc3/jsdoc):\n\n+ The string `function` is treated as a function type with no parameters.\n+ In a function type with repeatable parameters, the names of repeatable parameters are not required\nto be enclosed in square brackets (for example, `function(...foo)` is allowed).\n+ The period may be omitted from type applications. For example, `Array.<string>` and\n`Array<string>` will be parsed in the same way.\n+ You may append `[]` to a name expression (for example, `string[]`) to interpret it as a type\napplication with the expression `Array` (for example, `Array.<string>`).\n+ Name expressions may contain the characters `#`, `~`, `:`, and `/`.\n+ Name expressions may contain a suffix that is similar to a function signature (for example,\n`MyClass(foo, bar)`).\n+ Name expressions may contain a reserved word.\n+ Record types may use types other than name expressions for keys.\n\n#### Parameters ####\n+ `type`: A string containing a Closure Compiler type expression.\n+ `options`: Options for parsing the type expression.\n + `options.jsdoc`: Specifies whether to enable parsing of JSDoc-style type expressions. Defaults\n to `false`.\n + `options.useCache`: Specifies whether to use the cache of parsed types. Defaults to `true`.\n\n#### Returns ####\nAn object containing the parse results. See the `test/specs/` directory for examples of the parse\nresults for different type expressions.\n\nThe object also includes two non-enumerable properties:\n\n+ `jsdoc`: A boolean indicating whether the type expression was parsed with JSDoc support enabled.\n+ `typeExpression`: A string containing the type expression that was parsed.\n\n### stringify(parsedType, options) ###\nStringify `parsedType`, and return the type expression. If validation is enabled, throws an error if\nthe stringified
|
||
|
"readmeFilename": "README.md",
|
||
|
"_id": "catharsis@0.5.6",
|
||
|
"dist": {
|
||
|
"shasum": "210a0cfa23c5d09fa994d6fafe1a76383c170cbb"
|
||
|
},
|
||
|
"_from": "catharsis@0.5.6",
|
||
|
"_resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.5.6.tgz"
|
||
|
}
|