Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/av/dtg
Data generation tool
https://github.com/av/dtg
data data-engineering data-generator dtg generator node nodejs npm-module npm-package random-generation utility
Last synced: about 13 hours ago
JSON representation
Data generation tool
- Host: GitHub
- URL: https://github.com/av/dtg
- Owner: av
- Created: 2016-04-07T07:01:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-05T22:25:41.000Z (about 2 years ago)
- Last Synced: 2024-12-14T09:18:56.899Z (8 days ago)
- Topics: data, data-engineering, data-generator, dtg, generator, node, nodejs, npm-module, npm-package, random-generation, utility
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![DTG](https://img42.com/bkCep+)
## What's DTG?
DTG - DaTa Generator, allows you to develop your data generation scripts faster
## Terms
+ dtg - tool for data generation
+ template - javascript object containing fields with generation operators
+ generation operator - string strating with '$'
+ plugin - code, existing in a sibling folder of dtg installation, which exports `install` function## Installation
```bash
npm install dtg
```## Usage
```javascript
const gen = require('dtg').generate;
const template = {
{
// Will be kept as is in output objects
type: '_ShipmentOrder',// The same, will not be modified
timestamp: Date.now(),// It's possible to put generation operators in the any
// place in object, except field's name
tags: ['some', '$pattern:NN-CC'],
customFields: {// Timestamp generator, will produce timestamp, from one to two months ago
shipment_date: `$timestamp: 1..2M ago`,// Will chose random value from given array
shipment_order: `$enum: ['EZ-104', 'BD-103', 'SO12', 'FDk2', 'DZ-105']`,
shipment_to_code: `$enum: ['14RD', '13SD', '22LD', '45SA', '14RA', '21SO', '56LS']`,// Will produce random int in given range, floats supported via
// $float generation operator
quantity: `$int: 10..100`
}
}
};let actions = [];
while (actions.length < 100) {
// Will produce 100 diferrent objects from template given.
actions.push(gen(template));
}```
## Plugins
DTG loads plugins automatically. The only place to locate them is a sibling folder of a dtg installation itself.
E.g.
```
/node_modules
/dtg
/dtg-plugin
```
Plugin must have either export a function or `install` field with function value in its exports. The function will retrieve the main DTG object when called and therefore do whatever needed.
E.g.
```
module.exports = {
install: function(dtg) {
dtg['curl'] = require('./curl-generator')
}
}module.exports = function(dtg) {
dtg['search-results'] = require('google-connector');
}
```