{"name":"test262-parser","version":"2.2.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":"git+https://github.com/smikes/test262-parser.git"},"keywords":["test262","es6","tc39","unit","test"],"author":{"name":"Brian Terlson"},"contributors":[{"name":"Sam Mikes"},{"name":"Adrian Heine"}],"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.4","jslint":"^0.12","mocha":"^6","yuidocjs":"^0.10"},"dependencies":{"js-yaml":"^3.2.1","through":"^2.3.4"},"gitHead":"d9440456a610ebc5dc9708d1f3d3d59f26e1a332","_id":"test262-parser@2.2.0","_npmVersion":"6.5.0","_nodeVersion":"11.8.0","_npmUser":{"name":"smikes","email":"smikes@cubane.com"},"dist":{"integrity":"sha512-SO5LlFZdnvVAnIHTfh9udDA72ij0gKVi0UcInftz0vSMhg/rXw16XxABXKEmI60ZJFhbVbuJW0/tUJER8DmG3Q==","shasum":"5a723922d04b3409e8da770c1b9cb9197aeab22a","tarball":"http://registry-npm.ywwl.com/test262-parser/download/test262-parser-2.2.0.tgz","fileCount":16,"unpackedSize":21990,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcicn1CRA9TVsSAnZWagAA3XAP/1mjBbT9dMeBWchHo/pz\naZZCUP/Z0a5JAEVUDioP/vl/DFRrBsuyZ9EGgeqyt5wwhHcuxYkaxi7pO2mJ\nWuEKdPOpCHxYVL/njTqj0svK94nOLSoTlk5z7w9UNj8K8clPIB7a65bxL7Fm\nNX9dazrfhYIrAIgbCtdlQ7dLcIdqRaXtsnLhkyJyR5mKVgfHm5jvVbJVwWz1\nXSHAvB5KkyvMybJC0d2z8zqNZTPgCPJE6V6k3gKUvzymc8jdjQPnYRYB2c3W\nqF7i6/rmujPwqHj4GVG5j3KL4l9Ifyo/S/Ym1gpgO5jTp53Q6ANPOyLm0UUA\nT+G/8dy7XpatXkZu44MFL+bI6uJ6OMO/SdNwy4k5dDSUKJl4G6uwXmYVYOj0\nVIpQFrkHPIvomZkmuFLPyvhdPPVHorqwL4YcuIf27KTT6aIlFCOiEScNyNZL\nkpVsJKj6JRW4rfNufLcSawlxFgaWmUAHvQtzgSyIw0s+gBH/IORjSWHHxXAC\nStFXHd+nkBs5uSo2+YyxtauH6qaYB3uYn6NA3csjNehSwFBh25YJDNF5q0mh\nUpnxrb1MmlDqo6TMNXsCP22b8+YJ6tX3XYX6FKYTJSbL+q/rnGeizXvCXgGU\nTtTFt9eAEqMoRu9S0Yait/WIjolwEIuHEQoDf2lAquLqQyksGRAipxCUfGMe\nib8u\r\n=iH6S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+Ag0j/HXHPt6a7+CzXtGWfRhWlX+sEoUt8BuuXkJbYwIgSlT3UKOwkv+6v0MZSRY4SiyOwoRiihbTxddWFc292CU="}],"size":7391,"noattachment":false,"key":"/test262-parser/-/test262-parser-2.2.0.tgz"},"maintainers":[{"email":"brian.terlson@gmail.com","name":"bterlson"},{"email":"waldron.rick@gmail.com","name":"rwaldron"},{"email":"smikes@cubane.com","name":"smikes"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/test262-parser_2.2.0_1552534004610_0.5436695578863247"},"_hasShrinkwrap":false,"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":1552534004728,"_cnpm_publish_time":1552534004728,"dist-tags":{"latest":"2.2.0"}}