Skip to content

Commit

Permalink
enable pledge to also handle thenables
Browse files Browse the repository at this point in the history
  • Loading branch information
dlueth committed Sep 3, 2020
1 parent 24ef2bc commit 184bca6
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dist/cache/dispose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cache/states.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/demand.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/demand.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/handler/css.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/html.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/json.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/legacy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/handler/text.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/cookie.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/lzstring.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugin/sri.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qoopido.demand",
"title": "Qoopido.demand",
"description": "Promise like module loader using XHR requests and localStorage caching to dynamically load JavaScript and CSS + dynamic dependency resolution + support for custom handlers",
"version": "7.1.1",
"version": "7.1.2",
"homepage": "https://github.com/dlueth/qoopido.demand",
"author": {
"name": "Dirk Lueth",
Expand Down
6 changes: 3 additions & 3 deletions src/class/pledge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout, log,
ERROR_UNHANDLED_PLEDGE_REJECTION, FUNCTION_EMPTY, UNDEFINED, STRING_UNDEFINED, NULL,
arrayPrototypeConcat,
validatorIsInstanceOf, validatorIsTypeOf,
validatorIsThenable, validatorIsTypeOf,
functionDefer, functionToArray,
ClassWeakmap, ClassFailure
*/

//=require constants.js
//=require shortcuts.js
//=require validator/isInstanceOf.js
//=require validator/IsThenable.js
//=require validator/isTypeOf.js
//=require function/defer.js
//=require function/toArray.js
Expand Down Expand Up @@ -53,7 +53,7 @@ var ClassPledge = (function() {
try {
result = pointer.handler.apply(NULL, properties.value);

if(validatorIsInstanceOf(result, ClassPledge)) {
if(validatorIsThenable(result)) {
result.then(pointer.dfd.resolve, pointer.dfd.reject);

continue;
Expand Down
1 change: 1 addition & 0 deletions src/demand.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
options && options.settings && demand.configure(options.settings);

// include additional components
//=require validator/IsInstanceOf.js
//=require function/hash.js
//=require class/queue.js
//=require class/processor.js
Expand Down
6 changes: 3 additions & 3 deletions src/function/demand.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global
global, document, demand, provide, queue, processor, settings, setTimeout, clearTimeout,
STRING_BOOLEAN, STRING_STRING, EVENT_REJECT, EVENT_PRE_RESOLVE, EVENT_POST_RESOLVE, EVENT_PRE_CONFIGURE, EVENT_POST_CONFIGURE, EVENT_CACHE_MISS, EVENT_CACHE_HIT, EVENT_PRE_REQUEST, EVENT_POST_REQUEST, EVENT_PRE_PROCESS, EVENT_POST_PROCESS, NULL, FALSE,
validatorIsTypeOf, validatorIsObject, validatorIsPositive, validatorIsInstanceOf, validatorIsSemver,
validatorIsTypeOf, validatorIsObject, validatorIsPositive, validatorIsThenable, validatorIsSemver,
functionIterate, functionMerge, functionDefer, functionIdle, functionToArray,
ClassPledge, ClassDependency, ClassPattern, ClassLoader,
singletonEvent, singletonCache
Expand All @@ -11,7 +11,7 @@
//=require validator/isTypeOf.js
//=require validator/isObject.js
//=require validator/isPositive.js
//=require validator/isInstanceOf.js
//=require validator/isThenable.js
//=require validator/isSemver.js
//=require function/iterate.js
//=require function/merge.js
Expand Down Expand Up @@ -170,7 +170,7 @@ demand = (function() {

if(dependency.enqueue === true) {
queue.enqueue(dependency);
} else if(validatorIsInstanceOf(dependency.enqueue, ClassPledge)) {
} else if(validatorIsThenable(dependency.enqueue)) {
dependency.enqueue.then(function() { queue.enqueue(dependency); });
}
});
Expand Down

0 comments on commit 184bca6

Please sign in to comment.