{ "name": "syntax-error", "version": "0.0.1", "description": "detect and report syntax errors in source code strings", "main": "index.js", "bin": {}, "directories": { "example": "example", "test": "test" }, "dependencies": { "esprima": "~0.9.9" }, "devDependencies": { "tap": "~0.3.0" }, "scripts": { "test": "tap test/*.js" }, "repository": { "type": "git", "url": "git://github.com/substack/node-syntax-error.git" }, "homepage": "https://github.com/substack/node-syntax-error", "keywords": [ "syntax", "error", "esprima", "stack", "line", "column" ], "author": { "name": "James Halliday", "email": "mail@substack.net", "url": "http://substack.net" }, "license": "MIT", "engine": { "node": ">=0.6" }, "readme": "# syntax-error\n\nDetect and report syntax errors in source code strings.\n\n[![build status](https://secure.travis-ci.org/substack/node-syntax-error.png)](http://travis-ci.org/substack/node-syntax-error)\n\nWhen you type `node src.js` you get a friendly error report about exactly where\nthe syntax error is. This module lets you check for syntax errors and report\nthem in a similarly friendly format that wrapping a try/catch around\n`Function()` or `vm.runInNewContext()` doesn't get you.\n\n# example\n\n``` js\nvar fs = require('fs');\nvar check = require('syntax-error');\n\nvar file = __dirname + '/src.js';\nvar src = fs.readFileSync(file);\n\nvar err = check(src, file);\nif (err) {\n console.error('ERROR DETECTED' + Array(62).join('!'));\n console.error(err);\n console.error(Array(76).join('-'));\n}\n```\n\n***\n\n```\n$ node check.js\nERROR DETECTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n/home/substack/projects/node-syntax-error/example/src.js:5\n if (Array.isArray(x) res.push.apply(res, x);\n ^\nParseError: Unexpected identifier\n---------------------------------------------------------------------------\n```\n\n# methods\n\n``` js\nvar check = require('syntax-error')\n```\n\n## var err = check(src, file)\n\nCheck the source code string `src` for syntax errors.\nOptionally you can specify a filename `file` that will show up in the output.\n\nIf `src` has a syntax error, return an error object `err` that can be printed or\nstringified.\n\nIf there are no syntax errors in `src`, return `undefined`.\n\n## err.toString()\n\nReturn the long string description with a source snippet and a `^` under\npointing exactly where the error was detected.\n\n# attributes\n\n## err.message\n\nshort string description of the error type\n\n## err.line\n\nline number of the error in the original source (indexing starts at 1)\n\n## err.column\n\ncolumn number of the error in the original source (indexing starts at 1)\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install syntax-error\n```\n\n# license\n\nMIT\n", "readmeFilename": "readme.markdown", "bugs": { "url": "https://github.com/substack/node-syntax-error/issues" }, "_id": "syntax-error@0.0.1", "dist": { "shasum": "e1c0c31584b28845778fcf888d0c316d90ff04ec" }, "_from": "syntax-error@~0.0.0", "_resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-0.0.1.tgz" }