From 6476fd12d5851039974b9209f72c7e2eba800435 Mon Sep 17 00:00:00 2001 From: "David P. Caldwell" Date: Sun, 26 Jun 2022 08:13:12 -0400 Subject: [PATCH] #176: Extract fp Stream to separate script Also: * Add $api.Function.RegExp.exec * Remove redundant fifty.$api.Function * Add commented-out code beginning #176 --- jsh/script/plugin.jsh.fifty.ts | 6 +- loader/$api-Function-stream.fifty.ts | 149 ++++++++++++++++++ loader/$api-Function-stream.js | 111 ++++++++++++++ loader/$api-Function.fifty.ts | 221 +++++++-------------------- loader/$api-Function.js | 103 ++----------- loader/$api.fifty.ts | 4 + loader/$api.js | 2 +- loader/mime.fifty.ts | 2 +- rhino/tools/git/module.fifty.ts | 2 +- tools/fifty/module.fifty.ts | 1 - tools/fifty/test.js | 1 - tools/wf/plugin-standard.jsh.js | 17 +++ 12 files changed, 359 insertions(+), 260 deletions(-) create mode 100644 loader/$api-Function-stream.fifty.ts create mode 100644 loader/$api-Function-stream.js diff --git a/jsh/script/plugin.jsh.fifty.ts b/jsh/script/plugin.jsh.fifty.ts index ed11fcb96..16c43bf56 100644 --- a/jsh/script/plugin.jsh.fifty.ts +++ b/jsh/script/plugin.jsh.fifty.ts @@ -338,7 +338,7 @@ namespace slime.jsh.script { fifty.tests.cli.invocation = function() { const subject = test.subject; - var parser = fifty.$api.Function.pipe( + var parser = fifty.global.$api.Function.pipe( subject.cli.option.string({ longname: "foo" }) ); var was = fifty.global.jsh.unit.$slime; @@ -365,7 +365,7 @@ namespace slime.jsh.script { }; fifty.tests.cli.run = function() { - const $api = fifty.$api; + const $api = fifty.global.$api; const subject = test.subject; var was: cli.Invocation; @@ -423,7 +423,7 @@ namespace slime.jsh.script { }; fifty.tests.cli.wrap = function() { - const $api = fifty.$api; + const $api = fifty.global.$api; var result: { status: number } = fifty.global.jsh.shell.jsh({ shell: fifty.global.jsh.shell.jsh.src, script: fifty.jsh.file.object.getRelativePath("test/cli.jsh.js").file, diff --git a/loader/$api-Function-stream.fifty.ts b/loader/$api-Function-stream.fifty.ts new file mode 100644 index 000000000..03cac51e6 --- /dev/null +++ b/loader/$api-Function-stream.fifty.ts @@ -0,0 +1,149 @@ +// LICENSE +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not +// distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// END LICENSE + +namespace slime.$api.fp { + export interface Stream { + iterate: () => { + next: Maybe, + remaining: Stream + } + } + + export interface Exports { + Stream: { + from: { + empty: () => Stream + array: (ts: T[]) => Stream + } + + //flatMap: (map: (t: T) => R) => (stream: Stream>) => Stream + + first: (ts: Stream) => Maybe + + find: { + (predicate: (w: W) => w is N): (ws: Stream) => Maybe + (predicate: Predicate): (ts: Stream) => Maybe + } + + filter: { + (predicate: (w: W) => w is N): (ws: Stream) => Stream + (predicate: Predicate): (ts: Stream) => Stream + } + + collect: (ts: Stream) => T[] + } + } + + ( + function( + fifty: slime.fifty.test.Kit + ) { + const { verify } = fifty; + const { $api } = fifty.global; + + fifty.tests.suite = function() { + fifty.run(function testEmptyStream() { + var stream = $api.Function.Stream.from.empty(); + var first = $api.Function.Stream.first(stream); + verify(first).present.is(false); + var collected = $api.Function.Stream.collect(stream); + verify(collected).length.is(0); + }); + + fifty.run(function testArrayStream() { + var array = [1,2,3,4]; + var stream = $api.Function.Stream.from.array(array); + var first = $api.Function.Stream.first(stream); + verify(first).present.is(true); + verify(first).evaluate.property("value").is(1); + var collected = $api.Function.Stream.collect(stream); + verify(collected).length.is(4); + verify(collected)[0].is(1); + verify(collected)[1].is(2); + verify(collected)[2].is(3); + verify(collected)[3].is(4); + }); + + function streamRange(start: number, limit: number): Stream { + function emptyStream(): Stream { + return { + iterate: function() { + return { + next: null, + remaining: emptyStream() + } + } + } + } + + return { + iterate: function() { + if (start < limit) { + return { + next: $api.Function.Maybe.value(start), + remaining: streamRange(start+1, limit) + } + } else { + return { + next: $api.Function.Maybe.nothing(), + remaining: emptyStream() + } + } + } + } + } + + function streamTo(limit: number): Stream { + return streamRange(0, limit); + } + + var isOdd: Predicate = (n: number) => n % 2 == 1; + + fifty.run(function testStream() { + var rv = $api.Function.Stream.collect(streamTo(10)); + verify(rv.join(",")).is("0,1,2,3,4,5,6,7,8,9") + }); + + fifty.run(function testFilter() { + var rv = $api.Function.result( + streamTo(10), + $api.Function.pipe( + $api.Function.Stream.filter(isOdd), + $api.Function.Stream.collect + ) + ); + verify(rv.join(",")).is("1,3,5,7,9"); + }); + + fifty.run(function testFind() { + var firstOdd = $api.Function.result( + streamTo(10), + $api.Function.Stream.find(isOdd) + ); + verify(firstOdd).present.is(true); + verify(firstOdd).evaluate.property("value").is(1); + + var firstOver10 = $api.Function.result( + streamTo(10), + $api.Function.Stream.find(function(v) { return v > 10; }) + ); + verify(firstOver10).present.is(false); + }); + } + } + //@ts-ignore + )(fifty); +} + +namespace slime.$api.fp.internal.stream { + export interface Context { + $f: slime.$api.Global["Function"] + } + + export type Exports = slime.$api.fp.Exports["Stream"]; + + export type Script = slime.loader.Script +} diff --git a/loader/$api-Function-stream.js b/loader/$api-Function-stream.js new file mode 100644 index 000000000..ae9c5c6bf --- /dev/null +++ b/loader/$api-Function-stream.js @@ -0,0 +1,111 @@ +// LICENSE +// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not +// distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// END LICENSE + +//@ts-check +( + /** + * + * @param { slime.$api.fp.internal.stream.Context } $context + * @param { slime.loader.Export } $export + */ + function($context,$export) { + var $f = $context.$f; + + $export({ + from: { + empty: function() { + return { + iterate: function() { + return { + next: $f.Maybe.nothing(), + remaining: $f.Stream.from.empty() + } + } + } + }, + array: function(array) { + /** + * @template { any } T + * @param { T[] } array + * @param { number } index + * @returns { slime.$api.fp.Stream } + */ + var ArrayStream = function recurse(array,index) { + return { + iterate: function() { + if (index < array.length) { + return { + next: $f.Maybe.value(array[index]), + remaining: recurse(array, index+1) + } + } else { + return { + next: $f.Maybe.nothing(), + remaining: $f.Stream.from.empty() + } + } + } + } + } + + return ArrayStream(array, 0); + } + }, + first: function(stream) { + return stream.iterate().next; + }, + collect: function(stream) { + var rv = []; + var more = true; + while(more) { + var current = stream.iterate(); + if (current.next.present) { + rv.push(current.next.value); + stream = current.remaining; + } else { + more = false; + } + } + return rv; + }, + filter: function filter(predicate) { + return function(stream) { + return { + iterate: function() { + while(true) { + var current = stream.iterate(); + if (!current.next.present) { + return { + next: $f.Maybe.nothing(), + remaining: $f.Stream.from.empty() + } + } + if (current.next.present && predicate(current.next.value)) { + return { + next: current.next, + remaining: filter(predicate)(current.remaining) + } + } else { + stream = current.remaining; + } + } + } + } + } + }, + find: function find(predicate) { + return $f.pipe( + $f.Stream.filter(predicate), + $f.Stream.first + ) + }//, + // flatMap: function(map) { + // throw new Error("Unimplemented"); + // } + }); + } +//@ts-ignore +)($context,$export); diff --git a/loader/$api-Function.fifty.ts b/loader/$api-Function.fifty.ts index 61d866d03..8e89d9a43 100644 --- a/loader/$api-Function.fifty.ts +++ b/loader/$api-Function.fifty.ts @@ -66,7 +66,7 @@ namespace slime.$api.fp { }; verify(calls).is(void(0)); - var memoized = fifty.$api.Function.memoized(counter); + var memoized = fifty.global.$api.Function.memoized(counter); verify(calls).is(void(0)); var result = memoized(); verify(result).is(42); @@ -221,9 +221,9 @@ namespace slime.$api.fp { } }; - var x = fifty.$api.Function.result( + var x = fifty.global.$api.Function.result( 2, - fifty.$api.Function.pipe( + fifty.global.$api.Function.pipe( times(3), plus(4) ) @@ -266,7 +266,7 @@ namespace slime.$api.fp { const { verify } = fifty; fifty.tests.is = function() { - var is2 = fifty.$api.Function.is(2); + var is2 = fifty.global.$api.Function.is(2); verify(is2(2)).is(true); //@ts-ignore @@ -348,14 +348,14 @@ namespace slime.$api.fp { fifty: slime.fifty.test.Kit ) { fifty.tests.string = function() { - var subject = fifty.$api.Function.string; + var subject = fifty.global.$api.Function.string; fifty.run(function repeat() { - var one = fifty.$api.Function.string.repeat(1)("foo"); + var one = fifty.global.$api.Function.string.repeat(1)("foo"); fifty.verify(one).is("foo"); - var three = fifty.$api.Function.string.repeat(3)("foo"); + var three = fifty.global.$api.Function.string.repeat(3)("foo"); fifty.verify(three).is("foofoofoo"); - var zero = fifty.$api.Function.string.repeat(0)("foo"); + var zero = fifty.global.$api.Function.string.repeat(0)("foo"); fifty.verify(zero).is(""); }); @@ -393,7 +393,7 @@ namespace slime.$api.fp { fifty.tests.Object = function() { run(function fromEntries() { var array = [ ["a", 2], ["b", 3] ]; - var result: { a: number, b: number } = fifty.$api.Function.result( + var result: { a: number, b: number } = fifty.global.$api.Function.result( array, Object.fromEntries ) as { a: number, b: number }; @@ -420,137 +420,6 @@ namespace slime.$api.fp { else: (f: () => T) => (m: Maybe) => T } } - - export interface Stream { - iterate: () => { - next: Maybe, - remaining: Stream - } - } - - export interface Exports { - Stream: { - from: { - empty: () => Stream - array: (ts: T[]) => Stream - } - - first: (ts: Stream) => Maybe - - collect: (ts: Stream) => T[] - - filter: { - (predicate: (w: W) => w is N): (ws: Stream) => Stream - (predicate: Predicate): (ts: Stream) => Stream - } - - find: { - (predicate: (w: W) => w is N): (ws: Stream) => Maybe - (predicate: Predicate): (ts: Stream) => Maybe - } - } - } - - ( - function( - fifty: slime.fifty.test.Kit - ) { - const { verify } = fifty; - const { $api } = fifty.global; - - fifty.tests.Stream = function() { - fifty.run(function testEmptyStream() { - var stream = $api.Function.Stream.from.empty(); - var first = $api.Function.Stream.first(stream); - verify(first).present.is(false); - var collected = $api.Function.Stream.collect(stream); - verify(collected).length.is(0); - }); - - fifty.run(function testArrayStream() { - var array = [1,2,3,4]; - var stream = $api.Function.Stream.from.array(array); - var first = $api.Function.Stream.first(stream); - verify(first).present.is(true); - verify(first).evaluate.property("value").is(1); - var collected = $api.Function.Stream.collect(stream); - verify(collected).length.is(4); - verify(collected)[0].is(1); - verify(collected)[1].is(2); - verify(collected)[2].is(3); - verify(collected)[3].is(4); - }); - - function streamRange(start: number, limit: number): Stream { - function emptyStream(): Stream { - return { - iterate: function() { - return { - next: null, - remaining: emptyStream() - } - } - } - } - - return { - iterate: function() { - if (start < limit) { - return { - next: $api.Function.Maybe.value(start), - remaining: streamRange(start+1, limit) - } - } else { - return { - next: $api.Function.Maybe.nothing(), - remaining: emptyStream() - } - } - } - } - } - - function streamTo(limit: number): Stream { - return streamRange(0, limit); - } - - var isOdd: Predicate = (n: number) => n % 2 == 1; - - fifty.run(function testStream() { - var rv = $api.Function.Stream.collect(streamTo(10)); - verify(rv.join(",")).is("0,1,2,3,4,5,6,7,8,9") - }); - - fifty.run(function testFilter() { - var rv = $api.Function.result( - streamTo(10), - $api.Function.pipe( - $api.Function.Stream.filter(isOdd), - $api.Function.Stream.collect - ) - ); - verify(rv.join(",")).is("1,3,5,7,9"); - }); - - fifty.run(function testFind() { - var firstOdd = $api.Function.result( - streamTo(10), - $api.Function.Stream.find(isOdd) - ); - verify(firstOdd).present.is(true); - verify(firstOdd).evaluate.property("value").is(1); - - var firstOver10 = $api.Function.result( - streamTo(10), - $api.Function.Stream.find(function(v) { return v > 10; }) - ); - verify(firstOver10).present.is(false); - }); - } - } - //@ts-ignore - )(fifty); - export interface Exports { Array: { filter: (f: fp.Predicate) => (ts: T[]) => T[] @@ -604,8 +473,8 @@ namespace slime.$api.fp { { a: 2, b: "b" } ] - const f1: Predicate = fifty.$api.Function.Predicate.property("a", function(v) { return v == 1; }); - const f2: Predicate = fifty.$api.Function.Predicate.property("b", function(v) { return v == "b"; }); + const f1: Predicate = fifty.global.$api.Function.Predicate.property("a", function(v) { return v == 1; }); + const f2: Predicate = fifty.global.$api.Function.Predicate.property("b", function(v) { return v == "b"; }); verify(ts).evaluate(function(ts) { return ts.filter(f1); }).length.is(1); verify(ts.filter(f1))[0].a.is(1); @@ -639,17 +508,23 @@ namespace slime.$api.fp { * @param modifier A function that receives the pattern of the original RegExp as an argumentt and returns a new pattern. */ modify: (modifier: (pattern: string) => string) => (original: RegExp) => RegExp + + exec: (regexp: RegExp) => (string: string) => Maybe } } ( function( - $api: slime.$api.Global, fifty: slime.fifty.test.Kit ) { - fifty.tests.RegExp = function() { + const { verify } = fifty; + const subject = fifty.global.$api.Function.RegExp; + + fifty.tests.exports.RegExp = fifty.test.Parent(); + + fifty.tests.exports.RegExp.modify = function() { var foo = /^(.*)foo$/; - var bar = fifty.$api.Function.RegExp.modify( + var bar = subject.modify( function(pattern) { return pattern.replace(/foo/g, "bar"); } )(foo); @@ -664,10 +539,26 @@ namespace slime.$api.fp { verify(foo).evaluate(test("bar")).is(false); verify(bar).evaluate(test("foo")).is(false); verify(bar).evaluate(test("bar")).is(true); + }; + + fifty.tests.exports.RegExp.exec = function() { + var pattern = /a(b+)c/; + + var matcher = subject.exec(pattern); + + var one = matcher("abbc"); + verify(one).present.is(true); + if (one.present) { + verify(one).value[0].is("abbc"); + verify(one).value[1].is("bb"); + } + + var two = matcher("ac"); + verify(two).present.is(false); } } //@ts-ignore - )($api,fifty); + )(fifty); export type Comparator = (t1: T, t2: T) => number @@ -710,27 +601,27 @@ namespace slime.$api.fp { { name: "b", value: 0 }, { name: "c", value: 2 } ]; - var comparator: slime.$api.fp.Comparator<{ name: string, value: number }> = fifty.$api.Function.comparator.create( - fifty.$api.Function.property("value"), - fifty.$api.Function.comparator.operators + var comparator: slime.$api.fp.Comparator<{ name: string, value: number }> = fifty.global.$api.Function.comparator.create( + fifty.global.$api.Function.property("value"), + fifty.global.$api.Function.comparator.operators ); array.sort(comparator); verify(array)[0].name.is("b"); verify(array)[1].name.is("a"); verify(array)[2].name.is("c"); - array.sort(fifty.$api.Function.comparator.reverse(comparator)); + array.sort(fifty.global.$api.Function.comparator.reverse(comparator)); verify(array)[0].name.is("c"); verify(array)[1].name.is("a"); verify(array)[2].name.is("b"); - var tiebreaking: slime.$api.fp.Comparator<{ name: string, value: number, tiebreaker: number }> = fifty.$api.Function.comparator.create( - fifty.$api.Function.property("tiebreaker"), - fifty.$api.Function.comparator.operators + var tiebreaking: slime.$api.fp.Comparator<{ name: string, value: number, tiebreaker: number }> = fifty.global.$api.Function.comparator.create( + fifty.global.$api.Function.property("tiebreaker"), + fifty.global.$api.Function.comparator.operators ); - var multicomparator: slime.$api.fp.Comparator<{ name: string, value: number, tiebreaker: number }> = fifty.$api.Function.comparator.compose( - fifty.$api.Function.comparator.reverse(comparator), - fifty.$api.Function.comparator.reverse(tiebreaking) + var multicomparator: slime.$api.fp.Comparator<{ name: string, value: number, tiebreaker: number }> = fifty.global.$api.Function.comparator.compose( + fifty.global.$api.Function.comparator.reverse(comparator), + fifty.global.$api.Function.comparator.reverse(tiebreaking) ); var multi = [ @@ -848,7 +739,7 @@ namespace slime.$api.fp { var f3 = function(p: { number: number }) { p.number -= 3; } - var f = fifty.$api.Function.impure.compose(f1, f2, f3); + var f = fifty.global.$api.Function.impure.compose(f1, f2, f3); var input = { number: 4 }; var output = f(input); verify(output).number.is(7); @@ -857,14 +748,14 @@ namespace slime.$api.fp { return { number: 9 }; }; - var r = fifty.$api.Function.impure.compose(f1, r1, f3); + var r = fifty.global.$api.Function.impure.compose(f1, r1, f3); var rinput = { number: 4 }; var routput = r(rinput); verify(routput).number.is(6); fifty.run(function() { - var nullRevision = fifty.$api.Function.impure.revise(null); - var undefinedRevision = fifty.$api.Function.impure.revise(void(0)); + var nullRevision = fifty.global.$api.Function.impure.revise(null); + var undefinedRevision = fifty.global.$api.Function.impure.revise(void(0)); var two = { number: 2 } @@ -880,7 +771,7 @@ namespace slime.$api.fp { function(a: A) { a.b++ }, function(a: A) { a.c = 0 } ]; - var update = fifty.$api.Function.impure.Update.compose(updates); + var update = fifty.global.$api.Function.impure.Update.compose(updates); update(a); verify(a).a.is(2); verify(a).b.is(3); @@ -1024,7 +915,7 @@ namespace slime.$api.fp { const { verify } = fifty; fifty.tests.deprecated = function() { - var check = fifty.$api.Function.argument.check; + var check = fifty.global.$api.Function.argument.check; var tester = { invoke: function(argument,array) { @@ -1048,7 +939,6 @@ namespace slime.$api.fp { fifty.tests.suite = function() { fifty.run(fifty.tests.exports); fifty.run(fifty.tests.string); - fifty.run(fifty.tests.RegExp); fifty.run(fifty.tests.impure); fifty.run(fifty.tests.compare); fifty.run(fifty.tests.is); @@ -1056,7 +946,8 @@ namespace slime.$api.fp { fifty.run(fifty.tests.Object); fifty.run(fifty.tests.deprecated); fifty.run(fifty.tests.series); - fifty.run(fifty.tests.Stream); + + fifty.load("$api-Function-stream.fifty.ts"); } } //@ts-ignore @@ -1076,6 +967,8 @@ namespace slime.$api.fp.internal { events: slime.runtime.internal.events.Exports deprecate: slime.$api.Global["deprecate"] + + script: slime.$api.internal.script } export interface Exports { diff --git a/loader/$api-Function.js b/loader/$api-Function.js index 767170cad..e72960ccc 100644 --- a/loader/$api-Function.js +++ b/loader/$api-Function.js @@ -173,95 +173,15 @@ } } - $exports.Function.Stream = { - from: { - empty: function() { - return { - iterate: function() { - return { - next: $exports.Function.Maybe.nothing(), - remaining: $exports.Function.Stream.from.empty() - } - } - } - }, - array: function(array) { - /** - * @template { any } T - * @param { T[] } array - * @param { number } index - * @returns { slime.$api.fp.Stream } - */ - var ArrayStream = function recurse(array,index) { - return { - iterate: function() { - if (index < array.length) { - return { - next: $exports.Function.Maybe.value(array[index]), - remaining: recurse(array, index+1) - } - } else { - return { - next: $exports.Function.Maybe.nothing(), - remaining: $exports.Function.Stream.from.empty() - } - } - } - } - } + var code = { + /** @type { slime.$api.fp.internal.stream.Script } */ + Stream: $context.script("$api-Function-stream.js") + }; - return ArrayStream(array, 0); - } - }, - first: function(stream) { - return stream.iterate().next; - }, - collect: function(stream) { - var rv = []; - var more = true; - while(more) { - var current = stream.iterate(); - if (current.next.present) { - rv.push(current.next.value); - stream = current.remaining; - } else { - more = false; - } - } - return rv; - }, - filter: function filter(predicate) { - return function(stream) { - return { - iterate: function() { - while(true) { - var current = stream.iterate(); - if (!current.next.present) { - return { - next: $exports.Function.Maybe.nothing(), - remaining: $exports.Function.Stream.from.empty() - } - } - if (current.next.present && predicate(current.next.value)) { - return { - next: current.next, - remaining: filter(predicate)(current.remaining) - } - } else { - stream = current.remaining; - } - } - } - } - } - }, - find: function find(predicate) { - return $exports.Function.pipe( - $exports.Function.Stream.filter(predicate), - $exports.Function.Stream.first - ) - } - } + $exports.Function.Stream = code.Stream({ + //@ts-ignore + $f: $exports.Function + }) $exports.Function.Array = { filter: function(f) { @@ -387,6 +307,13 @@ return function(regexp) { return new RegExp( modifier(regexp.source) ); } + }, + exec: function(regexp) { + return function(string) { + // We copy the RegExp to deal with possibilities of multithreaded access + var copy = new RegExp(regexp.source); + return $exports.Function.Maybe.from(copy.exec(string)); + } } } diff --git a/loader/$api.fifty.ts b/loader/$api.fifty.ts index dabfa3b4a..fd664b343 100644 --- a/loader/$api.fifty.ts +++ b/loader/$api.fifty.ts @@ -426,3 +426,7 @@ namespace slime.$api { //@ts-ignore )(fifty) } + +namespace slime.$api.internal { + export type script = (name: string) => slime.loader.Script +} diff --git a/loader/$api.js b/loader/$api.js index 827aa8b00..7720cd838 100644 --- a/loader/$api.js +++ b/loader/$api.js @@ -72,7 +72,7 @@ (function() { var old = code.Function_old({ deprecate: $exports.deprecate }); - var current = code.Function({ $api: $exports, events: events, old: old, deprecate: $exports.deprecate }); + var current = code.Function({ $api: $exports, events: events, old: old, deprecate: $exports.deprecate, script: script }); Object.assign($exports, current); })(); diff --git a/loader/mime.fifty.ts b/loader/mime.fifty.ts index 15c07062d..b390e0370 100644 --- a/loader/mime.fifty.ts +++ b/loader/mime.fifty.ts @@ -79,7 +79,7 @@ namespace slime.$api { ) { fifty.tests.suite = function() { var subject: slime.$api.mime.Export = fifty.$loader.module("mime.js", { - Function: fifty.$api.Function, + Function: fifty.global.$api.Function, deprecate: function(f) { return f; } diff --git a/rhino/tools/git/module.fifty.ts b/rhino/tools/git/module.fifty.ts index cc57678e8..67d77f65b 100644 --- a/rhino/tools/git/module.fifty.ts +++ b/rhino/tools/git/module.fifty.ts @@ -366,7 +366,7 @@ namespace slime.jrunscript.tools.git { }); fifty.run(function worksWithEmptyDirectory() { - const $api = fifty.$api; + const $api = fifty.global.$api; var directory = fifty.jsh.file.object.temporary.directory(); fixture.write({ diff --git a/tools/fifty/module.fifty.ts b/tools/fifty/module.fifty.ts index a4f36b748..ac528f0bd 100644 --- a/tools/fifty/module.fifty.ts +++ b/tools/fifty/module.fifty.ts @@ -115,7 +115,6 @@ namespace slime.fifty { }, promises: slime.definition.test.promises.Export $api: { - Function: slime.$api.Global["Function"] Events: { /** * Creates a {@link slime.$api.events.Handler} that captures and stores all received {@link slime.$api.Event}s for querying. diff --git a/tools/fifty/test.js b/tools/fifty/test.js index 81d6103f0..236ebe1e1 100644 --- a/tools/fifty/test.js +++ b/tools/fifty/test.js @@ -381,7 +381,6 @@ $loader: loader, promises: $context.promises, $api: { - Function: $api.Function, Events: { Captor: function(template) { var events = []; diff --git a/tools/wf/plugin-standard.jsh.js b/tools/wf/plugin-standard.jsh.js index 595358daf..b9f0829d2 100644 --- a/tools/wf/plugin-standard.jsh.js +++ b/tools/wf/plugin-standard.jsh.js @@ -194,6 +194,23 @@ } $exports.status = function(p) { + // /** @type { slime.jrunscript.tools.git.Command } */ + // var stashList = { + // invocation: function() { + // return { + // command: "stash", + // arguments: ["list"] + // } + // }, + // result: $api.Function.pipe( + // $api.Function.string.split("\n"), + // $api.Function.Array.map($api.Function.RegExp.exec(/^(.*)\:/)), + // function(p) { + // // will use flatMap when complete + // } + // ) + // } + // TODO add option for offline var oRepository = jsh.wf.git.fetch(); var fRepository = jsh.tools.git.program({ command: "git" }).repository(oRepository.directory.toString());