# expected-write

> A promise based expect-and-write for child_processes and streams

Latest version **0.0.1** (published 2015-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install expected-write
pnpm add expected-write
yarn add expected-write
bun add expected-write
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-06-24 |
| First published | 2015-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | steelbrain |
| Maintainers | steelbrain |

## Links

- npm: https://www.npmjs.com/package/expected-write
- Repository: https://github.com/steelbrain/Expected-Write
- Homepage: https://github.com/steelbrain/Expected-Write#readme
- Issues: https://github.com/steelbrain/Expected-Write/issues
- npm.io page: https://npm.io/package/expected-write

## Dependencies (1)

- [a-promise](https://npm.io/package/a-promise.md) latest

## Recent versions

- 0.0.1 (latest) — 2015-06-24

## README

Expected-Write
===========
Expected-Write is a tiny Promise-based expect-and-write library. It's super simple to get going with it and it works on all kinds of streams and child processes.

#### SSH Example
```js
var SSHDriver = require('node-ssh')
var ExpectedWrite = require('expected-write')
var SSH = new SSHDriver({
  host: 'localhost',
  username: 'steel',
  privateKey: '/home/steel/.ssh/id_rsa'
})
SSH.connect().then(function(){
  return SSH.requestShell()
}).then(function(SSHShell){
  var E = new ExpectedWrite(SSHShell)
  E.write("sudo echo test\n").expect('[sudo] password')
    .then(function(Content)){
      console.log(Content) // [sudo] password for steel:
      E.write("mySecretPassword")
      return E.expect("test")
    })
    .then(function(Info){
      E.end()
    })
})
```

#### API
```js
enum StreamType { stdout, stderr, both }
class ExpectedWrite extends EventEmitter{
  expect(toExpect: String, expectedStream: StreamType): Promise
  write(Content: String): this
  end(?Content: String): Promise
  onEnd(): Promise
}
```

#### License
This project is licensed under the terms of MIT License. See the License file for more info.

---
_Source: https://npm.io/package/expected-write · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
