made with esnextbin
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 Account(){ | |
| //private | |
| var _isReseller = false; | |
| //public | |
| var account = { | |
| isReseller:function(){ | |
| return _isReseller; | |
| }, | |
| setReseller:function(isR){ |
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
| rx.Observable.prototype.to$q = function(onFulfiled, onRejected) { | |
| var source = this; | |
| var deferred = $q.defer(); | |
| var value, hasValue = true; | |
| source.subscribe(function(v) { | |
| value = v; | |
| hasValue = true; | |
| }, deferred.reject, function () { | |
| hasValue && deferred.resolve(value); |
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
| rx.Observable.prototype.safeSubscribe = function(scope, fn, err, cmp) { | |
| var disposable = this.safeApply(scope, fn).subscribe(angular.noop, err, cmp); | |
| scope.$on("$destroy", function() { | |
| disposable.dispose(); | |
| }); | |
| return disposable; | |
| }; |
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
| Date.prototype.toFriendlyDateTime = function() { | |
| var friendlyTime = this.toLocaleTimeString(); | |
| friendlyTime = friendlyTime.substring(friendlyTime.lastIndexOf(":"), 0); | |
| return friendlyTime + " " + this.toLocaleDateString(); | |
| } |
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
| this.getDOMNode().attributes['data-reactid'].value |
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
| spyOn(your_instance.__proto__, 'base_method'); |
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 most from 'most'; | |
| const load$ = most.fromEvent('DOMContentLoaded', document); | |
| const tick$ = load$.flatMap(() => { | |
| return most.iterate((f) => f + 1, 0).take(5).flatMap(v => most.of(v).delay(v * 1000)); | |
| }); | |
| load$.observe(() => console.log('timer start')); | |
| tick$.observe(x => console.log('timer tick', 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
| const now = moment(); | |
| const end = now.clone().add(2, 'minutes'); | |
| const diff = (end - now) / 1000; | |
| const tick$ = Rx.Observable.timer(0,1000) | |
| .scan((acc) => { | |
| return acc - 1; | |
| }, diff) | |
| .take(diff); |
made with esnextbin