This package has been deprecated

Author message:

Archived project

@qiskit/qasm

0.9.0 • Public • Published

Qiskit.js OpenQASM

⚛️ Quantum Information Science Kit OpenQASM library.

Please visit the main repository of the project to know about the rest of the tools.

Install

Install lastest Node.js stable version (or LTS) and then:

npm i @qiskit/qasm

Use

📝 You can visit the complete example in this test.

const qasm = require('@qiskit/qasm');
const fs = require('fs');
const util = require('util');

console.log('Version');
console.log(qasm.version);

const parser = new qasm.Parser();

const circuit = fs.readFileSync('./example.qasm', 'utf8');

console.log(util.inspect(parser.parse(circuit), { depth: null }));

API

👀 Full specification.

version

The actual version of the library.

  • version (string) - Version number.

Parser(opts) -> parser

The constructor accepts next option:

  • core (boolean) - To include core libraries. (default: true)

parser.parse(circuit) -> circuitJson

NOTE: Method still partially implemented Get the intermediate representation of the circuit using the OpenQASM parser.

  • circuit (string) - QASM circuit representation.
  • circuitJson (object): The same information in JSON format.

QasmError(msg, opts) -> error

Custom QASM error class.

  • msg (string) - Error message.
  • opts (object) - Optional parameter, including next fields:
    • line (number) - Line number where the error happened.
    • column (number) - Column number where the error happened.
    • text (string) - Text extracted from where the error happened.
    • token (string) - Identifier found where the error happened.
    • expected (string) - Regular expresion for supported values.
  • error (Error) - A common JS error including also next fields:
    • name (string) - Error name ("QasmError").
    • message (string) - Error message.
    • stack (string) - Error stack.
    • From here the same fields that for opts are included.

Package Sidebar

Install

npm i @qiskit/qasm

Weekly Downloads

6

Version

0.9.0

License

Apache-2.0

Unpacked Size

27.7 kB

Total Files

8

Last publish

Collaborators

  • abdonrd
  • atilag
  • dbevenius
  • jelcaf
  • jesusprubio
  • qiskit-team