made with esnextbin
Last active
March 9, 2016 01:02
-
-
Save TylorS/7e0f3eb211ee875e8fe8 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
<div id='app'></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// combineObj code | |
const {combineArray} = require('most') | |
function combineObj(obj) { | |
const keys = Object.keys(obj) | |
const length = keys.length | |
const sources = new Array(length) | |
const sanitizedKeys = new Array(length) | |
let i = 0 | |
for (; i < length; ++i) { | |
sanitizedKeys[i] = keys[i].replace(/\$$/, '') | |
sources[i] = obj[keys[i]] | |
} | |
return combineArray(function(...args) { | |
const combination = {} | |
for (i = 0; i < length; ++i) { | |
combination[sanitizedKeys[i]] = args[i] | |
} | |
return combination | |
}, sources) | |
} | |
// usage code | |
const {of, from} = require('most') | |
const a = of(1) | |
const b = of(2) | |
const c$ = from([ of(1), of(2), of(3) ]).join() | |
combineObj({a, something: b, c$}).observe(x => document.write(JSON.stringify(x))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"most": "0.18.2", | |
"babel-runtime": "6.6.1" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _stringify = require('babel-runtime/core-js/json/stringify'); | |
var _stringify2 = _interopRequireDefault(_stringify); | |
var _keys = require('babel-runtime/core-js/object/keys'); | |
var _keys2 = _interopRequireDefault(_keys); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
// combineObj code | |
var _require = require('most'); | |
var combineArray = _require.combineArray; | |
function combineObj(obj) { | |
var keys = (0, _keys2.default)(obj); | |
var length = keys.length; | |
var sources = new Array(length); | |
var sanitizedKeys = new Array(length); | |
var i = 0; | |
for (; i < length; ++i) { | |
sanitizedKeys[i] = keys[i].replace(/\$$/, ''); | |
sources[i] = obj[keys[i]]; | |
} | |
return combineArray(function () { | |
var combination = {}; | |
for (i = 0; i < length; ++i) { | |
combination[sanitizedKeys[i]] = arguments[i]; | |
} | |
return combination; | |
}, sources); | |
} | |
// usage code | |
var _require2 = require('most'); | |
var of = _require2.of; | |
var from = _require2.from; | |
var a = of(1); | |
var b = of(2); | |
var c$ = from([of(1), of(2), of(3)]).join(); | |
combineObj({ a: a, something: b, c$: c$ }).observe(function (x) { | |
return document.write((0, _stringify2.default)(x)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment