# process-and-test

> A JS module that allows for a pipeline process that allows for multiple tests to be passed along its process.

Latest version **0.1.1** (published 2017-01-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install process-and-test
pnpm add process-and-test
yarn add process-and-test
bun add process-and-test
```

## 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.1.1 |
| Published | 2017-01-25 |
| First published | 2017-01-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | phillip chan |
| Maintainers | phillipchan1 |
| Keywords | javascript, middleware |

## Links

- npm: https://www.npmjs.com/package/process-and-test
- Repository: https://github.com/phillipchan2/process-and-test
- Homepage: https://github.com/phillipchan2/process-and-test#readme
- Issues: https://github.com/phillipchan2/process-and-test/issues
- npm.io page: https://npm.io/package/process-and-test

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-01-25
- 0.1.0 — 2017-01-25

## README

# process-and-test.js
A JS module that allows for a pipeline process that allows for multiple tests to be passed along its process.

## Table of Contents
1. [General](#general)
2. [Usage](#usage)
    - [Getting Started](#getting-started)
    - [Writing Your Tests](#writing-your-tests)
    - [Async Processes](#async-processes)
3. [Developing](#developing)

## General
![alt tag](assets/process-and-test.png?raw=true)

Often, we need to simultaneously process and a file and test it along the way to ensure the integrity of the file. This module should help that.

If it's good, it will return the final process of the file.
If not, it should return the error message set for that step.

## Usage

#### Getting Started
1) Init our object and pass in your data that you're processing:

```
var someProcess = new processAndTest(data);
```

2) Add in each step along with the tests we want to attach to that step. See the options in the constructor:

```
someProcess.newProcess({
    // whatever we want to do with our data-as long as we return it.
        return data;
    action: function() {
        
    },

    // Whether the process is 'async' or 'sync'
    mode: 'sync',

    // tests that we're passing in
    tests: [
        test1,
        test2
    ],

    // specify an error message to go with these sets of tests
    errorMessage: "The error message given if this fails the test."
});
```

3) Specify what happens with data after it is done testing and processing:
```
someProcess.onEnd = function() {
    // the pass property will return either true or false
    console.log(someProcess.pass);

    // the data will either give you the processed file or the error message
    console.log(someProcess.data);
}
```

4) Run the test with the `run()` method.

```
someProcess.run();
```

And you're set.

#### Writing Your Tests

Example test to pass in:
```
// tests must return true or return an error message (a string)
var test1 = function(csv) {
    if (true) {
        return true;    
    }
    else {
        return "Random error message";
    }
}
```

#### Async Processes

The module allows for asyncronous processes through the use of JS promises. In your process, just return the resolved promise object.

Example:
```
var readFile = function(file) {
    return new Promise(function(resolve, reject) {
        var reader = new FileReader();
        var content = reader.readAsText(file);

        reader.onload = function() {
            resolve(reader.result);
        }
    }); 
};
```

## Developing
This project leverages gulp and mocha. Source files are located in `/src` and tests are located in `/test`.

1. Download dependencies: `npm init`
2. Run compiler `gulp`

*It's now watching for changes, compiling and minifying, and running tests*

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