sdf-parser is a JavaScript/TypeScript library designed to parse Structure-Data File (SDF) format files, which are commonly used in cheminformatics to represent chemical structures and associated data. It efficiently converts the content of SDF files into an array of JavaScript objects, where each object represents a chemical entry including its molfile and associated data fields. The current stable version is 8.0.0. The package maintains an active release cadence, with frequent updates. Key features include robust parsing with options for field inclusion/exclusion, custom data transformations via modifiers, and filtering capabilities based on entry properties. For processing large SDF files, it offers an `iterator` API that leverages web streams for memory-efficient handling, compatible with both Node.js and browser environments.
npm install sdf-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both the synchronous `parse` function for smaller SDF strings, including options for filtering and modifying fields, and the asynchronous `iterator` function for efficient processing of larger SDF data via streams, highlighting the `TextDecoderStream` requirement.
Update all `require()` calls to `import` statements (e.g., `const { parse } = require('sdf-parser');` becomes `import { parse } from 'sdf-parser';`). Ensure your project is configured for ESM or use a bundler that supports ESM.When using `iterator`, ensure your stream is processed with `stream.pipeThrough(new TextDecoderStream())`. For example: `for await (const entry of iterator(file.stream().pipeThrough(new TextDecoderStream())))`.
Migrate any usage of the `stream` function to the `iterator` function. The `iterator` function provides an asynchronous iterable interface for processing SDF entries one by one.
For gzipped files, the stream pipeline should look like: `file.stream().pipeThrough(new DecompressionStream('gzip')).pipeThrough(new TextDecoderStream())`.Change `const { symbol } = require('sdf-parser');` to `import { symbol } from 'sdf-parser';` and ensure your project is configured for ES Modules.Modify your stream pipeline to include `pipeThrough(new TextDecoderStream())` before passing it to `iterator`. Example: `iterator(yourStream.pipeThrough(new TextDecoderStream()))`.
Replace calls to the deprecated `stream` function with the `iterator` function. `iterator` provides similar functionality but with an asynchronous iterable interface.
No dependency data recorded yet.