
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Half-Faked is a tool for generating fake data for a given schema definition. It was originally apart of the Restfool library as the fixture()
function, but has since been isolated into its own module. This tool can be used for creating more accurate and varied test cases, modeling data architecture, or even setting up mock services that deliver data for your front-end team(s) to develop against.
Half-Faked helps you get something close to what your final data will look like, without being your final data!
Install via npm
:
Note: We recommend installing the awesome faker library to use in conjunction with half-faked.
npm install --save-dev half-faked
Then, require
it in your project like so...
const createFactory = require('half-faked');
This library exposes a single function that accepts either an object literal or function that provides the desired output schema. Any functional values found will be called and their results can will also be checked for functional values to invoke.
type createFactory = (Object|Func schema) -> Factory
The return value of this function is a "factory" function that will be used for generating n
number of copies.
type Factory = (Integer count [, Object|Func modifier]) -> Array
Note: As previously mentioned, we're using the faker library below to quickly generate some fake data.
const createFactory = require('half-faked');
const faker = require('faker');
// object literal
const makeAddress = createFactory({
street: faker.address.streetAddress,
city: faker.address.city,
state: faker.address.usState,
country: 'usa',
zipcode: faker.address.zipCode
});
// function
const makeUser = createFactory(function () {
return {
name: faker.name.firstName() + ' '+ faker.name.lastName(),
email: faker.internet.email,
password: faker.random.uuid,
addresses: makeAddress(5)
};
});
Now that you've created a factory for your data, you can start creating rows using the returned factory function. You can create a single item by providing no first argument, or you can create a collection of items by specifying a count of 1
or greater.
var one = makeUser();
// => { name: 'Nick Glenn', email: ... }
var oneInArray = makeUser(1);
// => [ { name: 'Nick Glenn', email: ... } ]
var many = makeUser(5);
// => [ {...}, {...}, {...}, {...}, {...} ]
You can override the results of custom values by passing an object or function in as a second argument. This is called a modifier.
Using an object as a second argument will simply merge the given object with the data of each row in the collection, overriding the value of any existing matched keys.
var active = makeUser(2, { active: true });
// => [ {name: '...', active: true}, {name: '...', active: true} ]
Providing a function will give you a greater level of control. The generated object will be passed to the function and whatever is returned will take its place.
var users = makeUser(10, function (user) {
if (user.email === 'admin@example.com') {
user.password = '123456789';
}
return user;
});
FAQs
A simple tool for generating fake data using schemas.
The npm package half-faked receives a total of 1 weekly downloads. As such, half-faked popularity was classified as not popular.
We found that half-faked 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.