Comparing version 0.3.4 to 0.3.5
{ | ||
"name": "react", | ||
"description": "React is a javascript module to make it easier to work with asynchronous code, by reducing boilerplate code and improving error and exception handling while allowing variable and task dependencies when defining flow.", | ||
"version": "0.3.4", | ||
"description": "React is a javascript module implementing a lightweight rules engine to make it easier to work with asynchronous code, by reducing boilerplate code and improving error and exception handling while allowing variable and task dependencies when defining flow.", | ||
"version": "0.3.5", | ||
"author": "Jeff Barczewski <jeff.barczewski@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { "type": "git", "url": "http://github.com/jeffbski/react.git" }, |
@@ -87,37 +87,60 @@ # React.js | ||
- Simple example showing flow definition of two async functions feeding a | ||
synchronous function. | ||
- First two async functions inputs are satisfied by the flow inputs, so | ||
they will both run immediately in parallel. | ||
- The last function waits for the outputs of the previous ones, then | ||
executes synchronously. | ||
- Finally the flow calls the callback with the output values once all | ||
the tasks have completed. | ||
```javascript | ||
// in your foo module | ||
// in your foobar module | ||
var react = require('react'); | ||
// some normal async and sync functions | ||
function loadUser(uid, cb){ } | ||
function loadFile(filename, cb){ } | ||
function markdown(filedata) { } | ||
function writeOutput(html, user, cb){ } | ||
function loadEmailTemplate(cb) { } | ||
function customizeEmail(user, emailHtml, cb) { } | ||
function deliverEmail(custEmailHtml, cb) { } | ||
function loadFoo(fooPath, cb) { | ||
setTimeout(function () { | ||
cb(null, [fooPath, 'data'].join(':')); | ||
}, 10); | ||
} | ||
function loadBar(barPath, barP2, cb) { | ||
setTimeout(function () { | ||
cb(null, [barPath, barP2, 'data'].join(':')); | ||
}, 10); | ||
} | ||
function render(foo, bar) { | ||
return ['<html>', foo, '/', bar, '</html>'].join(''); | ||
} | ||
// define fn, glue together with react, it will parallelize | ||
// starts with name and in/out params, then the tasks | ||
var loadAndSend = react('loadAndSend', 'uid, filename, cb -> err, user', | ||
loadUser, 'uid, cb -> err, user', | ||
loadFile, 'filename, cb -> err, filemd', | ||
markdown, 'filemd -> html', // no cb, implies sync fn | ||
writeOutput, 'html, user, cb -> err, htmlBytesWritten', | ||
loadEmailTemplate, 'cb -> err, emailmd', | ||
markdown, 'emailmd -> emailHtml', // no cb, implies sync fn | ||
customizeEmail, 'user, emailHtml, cb -> err, custEHtml', | ||
deliverEmail, 'custEHtml, cb -> err, custBytesWritten' | ||
var loadRender = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut', | ||
loadFoo, 'fooPath, cb -> err, foo', // async cb function | ||
loadBar, 'barPath, barP2, cb -> err, bar', // async cb function | ||
render, 'foo, bar -> renderedOut' // sync function using outputs from first two | ||
); | ||
exports.loadAndSend = loadAndSend; // is a normal fn created by react | ||
exports.loadRender = loadRender; // is a normal fn created by react | ||
// in a different module far far away, use this as any other node function | ||
var foo = require('foo'); | ||
foo.loadAndSend(100, 'bar.md', function (err, user) { | ||
// tasks were parallelized based on their depedencies | ||
} | ||
var foobar = require('foobar'); | ||
foobar.loadRender('foo.txt', 'bar.txt', 'BBB', function (err, renderedOut) { | ||
// tasks in loadRender were parallelized based on their input dependencies | ||
console.error('results:', renderedOut); | ||
}); | ||
``` | ||
Below is a graph of how the dependencies are mapped by React which | ||
also indicates how the tasks will be executed | ||
![default-simple.dot.png](https://github.com/jeffbski/react/raw/master/doc/default-simple.dot.png) | ||
<a name="directAST"/> | ||
@@ -155,5 +178,5 @@ ### Example directly using AST | ||
1. [Using pseudocode DSL](http://github.com/jeffbski/react/raw/master/doc/alternate-dsls.md#pcode) | ||
2. [Using jquery-like chaining DSL](http://github.com/jeffbski/react/raw/master/doc/alternate-dsls.md#chain) | ||
3. [Using function string DSL](http://github.com/jeffbski/react/raw/master/doc/alternate-dsls.md#fstr) | ||
1. [Using pseudocode DSL](https://github.com/jeffbski/react/blob/master/doc/alternate-dsls.md#pcode) | ||
2. [Using jquery-like chaining DSL](https://github.com/jeffbski/react/blob/master/doc/alternate-dsls.md#chain) | ||
3. [Using function string DSL](https://github.com/jeffbski/react/blob/master/doc/alternate-dsls.md#fstr) | ||
@@ -287,3 +310,3 @@ | ||
Additional DSL's can be loaded by requiring them. See the [Alternate DSL](http://github.com/jeffbski/react/raw/master/doc/alternate-dsls.md) page for more info. | ||
Additional DSL's can be loaded by requiring them. See the [Alternate DSL](https://github.com/jeffbski/react/blob/master/doc/alternate-dsls.md) page for more info. | ||
@@ -293,3 +316,3 @@ | ||
- 2012-01-17 - Additional documentation (v0.3.4) | ||
- 2012-01-17 - Additional documentation (v0.3.5) | ||
- 2012-01-16 - Refine events and create logging plugin (v0.3.3) | ||
@@ -296,0 +319,0 @@ - 2012-01-13 - Add promise tasks, promise resolution, refactor alternate DSL interfaces as optional requires (v0.3.0) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5398000
267
17939
365
3
11