
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
test262-parser
Advanced tools
This package will allow you to parse test262 test files into their component pieces, for further use and manipulation.
The simplest function exported by this module is parseFile, which works like so:
'use strict';
var fs = require('fs');
var test262Parser = require('test262-parser');
var testContents = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');
// Pass in file object and it will be mutated with parsed data:
var file = {
file: 'built-ins/Array/prototype/includes/array-like.js',
contents: testContents
};
test262Parser.parseFile(file);
// `file` now has `attrs` and `async` properties
console.log(file.attrs);
// Outputs normalized attributes from the YAML front-matter:
// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#frontmatter
console.log(file.async);
// Outputs `true` or `false` depending on whether the test is async:
// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#writing-asynchronous-tests
console.log(file.copyright);
// Outputs copyright header
// https://github.com/tc39/test262/blob/master/CONTRIBUTING.md#copyright
// You can also parse test contents directly; it will create a file object
var parsedFile = test262Parser.parseFile(testContents);
console.log(parsedFile.file); // '<unknown>'
console.log(parsedFile.contents); // the same as `testContents`
console.log(parsedFile.attrs); // the normalized attributes
consoel.log(parsedFile.async); // whether or not the test is async
The extractYAML function takes a string containing the text contents and returns back the substring that constitutes the YAML front matter:
'use strict';
var fs = require('fs');
var test262Parser = require('test262-parser');
var testContents = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');
var yaml = test262Parser.extractYAML(testContents);
console.log(yaml);
will output
description: Array.prototype.includes works on array-like objects
author: Domenic Denicola
The 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:
'use strict';
var fs = require('fs');
var test262Parser = require('test262-parser');
var transformStream = test262Parser();
transformStream.pipe(process.stdout);
var testContents = fs.readFileSync('built-ins/Array/prototype/includes/array-like.js');
transformStream.write(testContents);
will output to process.stdout the (stringification of the) file object.
FAQs
Parse a test262-format test and provide API
The npm package test262-parser receives a total of 1,450 weekly downloads. As such, test262-parser popularity was classified as popular.
We found that test262-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.