squiggle/packages/website/docs/Features/Node-Packages.md

37 lines
1.6 KiB
Markdown
Raw Normal View History

2022-02-06 18:40:28 +00:00
---
sidebar_position: 4
2022-04-27 20:28:10 +00:00
title: Node Packages
2022-02-06 18:40:28 +00:00
---
2022-03-25 02:08:46 +00:00
There are two JavaScript packages currently available for Squiggle:
2022-04-10 23:15:46 +00:00
2022-04-27 20:28:10 +00:00
- [`@quri/squiggle-lang`](https://www.npmjs.com/package/@quri/squiggle-lang) ![npm version](https://badge.fury.io/js/@quri%2Fsquiggle-lang.svg)
- [`@quri/squiggle-components`](https://www.npmjs.com/package/@quri/squiggle-components) ![npm version](https://badge.fury.io/js/@quri%2Fsquiggle-components.svg)
2022-02-06 18:40:28 +00:00
2022-03-25 02:08:46 +00:00
Types are available for both packages.
2022-02-09 15:22:51 +00:00
2022-03-25 02:08:46 +00:00
## Squiggle Language
2022-02-09 15:22:51 +00:00
2022-03-25 02:08:46 +00:00
The `@quri/squiggle-lang` package exports a single function, `run`, which given
a string of Squiggle code, will execute the code and return any exports and the
environment created from the squiggle code.
`run` has two optional arguments. The first optional argument allows you to set
sampling settings for Squiggle when representing distributions. The second optional
argument allows you to pass an environment previously created by another `run`
call. Passing this environment will mean that all previously declared variables
in the previous environment will be made available.
2022-04-27 20:51:23 +00:00
The return type of `run` is a bit complicated, and comes from auto generated `js`
2022-04-27 20:28:10 +00:00
code that comes from rescript. We highly recommend using typescript when using
2022-03-25 02:08:46 +00:00
this library to help navigate the return type.
## Squiggle Components
The `@quri/squiggle-components` package offers several components and utilities
for people who want to embed Squiggle components into websites. This documentation
uses `@quri/squiggle-components` frequently.
2022-03-25 02:08:46 +00:00
2022-04-10 23:52:39 +00:00
We host [a storybook](https://squiggle-components.netlify.app/) with details
2022-03-25 02:08:46 +00:00
and usage of each of the components made available.