Comparing version 0.1.1 to 0.1.2
@@ -39,3 +39,3 @@ 'use strict'; | ||
var initialCacheState = arguments[1] === undefined ? {} : arguments[1]; | ||
var initialCacheState = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -46,3 +46,3 @@ _classCallCheck(this, Avenger); | ||
if (process.env.NODE_ENV !== 'production') { | ||
(0, _types.EmitMeta)(meta); | ||
_types.EmitMeta(meta); | ||
} | ||
@@ -115,7 +115,3 @@ | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return (_emitter = this.emitter).on.apply(_emitter, args); | ||
return (_emitter = this.emitter).on.apply(_emitter, arguments); | ||
}; | ||
@@ -126,7 +122,3 @@ | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return (_emitter2 = this.emitter).off.apply(_emitter2, args); | ||
return (_emitter2 = this.emitter).off.apply(_emitter2, arguments); | ||
}; | ||
@@ -139,3 +131,3 @@ | ||
var built = (0, _build2['default'])(input, this.allQueries); | ||
var built = _build2['default'](input, this.allQueries); | ||
@@ -152,3 +144,3 @@ // cleanup current result.. | ||
return (0, _run.runLocal)({ | ||
return _run.runLocal({ | ||
input: built, | ||
@@ -177,3 +169,3 @@ oldInput: this.currentInput, | ||
return (0, _invalidate2.invalidateLocal)({ | ||
return _invalidate2.invalidateLocal({ | ||
invalidate: _invalidate, | ||
@@ -198,3 +190,3 @@ input: this.currentInput, | ||
if (process.env.NODE_ENV !== 'production') { | ||
(0, _types.Command)(command); | ||
_types.Command(command); | ||
} | ||
@@ -208,3 +200,3 @@ | ||
}); | ||
} | ||
}; | ||
@@ -221,4 +213,2 @@ // runToRecipe(input, state) { | ||
// } | ||
; | ||
return Avenger; | ||
@@ -225,0 +215,0 @@ })(); |
@@ -24,7 +24,7 @@ // a cache implementation able to produce an ActualizedCache | ||
var log = (0, _debug2['default'])('AvengerCache'); | ||
var log = _debug2['default']('AvengerCache'); | ||
function hashedParams(params) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
(0, _types.State)(params); | ||
_types.State(params); | ||
} | ||
@@ -36,3 +36,3 @@ var keys = Object.keys(params); | ||
var hashed = keys.map(function (k1) { | ||
return '' + k1 + ':' + params[k1]; | ||
return k1 + ':' + params[k1]; | ||
}).join('-'); | ||
@@ -46,3 +46,3 @@ return hashed ? hashed : '∅'; | ||
var initialState = arguments[0] === undefined ? {} : arguments[0]; | ||
var initialState = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -49,0 +49,0 @@ _classCallCheck(this, AvengerCache); |
@@ -41,3 +41,3 @@ 'use strict'; | ||
var _upset = (0, _upset3['default'])(input); | ||
var _upset = _upset3['default'](input); | ||
@@ -53,5 +53,5 @@ var builtUp = Object.keys(_upset).reduce(function (_ref) { | ||
}); | ||
var firstFree = (0, _lodashCollectionFind2['default'])(fromList, function (_ref2) { | ||
var firstFree = _lodashCollectionFind2['default'](fromList, function (_ref2) { | ||
var deps = _ref2.dependencies; | ||
return (0, _lodashCollectionEvery2['default'])(Object.keys(deps || {}).map(function (k) { | ||
return _lodashCollectionEvery2['default'](Object.keys(deps || {}).map(function (k) { | ||
return deps[k].query.id; | ||
@@ -63,3 +63,3 @@ }), function (id) { | ||
return { | ||
from: _extends({}, (0, _lodashObjectOmit2['default'])(from, firstFree.id)), | ||
from: _extends({}, _lodashObjectOmit2['default'](from, firstFree.id)), | ||
to: _extends({}, to, (_extends3 = {}, _extends3[firstFree.id] = { | ||
@@ -66,0 +66,0 @@ query: firstFree, |
@@ -43,3 +43,3 @@ 'use strict'; | ||
var depsKeys = Object.keys(depsParams); | ||
_tcomb2['default'].assert((0, _lodashArrayUnion2['default'])(stateKeys, depsKeys).length === stateKeys.length + depsKeys.length, 'duplicate keys between state params and dependencies params for query ' + id + '. state:', state, 'deps:', depsParams); | ||
_tcomb2['default'].assert(_lodashArrayUnion2['default'](stateKeys, depsKeys).length === stateKeys.length + depsKeys.length, 'duplicate keys between state params and dependencies params for query ' + id + '. state:', state, 'deps:', depsParams); | ||
} | ||
@@ -54,3 +54,3 @@ | ||
var filteredCacheParams = filteredKeys.reduce.apply(filteredKeys, (0, _util.collect)(allParams)); | ||
var filteredCacheParams = filteredKeys.reduce.apply(filteredKeys, _util.collect(allParams)); | ||
var fromCache = cacheable && cache.get(id, filteredCacheParams); | ||
@@ -72,3 +72,3 @@ var needsFetch = cacheMode === 'optimistic' || !fromCache; | ||
return res; | ||
}, (0, _util.error)(emit, id, reject))['catch']((0, _util.error)(emit, id, reject)); | ||
}, _util.error(emit, id, reject))['catch'](_util.error(emit, id, reject)); | ||
} else { | ||
@@ -75,0 +75,0 @@ return Promise.resolve(fromCache); |
@@ -35,5 +35,11 @@ 'use strict'; | ||
var invalidate = params.invalidate; | ||
var input = params.input; | ||
var result = params.result; | ||
var | ||
// queries to be invalidated | ||
invalidate = params.invalidate; | ||
var | ||
// current QS queries | ||
input = params.input; | ||
var | ||
// current result | ||
result = params.result; | ||
var state = params.state; | ||
@@ -68,3 +74,3 @@ var cache = params.cache; | ||
}); | ||
var filteredCacheParams = filteredKeys.reduce.apply(filteredKeys, (0, _util.collect)(allParams)); | ||
var filteredCacheParams = filteredKeys.reduce.apply(filteredKeys, _util.collect(allParams)); | ||
@@ -86,3 +92,3 @@ // invalidate cache for this query | ||
return (0, _run.runLocal)({ | ||
return _run.runLocal({ | ||
state: state, oldState: state, | ||
@@ -99,8 +105,2 @@ input: input, oldInput: oldInput, | ||
// export function invalidateRemote() {} | ||
// queries to be invalidated | ||
// current QS queries | ||
// current result | ||
// export function invalidateRemote() {} |
@@ -14,3 +14,3 @@ 'use strict'; | ||
var _types = require('./types'); | ||
var _types = require( /*, MinimizedCache*/'./types'); | ||
@@ -69,3 +69,3 @@ var _util = require('./util'); | ||
var diff = (0, _positiveDiff2['default'])({ | ||
var diff = _positiveDiff2['default']({ | ||
a: input, b: oldInput, aState: state, bState: oldState | ||
@@ -75,3 +75,3 @@ }); | ||
return diff[k]; | ||
})).reduce.apply(_Object$keys$filter, (0, _util.collect)(input)); | ||
})).reduce.apply(_Object$keys$filter, _util.collect(input)); | ||
var runState = {}; | ||
@@ -96,10 +96,10 @@ | ||
var depsPrsObj = (_Object$keys = Object.keys(parents)).reduce.apply(_Object$keys, (0, _util.collect)(parents, _run)); | ||
var depsPrs = (0, _util.allValues)(depsPrsObj); | ||
var depsPrsObj = (_Object$keys = Object.keys(parents)).reduce.apply(_Object$keys, _util.collect(parents, _run)); | ||
var depsPrs = _util.allValues(depsPrsObj); | ||
runState[id] = new Promise(function (resolve, reject) { | ||
depsPrs.then(function (depsResults) { | ||
return (0, _createFetcher2['default'])({ | ||
return _createFetcher2['default']({ | ||
id: id, fetch: fetch, state: state, cache: cache, cacheMode: cacheMode, cacheParams: cacheParams, emit: emit, reject: reject, | ||
depsParams: (0, _minDepsParams2['default'])(dependencies || {}, depsResults), | ||
depsParams: _minDepsParams2['default'](dependencies || {}, depsResults), | ||
multiDep: (function () { | ||
@@ -119,4 +119,4 @@ var multiKey = Object.keys(dependencies || {}).filter(function (k) { | ||
return res; | ||
}, (0, _util.error)(emit, id, reject)); | ||
}, (0, _util.error)(emit, id, reject))['catch']((0, _util.error)(emit, id, reject)); | ||
}, _util.error(emit, id, reject)); | ||
}, _util.error(emit, id, reject))['catch'](_util.error(emit, id, reject)); | ||
}); | ||
@@ -127,3 +127,3 @@ | ||
return (0, _util.allValues)((_Object$keys2 = Object.keys(toRun)).reduce.apply(_Object$keys2, (0, _util.collect)(toRun, _run))); | ||
return _util.allValues((_Object$keys2 = Object.keys(toRun)).reduce.apply(_Object$keys2, _util.collect(toRun, _run))); | ||
} | ||
@@ -141,4 +141,2 @@ | ||
// } | ||
/*, MinimizedCache*/ | ||
// } |
@@ -130,2 +130,3 @@ 'use strict'; | ||
exports.EmitMeta = EmitMeta; | ||
// export const MinimizedCache = t.dict( | ||
@@ -150,3 +151,2 @@ // // dependant qId | ||
// }) | ||
// }, 'Value'); | ||
exports.EmitMeta = EmitMeta; | ||
// }, 'Value'); |
@@ -19,5 +19,7 @@ 'use strict'; | ||
return Promise.all(promises).then(function (values) { | ||
return (0, _lodashArrayZipObject2['default'])(keys, values); | ||
return _lodashArrayZipObject2['default'](keys, values); | ||
}, function (err) { | ||
throw err; | ||
})['catch'](function (err) { | ||
throw err; | ||
}); | ||
@@ -28,3 +30,3 @@ }; | ||
var collect = function collect(o) { | ||
var map = arguments[1] === undefined ? function (v) { | ||
var map = arguments.length <= 1 || arguments[1] === undefined ? function (v) { | ||
return v; | ||
@@ -42,7 +44,6 @@ } : arguments[1]; | ||
return function (err) { | ||
reject(err); | ||
emit({ id: id, error: true }, err); | ||
reject(err); | ||
throw err; | ||
}; | ||
}; | ||
exports.error = error; |
{ | ||
"name": "avenger", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "index.js", | ||
@@ -29,5 +29,5 @@ "scripts": { | ||
"babel": "^5.5.8", | ||
"babel-eslint": "^3.1.15", | ||
"babel-eslint": "^4.1.3", | ||
"better-assert": "^1.0.2", | ||
"eslint": "^0.23.0", | ||
"eslint": "^1.6.0", | ||
"expect": "^1.6.0", | ||
@@ -34,0 +34,0 @@ "mocha": "*", |
@@ -11,3 +11,5 @@ import zipObject from 'lodash/array/zipObject'; | ||
} | ||
); | ||
).catch(err => { | ||
throw err; | ||
}); | ||
}; | ||
@@ -24,5 +26,4 @@ | ||
export const error = (emit, id, reject) => err => { | ||
reject(err); | ||
emit({ id, error: true }, err); | ||
reject(err); | ||
throw err; | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
317804
30
1434