# data-transform-descriptor

> A tiny module to describe and implement data transforms/mappings.

Latest version **0.0.7** (published 2017-06-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install data-transform-descriptor
pnpm add data-transform-descriptor
yarn add data-transform-descriptor
bun add data-transform-descriptor
```

## 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.7 |
| Published | 2017-06-01 |
| First published | 2017-05-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.0.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | lukepur |

## Links

- npm: https://www.npmjs.com/package/data-transform-descriptor
- npm.io page: https://npm.io/package/data-transform-descriptor

## Dependencies (3)

- [q](https://npm.io/package/q.md) ^1.5.0
- [papaparse](https://npm.io/package/papaparse.md) ^4.3.2
- [data-structure-validator](https://npm.io/package/data-structure-validator.md) 0.0.6

## Recent versions

- 0.0.7 (latest) — 2017-06-01
- 0.0.6 — 2017-05-31
- 0.0.5 — 2017-05-31
- 0.0.4 — 2017-05-28
- 0.0.3 — 2017-05-20
- 0.0.2 — 2017-05-18
- 0.0.1 — 2017-05-17

## README

# data-transform-descriptor
A tiny module to describe and implement data transforms/mappings.

Uses validate.js (and some custom validators) to document a data transformation in terms of input and output requirements.

Demo site: [https://lukepur.github.io/data-transform-descriptor/](https://lukepur.github.io/data-transform-descriptor/)

## Installation

```
npm install data-transform-descriptor
```

## Usage

```
const createTransformer = require('data-transform-descriptor');

const adder = createTransformer(
    // input constraints (see validate.js)
   [
        {
            id: 'a',
            type: 'number',
            required: true
        },
        {
            id: 'b',
            type: 'number',
            required: true
        }
    ],
    // output constraints
    {
        type: 'number'
    },
    // worker resolvable
    {
        fn: add,
        args: ['$.a', '$.b']
    },
    // meta
    { name: 'Adder' }
);

adder.meta();
// -> { name: 'Adder', ...inputConstraints, ...outputConstraints }

adder.validateInput({a: 1, b: 2});
// -> undefined

adder.validateInput({a: 'a', b: 2});
// -> {a: ['a must be a number (got string)']}

adder.run({a: 1, b: 2});
// -> 3

adder.run({a: '1', b: 2});
// -> {a : ['a must be a number (got string))']}

adder.run({a: 1});
// -> {b : ["b is can't be blank", 'b must be a number (got undefined)']}
```

## Why?

The motivation for data-transform-descriptor is to build a simple framework for describing units of work against data.

This could be enhanced with tooling to build rich systems for composing these units of work into much more useful
workflows.

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