These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].
The most interesting being the Map literal
var map = im{"foo": "bar", "baz": "quux"};
This compiles to the 2d array version of Immutable.Map.
class test | |
constructor:()-> |
#see https://github.com/joyent/node/blob/master/src/node.js#L367 | |
#and http://stackoverflow.com/questions/9475792/how-does-require-in-node-js-work | |
#and https://github.com/joyent/node/blob/906a175a0b40fc56dfafbe0929e4fbbb4df68ff2/src/node.js#L699 | |
globals = {} | |
class Module | |
constructor:-> | |
@exports = {} | |
@content = "" |
<three-js id="threeJs"> | |
<three-stats id="stats" show></three-stats> | |
<tween-js></tween-js> | |
<three-js-scene name="main" active pickable> | |
<three-directionalLight color="0xffdddd" castShadow shadowDarkness="0.4" pos="[500,200,300]"> </three-directionalLight> | |
<three-ambientLight color="0xffffff" intensity="0.5"> </three-ambientLight> | |
<shadow-plane up=[0,1,0]> </shadow-plane> | |
<mirror-plane up=[0,1,0] resolution=1024> </mirror-plane> | |
</three-js-scene> | |
<three-js-scene name="helpers" active> |
<polymer-element name="object-rotate-plugin" > | |
<script> | |
Polymer("object-rotate-plugin",{ | |
methodsToInject: ["rotateSelection"], | |
attached:function(){ | |
this.injectInParent(); | |
}, | |
injectInParent: function() { |
// Enable DELTA kinematics | |
#define DELTA | |
// Make delta curves from many straight lines (linear interpolation). | |
// This is a trade-off between visible corners (not enough segments) | |
// and processor overload (too many expensive sqrt calls). | |
#define DELTA_SEGMENTS_PER_SECOND 200 | |
// Center-to-center distance of the holes in the diagonal push rods. | |
//#define DELTA_DIAGONAL_ROD 191.96 // mm |
// ES6 for loops | |
// ============= | |
// Things in ES6 can be "iterable". Arrays are iterable by default. | |
var fruits = ['Apple', 'Banana', 'Grape']; | |
for (var fruit of fruits) | |
console.log('Fruit: ' + fruit); |
var data = immstruct({ something: 'initial', another: 'part' }); | |
data.on('swap', function (newData, oldData, path) { | |
console.log( | |
"new", newData.toJS(), // { something: "updated", another: 'part' } | |
"old",oldData.toJS(), // { something: "initial", another: 'part' } | |
"path",path) // ['something'] | |
}); | |
var MyData={ |
These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].
The most interesting being the Map literal
var map = im{"foo": "bar", "baz": "quux"};
This compiles to the 2d array version of Immutable.Map.
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
/*var Immutable = require('immutable'); | |
var diff = require('immutablediff'); | |
var map1 = Immutable.Map({a:1, b:2, c:3,e:{a:42,stuff:"stom"} }); | |
var map2 = Immutable.Map({a:1, b:2, d: 4,e:{c:4,foobar:4564}}); | |
var a = diff(map1, map2); | |
console.log("blah",a.toJS());*/ |
Original tweet size in JSON 2624 Msgpack = 1817 Gzip + Json = 1058 Gzip + Msgpack = 1116 LZ4 + Json = 1628 LZ4 + Msgpack = 1361 | |
Original tweet size in JSON 1863 Msgpack = 1443 Gzip + Json = 0783 Gzip + Msgpack = 0835 LZ4 + Json = 1153 LZ4 + Msgpack = 1040 | |
Original tweet size in JSON 2074 Msgpack = 1670 Gzip + Json = 0842 Gzip + Msgpack = 0894 LZ4 + Json = 1229 LZ4 + Msgpack = 1139 | |
Original tweet size in JSON 2025 Msgpack = 1617 Gzip + Json = 0845 Gzip + Msgpack = 0895 LZ4 + Json = 1238 LZ4 + Msgpack = 1143 | |
Original tweet size in JSON 2069 Msgpack = 1663 Gzip + Json = 0846 Gzip + Msgpack = 0901 LZ4 + Json = 1243 LZ4 + Msgpack = 1164 | |
Original tweet size in JSON 2035 Msgpack = 1634 Gzip + Json = 0852 Gzip + Msgpack = 0907 LZ4 + Json = 1247 LZ4 + Msgpack = 1167 | |
Original tweet size in JSON 1988 Msgpack = 1464 Gzip + Json = 0804 Gzip + Msgpack = 0862 LZ4 + Json = 1220 LZ4 + Msgpack = 1061 | |
Original tweet size in JSON 1910 Msgpack = 1502 Gzip + Json = 0775 Gzip + Msgpack = 0832 LZ4 + Json = 1154 LZ4 + Msgpack = 1060 |