{"_id":"@adrianheine/test262-parser","_rev":"2-7ff28592c78f2f9c28aca49ea8d71503","name":"@adrianheine/test262-parser","dist-tags":{"latest":"2.1.0"},"versions":{"2.1.0":{"name":"@adrianheine/test262-parser","version":"2.1.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/adrianheine/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/adrianheine/test262-parser/issues"},"homepage":"https://github.com/adrianheine/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":"6c0c98b2b7a1e5278f44980b56af4aa165392800","_id":"@adrianheine/test262-parser@2.1.0","_npmVersion":"5.8.0","_nodeVersion":"10.15.1","_npmUser":{"name":"adrianheine","email":"mail@adrianheine.de"},"dist":{"integrity":"sha512-E0e7Re/WKiONVl3e1haJpKKhloIqCFfetTh9+ovZbX73X7Aei8G0qQd636TP7JRE2EpOxkn1W9eALAq0yBee/Q==","shasum":"18c429d6d9a6b773a442a3f5d48c131d3a68c3c9","tarball":"https://registry.npmjs.org/@adrianheine/test262-parser/-/test262-parser-2.1.0.tgz","fileCount":16,"unpackedSize":22057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJccv0uCRA9TVsSAnZWagAAmTIQAJAELS3IfyM92mIhs0gJ\naVsMlkCLSJJzC5yIFDw3zGpvi4LKF/56nbTy54B4pdXTsrOZl/+YgK/qQJgP\nYgIK5AovRAQETyEBILfoAYpO5vDToSmGyRcisnS55M7CJvvtjusGt+Je3LBl\nwbl3mhFM4TgLl4IqLBjMr7dPZSOmHTOHVZ9772uKgqJUOTji+++y4KFYeEAX\nkWxTDOdU8jttofm1VbWV+gtN8WtKKtb0FHTxTxO1WaDhINa/28pJvZ7IG8Uo\n1OTrAUB7mMc3wRi8yddJN98jwTbrURilX4qh1yWjeIYSV0FegmyJ1LB11Grk\nCFaZuwu8XDUTJyFHun84deEtfaCeuIQ2eN/ulh6hddk928wTFQy69v2jrFUo\nmVCCwQg4y3PA2ASeUX48ikafZwsHzwaXZNWPhmHZtXVFpcOzwHLTtuvyIoKD\nHLHo8J6GxFQF1nbFS27kAErqmANLwo36uQg1ikdOWsKoo9b8TqIi+xIrlLrI\nxAufqCSy11q0zF5MPn7LvsLHdnjZiVClFOpNS1btB9tQpswqiUDsyAZ5oUXW\n9cOHyMOPcqUEgwwrsgT2Cg6IIQcIIIC//zhqO41P3tzz/Nw72Rl164AlnbxF\nKirJZzxKrNdjyF6oJv8f2dSJLim7jXa6X5dHxmkEFGb10A5RTl0ibhdfoqSP\nP8ES\r\n=VzN6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/KZlxEI2Fpova+fBLXlllZ2bEQ0OiJXHE/aB8iuZuqQIgcg+emjGk3J5i62PiipRAau+mmSYU71ZaBvKIstKhPJ0="}]},"maintainers":[{"name":"adrianheine","email":"mail@adrianheine.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/test262-parser_2.1.0_1551039789580_0.2827447191171979"},"_hasShrinkwrap":false,"deprecated":"Keep using test262-parser"}},"time":{"created":"2019-02-24T20:23:09.181Z","2.1.0":"2019-02-24T20:23:09.718Z","modified":"2022-04-04T11:37:11.765Z"},"maintainers":[{"name":"adrianheine","email":"mail@adrianheine.de"}],"description":"Parse a test262-format test and provide API","homepage":"https://github.com/adrianheine/test262-parser","keywords":["test262","es6","tc39","unit","test"],"repository":{"type":"git","url":"git+https://github.com/adrianheine/test262-parser.git"},"contributors":[{"name":"Sam Mikes"},{"name":"Adrian Heine"}],"author":{"name":"Brian Terlson"},"bugs":{"url":"https://github.com/adrianheine/test262-parser/issues"},"license":"MSFT MIT-like","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('@adrianheine/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('@adrianheine/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('@adrianheine/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","readmeFilename":"README.md"}