made with esnextbin
Created
December 7, 2016 04:21
-
-
Save trxcllnt/6f101c122426cdf397acba5cc3315ab2 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 --> | |
</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
import { Observable } from 'rxjs'; | |
function fibs(total = Infinity) { | |
return Observable | |
.interval(100) | |
.scan(([i, n], count) => | |
[n, i + n], | |
[1, 0] | |
) | |
.take(total) | |
.pluck(0); | |
} | |
fibs().take(20).subscribe(::console.log); |
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": { | |
"babel-runtime": "6.18.0", | |
"rxjs": "5.0.0-rc.5" | |
} | |
} |
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 _slicedToArray2 = require('babel-runtime/helpers/slicedToArray'); | |
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); | |
var _context; | |
var _rxjs = require('rxjs'); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function fibs() { | |
var total = arguments.length <= 0 || arguments[0] === undefined ? Infinity : arguments[0]; | |
return _rxjs.Observable.interval(100).scan(function (_ref, count) { | |
var _ref2 = (0, _slicedToArray3.default)(_ref, 2); | |
var i = _ref2[0]; | |
var n = _ref2[1]; | |
return [n, i + n]; | |
}, [1, 0]).take(total).pluck(0); | |
} | |
fibs().take(20).subscribe((_context = console).log.bind(_context)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment