Gathering detailed insights and metrics for @joxnathan/mock-randomizer
Gathering detailed insights and metrics for @joxnathan/mock-randomizer
Gathering detailed insights and metrics for @joxnathan/mock-randomizer
Gathering detailed insights and metrics for @joxnathan/mock-randomizer
npm install @joxnathan/mock-randomizer
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
fills a structure with randomized data to mock a service or other model provider. number of items in a collection of objects can also be random.
npm install @joxnathan/mock-randomizer
import mock from '@joxnathan/mock-randomizer';
this.history.GetChangeHistory = () => Promise.resolve(
mock.filledList({
Id: 'guid',
TimeStamp: 'date:now:now',
User: { Id: 'number:100:501', Name: 'string:8', Email: 'email' },
Data: [{
Id: 'number:1000:2001',
ChangeType: 'choose:Insert,Update,Delete',
TableName: 'choose:Claimant,Processor,Advisor,Supervisor,Client,Vendor',
RecordId: 'number:10:41',
FieldName: 'choose:Id,Name,Address,City,State,Zip',
PrevValue: '{}',
CurrValue: '{}'
}]
}, { min: 11, max: 75 }, { Data: { max: 4 } }).map(entry => {
const getData = () => JSON.stringify(mock.filledObject({
Id: 'guid',
version: 'ver',
Name: '',
Value: '',
FullName: 'fullname',
FirstName: 'firstname',
LastName: 'lastname',
Company: 'company',
Street: 'street',
City: 'city',
State: 'state',
Zip: 'zip',
Tz: 'tz',
Phone: 'phone',
Email: 'email',
Book: 'title',
TypeSet: 'typeset',
Locations: [],
HasApproval: 'boolean',
CreatedOn: 'date:today-12M:now-1M',
CreatedBy: '',
ModifiedOn: 'date:today-7d:now',
ModifiedBy: ''
}, { Locations: { min: 1, max: 3 } }));
for (const data of entry.Data || []) {
const vals = {
prev: ['Delete', 'Update'].includes(data.ChangeType) ? getData() : undefined,
curr: ['Insert', 'Update'].includes(data.ChangeType) ? getData() : undefined
};
data.PrevValue = vals.prev;
data.CurrValue = vals.curr;
}
return entry;
})
);
const mock = require("@joxnathan/mock-randomizer").default;
const getChangeHistory = () =>
mock.filledList({
Id: 'guid',
TimeStamp: 'date:now:now',
User: { Id: 'number:100:501', Name: 'string:8', Email: 'email' },
Data: [{
Id: 'number:1000:2001',
ChangeType: 'choose:Insert,Update,Delete',
TableName: 'choose:Claimant,Processor,Advisor,Supervisor,Client,Vendor',
RecordId: 'number:10:41',
FieldName: 'choose:Id,Name,Address,City,State,Zip',
PrevValue: '{}',
CurrValue: '{}'
}]
}, { min: 11, max: 75 }, { Data: { max: 4 } }).map(entry => {
const getData = () => JSON.stringify(mock.filledObject({
Id: 'guid',
version: 'ver',
Name: '',
Value: 'string:4:6:upper',
FullName: 'fullname',
FirstName: 'firstname',
LastName: 'lastname',
Company: 'company',
Street: 'street',
City: 'city',
State: 'state',
Zip: 'zip',
Tz: 'tz',
Phone: 'phone',
Email: 'email',
Book: 'title',
TypeSet: 'typeset',
Locations: [],
HasApproval: 'boolean',
CreatedOn: 'date:today-12M:now-1M',
CreatedBy: '',
ModifiedOn: 'date:today-7d:now',
ModifiedBy: ''
}, { Locations: { min: 1, max: 3 } }));
for (const data of entry.Data || []) {
const vals = {
prev: ['Delete', 'Update'].includes(data.ChangeType) ? getData() : undefined,
curr: ['Insert', 'Update'].includes(data.ChangeType) ? getData() : undefined
};
data.PrevValue = vals.prev;
data.CurrValue = vals.curr;
}
return entry;
});
const hist = getChangeHistory();
console.log({ hist });
1. DSL 'email:[props]' - add option to specify that the value relies on another.
2. DSL 'string:2 number:1:4 number:1:10 number boolean' - string the dsl commands together in a single property. (not really too sure about this one)
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
No vulnerabilities found.
No security vulnerabilities found.