This file contains 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
Entity._save = Promise.promisify(Item.prototype.save); | |
Entity.prototype._create = Promise.method(function(itemData) { | |
if (!this.Model) throw new Error('No Mongoose.Model defined, use setModel()'); | |
var item = new this.Model(itemData); | |
return Entity._save.apply(item); | |
}); |
This file contains 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
<ul> | |
<li ng-repeat="Rating in Ratings | restrict: 'ratingHistory'" ng-click="showRating(Rating)" ng-class="Rating.rating" analytics="clicked-on-Rating-History" analytics-props="Rating.analyticsProps" > | |
<!--- ... ---> | |
<div class="more-info" ng-show="Rating.show"> | |
<!--- ... ---> | |
<d3overview stock="Rating.stock" show-legend="false" show-duration="false" show-recommendations="true" /> | |
</div> | |
</li> | |
</ul> |
This file contains 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
Promise.longStackTraces(); | |
//end debug | |
/** | |
Hijack Promise.map to accept parallelism limit argument | |
**/ | |
function queueConcurrent(work, degreeOfParallelism) { | |
// work is array of functions returning promises | |
"use strict"; |
This file contains 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":"11(None)","parent":"null"},{"name":"False","parent":"11(None)"},{"name":"2(None)","parent":"11(None)"},{"name":"True","parent":"2(None)"},{"name":"False","parent":"2(None)"},{"name":"False","parent":"11(None)"},{"name":"8(None)","parent":"null"},{"name":"False","parent":"8(None)"},{"name":"True","parent":"8(None)"},{"name":"6(None)","parent":"8(None)"},{"name":"True","parent":"6(None)"},{"name":"False","parent":"6(None)"},{"name":"False","parent":"6(None)"},{"name":"10(None)","parent":"null"},{"name":"14(None)","parent":"10(None)"},{"name":"2(None)","parent":"14(None)"},{"name":"True","parent":"2(None)"},{"name":"15(None)","parent":"2(None)"},{"name":"0(None)","parent":"15(None)"},{"name":"False","parent":"0(None)"},{"name":"True","parent":"0(None)"},{"name":"True","parent":"15(None)"},{"name":"True","parent":"14(None)"},{"name":"9(None)","parent":"14(None)"},{"name":"15(None)","parent":"9(None)"},{"name":"True","parent":"15(None)"},{"name":"1(None)","parent":"15(None)"},{"name":"False","parent":"1( |
This file contains 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
// returns a version of a given promise returning function fn that always uses the same cached value | |
function once(fn){ | |
var called = false, cache = null; | |
return function cachedPromise(){ | |
if(called) return cache; | |
cache = fn.apply(this,arguments); | |
called = true; | |
return cache; | |
}; | |
} |
This file contains 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 ResourceBuilder(){ | |
this._dependencies = []; | |
} | |
ResourceBuilder.prototype.addDependency = function(dep){ | |
this._dependencies.add(dep); | |
} | |
ResourceBuilder.protototype.get = function(){ | |
var loadPromises = this._dependencies.map(loadDependency); // alternatively, dependencies could be promises already | |
return Promise.all(loadPromises).then(function(loadedResourcesArray){ |
This file contains 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 will load a script, I assume each dependency contains what it needs inside | |
// `dependency.needs` and we'll load that. | |
// | |
// stuff is called script here, but it could also be a stylesheet or whatever. | |
// | |
// Since when we return a promise from a `.then` it unwraps and runs the promise we return, we can | |
// return a promise for the values of our _own_ dependencies, and continue doing so, promises will | |
// unwrap everything for us. | |
// | |
// This does not do have the same `.addDependency` interface from before, it's just a function to show |
This file contains 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
class Foo<A,B>{ | |
var bar:[(A,B)] = [(A,B)]() // why is this invalid? | |
} |
This file contains 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
// | |
// Promise.swift | |
// Promise | |
// | |
// Created by Benjamin Gruenbaum on 8/12/14. | |
// Copyright (c) 2014 Tipranks. All rights reserved. | |
// | |
import Foundation |
This file contains 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
// | |
// Promise.swift | |
// Promise | |
// | |
// Created by Benjamin Gruenbaum on 8/12/14. | |
// Copyright (c) 2014 Tipranks. All rights reserved. | |
// | |
import Foundation |
OlderNewer