here are the most useful pull streams modules
a library of simple functions that will be familiar functional programmers.
| function nonBlocking(generator) { | |
| return (...args) => { | |
| var callback = args[args.length - 1]; | |
| var iter = generator(...args); | |
| function next() { | |
| try { | |
| var res = iter.next(); | |
| } | |
| catch (e) { | |
| callback(e); |
| Result: 1 | |
| Items { | |
| TemplateId: "BADGE_BATTLE_ATTACK_WON" | |
| Badge { | |
| BadgeType: BADGE_BATTLE_ATTACK_WON | |
| BadgeRanks: 4 | |
| Targets: "\nd\350\007" | |
| } | |
| } | |
| Items { |
| // Array literal (= []) is faster than Array constructor (new Array()) | |
| // http://jsperf.com/new-array-vs-literal/15 | |
| var array = []; | |
| // Object literal (={}) is faster than Object constructor (new Object()) | |
| // http://jsperf.com/new-array-vs-literal/26 | |
| var obj = {}; | |
| // property === undefined is faster than hasOwnProperty(property) | |
| // http://jsperf.com/hasownproperty-vs-in-vs-undefined/17 |
here are the most useful pull streams modules
a library of simple functions that will be familiar functional programmers.
| var polygonFilling = function( vertices ) { | |
| // "global" variables | |
| var verticesCount = vertices.length, | |
| edgesEntered, | |
| // table cols | |
| yMax, yMin, xInt, invNegSlope; | |
| // ************************* |
| public class Perlin { | |
| public int repeat; | |
| public Perlin(int repeat = -1) { | |
| this.repeat = repeat; | |
| } | |
| public double OctavePerlin(double x, double y, double z, int octaves, double persistence) { | |
| double total = 0; |
| var mutators = [ | |
| 'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift' | |
| ] | |
| function ObservableArray(onChange){ | |
| var array = [] | |
| array.set = set | |
| array.onchange = onChange |
| // NOTICE 2020-04-18 | |
| // Please see the comments below about why this is not a great PRNG. | |
| // Read summary by @bryc here: | |
| // https://github.com/bryc/code/blob/master/jshash/PRNGs.md | |
| // Have a look at js-arbit which uses Alea: | |
| // https://github.com/blixt/js-arbit | |
| /** |
| // String utils | |
| // | |
| // resources: | |
| // -- mout, https://github.com/mout/mout/tree/master/src/string | |
| /** | |
| * "Safer" String.toLowerCase() | |
| */ | |
| function lowerCase(str) { | |
| return str.toLowerCase(); |