Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "rosie", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "factory for building JavaScript objects, mostly useful for setting up test data. Inspired by factory_girl", | ||
@@ -16,7 +16,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "^7.9.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-jest": "^24.0.2", | ||
"jest": "^26.4.2", | ||
"prettier": "^2.1.2", | ||
"eslint": "^8.29.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-jest": "^27.1.6", | ||
"jest": "^29.3.1", | ||
"prettier": "^2.8.0", | ||
"prettier-check": "^2.0.0" | ||
@@ -23,0 +23,0 @@ }, |
@@ -5,3 +5,3 @@ # Rosie | ||
Rosie is a factory for building JavaScript objects, mostly useful for setting up test data. It is inspired by [factory_girl](https://github.com/thoughtbot/factory_girl). | ||
Rosie is a factory for building JavaScript objects, mostly useful for setting up test data. It is inspired by [factory_bot](https://github.com/thoughtbot/factory_bot). | ||
@@ -8,0 +8,0 @@ To use Rosie you first define a _factory_. The _factory_ is defined in terms of _attributes_, _sequences_, _options_, _callbacks_, and can inherit from other factories. Once the factory is defined you use it to build _objects_. |
@@ -310,2 +310,6 @@ /** | ||
build(attributes, options) { | ||
// Precalculate options. | ||
// Because options cannot depend on themselves or on attributes, subsequent calls to | ||
// `this.options` will be idempotent and we can avoid re-running builders | ||
options = this.options(options); | ||
const result = this.attributes(attributes, options); | ||
@@ -322,3 +326,3 @@ let retval = null; | ||
for (let i = 0; i < this.callbacks.length; i++) { | ||
const callbackResult = this.callbacks[i](retval, this.options(options)); | ||
const callbackResult = this.callbacks[i](retval, options); | ||
retval = callbackResult || retval; | ||
@@ -325,0 +329,0 @@ } |
28552
439