Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
datagen-rs-node
Advanced tools
This package contains node.js bindings to `datagen` for generating random data. The bindings are built using [napi-rs](https://napi.rs).
This package contains node.js bindings to datagen
for generating random data.
The bindings are built using napi-rs.
npm install datagen-rs-node
If you want to use the bindings in a TypeScript project, you may also need to install the
datagen-rs-types
package:
npm install --save-dev @datagen-rs/types
In order to generate random data, you must pass a JSON schema to the generateRandomData
function:
import { generateRandomData } from 'datagen-rs-node';
const generated = await generateRandomData({
type: 'string',
generator: {
type: 'uuid',
},
});
The result will be the serialized generated data as a string. In order to customize the
serialization, you can pass a serializer into the
options
object.
If you want to get progress updates while generating data, you can
pass a progress callback to the generateRandomData
function:
import { generateRandomData } from 'datagen-rs-node';
const generated = await generateRandomData(
{
type: 'string',
generator: {
type: 'uuid',
},
},
({ current, total }) => {
console.log(`Generated ${current}/${total} items`);
}
);
The progress value is of type GenerateProgress
and has the following structure:
interface GenerateProgress {
current: number;
total: number;
}
Check the progress-plugin
documentation
for further information on how the progress is calculated.
You can pass additional plugins to the generateRandomData
function. These plugins
will be loaded before the generation starts and can be used to extend the functionality
of datagen
. Check out the
plugin documentation
for more information on creating node.js plugins.
import { generateRandomData, CurrentSchema } from 'datagen-rs-node';
const generated = await generateRandomData(
{
type: 'plugin',
pluginName: 'myPlugin',
args: {
name: 'test',
},
},
null,
{
myPlugin: {
generate(schema: CurrentSchema, args: any): any {
return 'Hello World!';
},
},
}
);
Note that this package also exports a CurrentSchema
type that can be used to type the
schema
parameter of the generate
function. This is simply the implementation
of the CurrentSchema
interface from the @datagen/types
package.
In order to retrieve the JSON schema, you can use the getJsonSchema
or
getJsonSchemaAsync
functions:
import { getJsonSchema, getJsonSchemaAsync } from 'datagen-rs-node';
const schema = getJsonSchema();
const schemaAsync = await getJsonSchemaAsync();
FAQs
This package contains node.js bindings to `datagen` for generating random data. The bindings are built using [napi-rs](https://napi.rs).
The npm package datagen-rs-node receives a total of 0 weekly downloads. As such, datagen-rs-node popularity was classified as not popular.
We found that datagen-rs-node 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.