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 xs from 'xstream' | |
| import {Sources, Sinks} from './interfaces' | |
| const intent = (sources$: Sources) => sources$.DOM | |
| .select('button') | |
| .events('click') | |
| .map(ev => 1); | |
| const model = (intent$: any) => intent$ | |
| .fold((total, change) => total + change, 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
| function guard(predicate, callback) { | |
| return function guarded(reason) { | |
| if (!predicate(reason)) { | |
| throw reason; | |
| } | |
| return callback(reason); | |
| }; | |
| } | |
| function instanceOf(constructor, callback) { |
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
| // from https://github.com/tc39/proposal-observable/blob/master/demo/mouse-drags.js | |
| // Emits each element of the input stream until the control stream has emitted an | |
| // element. | |
| function takeUntil(stream, control) { | |
| return new Observable(sink => { | |
| let source = stream.subscribe(sink); |
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
| cont foo = { | |
| bar() { return this.baz }, | |
| baz() { console.log(this) }, | |
| } | |
| foo.baz() // Logs `foo` | |
| foo.bar().baz() // Logs `undefined` |
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
| $ grasp -e 'invoke($f, _$rest)' tests -r -R '() => {{f}}({{rest | join ", "}})' --in-place |
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 Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| appName: 'Ember Twiddle', | |
| name: '', | |
| something: function() { | |
| console.log('dirtied something'); | |
| return !!this.get('name'); |
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 getAt from './get-at'; | |
| export default function injectTemplate(text, context) { | |
| return String(text).replace(/(?:\{\{)([^}]*)(?:\}\})/g, | |
| (placeholder, path) => getAt(context, path.split('.'))); | |
| } |
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
| let flip = (flopped => { | |
| return function flip(fn) { | |
| if (flopped.has(fn)) { | |
| return flopped.get(fn); | |
| } | |
| flopped.set(fn, flipped); | |
| flopped.set(flipped, fn); | |
| return flipped; |
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
| let pendingRequests = 0; | |
| $(document) | |
| .ajaxStart(() => { pendingRequests += 1; }) | |
| .ajaxStop(() => { pendingRequests -= 1; }); | |
| function andThen(callback) { | |
| wait().then(callback); | |
| } |
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
| export function testRoutes() { | |
| return function() { | |
| this.post('/api/user/login', login()); | |
| }; | |
| function login() {} | |
| } | |
| /* | |
| Fails jshint: |