{"name":"test262-parser","version":"2.0.0","description":"Parse a test262-format test and provide API","main":"lib/parser.js","scripts":{"test":"mocha","cover":"istanbul cover --root lib --print=both -- node_modules/mocha/bin/_mocha","lint":"jslint --terse lib/*.js test/*.js","doc":"yuidoc","mypublish":"npm run-script doc; npm publish"},"repository":{"type":"git","url":"https://github.com/smikes/test262-parser.git"},"keywords":["test262","es6","tc39","unit","test"],"author":{"name":"Brian Terlson"},"contributors":[{"name":"Sam Mikes"}],"license":"MSFT MIT-like","directories":["lib","doc"],"bugs":{"url":"https://github.com/smikes/test262-parser/issues"},"homepage":"https://github.com/smikes/test262-parser","devDependencies":{"istanbul":"^0.3.2","jslint":"^0.6.2","mocha":"^2.0.1","yuidocjs":"^0.4.0"},"dependencies":{"js-yaml":"^3.2.1","through":"^2.3.4"},"gitHead":"cf1eb73b35c6e36f054a5107517accc1ccd5d0d0","_id":"test262-parser@2.0.0","_shasum":"41ae6eace9b35eeaf979f1f0a04f0cbb22e4b0e4","_from":".","_npmVersion":"2.1.8","_nodeVersion":"0.11.14","_npmUser":{"name":"smikes","email":"smikes@cubane.com"},"maintainers":[{"name":"smikes","email":"smikes@cubane.com"},{"name":"bterlson","email":"brian.terlson@microsoft.com"}],"dist":{"shasum":"41ae6eace9b35eeaf979f1f0a04f0cbb22e4b0e4","tarball":"http://registry-npm.ywwl.com/test262-parser/download/test262-parser-2.0.0.tgz","integrity":"sha512-DIpNMSsKROYTr+R5gt7SqlVVWpNZaPAqFw6rnOBwKn5gWhv+0jsdq+fM3ov09uZi/U6ck8t5DqZqO/LaZ8CZ6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwqnjuipLls/gaGPLckH9uv/6jVnscL/u8cYzuwJB0JQIgI5gGlm7C3bNOnqib5yNDER5aQKl87O1KF0pstknHuew="}],"size":6361,"noattachment":false,"key":"/test262-parser/-/test262-parser-2.0.0.tgz"},"readme":"# Parse test262 test files\n\nThis package will allow you to parse [test262](https://github.com/tc39/test262/) test files into their component pieces, for further use and manipulation.\n\n## API\n\n### parseFile\n\nThe simplest function exported by this module is `parseFile`, which expects either a string representing the file contents, or an object with members `file` and `contents`, which are strings containing the filename and contents respectively.\n\nThe result of parseFile is an object `f` with (at least) a `contents` member.\n\nIf the input to parseFile contains the special YAML frontmatter comments `/*---` `---*/`, then the following things are done:\n\n1. the copyright message is stored in `f.copyright`\n2. the YAML frontmatter is parsed and stored as an object, `f.attrs`\n3. the test's async status (`true`/`false`) is stored in `f.async`\n4. `f.contents` is **modified** to contain only the text following the YAML closer comment `---*/`\n\nIf the input does not contain YAML frontmatter, some of the above parsing is still attempted but the `f.contents` member will **remain unchanged**.  This provides backwards compatibility to `test262-runner` which uses `parseFile` to parse test helpers as well as test files.\n\n#### parseFile examples\n\n```js\n'use strict';\nvar fs = require('fs');\nvar test262Parser = require('test262-parser');\n\nvar rawTest = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');\n\n// Pass in file object and it will be mutated with parsed data:\nvar file = {\n    file: 'built-ins/Array/prototype/includes/array-like.js',\n    contents: rawTest\n};\n\ntest262Parser.parseFile(file);\n// `file` now has `attrs`, `async`, and `copyright` properties, with `contents` modified\n\nconsole.log(file.attrs);\n// Outputs normalized attributes from the YAML front-matter:\n// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#frontmatter\n\nconsole.log(file.async);\n// Outputs `true` or `false` depending on whether the test is async:\n// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#writing-asynchronous-tests\n\nconsole.log(file.copyright);\n// Outputs the copyright header:\n// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#copyright\n\nconsole.log(file.contents);\n// Outputs the main test body, without the copyright or YAML front-matter.\n\n// You can also parse test contents directly; it will create a file object\nvar parsedFile = test262Parser.parseFile(rawTest);\n\nconsole.log(parsedFile.file);      // '<unknown>'\nconsole.log(parsedFile.contents);  // the main test body\nconsole.log(parsedFile.copyright); // the copyright header\nconsole.log(parsedFile.attrs);     // the normalized attributes\nconsoel.log(parsedFile.async);     // whether or not the test is async\n```\n\n### extractYAML\n\nThe `extractYAML` function takes a string containing the text contents and returns back the substring that constitutes the YAML front matter:\n\n```js\n'use strict';\nvar fs = require('fs');\nvar test262Parser = require('test262-parser');\n\nvar testContents = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');\n\nvar yaml = test262Parser.extractYAML(testContents);\nconsole.log(yaml);\n```\n\nwill output\n\n```\ndescription: Array.prototype.includes works on array-like objects\nauthor: Domenic Denicola\n```\n\n### Streaming interface\n\nThe default export of the module is a transform stream factory. Every time you write a string or file object to the transform stream, it emits a parsed file object:\n\n```js\n'use strict';\nvar fs = require('fs');\nvar test262Parser = require('test262-parser');\n\nvar transformStream = test262Parser();\ntransformStream.pipe(process.stdout);\n\nvar testContents = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');\ntransformStream.write(testContents);\n```\n\nwill output to `process.stdout` the (stringification of the) file object.\n","publish_time":1417611108861,"_cnpm_publish_time":1417611108861,"dist-tags":{"latest":"2.2.0"}}