Skip to content

Commit

Permalink
Merge pull request #1641 from davidpcaldwell/davidpcaldwell/issue/#1625
Browse files Browse the repository at this point in the history
Resolve #1625: js/object/api.html JSAPI -> Fifty
  • Loading branch information
davidpcaldwell authored Sep 1, 2024
2 parents 020ff87 + c01cf72 commit 033c84e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 167 deletions.
1 change: 0 additions & 1 deletion contributor/browser-jsapi-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
4 changes: 0 additions & 4 deletions contributor/jrunscript.jsh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}));
Expand Down
142 changes: 0 additions & 142 deletions js/object/api.html

This file was deleted.

27 changes: 26 additions & 1 deletion js/object/module.fifty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <div> <ul> <li>Object <ul> <li>ECMA 262v5: Object.keys</li> </ul> </li> <li>Array <ul> <li>JS 1.6: Array.prototype.indexOf</li> <li>JS 1.6: Array.prototype.filter</li> <li>JS 1.6: Array.prototype.forEach</li> <li>JS 1.6: Array.prototype.map</li> </ul> </li> </ul> </div>
*/
globals: boolean
}

Expand Down Expand Up @@ -693,8 +701,25 @@ namespace slime.$api.old {

export interface Exports {
Error: any
Task: any
}

export interface Tell<O,T> {
(this: O, e: Error, t: T): void
(this: O, result: { threw: Error } | { returned: T }): void
}

export interface Exports {
Task: {
tell: <O,T>(p: {
target?: O
tell: Tell<O,T>
threw?: Error
returned?: T
}) => void
}
}

export interface Exports {
/**
* @deprecated
*/
Expand Down
39 changes: 20 additions & 19 deletions js/object/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};

Expand Down

0 comments on commit 033c84e

Please sign in to comment.