function-tree
Advanced tools
Comparing version 3.2.0-1518985373143 to 3.2.0-1519006927624
@@ -27,3 +27,3 @@ 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; }; }(); | ||
_this.latestExecutionId = null; | ||
_this.version = "3.2.0-1518985373143"; | ||
_this.version = "3.2.0-1519006927624"; | ||
_this.init(); | ||
@@ -30,0 +30,0 @@ return _this; |
@@ -11,73 +11,75 @@ import { FunctionTreeExecutionError } from './errors'; | ||
*/ | ||
export default function executeTree(execution, initialPayload, branchStart, branchEnd, parallelStart, parallelProgress, parallelEnd, end) { | ||
export default function executeTree(execution, initialPayload, executeBranchWrapper, branchStart, branchEnd, parallelStart, parallelProgress, parallelEnd, end) { | ||
function runBranch(branch, index, payload, prevPayload, nextBranch) { | ||
function runNextItem(result) { | ||
runBranch(branch, index + 1, result, payload, nextBranch); | ||
} | ||
executeBranchWrapper(function () { | ||
function runNextItem(result) { | ||
runBranch(branch, index + 1, result, payload, nextBranch); | ||
} | ||
function processFunctionOutput(funcDetails, outputResult) { | ||
return function (result) { | ||
var newPayload = Object.assign({}, payload, result ? result.payload : {}); | ||
function processFunctionOutput(funcDetails, outputResult) { | ||
return function (result) { | ||
var newPayload = Object.assign({}, payload, result ? result.payload : {}); | ||
if (result && funcDetails.outputs) { | ||
var outputs = Object.keys(funcDetails.outputs); | ||
if (result && funcDetails.outputs) { | ||
var outputs = Object.keys(funcDetails.outputs); | ||
if (~outputs.indexOf(result.path)) { | ||
branchStart(funcDetails, result.path, newPayload); | ||
runBranch(funcDetails.outputs[result.path].items, 0, newPayload, payload, outputResult); | ||
if (~outputs.indexOf(result.path)) { | ||
branchStart(funcDetails, result.path, newPayload); | ||
runBranch(funcDetails.outputs[result.path].items, 0, newPayload, payload, outputResult); | ||
} else { | ||
throw new FunctionTreeExecutionError(execution, funcDetails, payload, 'function ' + funcDetails.name + ' must use one of its possible outputs: ' + outputs.join(', ') + '.'); | ||
} | ||
} else { | ||
throw new FunctionTreeExecutionError(execution, funcDetails, payload, 'function ' + funcDetails.name + ' must use one of its possible outputs: ' + outputs.join(', ') + '.'); | ||
outputResult(newPayload); | ||
} | ||
} else { | ||
outputResult(newPayload); | ||
}; | ||
} | ||
var currentItem = branch[index]; | ||
if (!currentItem) { | ||
if (branch !== execution.staticTree) { | ||
branchEnd(payload); | ||
} | ||
}; | ||
} | ||
nextBranch(payload); | ||
} else if (isPrimitive(currentItem, 'sequence')) { | ||
runBranch(currentItem.items, 0, payload, prevPayload, runNextItem); | ||
} else if (isPrimitive(currentItem, 'parallel')) { | ||
var itemLength = currentItem.items.length; | ||
var payloads = []; | ||
var currentItem = branch[index]; | ||
parallelStart(payload, itemLength); | ||
currentItem.items.forEach(function (func, index) { | ||
if (func.function) { | ||
execution.runFunction(func, payload, prevPayload, processFunctionOutput(func, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
})); | ||
} else { | ||
runBranch(func.items, 0, payload, prevPayload, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
}); | ||
} | ||
if (!currentItem) { | ||
if (branch !== execution.staticTree) { | ||
branchEnd(payload); | ||
return payloads; | ||
}); | ||
} else { | ||
execution.runFunction(currentItem, payload, prevPayload, processFunctionOutput(currentItem, runNextItem)); | ||
} | ||
nextBranch(payload); | ||
} else if (isPrimitive(currentItem, 'sequence')) { | ||
runBranch(currentItem.items, 0, payload, prevPayload, runNextItem); | ||
} else if (isPrimitive(currentItem, 'parallel')) { | ||
var itemLength = currentItem.items.length; | ||
var payloads = []; | ||
parallelStart(payload, itemLength); | ||
currentItem.items.forEach(function (func, index) { | ||
if (func.function) { | ||
execution.runFunction(func, payload, prevPayload, processFunctionOutput(func, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
})); | ||
} else { | ||
runBranch(func.items, 0, payload, prevPayload, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
}); | ||
} | ||
return payloads; | ||
}); | ||
} else { | ||
execution.runFunction(currentItem, payload, prevPayload, processFunctionOutput(currentItem, runNextItem)); | ||
} | ||
}); | ||
} | ||
return runBranch([execution.staticTree], 0, initialPayload, null, end); | ||
runBranch([execution.staticTree], 0, initialPayload, null, end); | ||
} | ||
//# sourceMappingURL=executeTree.js.map |
export { default as debounce } from './debounce'; | ||
export { default as wait } from './wait'; | ||
//# sourceMappingURL=index.js.map |
@@ -238,2 +238,3 @@ 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 contextProviders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -246,2 +247,5 @@ _classCallCheck(this, FunctionTree); | ||
_this.cachedStaticTrees = []; | ||
_this.executeBranchWrapper = options.executeBranchWrapper || function (cb) { | ||
cb(); | ||
}; | ||
@@ -316,3 +320,3 @@ if ((typeof contextProviders === 'undefined' ? 'undefined' : _typeof(contextProviders)) !== 'object' || contextProviders === null || Array.isArray(contextProviders)) { | ||
_this2.emit('start', execution, payload); | ||
executeTree(execution, payload, function (funcDetails, path, currentPayload) { | ||
executeTree(execution, payload, _this2.executeBranchWrapper, function (funcDetails, path, currentPayload) { | ||
_this2.emit('pathStart', path, execution, funcDetails, currentPayload); | ||
@@ -319,0 +323,0 @@ }, function (currentPayload) { |
@@ -13,7 +13,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
_ref$wrap = _ref.wrap, | ||
wrap = _ref$wrap === undefined ? true : _ref$wrap; | ||
wrap = _ref$wrap === undefined ? true : _ref$wrap, | ||
_ref$ignoreDefinition = _ref.ignoreDefinition, | ||
ignoreDefinition = _ref$ignoreDefinition === undefined ? false : _ref$ignoreDefinition; | ||
_classCallCheck(this, Provider); | ||
this.verifyDefinition(definition); | ||
if (!ignoreDefinition) { | ||
this.verifyDefinition(definition); | ||
} | ||
this.wrap = wrap; | ||
@@ -30,3 +35,3 @@ | ||
}; | ||
this.WrappedProviderConstructor.prototype = Object.keys(definition).reduce(function (wrappedProvider, key) { | ||
this.WrappedProviderConstructor.prototype = Object.keys(ignoreDefinition ? {} : definition).reduce(function (wrappedProvider, key) { | ||
var originalFunc = definition[key]; | ||
@@ -82,2 +87,6 @@ | ||
value: function verifyDefinition(definition) { | ||
if (this.ignoreDefinition) { | ||
return; | ||
} | ||
if ((typeof definition === 'undefined' ? 'undefined' : _typeof(definition)) !== 'object' || definition === null) { | ||
@@ -84,0 +93,0 @@ throw new Error('The definition passed as Provider is not valid'); |
@@ -1,4 +0,4 @@ | ||
import { FunctionTreeExecutable } from '../' | ||
import { FunctionTree } from '../' | ||
export interface DebounceFunction extends FunctionTreeExecutable { | ||
export interface DebounceFunction extends FunctionTree { | ||
displayName: string | ||
@@ -13,2 +13,8 @@ (context: { path: string }): Promise<any> | ||
export const debounce: Debounce | ||
export const debounce: Debounce | ||
export interface Wait { | ||
(time: number): FunctionTree | ||
} | ||
export const wait: Wait |
173
index.d.ts
import { EventEmitter } from 'eventemitter3' | ||
interface Payload { | ||
[key: string]: any | ||
[key: number]: any | ||
} | ||
export interface IPath { | ||
path: string | ||
payload: Payload | ||
} | ||
export class Path implements IPath { | ||
path: string | ||
payload: Payload | ||
constructor(path: string, payload: Payload) | ||
toJS(): IPath | ||
} | ||
export class Abort { | ||
constructor(payload: Payload) | ||
} | ||
export function createStaticTree(tree: Primitive | Array<Function | Primitive>): Array<Primitive> | ||
type RunFunctionResolve = (funcDetails: Primitive, payload: Payload, prevPayload: Payload, next: any) => void | ||
type BranchStartCallback = (funcDetails: Primitive, path: string, payload: Payload) => void | ||
type BranchEndCallback = (payload: Payload) => void | ||
type ParallelStartEndCallback = (payload: Payload, itemLength: number) => void | ||
type ParallelProgressCallback = (payload: Payload, remainingLength: number) => void | ||
export function executeTree( | ||
tree: Array<Primitive>, | ||
resolveFunctionResult: RunFunctionResolve, | ||
initialPayload: Payload, | ||
branchStart: BranchStartCallback, | ||
branchEnd: BranchEndCallback, | ||
parallelStart: ParallelStartEndCallback, | ||
parallelProgress: ParallelProgressCallback, | ||
parallelEnd: ParallelStartEndCallback, | ||
end: BranchEndCallback | ||
): void | ||
export class Primitive { | ||
name?: string | ||
"function": Function | ||
function: Function | ||
functionIndex: number | ||
@@ -55,104 +13,66 @@ items: Array<Primitive> | ||
// deprectated, use Primitive instead | ||
export type FunctionTreePrimitive = Primitive | ||
export interface FunctionTreeExecutable { | ||
type TPath = { | ||
[key: string]: TFunctionTreeExecutable | ||
} | ||
export function sequence(items: Array<FunctionTreeExecutable>): Primitive | ||
export function sequence(name: string, items: Array<FunctionTreeExecutable>): Primitive | ||
type TSequenceArray = Array<Primitive | Function | TPath> | ||
export function parallel(items: Array<FunctionTreeExecutable>): Primitive | ||
export function parallel(name: string, items: Array<FunctionTreeExecutable>): Primitive | ||
export type TFunctionTreeExecutable = Primitive | Function | TPath | TSequenceArray | ||
export interface RunTreeFunction { | ||
(): void | ||
on(event: string | symbol, listener: Function): this | ||
once(event: string | symbol, listener: Function): this | ||
off(event: string | symbol, listener: Function): this | ||
interface IPayload { | ||
[key: string]: any | ||
[key: number]: any | ||
} | ||
export interface IPath { | ||
path: string | ||
payload: IPayload | ||
} | ||
export interface DevtoolsOptions { | ||
host: string | ||
type TContextProviders = { | ||
[key: string]: Provider | ||
} | ||
export class Devtools { | ||
constructor(options: DevtoolsOptions) | ||
addListeners(): void | ||
init(): void | ||
safeStringify(object: any): string | ||
reInit(): void | ||
sendMessage(message: string): void | ||
watchExecution(tree: FunctionTree): void | ||
sendInitial(): void | ||
createExecutionMessage(debuggingData: any, context: any, functionDetails: Primitive, payload: Payload): string | ||
sendExecutionData(debuggingData: any, context: any, functionDetails: Primitive, payload: Payload): void | ||
Provider(): (context: any, functionDetails: Primitive, payload: Payload) => any | ||
export class FunctionTree extends EventEmitter { | ||
constructor(contextProviders?: TContextProviders) | ||
run(sequence: TFunctionTreeExecutable, payload?: IPayload): Promise<any> | ||
} | ||
export class FunctionTreeError extends Error { | ||
constructor(error: any) | ||
toJSON(): any | ||
export interface IBaseContext { | ||
[providerName: string]: any | ||
resolve: IResolve | ||
} | ||
export class FunctionTreeExecutionError extends FunctionTreeError { | ||
constructor(execution: any, funcDetails: any, payload: any, error: any) | ||
toJSON(): any | ||
export interface IContext<T={}> extends IBaseContext { | ||
props: T | ||
} | ||
export type Provider = (context: any, funcDetails: Primitive, payload: Payload, next: Payload) => any | ||
type TTagFactory<T> = (path: TemplateStringsArray | string[], ...values: any[]) => Tag<T> | ||
export function ReduxProvider(store: any): Provider | ||
export function PropsProvider(): Provider | ||
export function PathProvider(): Provider | ||
export function ExecutionProvider(execution: any, abort: Abort): Provider | ||
export function ContextProvider(extendedContext: any): Provider | ||
export function createTemplateTag<T=any>(tagName: string, getValue: (path: string, context: IBaseContext) => T): TTagFactory<T> | ||
export class FunctionTree extends EventEmitter { | ||
constructor(contextProviders: Array<Provider>) | ||
cachedTrees: Array<Primitive> | ||
contextProviders: Array<Provider> | ||
runTree: RunTreeFunction | ||
export function extractValueWithPath<T=any>(obj: any, path: string): T | ||
createContext(funcDetails: Primitive, payload: Payload, prevPayload: Payload): Array<Provider> | ||
run(...args: any[]): Promise<any> | ||
export function resolveObject<T=any>(obj: any): ResolveValue<T> | ||
export class Provider<IContext = {}> { | ||
constructor (definition: { [key: string]: (this: { context: IContext }, ...args : any[]) => void }) | ||
} | ||
// ========= Contextual value | ||
export interface BaseContext { | ||
[providerName: string]: any | ||
// Keys set to 'any' type are not defined so that they | ||
// can be overriden in generic type. | ||
// execution: any | ||
// path: any | ||
// props: any | ||
resolve: Resolve | ||
export class Path implements IPath { | ||
path: string | ||
payload: IPayload | ||
constructor(path: string, payload: IPayload) | ||
toJS(): IPath | ||
} | ||
export type Context<T={}> = BaseContext & T | ||
export function sequence(items: Array<TSequenceArray>): Primitive | ||
export function sequence(name: string, items: Array<TSequenceArray>): Primitive | ||
export function parallel(items: Array<TSequenceArray>): Primitive | ||
export function parallel(name: string, items: Array<TSequenceArray>): Primitive | ||
export abstract class ResolveValue<T=any, C={}> { | ||
abstract getValue(context: Context<C>): T | ||
} | ||
export class ResolveValue<T=any> {} | ||
interface TagOptions { | ||
hasValue?: boolean | ||
isStateDependency?: boolean | ||
} | ||
export class Tag<T=any> extends ResolveValue<T> { | ||
constructor( | ||
tag: string, | ||
options: TagOptions, | ||
strings: string[], | ||
values: any[] | ||
) | ||
options: TagOptions | ||
strings: string[] | ||
type: string | ||
values: any[] | ||
constructor() | ||
getPath(getters: any): string | ||
@@ -162,6 +82,5 @@ getValue(getters: any): T | ||
export interface Resolve { | ||
export interface IResolve { | ||
isTag(arg: any, ...types: string[]): arg is Tag | ||
isResolveValue(arg: any): arg is ResolveValue | ||
path(tag: Tag): string | ||
@@ -172,10 +91,2 @@ value<T>(value: Tag<T>, overrideContext?: any): T | ||
value<T=any>(value: ResolveValue<T> | T, overrideContext?: any): T | ||
} | ||
// ========= Helpers | ||
export function extractValueWithPath<T=any>(obj: any, path: string): T | ||
type TagFactory<T> = (path: TemplateStringsArray | string[], ...values: any[]) => Tag<T> | ||
export function createTemplateTag<T=any>(tagName: string, getValue: (path: string, context: BaseContext) => T): TagFactory<T> | ||
export function resolveObject<T=any>(obj: any): ResolveValue<T> | ||
} |
@@ -48,3 +48,3 @@ 'use strict'; | ||
_this.latestExecutionId = null; | ||
_this.version = "3.2.0-1518985373143"; | ||
_this.version = "3.2.0-1519006927624"; | ||
_this.init(); | ||
@@ -51,0 +51,0 @@ return _this; |
@@ -18,73 +18,75 @@ 'use strict'; | ||
*/ | ||
function executeTree(execution, initialPayload, branchStart, branchEnd, parallelStart, parallelProgress, parallelEnd, end) { | ||
function executeTree(execution, initialPayload, executeBranchWrapper, branchStart, branchEnd, parallelStart, parallelProgress, parallelEnd, end) { | ||
function runBranch(branch, index, payload, prevPayload, nextBranch) { | ||
function runNextItem(result) { | ||
runBranch(branch, index + 1, result, payload, nextBranch); | ||
} | ||
executeBranchWrapper(function () { | ||
function runNextItem(result) { | ||
runBranch(branch, index + 1, result, payload, nextBranch); | ||
} | ||
function processFunctionOutput(funcDetails, outputResult) { | ||
return function (result) { | ||
var newPayload = Object.assign({}, payload, result ? result.payload : {}); | ||
function processFunctionOutput(funcDetails, outputResult) { | ||
return function (result) { | ||
var newPayload = Object.assign({}, payload, result ? result.payload : {}); | ||
if (result && funcDetails.outputs) { | ||
var outputs = Object.keys(funcDetails.outputs); | ||
if (result && funcDetails.outputs) { | ||
var outputs = Object.keys(funcDetails.outputs); | ||
if (~outputs.indexOf(result.path)) { | ||
branchStart(funcDetails, result.path, newPayload); | ||
runBranch(funcDetails.outputs[result.path].items, 0, newPayload, payload, outputResult); | ||
if (~outputs.indexOf(result.path)) { | ||
branchStart(funcDetails, result.path, newPayload); | ||
runBranch(funcDetails.outputs[result.path].items, 0, newPayload, payload, outputResult); | ||
} else { | ||
throw new _errors.FunctionTreeExecutionError(execution, funcDetails, payload, 'function ' + funcDetails.name + ' must use one of its possible outputs: ' + outputs.join(', ') + '.'); | ||
} | ||
} else { | ||
throw new _errors.FunctionTreeExecutionError(execution, funcDetails, payload, 'function ' + funcDetails.name + ' must use one of its possible outputs: ' + outputs.join(', ') + '.'); | ||
outputResult(newPayload); | ||
} | ||
} else { | ||
outputResult(newPayload); | ||
}; | ||
} | ||
var currentItem = branch[index]; | ||
if (!currentItem) { | ||
if (branch !== execution.staticTree) { | ||
branchEnd(payload); | ||
} | ||
}; | ||
} | ||
nextBranch(payload); | ||
} else if (isPrimitive(currentItem, 'sequence')) { | ||
runBranch(currentItem.items, 0, payload, prevPayload, runNextItem); | ||
} else if (isPrimitive(currentItem, 'parallel')) { | ||
var itemLength = currentItem.items.length; | ||
var payloads = []; | ||
var currentItem = branch[index]; | ||
parallelStart(payload, itemLength); | ||
currentItem.items.forEach(function (func, index) { | ||
if (func.function) { | ||
execution.runFunction(func, payload, prevPayload, processFunctionOutput(func, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
})); | ||
} else { | ||
runBranch(func.items, 0, payload, prevPayload, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
}); | ||
} | ||
if (!currentItem) { | ||
if (branch !== execution.staticTree) { | ||
branchEnd(payload); | ||
return payloads; | ||
}); | ||
} else { | ||
execution.runFunction(currentItem, payload, prevPayload, processFunctionOutput(currentItem, runNextItem)); | ||
} | ||
nextBranch(payload); | ||
} else if (isPrimitive(currentItem, 'sequence')) { | ||
runBranch(currentItem.items, 0, payload, prevPayload, runNextItem); | ||
} else if (isPrimitive(currentItem, 'parallel')) { | ||
var itemLength = currentItem.items.length; | ||
var payloads = []; | ||
parallelStart(payload, itemLength); | ||
currentItem.items.forEach(function (func, index) { | ||
if (func.function) { | ||
execution.runFunction(func, payload, prevPayload, processFunctionOutput(func, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
})); | ||
} else { | ||
runBranch(func.items, 0, payload, prevPayload, function (payload) { | ||
payloads.push(payload); | ||
if (payloads.length === itemLength) { | ||
parallelEnd(payload, itemLength); | ||
runNextItem(Object.assign.apply(Object, [{}].concat(payloads))); | ||
} else { | ||
parallelProgress(payload, itemLength - payloads.length); | ||
} | ||
}); | ||
} | ||
return payloads; | ||
}); | ||
} else { | ||
execution.runFunction(currentItem, payload, prevPayload, processFunctionOutput(currentItem, runNextItem)); | ||
} | ||
}); | ||
} | ||
return runBranch([execution.staticTree], 0, initialPayload, null, end); | ||
runBranch([execution.staticTree], 0, initialPayload, null, end); | ||
} | ||
//# sourceMappingURL=executeTree.js.map |
@@ -16,3 +16,12 @@ 'use strict'; | ||
var _wait = require('./wait'); | ||
Object.defineProperty(exports, 'wait', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_wait).default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
@@ -267,2 +267,3 @@ 'use strict'; | ||
var contextProviders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -275,2 +276,5 @@ _classCallCheck(this, FunctionTree); | ||
_this.cachedStaticTrees = []; | ||
_this.executeBranchWrapper = options.executeBranchWrapper || function (cb) { | ||
cb(); | ||
}; | ||
@@ -345,3 +349,3 @@ if ((typeof contextProviders === 'undefined' ? 'undefined' : _typeof(contextProviders)) !== 'object' || contextProviders === null || Array.isArray(contextProviders)) { | ||
_this2.emit('start', execution, payload); | ||
(0, _executeTree2.default)(execution, payload, function (funcDetails, path, currentPayload) { | ||
(0, _executeTree2.default)(execution, payload, _this2.executeBranchWrapper, function (funcDetails, path, currentPayload) { | ||
_this2.emit('pathStart', path, execution, funcDetails, currentPayload); | ||
@@ -348,0 +352,0 @@ }, function (currentPayload) { |
@@ -19,7 +19,12 @@ 'use strict'; | ||
_ref$wrap = _ref.wrap, | ||
wrap = _ref$wrap === undefined ? true : _ref$wrap; | ||
wrap = _ref$wrap === undefined ? true : _ref$wrap, | ||
_ref$ignoreDefinition = _ref.ignoreDefinition, | ||
ignoreDefinition = _ref$ignoreDefinition === undefined ? false : _ref$ignoreDefinition; | ||
_classCallCheck(this, Provider); | ||
this.verifyDefinition(definition); | ||
if (!ignoreDefinition) { | ||
this.verifyDefinition(definition); | ||
} | ||
this.wrap = wrap; | ||
@@ -36,3 +41,3 @@ | ||
}; | ||
this.WrappedProviderConstructor.prototype = Object.keys(definition).reduce(function (wrappedProvider, key) { | ||
this.WrappedProviderConstructor.prototype = Object.keys(ignoreDefinition ? {} : definition).reduce(function (wrappedProvider, key) { | ||
var originalFunc = definition[key]; | ||
@@ -88,2 +93,6 @@ | ||
value: function verifyDefinition(definition) { | ||
if (this.ignoreDefinition) { | ||
return; | ||
} | ||
if ((typeof definition === 'undefined' ? 'undefined' : _typeof(definition)) !== 'object' || definition === null) { | ||
@@ -90,0 +99,0 @@ throw new Error('The definition passed as Provider is not valid'); |
{ | ||
"name": "function-tree", | ||
"version": "3.2.0-1518985373143", | ||
"version": "3.2.0-1519006927624", | ||
"description": "When a function is not enough", | ||
@@ -11,6 +11,7 @@ "main": "lib/index.js", | ||
"test": "cross-env BABEL_ENV=test mocha --compilers js:babel-register \"src/**/*.test.js\" \"__test__/**/*.test.js\"", | ||
"test:ts": "cross-env mocha --require ts-runtime.js \"src/**/*.test.ts\" \"__test__/**/*.test.ts\"", | ||
"test:watch": "npm run test -- --watch", | ||
"build:cjs": "cross-env BABEL_ENV=cjs babel src/ --out-dir=lib/ -s", | ||
"build:es": "cross-env BABEL_ENV=es babel src/ --out-dir=es/ -s", | ||
"build": "run-p build:*", | ||
"build": "tsc && run-p build:*", | ||
"coverage": "nyc --reporter=lcov --reporter=json npm run test", | ||
@@ -26,2 +27,4 @@ "prepublish": "npm run build" | ||
"devDependencies": { | ||
"@types/assert": "0.0.31", | ||
"@types/mocha": "^2.2.47", | ||
"mock-socket": "6.0.4" | ||
@@ -28,0 +31,0 @@ }, |
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
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
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
350609
96
3450
3