Skip to content
This repository
Browse code

renamed files to use new extensions + got rid of obsolete files

  • Loading branch information...
commit 9a850539332b9b6f31b259c5466f7d28f52b5d02 1 parent 065afe0
Bruno Jouhier bjouhier authored

Showing 27 changed files with 6 additions and 1,858 deletions. Show diff stats Hide diff stats

  1. +0 1  examples/misc/{bench.js → bench._js}
  2. +1 1  examples/misc/shebang-coffee.sh
  3. +1 1  examples/misc/shebang.sh
  4. +0 1  examples/streams/{googleClient.js → googleClient._js}
  5. +0 3  lib/compile.js
  6. +1 1  lib/compiler/underscored.js
  7. +1 3 lib/index.js
  8. +0 3  lib/register.js
  9. +0 148 lib/streams/client/streams--fibers.js
  10. +0 1  lib/streams/client/{streams_.js → streams._js}
  11. +0 1  lib/streams/{jsonRequest.js → jsonRequest._js}
  12. +0 1  lib/streams/{readers.js → readers._js}
  13. +0 146 lib/streams/server/httpHelper.js
  14. +0 1  lib/streams/server/{streams.js → streams._js}
  15. +2 8 lib/streams/streams.js
  16. +0 1  lib/tools/{docTool.js → docTool._js}
  17. +0 3  lib/transform.js
  18. +0 338 lib/util/flows--fibers.js
  19. +0 1  lib/util/{flows_.js → flows._js}
  20. +0 334 lib/util/flows.js
  21. +0 211 test/common/flows-test--fibers.js
  22. +0 1  test/common/{flows-test_.js → flows-test._js}
  23. +0 207 test/common/flows-test.js
  24. +0 222 test/common/stack-test--fibers.js
  25. +0 1  test/common/{stack-test_.js → stack-test._js}
  26. +0 218 test/common/stack-test.js
  27. +0 1  test/server/{streams-test.js → streams-test._js}
1  examples/misc/bench.js → examples/misc/bench._js
... ... @@ -1,5 +1,4 @@
1 1 "use strict";
2   -if (!require('streamline/module')(module)) return;
3 2
4 3 var mode = typeof fstreamline__ !== 'undefined' ? "fibers" : "callback";
5 4
2  examples/misc/shebang-coffee.sh
... ... @@ -1,4 +1,4 @@
1   -#!/usr/bin/env coffee-streamline
  1 +#!/usr/bin/env _coffee
2 2 console.log "waiting 1 second"
3 3 setTimeout _, 1000
4 4 console.log "done!"
2  examples/misc/shebang.sh
... ... @@ -1,4 +1,4 @@
1   -#!/usr/bin/env node-streamline
  1 +#!/usr/bin/env _node
2 2 console.log("waiting 1 second");
3 3 setTimeout(_, 1000);
4 4 console.log("done!");
1  examples/streams/googleClient.js → examples/streams/googleClient._js
@@ -4,7 +4,6 @@
4 4 * Demonstrates the streamline http client wrapper
5 5 */
6 6 "use strict";
7   -if (!require('streamline/module')(module)) return;
8 7
9 8 // require the streamline streams wrapper
10 9 var streams = require('streamline/lib/streams/server/streams');
3  lib/compile.js
... ... @@ -1,3 +0,0 @@
1   -console.error("Module moved to subdirectory. New require path is streamline/lib/compiler/compile");
2   -var moved = require("./compiler/compile");
3   -for (var name in moved) exports[name] = moved[name];
2  lib/compiler/underscored.js
@@ -55,7 +55,7 @@ function run(options) {
55 55 // Streamlined JavaScript extension handler.
56 56 require.extensions['._js'] = function (module, filename) {
57 57 var code = fs.readFileSync(filename, "utf8");
58   - streamliners.node(module, filename, code);
  58 + streamliners.js(module, filename, code);
59 59 }
60 60
61 61 if (options.registerOnly) return;
4 lib/index.js
... ... @@ -1,3 +1 @@
1   -//console.error("Module moved to subdirectory. New require path is streamline/lib/compiler");
2   -var moved = require("./compiler/index");
3   -for (var name in moved) exports[name] = moved[name];
  1 +module.exports = require("./compiler/index");
3  lib/register.js
... ... @@ -1,3 +0,0 @@
1   -console.error("Module moved to subdirectory. New require path is streamline/lib/compiler/register");
2   -var moved = require("./compiler/register");
3   -for (var name in moved) exports[name] = moved[name];
148 lib/streams/client/streams--fibers.js
... ... @@ -1,148 +0,0 @@
1   -/*** Generated by streamline fibers 0.2.4 - DO NOT EDIT ***/var fstreamline__ = require("streamline/lib/fibers/runtime"); (fstreamline__.create(function(_) { /**
2   - * Copyright (c) 2011 Bruno Jouhier <bruno.jouhier@sage.com>
3   - * MIT License
4   - */
5   -"use strict";
6   -//streamline.options = { "lines" : "preserve" }
7   -/// !nodoc
8   -///
9   -/// # streamline/lib/streams/client/streams
10   -///
11   -/// Client Streams module
12   -/// The `streams` module contains _pull mode_ wrappers around AJAX streams.
13   -///
14   -// TODO: Client streams only deal with strings for now
15   -
16   -function DataBuffer(options) {
17   - var _chunks = [];
18   -
19   - this.read = fstreamline__.create(function(_, len) {
20   - if (len < 0) len = Infinity;
21   - if (len == 0) return "";
22   - var chunks = [],
23   - total = 0;
24   - while (total < len) {
25   - var chunk = _chunks.splice(0, 1)[0];
26   - if (!chunk) return chunks.length == 0 ? null : chunks.join('');
27   - if (total + chunk.length <= len) {
28   - chunks.push(chunk);
29   - total += chunk.length;
30   - } else {
31   - chunks.push(chunk.substring(0, len - total));
32   - _chunks.splice(0, 0, chunk.substring(len - total));
33   - total = len;
34   - }
35   - }
36   - return chunks.join('');
37   - }, 0)
38   - /// * `data = stream.readAll(_)`
39   - /// reads till the end of stream.
40   - /// Equivalent to `stream.read(_, -1)`.
41   - this.readAll = fstreamline__.create(function(_) {
42   - return fstreamline__.invoke(this, "read", [_, -1], 0);
43   - }, 0)
44   - /// * `stream.unread(chunk)`
45   - /// pushes the chunk back to the stream.
46   - /// returns `this` for chaining.
47   - this.unread = function(chunk) {
48   - _chunks.splice(0, 0, chunk);
49   - return this;
50   - }
51   -
52   - this.write = fstreamline__.create(function(_, data, enc) {
53   - _chunks.push(data);
54   - return this;
55   - }, 0)
56   -
57   - this.end = function(data, enc) {
58   - if (data) _chunks.push(data);
59   - return this;
60   - }
61   -
62   - this.contents = function() {
63   - return _chunks.join('');
64   - }
65   -}
66   -
67   -function HttpError(statusCode, message) {
68   - this.statusCode = statusCode;
69   - this.message = message;
70   - this.stack = new Error().stack;
71   -}
72   -
73   -function _fixHttpClientOptions(options) {
74   - if (!options) throw new Error("request error: no options");
75   - if (typeof options === "string") options = {
76   - url: options
77   - };
78   - return options;
79   -}
80   -///
81   -/// ## HttpClientRequest
82   -///
83   -/// This is a wrapper around jQuery's `$.ajax` call, with
84   -/// the same API as the server side HttpClientRequest
85   -///
86   -/// This stream is writable (see Writable Stream above).
87   -///
88   -/// * `request = streams.httpRequest(options)`
89   -/// creates the wrapper.
90   -/// The options are the following:
91   -/// * `method`: the HTTP method, `'GET'` by default.
92   -/// * `headers`: the HTTP headers.
93   -/// * `url`: the requested URL (with query string if necessary).
94   -/// * `proxy.url`: the proxy URL.
95   -/// * `lowMark` and `highMark`: low and high water mark values for buffering (in bytes or characters depending
96   -/// on encoding).
97   -/// Note that these values are only hints as the data is received in chunks.
98   -
99   -
100   -function HttpClientRequest(options) {
101   - options = _fixHttpClientOptions(options);
102   - DataBuffer.call(this, options);
103   - var _xhr;
104   - this.response = function(callback) {
105   - if (!callback) return __future.call(this, this.response, arguments, 0);
106   - $.ajax({
107   - url: options.url,
108   - headers: options.headers,
109   - type: options.method,
110   - data: this.contents(),
111   - dataType: "text",
112   - // bypass jQuery parsing
113   - beforeSend: function(xhr) {
114   - _xhr = xhr;
115   - },
116   - success: function(data, statusText, xhr) {
117   - callback(null, new HttpClientResponse(data, xhr));
118   - },
119   - error: function(xhr, statusText, message) {
120   - if (statusText == "error") callback(new HttpError(xhr.status, statusText + ": " + message));
121   - else callback(new HttpError(400, statusText + ": " + message));
122   - }
123   - });
124   - }
125   - this.abort = function() {
126   - _xhr && _xhr.abort();
127   - _xhr = null;
128   - }
129   -}
130   -
131   -function HttpClientResponse(data, xhr) {
132   - DataBuffer.call(this);
133   - this.end(data);
134   - this.statusCode = xhr.status;
135   - this.headers = {};
136   - var self = this;
137   - xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n').forEach(function(header) {
138   - var pair = header.split(':');
139   - self.headers[pair[0].toLowerCase()] = pair[1] && pair[1].trim();
140   - });
141   -}
142   -
143   -exports.httpRequest = function(options) {
144   - return new HttpClientRequest(options);
145   -};
146   -}, 0).call(this, function(err) {
147   - if (err) throw err;
148   -}));
1  lib/streams/client/streams_.js → lib/streams/client/streams._js
@@ -3,7 +3,6 @@
3 3 * MIT License
4 4 */
5 5 "use strict";
6   -//streamline.options = { "lines" : "preserve" }
7 6 /// !nodoc
8 7 ///
9 8 /// # streamline/lib/streams/client/streams
1  lib/streams/jsonRequest.js → lib/streams/jsonRequest._js
@@ -3,7 +3,6 @@
3 3 * MIT License
4 4 */
5 5 "use strict";
6   -if (!require('streamline/module')(module)) return;
7 6
8 7 var streams = require("./streams");
9 8 /// !nodoc -- experimental
1  lib/streams/readers.js → lib/streams/readers._js
@@ -3,7 +3,6 @@
3 3 * MIT License
4 4 */
5 5 "use strict";
6   -if (!require('streamline/module')(module)) return;
7 6
8 7 var streams = require("./streams");
9 8
146 lib/streams/server/httpHelper.js
... ... @@ -1,146 +0,0 @@
1   -/**
2   - * Copyright (c) 2011 Bruno Jouhier <bruno.jouhier@sage.com>
3   - * MIT License
4   - */
5   -"use strict";
6   -if (!require('streamline/module')(module)) return;
7   -
8   -console.log("streamline/lib/streams/server/httpHelper is OBSOLETE.\nYou can still turn it into a private module and hack it at your will.")
9   -var urlHelper = require("streamline/lib/util/url");
10   -/// !nodoc -- experimental
11   -///
12   -/// # streamline/lib/streams/server/httpHelper
13   -///
14   -/// HTTP helpers
15   -exports.HttpStatus = {
16   - OK: 200,
17   - Created: 201,
18   - Accepted: 202,
19   - NoContent: 204,
20   - MovedPermanently: 301,
21   - Found: 302,
22   - SeeOther: 303,
23   - NotModified: 304,
24   - TemporaryRedirect: 307,
25   - BadRequest: 400,
26   - Unauthorized: 401,
27   - Forbidden: 403,
28   - NotFound: 404,
29   - MethodNotAllowed: 405,
30   - NotAcceptable: 406,
31   - Conflict: 409,
32   - Gone: 410,
33   - PreconditionFailed: 412,
34   - UnsupportedMediaType: 415,
35   - InternalServerError: 500,
36   - NotImplemented: 501,
37   - ServiceUnavailable: 503
38   -}
39   -
40   -function _classifyMedia(str) {
41   - if (str == "*" || str == "*/*") return "*";
42   - var lower = str.toLowerCase();
43   - if (lower.indexOf("xml") >= 0) return "xml";
44   - if (lower.indexOf("html") >= 0) return "html";
45   - if (lower.indexOf("json") >= 0) return "json";
46   - if (lower.indexOf("text") >= 0) return "text";
47   - if (lower.indexOf("image") >= 0) return "image";
48   - if (lower.indexOf("pdf") >= 0) return "pdf";
49   - return "unknown";
50   -}
51   -
52   -exports.parseAccept = function(str) {
53   - // parse and sort by decreasing quality
54   - var accept = (str || "").toString().split(/,\s*/).map(function(part, i) {
55   - var m = part.match(/^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$/)
56   - return m && [m[1], Number(m[2] || 1.0), i];
57   - }).filter(function(elt) {
58   - return elt;
59   - }).sort(function(elt1, elt2) {
60   - return elt2[1] - elt1[1] || elt1[2] - elt2[2]; // 2nd test to preserve order
61   - }).map(function(elt) {
62   - var split = elt[0].split(';');
63   - var result = {
64   - rawType: split[0],
65   - type: _classifyMedia(split[0]),
66   - parameters: {}
67   - };
68   - split.slice(1).forEach(function(str) {
69   - var pair = str.split(/\s*=\s*/);
70   - result.parameters[pair[0]] = pair[1];
71   - });
72   - return result;
73   - })
74   - // empty accept means accept anything
75   - return accept.length > 0 ? accept : [{
76   - rawType: "*",
77   - type: "*",
78   - parameters: {}
79   - }];
80   -}
81   -
82   -function HttpError(statusCode, message) {
83   - this.statusCode = statusCode;
84   - this.message = message;
85   - this.stack = new Error().stack;
86   -}
87   -
88   -exports.tracer = null;
89   -
90   -exports.HttpContext = function(request, response, options) {
91   - if (request == null) // subclassing
92   - return;
93   - options = options || {};
94   -
95   - if (exports.tracer) {
96   - exports.tracer("\nHTTP REQUEST: " + request.method + " " + request.url + "\n");
97   - exports.tracer("headers: " + JSON.stringify(request.headers) + "\n");
98   - }
99   -
100   - this.request = request;
101   - this.response = response;
102   - this.method = (request.headers[options.methodHeader || "x-http-method-override"] || request.method).toLowerCase();
103   - // URL stuff
104   - var _split = request.url.split('?');
105   - this.path = _split.splice(0, 1)[0];
106   - var _urlBegin = (request.socket.secure ? "https" : "http") + "://" + request.headers.host;
107   - this.url = _urlBegin + this.path;
108   - this.rawQuery = _split.join('?');
109   - this.query = urlHelper.parseQueryString(this.rawQuery);
110   - var _segments = this.path.split('/').map(function(seg) {
111   - return decodeURIComponent(seg);
112   - });
113   - var _segI = 1; // start after leading /
114   - this.walkUrl = function() {
115   - return _segments[_segI++];
116   - }
117   - this.walked = function() {
118   - return _urlBegin + _segments.slice(0, _segI).join("/");
119   - }
120   -
121   - // Accept stuff
122   - this.rawAccept = this.query[options.acceptParam] || request.headers.accept || "*";
123   - this.accept = exports.parseAccept(this.rawAccept);
124   -
125   - // Request body stuff
126   - this.parseBody = function(_) {
127   - var ct = request.headers["content-type"];
128   - if (!ct) return null;
129   - if (ct.indexOf("application/json") !== 0) throw new HttpError(415, "expected application/json, got: " + ct);
130   - // assume utf8 -- be smarter later
131   - //request.setEncoding('utf8');
132   - var str = request.readAll(_);
133   - if (str == null) return null;
134   - if (exports.tracer) exports.tracer("body: " + str + "\n")
135   - return JSON.parse(str);
136   - }
137   -
138   - this.reply = function(code, message, headers) {
139   - headers = headers || {};
140   - if (message && !headers["content-type"]) headers["content-type"] = "text/plain";
141   - response.writeHead(code, headers);
142   - response.end(message);
143   - }
144   -
145   - this.scratch = {}; // scratch area where business logic can write stuff
146   -}
1  lib/streams/server/streams.js → lib/streams/server/streams._js
@@ -3,7 +3,6 @@
3 3 * MIT License
4 4 */
5 5 "use strict";
6   -if (!require('streamline/module')(module, { "ninja": true })) return;
7 6
8 7 /// !doc
9 8 ///
10 lib/streams/streams.js
@@ -7,15 +7,9 @@
7 7 /// !nodoc -- experimental combo streams
8 8 ///
9 9
10   -
11   -function copy(src, dst) {
12   - Object.keys(src).forEach(function(key) {
13   - dst[key] = src[key]
14   - })
15   -}
16 10 if (typeof process === "object" && typeof process.cwd === "function") {
17 11 var req = require; // trick to skip this dependency when serving client side requires
18   - copy(req('./server/streams'), exports);
  12 + module.exports = req('./server/streams');
19 13 } else {
20   - copy(require('./client/streams'), exports);
  14 + module.exports = require('./client/streams');
21 15 }
1  lib/tools/docTool.js → lib/tools/docTool._js
@@ -4,7 +4,6 @@
4 4 */
5 5
6 6 "use strict";
7   -if (!require('streamline/module')(module)) return;
8 7 /// !doc
9 8 ///
10 9 /// # streamline/lib/tools/docTool
3  lib/transform.js
... ... @@ -1,3 +0,0 @@
1   -console.error("Module moved to subdirectory. New require path is streamline/lib/callbacks/transform");
2   -var moved = require("./callbacks/transform");
3   -for (var name in moved) exports[name] = moved[name];
338 lib/util/flows--fibers.js
... ... @@ -1,338 +0,0 @@
1   -/*** Generated by streamline fibers 0.2.4 - DO NOT EDIT ***/var fstreamline__ = require("streamline/lib/fibers/runtime"); (fstreamline__.create(function(_) { /**
2   - * Copyright (c) 2011 Bruno Jouhier <bruno.jouhier@sage.com>
3   - *
4   - * Permission is hereby granted, free of charge, to any person
5   - * obtaining a copy of this software and associated documentation
6   - * files (the "Software"), to deal in the Software without
7   - * restriction, including without limitation the rights to use,
8   - * copy, modify, merge, publish, distribute, sublicense, and/or sell
9   - * copies of the Software, and to permit persons to whom the
10   - * Software is furnished to do so, subject to the following
11   - * conditions:
12   - *
13   - * The above copyright notice and this permission notice shall be
14   - * included in all copies or substantial portions of the Software.
15   - *
16   - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17   - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18   - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19   - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20   - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21   - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22   - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23   - * OTHER DEALINGS IN THE SOFTWARE.
24   - *
25   - * streamline.options = { "lines": "preserve" }
26   - */
27   -/// !doc
28   -///
29   -/// # streamline/lib/util/flows
30   -///
31   -/// Flows Module
32   -///
33   -/// The `streamline/lib/util/flows` module contains some handy utilities for streamline code
34   -///
35   -(function(exports) {
36   - "use strict";
37   - /// ## Array utilities
38   - ///
39   - /// The following functions are async equivalents of the ES5 Array methods (`forEach`, `map`, `filter`, ...)
40   - ///
41   - /// * `flows.each(_, array, fn, [thisObj])`
42   - /// applies `fn` sequentially to the elements of `array`.
43   - /// `fn` is called as `fn(_, elt, i)`.
44   - exports.each = fstreamline__.create(function(_, array, fn, thisObj) {
45   - if (!array || !array.length)
46   - return; // array;
47   - var len = array.length;
48   - for (var i = 0; i < len; i++)
49   - fstreamline__.invoke(fn, "call", [thisObj, _, array[i], i], 1)
50   - return array;
51   - }, 0)
52   - /// * `result = flows.map(_, array, fn, [thisObj])`
53   - /// transforms `array` by applying `fn` to each element in turn.
54   - /// `fn` is called as `fn(_, elt, i)`.
55   - exports.map = fstreamline__.create(function(_, array, fn, thisObj) {
56   - if (!array)
57   - return array;
58   - var result = [];
59   - var len = array.length;
60   - for (var i = 0; i < len; i++)
61   - result[i] = fstreamline__.invoke(fn, "call", [thisObj, _, array[i], i], 1);
62   - return result;
63   - }, 0)
64   - /// * `result = flows.filter(_, array, fn, [thisObj])`
65   - /// generates a new array that only contains the elements that satisfy the `fn` predicate.
66   - /// `fn` is called as `fn(_, elt)`.
67   - exports.filter = fstreamline__.create(function(_, array, fn, thisObj) {
68   - if (!array)
69   - return array;
70   - var result = [];
71   - var len = array.length;
72   - for (var i = 0; i < len; i++) {
73   - var elt = array[i];
74   - if (fstreamline__.invoke(fn, "call", [thisObj, _, elt], 1))
75   - result.push(elt)
76   - }
77   - return result;
78   - }, 0)
79   - /// * `bool = flows.every(_, array, fn, [thisObj])`
80   - /// returns true if `fn` is true on every element (if `array` is empty too).
81   - /// `fn` is called as `fn(_, elt)`.
82   - exports.every = fstreamline__.create(function(_, array, fn, thisObj) {
83   - if (!array)
84   - return; // undefined
85   - var len = array.length;
86   - for (var i = 0; i < len; i++) {
87   - if (!fstreamline__.invoke(fn, "call", [thisObj, _, array[i]], 1))
88   - return false;
89   - }
90   - return true;
91   - }, 0)
92   - /// * `bool = flows.some(_, array, fn, [thisObj])`
93   - /// returns true if `fn` is true for at least one element.
94   - /// `fn` is called as `fn(_, elt)`.
95   - exports.some = fstreamline__.create(function(_, array, fn, thisObj) {
96   - if (!array)
97   - return; // undefined
98   - var len = array.length;
99   - for (var i = 0; i < len; i++) {
100   - if (fstreamline__.invoke(fn, "call", [thisObj, _, array[i]], 1))
101   - return true;
102   - }
103   - return false;
104   - }, 0)
105   - /// * `result = flows.reduce(_, array, fn, val, [thisObj])`
106   - /// reduces by applying `fn` to each element.
107   - /// `fn` is called as `val = fn(_, val, elt, i, array)`.
108   - exports.reduce = fstreamline__.create(function(_, array, fn, v, thisObj) {
109   - if (!array)
110   - return v; // undefined
111   - var len = array.length;
112   - for (var i = 0; i < len; i++) {
113   - v = fstreamline__.invoke(fn, "call", [thisObj, _, v, array[i], i, array], 1);
114   - }
115   - return v;
116   - }, 0)
117   - /// * `result = flows.reduceRight(_, array, fn, val, [thisObj])`
118   - /// reduces from end to start by applying `fn` to each element.
119   - /// `fn` is called as `val = fn(_, val, elt, i, array)`.
120   - exports.reduceRight = fstreamline__.create(function(_, array, fn, v, thisObj) {
121   - if (!array)
122   - return v; // undefined
123   - var len = array.length;
124   - for (var i = len - 1; i >= 0; i--) {
125   - v = fstreamline__.invoke(fn, "call", [thisObj, _, v, array[i], i, array], 1);
126   - }
127   - return v;
128   - }, 0)
129   -
130   - /// * `array = flows.sort(_, array, compare, [beg], [end])`
131   - /// sorts the array.
132   - /// `compare` is called as `cmp = compare(_, elt1, elt2)`
133   - ///
134   - /// Note: this function _changes_ the original array (and returns it)
135   - exports.sort = fstreamline__.create(function(_, array, compare, beg, end){var _qsort_ = fstreamline__.create(_qsort);
136   - beg = beg || 0;
137   - end = end == null ? array.length - 1 : end;
138   -
139   - function _qsort(_, beg, end){
140   - if (beg >= end)
141   - return;
142   -
143   - if (end == beg + 1) {
144   - if (fstreamline__.invoke(null, compare, [_, array[beg], array[end]], 0) > 0) {
145   - var tmp = array[beg];
146   - array[beg] = array[end];
147   - array[end] = tmp;
148   - }
149   - return;
150   - }
151   -
152   - var mid = Math.floor((beg + end) / 2);
153   - var o = array[mid];
154   - var nbeg = beg;
155   - var nend = end;
156   -
157   - while (nbeg <= nend) {
158   - while (nbeg < end && fstreamline__.invoke(null, compare, [_, array[nbeg], o], 0) < 0)
159   - nbeg++;
160   -
161   - while (beg < nend && fstreamline__.invoke(null, compare, [_, o, array[nend]], 0) < 0)
162   - nend--;
163   -
164   - if (nbeg <= nend) {
165   - var tmp = array[nbeg];
166   - array[nbeg] = array[nend];
167   - array[nend] = tmp;
168   - nbeg++;
169   - nend--;
170   - }
171   - }
172   -
173   - if (nbeg < end)
174   - _qsort(_, nbeg, end);
175   - if (beg < nend)
176   - _qsort(_, beg, nend);
177   - }
178   - _qsort(_, beg, end);
179   - return array;
180   - }, 0)
181   - ///
182   - /// ## Object utility
183   - ///
184   - /// The following function can be used to iterate through object properties:
185   - ///
186   - /// * `flows.eachKey(_, obj, fn)`
187   - /// calls `fn(_, key, obj[key])` for every `key` in `obj`.
188   - exports.eachKey = fstreamline__.create(function(_, obj, fn, thisObj) {
189   - if (!obj)
190   - return obj;
191   - for (var key in obj) {
192   - if (Object.prototype.hasOwnProperty.call(obj, key))
193   - fstreamline__.invoke(fn, "call", [thisObj, _, key, obj[key]], 1);
194   - }
195   - return obj;
196   - }, 0)
197   - ///
198   - /// ## Workflow Utilities
199   - ///
200   - // deprecated -- don't document
201   - exports.spray = function(fns, max) {
202   - return new
203   - function() {
204   - var funnel = exports.funnel(max);
205   - this.collect = function(callback, count, trim) {
206   - if (typeof(callback) != "function")
207   - throw new Error("invalid call to collect: no callback")
208   - var results = trim ? [] : new Array(fns.length);
209   - count = count < 0 ? fns.length : Math.min(count, fns.length);
210   - if (count == 0)
211   - return callback(null, results);
212   - var collected = 0;
213   - for (var i = 0; i < fns.length; i++) {
214   - (function(i) {
215   - funnel( function(err, result) {
216   - if (err)
217   - return callback(err);
218   - if (trim)
219   - results.push(result);
220   - else
221   - results[i] = result;
222   - if (++collected == count)
223   - return callback(null, results);
224   - }, fns[i])
225   - })(i);
226   - }
227   - }
228   - this.collectOne = function(callback) {
229   - return this.collect( function(err, result) {
230   - return callback(err, result && result[0]);
231   - }, 1, true)
232   - }
233   - this.collectAll = function(callback) {
234   - return this.collect(callback, -1, false);
235   - }
236   - }
237   -
238   - }
239   - /// * `fun = flows.funnel(max)`
240   - /// limits the number of concurrent executions of a given code block.
241   - ///
242   - /// The `funnel` function is typically used with the following pattern:
243   - ///
244   - /// ``` javascript
245   - /// // somewhere
246   - /// var myFunnel = flows.funnel(10); // create a funnel that only allows 10 concurrent executions.
247   - ///
248   - /// // elsewhere
249   - /// myFunnel(_, function(_) { /* code with at most 10 concurrent executions */ });
250   - /// ```
251   - ///
252   - /// The `diskUsage2.js` example demonstrates how these calls can be combined to control concurrent execution.
253   - ///
254   - /// The `funnel` function can also be used to implement critical sections. Just set funnel's `max` parameter to 1.
255   - exports.funnel = function(max) {
256   - max = typeof max == "undefined" ? -1 : max;
257   - var queue = [];
258   - var active = 0;
259   -
260   - return function(callback, fn) {
261   - //console.log("FUNNEL: active=" + active + ", queued=" + queue.length);
262   - if (max < 0)
263   - return fn(callback);
264   -
265   - queue.push({
266   - fn: fn,
267   - cb: callback
268   - });
269   -
270   - function _doOne() {
271   - var current = queue.splice(0, 1)[0];
272   - if (!current.cb)
273   - return current.fn();
274   - active++;
275   - current.fn( function(err, result) {
276   - active--;
277   - current.cb(err, result);
278   - while (active < max && queue.length > 0)
279   - _doOne();
280   - });
281   - }
282   -
283   - while (active < max && queue.length > 0)
284   - _doOne();
285   - }
286   - }
287   -
288   - ///
289   - /// * `results = flows.collect(_, futures)`
290   - /// collects the results of an array of futures
291   - exports.collect = fstreamline__.create(function(_, futures) {
292   - return fstreamline__.invoke(exports, "map", [_, futures, fstreamline__.create(function(_, future) {
293   - return fstreamline__.invoke(null, future, [_], 0);
294   - }, 0)], 0);
295   - }, 0)
296   -
297   - // Obsolete API - use require('streamline/lib/globals').context instead
298   - var globals = require("streamline/lib/globals");
299   - exports.setContext = function(ctx) {
300   - var old = globals.context;
301   - globals.context = ctx;
302   - return old;
303   - }
304   - exports.getContext = function() {
305   - return globals.context;
306   - }
307   -
308   - ///
309   - /// ## Miscellaneous
310   - ///
311   - /// Utility functions:
312   - ///
313   - /// * `flows.nextTick(_)`
314   - /// `nextTick` function for both browser and server.
315   - /// Aliased to `process.nextTick` on the server side.
316   - exports.nextTick = typeof process === "object" && typeof process.nextTick === "function"
317   - ? process.nextTick : function(callback) {
318   - setTimeout(function() { callback(); }, 0);
319   - };
320   -
321   - /// * `result = flows.apply(_, fn, thisObj, args, [index])`
322   - /// Helper to apply `Function.apply` to streamline functions.
323   - /// Equivalent to `result = fn.apply(thisObj, argsWith_)` where `argsWith_` is
324   - /// a modified argument list in which the callback has been inserted at `index`
325   - /// (at the end of the argument list if `index` is not specified).
326   - exports.apply = function apply(callback, fn, thisObj, args, index) {
327   - if (callback == null)
328   - return __future(apply, arguments, 0);
329   - Array.prototype.splice.call(args, index != null ? index : args.length, 0, callback);
330   - return fn.apply(thisObj, args);
331   - }
332   -
333   -
334   -})(typeof exports !== 'undefined' ? exports : (window.StreamlineFlows = window.StreamlineFlows || {}));
335   -
336   -}, 0).call(this, function(err) {
337   - if (err) throw err;
338   -}));
1  lib/util/flows_.js → lib/util/flows._js
@@ -22,7 +22,6 @@
22 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 23 * OTHER DEALINGS IN THE SOFTWARE.
24 24 *
25   - * streamline.options = { "lines": "preserve" }
26 25 */
27 26 /// !doc
28 27 ///
334 lib/util/flows.js
... ... @@ -1,334 +0,0 @@
1   -/*** Generated by streamline 0.2.5 - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__forIn=__rt.__forIn,__future=__rt.__future,__propagate=__rt.__propagate,__trap=__rt.__trap,__setEF=__rt.__setEF,__g=__rt.__g; (function(exports) {
2   -
3   -
4   -
5   -
6   -
7   -
8   -
9   -
10   -
11   -
12   -
13   -
14   -
15   -
16   -
17   -
18   -
19   -
20   -
21   -
22   -
23   -
24   -
25   -
26   -
27   -
28   -
29   -
30   -
31   -
32   -
33   -
34   -
35   -
36   - "use strict";
37   -
38   -
39   -
40   -
41   -
42   -
43   -
44   - exports.each = function exports_each__1(_, array, fn, thisObj) { var len, i; var __frame = { name: "exports_each__1", line: 44 }; return __func(_, this, arguments, exports_each__1, 0, __frame, function __$exports_each__1() {
45   - if ((!array || !array.length)) { return _(null); } ;
46   -
47   - len = array.length;
48   - i = 0; var __2 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_each__1() { __more = false; if (__2) { i++; } else { __2 = true; } ; var __1 = (i < len); if (__1) {
49   - return fn.call(thisObj, __cb(_, __frame, 5, 3, function __$exports_each__1() { while (__more) { __loop(); }; __more = true; }, true), array[i], i); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_each__1() {
50   - return _(null, array); }); }); };
51   -
52   -
53   -
54   -
55   - exports.map = function exports_map__2(_, array, fn, thisObj) { var result, len, i; var __frame = { name: "exports_map__2", line: 55 }; return __func(_, this, arguments, exports_map__2, 0, __frame, function __$exports_map__2() {
56   - if (!array) {
57   - return _(null, array); } ;
58   - result = [];
59   - len = array.length;
60   - i = 0; var __3 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_map__2() { __more = false; if (__3) { i++; } else { __3 = true; } ; var __2 = (i < len); if (__2) {
61   - return fn.call(thisObj, __cb(_, __frame, 6, 15, function ___(__0, __1) { result[i] = __1; while (__more) { __loop(); }; __more = true; }, true), array[i], i); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_map__2() {
62   - return _(null, result); }); }); };
63   -
64   -
65   -
66   -
67   - exports.filter = function exports_filter__3(_, array, fn, thisObj) { var result, len, i, elt; var __frame = { name: "exports_filter__3", line: 67 }; return __func(_, this, arguments, exports_filter__3, 0, __frame, function __$exports_filter__3() {
68   - if (!array) {
69   - return _(null, array); } ;
70   - result = [];
71   - len = array.length;
72   - i = 0; var __3 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_filter__3() { __more = false; if (__3) { i++; } else { __3 = true; } ; var __2 = (i < len); if (__2) {
73   - elt = array[i];
74   - return fn.call(thisObj, __cb(_, __frame, 7, 7, function ___(__0, __1) { return (function __$exports_filter__3(__then) { if (__1) {
75   - result.push(elt); __then(); } else { __then(); } ; })(function __$exports_filter__3() { while (__more) { __loop(); }; __more = true; }); }, true), elt); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_filter__3() {
76   -
77   - return _(null, result); }); }); };
78   -
79   -
80   -
81   -
82   - exports.every = function exports_every__4(_, array, fn, thisObj) { var len, i; var __frame = { name: "exports_every__4", line: 82 }; return __func(_, this, arguments, exports_every__4, 0, __frame, function __$exports_every__4() {
83   - if (!array) { return _(null); } ;
84   -
85   - len = array.length;
86   - i = 0; var __4 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_every__4() { __more = false; if (__4) { i++; } else { __4 = true; } ; var __3 = (i < len); if (__3) {
87   - return fn.call(thisObj, __cb(_, __frame, 5, 8, function ___(__0, __2) { var __1 = !__2; return (function __$exports_every__4(__then) { if (__1) {
88   - return _(null, false); } else { __then(); } ; })(function __$exports_every__4() { while (__more) { __loop(); }; __more = true; }); }, true), array[i]); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_every__4() {
89   -
90   - return _(null, true); }); }); };
91   -
92   -
93   -
94   -
95   - exports.some = function exports_some__5(_, array, fn, thisObj) { var len, i; var __frame = { name: "exports_some__5", line: 95 }; return __func(_, this, arguments, exports_some__5, 0, __frame, function __$exports_some__5() {
96   - if (!array) { return _(null); } ;
97   -
98   - len = array.length;
99   - i = 0; var __3 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_some__5() { __more = false; if (__3) { i++; } else { __3 = true; } ; var __2 = (i < len); if (__2) {
100   - return fn.call(thisObj, __cb(_, __frame, 5, 7, function ___(__0, __1) { return (function __$exports_some__5(__then) { if (__1) {
101   - return _(null, true); } else { __then(); } ; })(function __$exports_some__5() { while (__more) { __loop(); }; __more = true; }); }, true), array[i]); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_some__5() {
102   -
103   - return _(null, false); }); }); };
104   -
105   -
106   -
107   -
108   - exports.reduce = function exports_reduce__6(_, array, fn, v, thisObj) { var len, i; var __frame = { name: "exports_reduce__6", line: 108 }; return __func(_, this, arguments, exports_reduce__6, 0, __frame, function __$exports_reduce__6() {
109   - if (!array) {
110   - return _(null, v); } ;
111   - len = array.length;
112   - i = 0; var __3 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_reduce__6() { __more = false; if (__3) { i++; } else { __3 = true; } ; var __2 = (i < len); if (__2) {
113   - return fn.call(thisObj, __cb(_, __frame, 5, 7, function ___(__0, __1) { v = __1; while (__more) { __loop(); }; __more = true; }, true), v, array[i], i, array); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_reduce__6() {
114   -
115   - return _(null, v); }); }); };
116   -
117   -
118   -
119   -
120   - exports.reduceRight = function exports_reduceRight__7(_, array, fn, v, thisObj) { var len, i; var __frame = { name: "exports_reduceRight__7", line: 120 }; return __func(_, this, arguments, exports_reduceRight__7, 0, __frame, function __$exports_reduceRight__7() {
121   - if (!array) {
122   - return _(null, v); } ;
123   - len = array.length;
124   - i = (len - 1); var __3 = false; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_reduceRight__7() { __more = false; if (__3) { i--; } else { __3 = true; } ; var __2 = (i >= 0); if (__2) {
125   - return fn.call(thisObj, __cb(_, __frame, 5, 7, function ___(__0, __1) { v = __1; while (__more) { __loop(); }; __more = true; }, true), v, array[i], i, array); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_reduceRight__7() {
126   -
127   - return _(null, v); }); }); };
128   -
129   -
130   -
131   -
132   -
133   -
134   -
135   - exports.sort = function exports_sort__8(_, array, compare, beg, end) {
136   -
137   -
138   -
139   - function _qsort(_, beg, end) { var tmp, mid, o, nbeg, nend; var __frame = { name: "_qsort", line: 139 }; return __func(_, this, arguments, _qsort, 0, __frame, function __$_qsort() {
140   - if ((beg >= end)) { return _(null); } ; return (function __$_qsort(__then) {
141   -
142   -
143   - if ((end == (beg + 1))) {
144   - return compare(__cb(_, __frame, 5, 8, function ___(__0, __2) { var __1 = (__2 > 0); return (function __$_qsort(__then) { if (__1) {
145   - tmp = array[beg];
146   - array[beg] = array[end];
147   - array[end] = tmp; __then(); } else { __then(); } ; })(function __$_qsort() { return _(null); }); }, true), array[beg], array[end]); } else { __then(); } ; })(function __$_qsort() {
148   -
149   -
150   -
151   -
152   - mid = Math.floor((((beg + end)) / 2));
153   - o = array[mid];
154   - nbeg = beg;
155   - nend = end; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false;
156   -
157   - var __4 = (nbeg <= nend); if (__4) { return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return (function __$_qsort(_) { return (function __$_qsort(_) {
158   - var __1 = (nbeg < end); if (!__1) { return _(null, __1); } ; return compare(__cb(_, __frame, 19, 25, function ___(__0, __3) { var __2 = (__3 < 0); return _(null, __2); }, true), array[nbeg], o); })(__cb(_, __frame, -138, 17, _, true)); })(__cb(_, __frame, -138, 17, function ___(__0, __5) { if (__5) {
159   - nbeg++; while (__more) { __loop(); }; __more = true; } else { __break(); } ; }, true)); }); do { __loop(); } while (__more); __more = true; })(function __$_qsort() { return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$_qsort() { __more = false; return (function __$_qsort(_) { return (function __$_qsort(_) {
160   -
161   - var __1 = (beg < nend); if (!__1) { return _(null, __1); } ; return compare(__cb(_, __frame, 22, 25, function ___(__0, __3) { var __2 = (__3 < 0); return _(null, __2); }, true), o, array[nend]); })(__cb(_, __frame, -138, 17, _, true)); })(__cb(_, __frame, -138, 17, function ___(__0, __7) { if (__7) {
162   - nend--; while (__more) { __loop(); }; __more = true; } else { __break(); } ; }, true)); }); do { __loop(); } while (__more); __more = true; })(function __$_qsort() {
163   -
164   - if ((nbeg <= nend)) {
165   - tmp = array[nbeg];
166   - array[nbeg] = array[nend];
167   - array[nend] = tmp;
168   - nbeg++;
169   - nend--; } ; while (__more) { __loop(); }; __more = true; }); }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$_qsort() { return (function __$_qsort(__then) {
170   -
171   -
172   -
173   - if ((nbeg < end)) {
174   - return _qsort(__cb(_, __frame, 35, 4, __then, true), nbeg, end); } else { __then(); } ; })(function __$_qsort() { return (function __$_qsort(__then) {
175   - if ((beg < nend)) {
176   - return _qsort(__cb(_, __frame, 37, 4, __then, true), beg, nend); } else { __then(); } ; })(_); }); }); }); }); }; var __frame = { name: "exports_sort__8", line: 135 }; return __func(_, this, arguments, exports_sort__8, 0, __frame, function __$exports_sort__8() { beg = (beg || 0); end = ((end == null) ? (array.length - 1) : end);
177   -
178   - return _qsort(__cb(_, __frame, 43, 2, function __$exports_sort__8() {
179   - return _(null, array); }, true), beg, end); }); };
180   -
181   -
182   -
183   -
184   -
185   -
186   -
187   -
188   - exports.eachKey = function exports_eachKey__9(_, obj, fn, thisObj) { var key; var __frame = { name: "exports_eachKey__9", line: 188 }; return __func(_, this, arguments, exports_eachKey__9, 0, __frame, function __$exports_eachKey__9() {
189   - if (!obj) {
190   - return _(null, obj); } ;
191   - var __1 = __forIn(obj); var __2 = 0; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$exports_eachKey__9() { __more = false; var __3 = (__2 < __1.length); if (__3) { key = __1[__2++]; return (function __$exports_eachKey__9(__then) {
192   - if (Object.prototype.hasOwnProperty.call(obj, key)) {
193   - return fn.call(thisObj, __cb(_, __frame, 5, 4, __then, true), key, obj[key]); } else { __then(); } ; })(function __$exports_eachKey__9() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$exports_eachKey__9() {
194   -
195   - return _(null, obj); }); }); };
196   -
197   -
198   -
199   -
200   -
201   - exports.spray = function(fns, max) {
202   - return new function() {
203   -
204   - var funnel = exports.funnel(max);
205   - this.collect = function(callback, count, trim) {
206   - if ((typeof (callback) != "function")) {
207   - throw new Error("invalid call to collect: no callback") };
208   - var results = (trim ? [] : new Array(fns.length));
209   - count = ((count < 0) ? fns.length : Math.min(count, fns.length));
210   - if ((count == 0)) {
211   - return callback(null, results) };
212   - var collected = 0;
213   - for (var i = 0; (i < fns.length); i++) {
214   - (function(i) {
215   - funnel(function(err, result) {
216   - if (err) {
217   - return callback(err) };
218   - if (trim) {
219   - results.push(result); } else {
220   -
221   - results[i] = result; };
222   - if ((++collected == count)) {
223   - return callback(null, results) };
224   - }, fns[i]);
225   - })(i); }; };
226   -
227   -
228   - this.collectOne = function(callback) {
229   - return this.collect(function(err, result) {
230   - return callback(err, (result && result[0]));
231   - }, 1, true); };
232   -
233   - this.collectAll = function(callback) {
234   - return this.collect(callback, -1, false); }; }; };
235   -
236   -
237   -
238   -
239   -
240   -
241   -
242   -
243   -
244   -
245   -
246   -
247   -
248   -
249   -
250   -
251   -
252   -
253   -
254   -
255   - exports.funnel = function(max) {
256   - max = ((typeof max == "undefined") ? -1 : max);
257   - var queue = [];
258   - var active = 0;
259   -
260   - return function(callback, fn) {
261   -
262   - if ((max < 0)) {
263   - return fn(callback) };
264   -
265   - queue.push({
266   - fn: fn,
267   - cb: callback });
268   -
269   -
270   - function _doOne() {
271   - var current = queue.splice(0, 1)[0];
272   - if (!current.cb) {
273   - return current.fn() };
274   - active++;
275   - current.fn(function(err, result) {
276   - active--;
277   - current.cb(err, result);
278   - while (((active < max) && (queue.length > 0))) { _doOne();; }; }); };
279   -
280   -
281   -
282   -
283   - while (((active < max) && (queue.length > 0))) { _doOne();; }; }; };
284   -
285   -
286   -
287   -
288   -
289   -
290   -
291   - exports.collect = function exports_collect__10(_, futures) { var __frame = { name: "exports_collect__10", line: 291 }; return __func(_, this, arguments, exports_collect__10, 0, __frame, function __$exports_collect__10() {
292   - return exports.map(__cb(_, __frame, 1, 9, _, true), futures, function __1(_, future) { var __frame = { name: "__1", line: 292 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {
293   - return future(__cb(_, __frame, 1, 10, _, true)); }); }); }); };
294   -
295   -
296   -
297   -
298   - var globals = require("streamline/lib/globals");
299   - exports.setContext = function(ctx) {
300   - var old = globals.context;
301   - globals.context = ctx;
302   - return old; };
303   -
304   - exports.getContext = function() {
305   - return globals.context; };
306   -
307   -
308   -
309   -
310   -
311   -
312   -
313   -
314   -
315   -
316   - exports.nextTick = (((typeof process === "object") && (typeof process.nextTick === "function")) ? process.nextTick : function(callback) {
317   -
318   - setTimeout(function() { callback(); }, 0); });
319   -
320   -
321   -
322   -
323   -
324   -
325   -
326   - exports.apply = function apply(callback, fn, thisObj, args, index) {
327   - if ((callback == null)) {
328   - return __future(apply, arguments, 0) };
329   - Array.prototype.splice.call(args, ((index != null) ? index : args.length), 0, callback);
330   - return fn.apply(thisObj, args); };
331   -
332   -
333   -
334   -})(((typeof exports !== "undefined") ? exports : (window.StreamlineFlows = (window.StreamlineFlows || {}))));
211 test/common/flows-test--fibers.js
... ... @@ -1,211 +0,0 @@
1   -/*** Generated by streamline fibers 0.2.4 - DO NOT EDIT ***/var fstreamline__ = require("streamline/lib/fibers/runtime"); (fstreamline__.create(function(_) {var delay_ = fstreamline__.create(delay), delayFail_ = fstreamline__.create(delayFail); //streamline.options = { "lines" : "preserve" }
2   -var module = QUnit.module;
3   -var flows = require("streamline/lib/util/flows");
4   -
5   -function delay(_, val) {
6   - fstreamline__.invoke(flows, "nextTick", [_], 0);
7   - return val;
8   -}
9   -
10   -function delayFail(_, err) {
11   - fstreamline__.invoke(flows, "nextTick", [_], 0);
12   - throw err;
13   -}
14   -
15   -module("flows");
16   -
17   -asyncTest("each", 1, fstreamline__.create(function(_) {
18   - var result = 1;
19   - fstreamline__.invoke(flows, "each", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
20   - result = result * delay(_, val);
21   - }, 0)], 0)
22   - strictEqual(result, 24);
23   - start();
24   -}, 0))
25   -asyncTest("map", 1, fstreamline__.create(function(_) {
26   - var result = fstreamline__.invoke(flows, "map", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
27   - return 2 * delay(_, val);
28   - }, 0)], 0);
29   - deepEqual(result, [2, 4, 6, 8]);
30   - start();
31   -}, 0))
32   -asyncTest("filter", 1, fstreamline__.create(function(_) {
33   - var result = fstreamline__.invoke(flows, "filter", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
34   - return delay(_, val) % 2;
35   - }, 0)], 0);
36   - deepEqual(result, [1, 3]);
37   - start();
38   -}, 0))
39   -asyncTest("every", 1, fstreamline__.create(function(_) {
40   - var result = fstreamline__.invoke(flows, "every", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
41   - return delay(_, val) < 5;
42   - }, 0)], 0);
43   - strictEqual(result, true);
44   - start();
45   -}, 0));
46   -asyncTest("every", 1, fstreamline__.create(function(_) {
47   - var result = fstreamline__.invoke(flows, "every", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
48   - return delay(_, val) < 3;
49   - }, 0)], 0);
50   - strictEqual(result, false);
51   - start();
52   -}, 0));
53   -asyncTest("some", 1, fstreamline__.create(function(_) {
54   - var result = fstreamline__.invoke(flows, "some", [_, [1, 2, 3, 4], fstreamline__.create(function(_, val) {
55   - return delay(_, val) < 3;
56   - }, 0)], 0);
57   - strictEqual(result, true);
58   - start();
59   -}, 0));
60   -asyncTest("some", 1, fstreamline__.create(functio