{"id":27263,"library":"psharp-js","title":"P#-JS","description":"An implementation of the P# programming language in JavaScript, including a transpiler from P# to JavaScript. Currently at version 0.1.0, this package provides tools to translate P# code (a probabilistic programming language) into executable JavaScript. As an early-stage release, it has limited documentation and may contain bugs. Key differentiators: it enables running P# programs in Node.js or browser environments, leveraging JavaScript's ecosystem. However, it is experimental and not suitable for production use.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install psharp-js","lang":"bash","label":"npm"},{"cmd":"yarn add psharp-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add psharp-js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is not available; use named import.","wrong":"import transpile from 'psharp-js'","symbol":"transpile","correct":"import { transpile } from 'psharp-js'"},{"note":"ESM-only; no CommonJS support in v0.1.0.","wrong":"const { run } = require('psharp-js');","symbol":"run","correct":"import { run } from 'psharp-js'"},{"note":"Version constant is exported from main entry, not a subpath.","wrong":"import { VERSION } from 'psharp-js/core'","symbol":"PSHARP_VERSION","correct":"import { VERSION } from 'psharp-js'"}],"quickstart":{"code":"import { transpile, run } from 'psharp-js';\n\n// Example P# code\nconst psharpCode = `\ndef main() {\n  x = sample Bernoulli(0.5);\n  return x;\n}\n`;\n\n// Transpile to JavaScript\nconst jsCode = transpile(psharpCode);\nconsole.log('Transpiled code:', jsCode);\n\n// Run the transpiled code (requires a random number generator environment)\nconst result = run(jsCode);\nconsole.log('Result:', result);\n","lang":"typescript","description":"Transpile a simple P# program with a Bernoulli sample and execute the resulting JavaScript code."},"warnings":[{"fix":"Pin to specific version and test thoroughly before upgrading.","message":"API changes may occur without notice as the package is pre-1.0.0.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"None.","message":"No deprecated features currently; all features are preliminary.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Run in a sandboxed environment or only use trusted sources.","message":"Transpiled code may not be secure; avoid running untrusted P# input.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import statements or set type: 'module' in package.json.","cause":"Using CommonJS require() on an ESM-only package.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Use import { transpile } from 'psharp-js'.","cause":"Incorrect import style (default import instead of named import).","error":"TypeError: transpile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}