
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
create-test-data
Advanced tools
$ npm install create-test-data
the default config like this:
const defaultOpts = {
* key: '', // the object key, and create data will use it as key.
* type: CONSTANT.TYPE[0], //data type, you can set it as one of ['string', 'number', 'numberic', 'email', 'url', 'float', 'idcard', 'html', 'chinese'].
* max: CONSTANT.DEFAULT_MAX_NUM, // the value max length.
* min: CONSTANT.DEFAULT_MIN_NUM, // the value min length.
isFixed: true // if you set it true, the value is random in min to max. if false, the value will fixed.
};
ex1. use object as args and default config.(create data is all about string)
import { CreateTestData } from 'create-test-data';
const tplData = {aaa: 1, bbb: 2, ccc: 3}
const data = CreateTestData.createData(tplData);
//output:
{ aaa: '9rrRoAj1xN1RhEpK4ipZ',
bbb: 'zNJpFoAJWkwxiRxz3b6P',
ccc: 'nMs3e21YqrUpgeOc85e3' }
e2. use array as args and default config.(create data is all about string)
If you use array as args and the array element is not reach the specifications for the config, you will get the object will meger all element.
import { CreateTestData } from 'create-test-data';
const tplData = [{aaa: 1, bbb: 2, ccc: 3}, {qqq: 1, www: 2, eee: 3}]
const data = CreateTestData.createData(tplData);
//output:
{ aaa: 'eDLqRy3DwQYN1xJmqHAU',
bbb: 'F4Dfu0AwM69odpuJFi8r',
ccc: 't3rMe1EibyHSV8fMSxrA',
qqq: '2D7hMbrl1maPyhksv7Di',
www: 'fED83pQODvOtk2Ln3Nsg',
eee: 'XPnts5D429OtsOehafNL' }
ex3. use config options.
import { CreateTestData } from 'create-test-data';
const data1 = CreateTestData.createData(
{key: 'aaa', type: 'number', max: 10, min: 1}
);
const data2 = CreateTestData.createData(
[{key: 'aaa', type: 'number', max: 10, min: 1}, {key: '',type:'string',max: 10, min: 2}]
);
// or
const data2 = CreateTestData.createData(
[
{key: 'aaa', type: 'number', max: 10, min: 1},
{key: 'bbb', type: 'string', max: 10, min: 2},
{key: 'ccc', type: 'string', max: 10, min: 2}
]
);
//or
const data3 = CreateTestData.createData(
[
{key: 'aaa', type: 'number', max: 10, min: 1},
{key: 'bbb', type: 'string', max: 10, min: 2},
{key: 'ccc', type: 'string', max: 10, min: 2},
{ddd:2,fff:3,eee:4}
]
);
//out put
data1:
{
aaa: 979332569
}
data2:
{ aaa: 914083701,
bbb: 'EysBiTp1J',
ccc: 'LGCl73iYM'
}
ddd3:
{
aaa: 874249513,
bbb: 'T5Rnb7SI91',
ccc: 'U75Uc62',
ddd: '7JOpIdz3Jsx85aKSKx7a',
fff: 'Y5ffgIf10n5HevHRLu6Z',
eee: 'GU2Nq8xILIkwcqMSEn0G'
}
If you have any question, you can submit issuse for me.
FAQs
Create test data in your work.
We found that create-test-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.