> npm install useless
New unit test system based on Promises (will replace the old buggy
Splitting of distinct framework parts to separate projects (finally, useful ones).
ANSI color management now available as separate NPM module: ansicolor.
asTable function now available as a separate NPM module: as-table.
String.ify function now available as a separate NPM module: string.ify.
A wiki entry explaining the Stream concept. Thanks to @kroitor for the translation/adaptation from Russian!
Build system now utilizes webpack for squashing
require imports. All external dependencies (e.g. underscore) now embedded in
useless.client.js — no need to link them separately.
init / beforeInit / afterInit now support Promise interface for asynchronous initialization. Old callback-passing style is gone.
A wiki entry explaining the new __ namespace (brought by Promise+). It contains a pack of highly abstract data-processing algorithms that can handle any type of data (arrays, objects, scalars) and any kind of operator function (either sync or async).
An early alpha of the new HTTP server framework built around the recent
Androgene subsystem. See a brief example here. It allows to write and debug complex asynchronous chains in no time, with unprecedented level of the error reporting legibility.
A working prototype of Androgene subsystem, delivering the "supervised Promises" concept for asynchronous/nonlinear logging and stack traces. It is also a core mechanism behind the upcoming unit test system (will replace the old
> node example.js
If everything's ok, example app will be running at http://localhost:1333. Currently there's not much example code, but it's on the way.
You may want to look into these projects (built upon Useless.js):
_.triggerOnce/ one-to-many broadcast
_.barrier/ synchronization primitive
_.observable/ state change notifications
Raw API (same for every mentioned primitive):
var mouseMoved = _/* Binding*/// bind// bind anothermouseMoved // bind with 'once' semantics (auto-unbinds itself upon calling)/* Calling*/// call/* Unbinding*/mouseMove // unbinds specific listenermouseMove // unbinds everything_ // unbinds callback from everything it's bound to
Compo =// simply call to perform multicast
compo =compocompocompocompovalue = 10 // simply assign a value to notify listenerscompovalue = 10 // won't trigger, as not changed
Using $component + 'once' semantics:
Button =button =buttonlayoutbuttonbutton // won't print anything
Working with ranges:
_ // linear interpolation between min and max_ // clips if out of range/* Projects from one range to another (super useful in widgets implementation)*/_
Vector math (Vec2, Transform, BBox, Bezier, intersections):
var offsetVec = thisanchornormalperp
var where = thisbodyBBox
Example report generated from a Promise chain:
Following are $traits defined at
args.jscommand line arguments parsing
config.jsonand default parameters
deploy.jsself-deployment protocol (automatic builds)
devtools.jsdeveloper-mode APIs for Git / source code access
exceptions.jscustom unhandled exception printer
history.jsjournal for DB operation
http.jsrequest serving basics
supervisor.jsauto-restart on source code change
templating.jsbasic templating (via underscore)
tests.jsself-tests on startup for TDD
npm install useless in root directory of your project.
node_modulessubfolder of your project
git clone https://github.com/xpl/useless.git, go to
npm installto install dependencies
node buildto test if everything's ok
/build folder and pick files needed.
There also exist a compressed (minified) version of each file.
node build <header-file-1> <header-file-2> ... <header-file-N> <output-folder> [no-compress] [no-stripped] [no-supervisor]
For building everything, run:
It will generate
./build/***.js by squashing all
require imports into a single monolithic file. Produced result will undergo stripping of tests and comments, and then finally compiled using Google Closure Compiler, outputting minified result to
Disables minification. Greatly speeds up build.
Disables generation of
Disables file monitor (for termination after run).
To make reduced/extended distribution (with some submodules disabled or enabled), you can create your own version of default header file, commenting out unneeded
$include directives or including additional ones. There exists
./useless.client.js as an example of custom distribution.
Applications that are based on top of
useless/server can easily enable automatic rebuilds feature by adding following $traits to main application component:
This will add test & build phase to app startup sequence, aborting if something went wrong and re-starting if source code has changed.
buildScriptPaths: process $uselessPathbuildScripts: 'useless.js' 'useless.micro.js' 'useless.devtools.js'buildPath: $uselessPath + 'build/'