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

factory-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factory-js - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

29

dist/factory.js

@@ -1,2 +0,2 @@

/*! factory 1.2.1 */
/*! factory-js 1.3.0 */
var Factory,

@@ -54,6 +54,10 @@ __hasProp = {}.hasOwnProperty,

Factory.define = function(name, block) {
var definition;
var definition, k;
definition = new FactoryDefinition(name);
if (typeof block === 'function') {
block.call(definition);
} else {
for (k in block) {
definition.attr(k, block[k]);
}
}

@@ -231,3 +235,4 @@ return this.factories[name] = definition;

FactoryDefinition.prototype.adapter = function(adapter) {
return this.buildAdapter = new adapter(this);
this.buildAdapter = new adapter(this);
return this;
};

@@ -244,9 +249,11 @@

FactoryDefinition.prototype.after = function(callback) {
return this.callbacks.push(callback);
this.callbacks.push(callback);
return this;
};
FactoryDefinition.prototype.attr = function(attr, value) {
return this.attrs[attr] = (typeof value === 'function' ? value : function() {
this.attrs[attr] = (typeof value === 'function' ? value : function() {
return value;
});
return this;
};

@@ -256,3 +263,3 @@

this.ignore(attr, []);
return this.after(function(attributes, factory) {
this.after(function(attributes, factory) {
if (!(this[attr] instanceof Array)) {

@@ -267,8 +274,10 @@ this[attr] = [];

});
return this;
};
FactoryDefinition.prototype.ignore = function(attr, value) {
return this.ignores[attr] = (typeof value === 'function' ? value : function() {
this.ignores[attr] = (typeof value === 'function' ? value : function() {
return value;
});
return this;
};

@@ -282,6 +291,7 @@

};
return this.attrs[attr] = function() {
this.attrs[attr] = function() {
factory.sequences[attr] = factory.sequences[attr] || 0;
return block.call(this, ++factory.sequences[attr]);
};
return this;
};

@@ -295,3 +305,4 @@

}
return this.traits[name] = definition;
this.traits[name] = definition;
return this;
};

@@ -298,0 +309,0 @@

@@ -1,2 +0,2 @@

/*! factory 1.2.1 */
var Factory,__hasProp={}.hasOwnProperty,__extends=function(a,b){function c(){this.constructor=a}for(var d in b)__hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},__slice=[].slice;Factory=function(){function a(){}var b;return a.Adapter=b=function(){function a(a){this.factory=a}return a.prototype.build=function(a,b){return b},a.prototype.create=function(a,b){return b},a.prototype.push=function(a,b){return this[a].push(b)},a}(),a.factories={},a.adapter=a.Adapter,a.clear=function(){return this.factories={},this.adapter=a.Adapter},a.reset=function(){var a,b,c,d;c=this.factories,d=[];for(b in c)a=c[b],d.push(a.sequences={});return d},a.define=function(a,b){var c;return c=new FactoryDefinition(a),"function"==typeof b&&b.call(c),this.factories[a]=c},a.getFactory=function(a){var b;return b=this.factories[a],null!=b?b:{factory:function(){throw new Error('undefined factory "'+a+'"')}()}},a.getTrait=function(a,b){var c;return c=a.traits[b],null!=c?c:{trait:function(){throw new Error('undefined trait "'+b+'" for factory "'+this.name+'"')}.call(this)}},a.abstractBuild=function(a,b,c){var d,e,f,g,h;return b=b.split(/\s+/),f=b[0],e=this.getFactory(f),h=b.slice(1,+b.length+1||9e9).map(function(a){return function(b){return a.getTrait(e,b)}}(this)),d=e.attributes(c,h),g=e.build(a,f,d.withoutIgnored),h.unshift(e),h.map(function(a){return a.applyCallbacks(g,d.withIgnored)}),g},a.abstractBuildList=function(a,b,c,d){var e;return"number"==typeof c?function(){e=[];for(var a=0;c>=0?c>a:a>c;c>=0?a++:a--)e.push(a);return e}.apply(this).map(function(c){return function(){return c.abstractBuild(a,b,d)}}(this)):c instanceof Array?c.map(function(c){return function(e){return"string"==typeof e?c.abstractBuild(a,""+b+" "+e,d):e.constructor===Object?c.abstractBuild(a,b,c.hash.merge({},d,e)):e}}(this)):void 0},a.attributes=function(a,b){return this.abstractBuild("attributes",a,b)},a.build=function(a,b){return this.abstractBuild("build",a,b)},a.create=function(a,b){return this.abstractBuild("create",a,b)},a.buildList=function(a,b,c){return this.abstractBuildList("build",a,b,c)},a.createList=function(a,b,c){return this.abstractBuildList("create",a,b,c)},a.setupForEmber=function(b){if(null==b)throw new Error('undefined "'+b+'"');return a.EmberDataAdapter=function(a){function c(){return c.__super__.constructor.apply(this,arguments)}return __extends(c,a),c.prototype.build=function(a,c){return Ember.run(function(){return b.__container__.lookup("store:main").createRecord(a,c)})},c.prototype.create=function(a,b){return this.build(a,b)},c.prototype.push=function(a,b){return Ember.run(function(c){return function(){return c.get(a).addObject(b)}}(this))},c}(a.Adapter),a.adapter=a.EmberDataAdapter},a.hash={merge:function(){var a,b,c,d,e,f,g;for(a=arguments[0],d=2<=arguments.length?__slice.call(arguments,1):[],f=0,g=d.length;g>f;f++){c=d[f];for(b in c)e=c[b],a[b]=e}return a},evaluate:function(a){var b,c;c=[];for(b in a)c.push(a[b]="function"==typeof a[b]?a[b]():a[b]);return c}},a}(),("undefined"!=typeof module&&null!==module?module.exports:void 0)?module.exports=Factory:window.Factory=Factory;var FactoryDefinition;FactoryDefinition=function(){function a(a){this.name=a,this.buildAdapter=new Factory.adapter(this),this.attrs={},this.ignores={},this.sequences={},this.traits={},this.callbacks=[]}return a.prototype.adapter=function(a){return this.buildAdapter=new a(this)},a.prototype.build=function(a,b,c){return this.buildAdapter[a]?this.buildAdapter[a](b,c):c},a.prototype.after=function(a){return this.callbacks.push(a)},a.prototype.attr=function(a,b){return this.attrs[a]="function"==typeof b?b:function(){return b}},a.prototype.hasMany=function(a,b){return this.ignore(a,[]),this.after(function(c,d){return this[a]instanceof Array||(this[a]=[]),Factory.buildList(b,c[a]).forEach(function(b){return function(c){return d.buildAdapter.push.call(b,a,c)}}(this))})},a.prototype.ignore=function(a,b){return this.ignores[a]="function"==typeof b?b:function(){return b}},a.prototype.sequence=function(a,b){var c;return c=this,b=b||function(a){return a},this.attrs[a]=function(){return c.sequences[a]=c.sequences[a]||0,b.call(this,++c.sequences[a])}},a.prototype.trait=function(b,c){var d;return d=new a(b),"function"==typeof c&&c.call(d),this.traits[b]=d},a.prototype.attributes=function(a,b){var c,d,e;d=Factory.hash.merge({},a),e={},b.forEach(function(a){var b,c;c=[];for(b in a.attrs)c.push(d[b]=a.attrs[b]);return c});for(c in this.attrs)d.hasOwnProperty(c)||(d[c]=this.attrs[c]);for(c in this.ignores)e[c]=d.hasOwnProperty(c)?d[c]:this.ignores[c],delete d[c];return Factory.hash.evaluate(d),Factory.hash.evaluate(e),{withIgnored:Factory.hash.merge({},d,e),withoutIgnored:d}},a.prototype.applyCallbacks=function(a,b){return this.callbacks.forEach(function(c){return function(d){return d.call(a,b,c)}}(this))},a}();
/*! factory-js 1.3.0 */
var Factory,__hasProp={}.hasOwnProperty,__extends=function(a,b){function c(){this.constructor=a}for(var d in b)__hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},__slice=[].slice;Factory=function(){function a(){}var b;return a.Adapter=b=function(){function a(a){this.factory=a}return a.prototype.build=function(a,b){return b},a.prototype.create=function(a,b){return b},a.prototype.push=function(a,b){return this[a].push(b)},a}(),a.factories={},a.adapter=a.Adapter,a.clear=function(){return this.factories={},this.adapter=a.Adapter},a.reset=function(){var a,b,c,d;c=this.factories,d=[];for(b in c)a=c[b],d.push(a.sequences={});return d},a.define=function(a,b){var c,d;if(c=new FactoryDefinition(a),"function"==typeof b)b.call(c);else for(d in b)c.attr(d,b[d]);return this.factories[a]=c},a.getFactory=function(a){var b;return b=this.factories[a],null!=b?b:{factory:function(){throw new Error('undefined factory "'+a+'"')}()}},a.getTrait=function(a,b){var c;return c=a.traits[b],null!=c?c:{trait:function(){throw new Error('undefined trait "'+b+'" for factory "'+this.name+'"')}.call(this)}},a.abstractBuild=function(a,b,c){var d,e,f,g,h;return b=b.split(/\s+/),f=b[0],e=this.getFactory(f),h=b.slice(1,+b.length+1||9e9).map(function(a){return function(b){return a.getTrait(e,b)}}(this)),d=e.attributes(c,h),g=e.build(a,f,d.withoutIgnored),h.unshift(e),h.map(function(a){return a.applyCallbacks(g,d.withIgnored)}),g},a.abstractBuildList=function(a,b,c,d){var e;return"number"==typeof c?function(){e=[];for(var a=0;0<=c?a<c:a>c;0<=c?a++:a--)e.push(a);return e}.apply(this).map(function(c){return function(){return c.abstractBuild(a,b,d)}}(this)):c instanceof Array?c.map(function(c){return function(e){return"string"==typeof e?c.abstractBuild(a,""+b+" "+e,d):e.constructor===Object?c.abstractBuild(a,b,c.hash.merge({},d,e)):e}}(this)):void 0},a.attributes=function(a,b){return this.abstractBuild("attributes",a,b)},a.build=function(a,b){return this.abstractBuild("build",a,b)},a.create=function(a,b){return this.abstractBuild("create",a,b)},a.buildList=function(a,b,c){return this.abstractBuildList("build",a,b,c)},a.createList=function(a,b,c){return this.abstractBuildList("create",a,b,c)},a.setupForEmber=function(b){if(null==b)throw new Error('undefined "'+b+'"');return a.EmberDataAdapter=function(a){function c(){return c.__super__.constructor.apply(this,arguments)}return __extends(c,a),c.prototype.build=function(a,c){return Ember.run(function(){return b.__container__.lookup("store:main").createRecord(a,c)})},c.prototype.create=function(a,b){return this.build(a,b)},c.prototype.push=function(a,b){return Ember.run(function(c){return function(){return c.get(a).addObject(b)}}(this))},c}(a.Adapter),a.adapter=a.EmberDataAdapter},a.hash={merge:function(){var a,b,c,d,e,f,g;for(a=arguments[0],d=2<=arguments.length?__slice.call(arguments,1):[],f=0,g=d.length;f<g;f++){c=d[f];for(b in c)e=c[b],a[b]=e}return a},evaluate:function(a){var b,c;c=[];for(b in a)c.push(a[b]="function"==typeof a[b]?a[b]():a[b]);return c}},a}(),("undefined"!=typeof module&&null!==module?module.exports:void 0)?module.exports=Factory:window.Factory=Factory;var FactoryDefinition;FactoryDefinition=function(){function a(a){this.name=a,this.buildAdapter=new Factory.adapter(this),this.attrs={},this.ignores={},this.sequences={},this.traits={},this.callbacks=[]}return a.prototype.adapter=function(a){return this.buildAdapter=new a(this),this},a.prototype.build=function(a,b,c){return this.buildAdapter[a]?this.buildAdapter[a](b,c):c},a.prototype.after=function(a){return this.callbacks.push(a),this},a.prototype.attr=function(a,b){return this.attrs[a]="function"==typeof b?b:function(){return b},this},a.prototype.hasMany=function(a,b){return this.ignore(a,[]),this.after(function(c,d){return this[a]instanceof Array||(this[a]=[]),Factory.buildList(b,c[a]).forEach(function(b){return function(c){return d.buildAdapter.push.call(b,a,c)}}(this))}),this},a.prototype.ignore=function(a,b){return this.ignores[a]="function"==typeof b?b:function(){return b},this},a.prototype.sequence=function(a,b){var c;return c=this,b=b||function(a){return a},this.attrs[a]=function(){return c.sequences[a]=c.sequences[a]||0,b.call(this,++c.sequences[a])},this},a.prototype.trait=function(b,c){var d;return d=new a(b),"function"==typeof c&&c.call(d),this.traits[b]=d,this},a.prototype.attributes=function(a,b){var c,d,e;d=Factory.hash.merge({},a),e={},b.forEach(function(a){var b,c;c=[];for(b in a.attrs)c.push(d[b]=a.attrs[b]);return c});for(c in this.attrs)d.hasOwnProperty(c)||(d[c]=this.attrs[c]);for(c in this.ignores)e[c]=d.hasOwnProperty(c)?d[c]:this.ignores[c],delete d[c];return Factory.hash.evaluate(d),Factory.hash.evaluate(e),{withIgnored:Factory.hash.merge({},d,e),withoutIgnored:d}},a.prototype.applyCallbacks=function(a,b){return this.callbacks.forEach(function(c){return function(d){return d.call(a,b,c)}}(this))},a}();
{
"name": "factory-js",
"version": "1.2.1",
"version": "1.3.0",
"keywords": [

@@ -5,0 +5,0 @@ "factory",

Sorry, the diff of this file is not supported yet

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