Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use import for code examples in the readme #471

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ different `ConnectionOptions`. At least two of them should work if your internet
is working.

```javascript
const { connect } = require("nats");
import { connect } from "nats";
const servers = [
{},
{ servers: ["demo.nats.io:4442", "demo.nats.io:4222"] },
Expand Down Expand Up @@ -103,7 +103,7 @@ all subscriptions have been drained and all outbound messages have been sent to
the server.

```javascript
const { connect, StringCodec } = require("nats");
import { connect, StringCodec } from "nats";

// to create a connection to a nats-server:
const nc = await connect({ servers: "demo.nats.io:4222" });
Expand Down Expand Up @@ -147,7 +147,7 @@ All subscriptions are independent. If two different subscriptions match a
subject, both will get to process the message:

```javascript
const { connect, StringCodec } = require("nats");
import { connect, StringCodec } from "nats";

const nc = await connect({ servers: "demo.nats.io:4222" });
const sc = StringCodec();
Expand Down Expand Up @@ -201,7 +201,7 @@ simply to illustrate not only how to create responses, but how the subject
itself is used to dispatch different behaviors.

```javascript
const { connect, StringCodec, Subscription } = require("nats");
import { connect, StringCodec, Subscription } from "nats";

// create a connection
const nc = await connect({ servers: "demo.nats.io" });
Expand Down Expand Up @@ -276,7 +276,7 @@ Here's a simple example of a client making a simple request from the service
above:

```javascript
const { connect, StringCodec } = require("nats");
import { connect, StringCodec } from "nats";

// create a connection
const nc = await connect({ servers: "demo.nats.io:4222" });
Expand Down Expand Up @@ -309,11 +309,11 @@ independent unit. Note that non-queue subscriptions are also independent of
subscriptions in a queue group.

```javascript
const {
import {
connect,
NatsConnection,
StringCodec,
} = require("nats");
} from "nats";

async function createService(
name,
Expand Down Expand Up @@ -390,7 +390,7 @@ are publishing a message with a header, it is possible for the recipient to not
support them.

```javascript
const { connect, createInbox, Empty, headers } = require("nats");
import { connect, createInbox, Empty, headers } from "nats";

const nc = await connect(
{
Expand Down Expand Up @@ -475,10 +475,10 @@ that handles the type of authentication specified.
Setting the `user`/`pass` or `token` options, simply initializes an
`Authenticator` and sets the username/password.

```typescript
```javascript
// if the connection requires authentication, provide `user` and `pass` or
// `token` options in the NatsConnectionOptions
const { connect } = require("nats");
import { connect } from "nats";

const nc1 = await connect({
servers: "127.0.0.1:4222",
Expand Down Expand Up @@ -633,7 +633,7 @@ published. The `reply` option can be used to override the generated inbox
subject with an application provided one. Note that setting `reply` requires
`noMux` to be `true`:

```typescript
```javascript
const m = await nc.request(
"q",
Empty,
Expand Down