UNPKG

ancient-graph-spreading

Version:

Automatic maintenance spreading of graph according other graphs.

17 lines 4.2 kB
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if('value'in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _get=function get(object,property,receiver){if(object===null)object=Function.prototype;var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if('value'in desc){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function')}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called')}return call&&(typeof call==='object'||typeof call==='function')?call:self}function _inherits(subClass,superClass){if(typeof superClass!=='function'&&superClass!==null){throw new TypeError('Super expression must either be null or a function, not '+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}/** * This method allows you to use RespreadGraph class to its inheritance chain. * Lets perceive spread graph as a reason for the spreader graph. * Fields launched, process, prev, path and root is required! * Manage fields launched and process. * Parent class mast be extended from class SpreadGraph. * * @param {Class} ParentClassSpreadGraph * @return {Class} RespreadGraph * @description `import { factoryRespreadGraph } from 'ancient-graph-spreading';` */function factoryRespreadGraph(ParentClassSpreadGraph){var RespreadGraph=function(_ParentClassSpreadGra){_inherits(RespreadGraph,_ParentClassSpreadGra);function RespreadGraph(){_classCallCheck(this,RespreadGraph);return _possibleConstructorReturn(this,(RespreadGraph.__proto__||Object.getPrototypeOf(RespreadGraph)).apply(this,arguments))}_createClass(RespreadGraph,[{key:'insert',/** * Parent insert with added 'respread' to launched field. You can override it field in modifier. */value:function insert(modifier,callback,context){if(!modifier[this.config.aliases.launched])modifier[this.config.aliases.launched]=['respread'];return _get(RespreadGraph.prototype.__proto__||Object.getPrototypeOf(RespreadGraph.prototype),'insert',this).call(this,modifier,callback,context)}/** * The method is strictly designed so that the class inherits from ExistedGraph. * Adds to launched field custom value from context. */},{key:'remove',value:function remove(selector,callback,context){if(!context)context=_defineProperty({},this.config.aliases.launched,['respread']);else if(!context[this.config.aliases.launched])context[this.config.aliases.launched]=['respread'];else{if(Object.prototype.toString.call(context[this.config.aliases.launched])==='[object Array]'){context[this.config.aliases.launched].push('respread')}else{context[this.config.aliases.launched]=[context[this.config.aliases.launched],'respread']}}return _get(RespreadGraph.prototype.__proto__||Object.getPrototypeOf(RespreadGraph.prototype),'remove',this).call(this,selector,callback,context)}}]);return RespreadGraph}(ParentClassSpreadGraph);return RespreadGraph};exports.factoryRespreadGraph=factoryRespreadGraph; //# sourceMappingURL=respread.js.map