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
| angular.module("dynacache", []) | |
| .service("dynacache", function($http) { | |
| // drop in replacement for $http | |
| // currently supports "get", "post", "put", "jsonp" methods | |
| // caches response body in localforage (http://mozilla.github.io/localForage/) | |
| // subsequent requests immediately serve up local data | |
| // whilst fetching new data from the server | |
| // once ajax returns, new data replaces old by firing success handler once again | |
| // expects lodash _ global to be present | |
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
| // prototype chain used to create a projection of current object as original + changes | |
| // the return object is always an instance of the provided object, changes form a change-set | |
| // todo deal with deeply nested prototype chains | |
| function seal(d) { | |
| var x = _seal(d); | |
| if (_.isObject(d)) { | |
| _.each(d, function(v, k) { | |
| if (d.hasOwnProperty(k) && _.isObject(v)) { | |
| x[k] = seal(v); | |
| } |
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
| var async = require('async'); | |
| function getUserFriends(userName, next) { | |
| db.users.findOne({name:userName}, foundUser); | |
| function foundUser(err, user) { | |
| err ? next(err) : getFriendsById(user.id, gotFriends); | |
| function gotFriends(err, friends) { | |
| if (err || user.type != 'power user') { |
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
| var request = require('request'); | |
| var fs = require('fs'); | |
| // file watches seem fuxed so I have some hacky workarounds in here | |
| /** | |
| * @param url (string) url to get like: "http://www.google.com" | |
| * @param path (string) path to file like: "/tmp/test/myfile.js" | |
| * @param callback(err, stuff) | |
| */ |
NewerOlder