Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jackfranklin/test-data-bot

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jackfranklin/test-data-bot - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

build/index.d.ts

@@ -40,3 +40,3 @@ /// <reference types="faker" />

}
export declare const build: <FactoryResultType>(factoryName: string, config: BuildConfiguration<FactoryResultType>) => (buildTimeConfig?: BuildTimeConfig<FactoryResultType> | undefined) => FactoryResultType;
export declare const build: <FactoryResultType>(factoryNameOrConfig: string | BuildConfiguration<FactoryResultType>, configObject?: BuildConfiguration<FactoryResultType> | undefined) => (buildTimeConfig?: BuildTimeConfig<FactoryResultType> | undefined) => FactoryResultType;
export declare const oneOf: <T>(...options: T[]) => OneOfGenerator;

@@ -43,0 +43,0 @@ export declare const bool: () => OneOfGenerator;

@@ -18,7 +18,9 @@ "use strict";

const identity = (x) => x;
exports.build = (factoryName, config) => {
exports.build = (factoryNameOrConfig, configObject) => {
const config = (typeof factoryNameOrConfig === 'string'
? configObject
: factoryNameOrConfig);
let sequenceCounter = 0;
const expandConfigFields = (fields, buildTimeConfig = {}) => {
const postBuild = config.postBuild || identity;
const finalBuiltThing = postBuild(lodash_1.mapValues(fields, (fieldValue, fieldKey) => {
const finalBuiltThing = lodash_1.mapValues(fields, (fieldValue, fieldKey) => {
const overrides = buildTimeConfig.overrides || {};

@@ -28,5 +30,4 @@ const valueOrOverride = overrides[fieldKey] || fieldValue;

return expandConfigField(valueOrOverride);
}));
const buildTimeMapFunc = buildTimeConfig.map || identity;
return buildTimeMapFunc(finalBuiltThing);
});
return finalBuiltThing;
};

@@ -76,3 +77,5 @@ const expandConfigField = (fieldValue) => {

const fieldsToReturn = expandConfigFields(config.fields, buildTimeConfig);
return fieldsToReturn;
const postBuild = config.postBuild || identity;
const buildTimeMapFunc = buildTimeConfig.map || identity;
return buildTimeMapFunc(postBuild(fieldsToReturn));
};

@@ -79,0 +82,0 @@ };

@@ -0,1 +1,12 @@

### 1.2.0 - 09 May 2020
- Factories now do not need a factory name property. You can simply pass in the configuration object :
```js
const userBuilder = build({ ... });
// rather than:
const userBuilder = build('User', { ... });
```
You can still pass a name if you like, but it's not required and will probably be removed in a future major version.
### 1.1.0 - 23 March 2020

@@ -2,0 +13,0 @@

{
"name": "@jackfranklin/test-data-bot",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",

@@ -35,15 +35,15 @@ "description": "Generate test data for your tests easily.",

"devDependencies": {
"@types/jest": "^25.1.1",
"@types/lodash": "^4.14.149",
"@types/node": "^13.5.2",
"@typescript-eslint/eslint-plugin": "^2.18.0",
"@typescript-eslint/parser": "^2.18.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"@types/jest": "^25.2.1",
"@types/lodash": "^4.14.150",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-unobtrusive": "^1.2.5",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-prettier": "^3.1.2",
"jest": "^25.1.0",
"eslint-plugin-jest": "^23.9.0",
"eslint-plugin-prettier": "^3.1.3",
"jest": "^25.5.4",
"prettier": "^2.0.2",
"ts-jest": "^25.1.0",
"ts-jest": "^25.5.0",
"typescript": "^3.7.5"

@@ -50,0 +50,0 @@ },

@@ -30,3 +30,3 @@ # @jackfranklin/test-data-bot

We use the `build` function to create a builder. It takes a name for the object it will create, and then some fields:
We use the `build` function to create a builder. You give a builder an object of fields you want to define:

@@ -49,2 +49,14 @@ ```js

**Note**: if you're using *Version 1.2 or higher* you can leave the name of the factory and pass in only the configuration object:
```js
const userBuilder = build({
fields: {
name: 'jack',
},
});
```
Feel free to use the name property if you like, but it's not used for anything in test-data-bot. It will probably get removed in a future major version.
Once you've created a builder, you can call it to generate an instance of that object - in this case, a `user`.

@@ -51,0 +63,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc