(emit) is a very rough work in progress. It can run both in the browser and on node.js.
emit = require"emit"// emit method APIs are identical to their native counterparts...Mathpow2 2 // 4emitMathpow2 2 // 4Array1 2 3 // [1, 2, 3]emitArray1 2 3 // [1, 2, 3]1 / 2 // .5emitops"/"1 2 // .5// with one exception: emit methods can also take functions, which are// treated as yet-unevaluated values that can be "watched". All emit// methods compose these (possibly unevaluated) values into a single// value; if any of these values are functions, the returned value will// also be a function.// Here's an example of such a function; it reports an incremented number// back to its listener every second.var cbnull i++i = 0sendsetIntervalsend 1000// Since the value reported by count changes every second, so does// the value of any method that uses it. So these are all functions:emitMathpow2 count // [Function]emitArray1 2 count // [Function]emitops"/"1 count // [Function]// We can observe these changing values through the console.console.loge || dataemitMathpow2 countlog // 1, 2, 4, 8, 16, 32...emitArray1 2 countlog // [1, 2, 0], [1, 2, 1], [1, 2, 2]...emitops"/"1 countlog // Infinity, 1, .5, .25...// Now we can now start to compose these into increasingly// complex values.random = emitMathrandompingrandBin = emitMathroundrandomcoinToss = emitops"?:"randBin "heads" "tails"message = emitops"+""The coin landed on " coinTossmessagelog // "The coin landed on heads"// "The coin landed on tails"// "The coin landed on heads"// ...
To install, head to your terminal and enter:
npm install emit
Array: all ES3/ES5 methods
Math: all statics and function
Copyright (c) 2012 Jed Schmidt, http://jed.is/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.