Skip to content

Commit

Permalink
Got ahead of my skies (#115)
Browse files Browse the repository at this point in the history
* github license is asl, so make match

* new license

* try
  • Loading branch information
epugh authored Sep 19, 2022
1 parent 4af6f81 commit f15eeac
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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 @@ -18,7 +18,7 @@
"elasticsearch",
"relevancy search"
],
"license": "MIT",
"license": "Apache-2.0",
"ignore": [
"**/.*",
"node_modules",
Expand Down
55 changes: 55 additions & 0 deletions services/promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';
// basic promise
// This file used to be shipped as part of splainer-search, along with bind.js
// It is unclear if we need it... Appears it is required by splainer. But adding
// to splainer didn't work.
(function() {
var Promise = function(taskFn, taskThis, taskArgs) {
this.completed = false;
// when taskFn signals done, do this
this.$$myFn = taskFn;
this.then = function(nextTaskFn, nextTaskThisOrArgs, nextTaskArgs) {
if (nextTaskThisOrArgs instanceof Array) {
nextTaskArgs = nextTaskThisOrArgs;
nextTaskThisOrArgs = undefined;
}
this.next = new Promise(nextTaskFn, nextTaskThisOrArgs, nextTaskArgs);
if (this.completed) {
this.completer();
}
return this.next;
};

// Run the underlying task
this.apply = function() {
taskFn.promise = this; // somebody then(...) me!
taskFn.apply(taskThis, taskArgs);
};

// We're done, the next thing can run
this.completer = function() {
this.completed = true;
if (this.next) {
this.next.apply();
this.completed = false;
}
};
this.complete = this.completer.bind(this);
};

Promise.create = function(func) {
if (func.hasOwnProperty('promise')) {
// I already have a stub promise waiting for
// somebody to call then on
return func.promise;
} else {
var firstPromise = new Promise();
return firstPromise;
}
};
window.Promise = Promise;
}());

// I have an easier time thinking as an implementor
// in terms of a sequence of asynchronous tasks to be
// chained

0 comments on commit f15eeac

Please sign in to comment.