diff --git a/contributor/browser-jsapi-suite.js b/contributor/browser-jsapi-suite.js index 73185482f..6beea7c40 100644 --- a/contributor/browser-jsapi-suite.js +++ b/contributor/browser-jsapi-suite.js @@ -26,7 +26,6 @@ suite.part(id, part); }; - add("js/object/", getSlimePart("js/object/api.html")); add("js/document/", getSlimePart("js/document/api.html")); // TODO: does js/promise have any real tests? add("js/promise/", getSlimePart("js/promise/api.html")); diff --git a/contributor/jrunscript.jsh.js b/contributor/jrunscript.jsh.js index 824718fde..8492c859a 100644 --- a/contributor/jrunscript.jsh.js +++ b/contributor/jrunscript.jsh.js @@ -79,10 +79,6 @@ // TODO loader/jrunscript/test/data/2/ has some tests but they require some classes in classpath })); - suite.add("js/object/other", new jsh.unit.html.Part({ - pathname: SRC.getRelativePath("js/object/api.html") - })); - suite.add("js/document", new jsh.unit.html.Part({ pathname: SRC.getRelativePath("js/document/api.html") })); diff --git a/js/object/api.html b/js/object/api.html deleted file mode 100644 index b00142899..000000000 --- a/js/object/api.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - JavaScript language constructs - - - - -
-

Context

- - -
-
-

Exports

- - -
- task - - A JavaScript function representing an operation that can be scheduled. Although it is both a function, and - represents a function-like operation (it can return a value), it does not receive arguments in the ordinary - sense; it can receive a single argument called a tell to which its results will be sent, or it can - return them directly to the caller. - -
- tell - An object to notify with the results of an task. -
has properties:
-
    -
  • -
    returned
    - A function that will be invoked when the task completes. -
    -
    Arguments
    -
      -
    1. - The value returned by the task. -
    2. -
    -
    -
  • -
  • -
    threw
    - A function that will be invoked if the task does not complete successfully. -
    -
    Arguments
    -
      -
    1. - The error (or value) thrown by the task. -
    2. -
    -
    -
  • -
  • -
    target
    - - (optional) - An object that will be this when the returned or threw functions - are invoked upon completion of the task. - -
  • -
-
-
-
Arguments
-
    -
  1. - tell - - (optional) - A recipient for the result of this task. - -
  2. -
-
-
-
Returns
- - If no tell was supplied, the value returned by the task. - -
-
-
- - diff --git a/js/object/module.fifty.ts b/js/object/module.fifty.ts index 675b4d879..827ba10d2 100644 --- a/js/object/module.fifty.ts +++ b/js/object/module.fifty.ts @@ -11,6 +11,14 @@ */ namespace slime.$api.old { export interface Context { + /** + * Whether to modify the global scope by supplying implementations of missing methods. If `true`, this module, + * in addition to providing the exports below, supplies implementations of the following JavaScript constructs if they are + * not supplied by the environment. These constructs do not currently have any automated tests implemented and thus should + * be treated as suspect. + * + *
+ */ globals: boolean } @@ -693,8 +701,25 @@ namespace slime.$api.old { export interface Exports { Error: any - Task: any + } + + export interface Tell { + (this: O, e: Error, t: T): void + (this: O, result: { threw: Error } | { returned: T }): void + } + export interface Exports { + Task: { + tell: (p: { + target?: O + tell: Tell + threw?: Error + returned?: T + }) => void + } + } + + export interface Exports { /** * @deprecated */ diff --git a/js/object/module.js b/js/object/module.js index 79e525e71..0c2a0a7db 100644 --- a/js/object/module.js +++ b/js/object/module.js @@ -672,27 +672,28 @@ $exports.Error = $loader.file("Error.js").Error; - $exports.Task = {}; - $exports.Task.tell = function(p) { - if (typeof(p.tell) != "function") { - throw new TypeError(); - } - var tell; - if (typeof(p.target) == "object" && p.target) { - tell = p.tell.bind(p.target); - } else { - tell = p.tell; - } - if (p.tell.length == 1) { - if (p.threw) { - tell({ threw: p.threw }); + $exports.Task = { + tell: function(p) { + if (typeof(p.tell) != "function") { + throw new TypeError(); + } + var tell; + if (typeof(p.target) == "object" && p.target) { + tell = p.tell.bind(p.target); } else { - tell({ returned: p.returned }); + tell = p.tell; + } + if (p.tell.length == 1) { + if (p.threw) { + tell({ threw: p.threw }); + } else { + tell({ returned: p.returned }); + } + } else if (p.tell.length == 2) { + tell(p.threw,p.returned); + } else { + throw new TypeError("Tell length: " + p.tell.length + " tell=" + p.tell.toString()); } - } else if (p.tell.length == 2) { - tell(p.threw,p.returned); - } else { - throw new TypeError("Tell length: " + p.tell.length + " tell=" + p.tell.toString()); } };