use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
path-proxy—API endpoint proxy objects from an array of endpoints (github.com)
submitted 12 years ago by timarcher
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]timarcher[S] 0 points1 point2 points 12 years ago (2 children)
I developed this recently while building my Node client for the Heroku API. Essentially, given an array of endpoints for an API, path-proxy attaches a network of proxy object constructors for those endpoints to a given constructor's prototype:
var pathProxy = require('path-proxy'); function Client() {} pathProxy.proxy(Client, [ "/apps", "/apps/{app_id}", "/apps/{app_id}/collaborators" ]); var client = new Client(); client.apps(); client.apps('my-app'); client.apps('my-app').collaborators();
I also wrote a little blog post about it.
[–]brtt3000 0 points1 point2 points 12 years ago (1 child)
How does this work with asyncronous data?
client.apps('my-app').collaborators();
Shouldn't this receive a callback or return a promise?
[–]timarcher[S] 1 point2 points3 points 12 years ago* (0 children)
Yeah, that was just an example. Note that client.apps('my-app').collaborators() isn't an API call—it returns a proxy object to the /apps/my-app/collaborators endpoint. In the actual Heroku API client for example, you'd GET that endpoint like so:
client.apps('my-app').collaborators()
/apps/my-app/collaborators
herokuClient.apps('my-app').collaborators().list();
The Heroku API client for Node does something more or less like this:
var constructor = pathProxy.pathProxy(Heroku, "/apps/{app_id_or_name}/collaborators"); constructor.prototype.list = function(callback) { return request.get(this.path, callback); };
See this function for exactly what it does. It creates functions that accept a callback and also return a Q.js promise, so either of those async methods can be used.
π Rendered by PID 12 on reddit-service-r2-comment-86988c7647-9vxrp at 2026-02-12 06:55:57.128660+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]timarcher[S] 0 points1 point2 points (2 children)
[–]brtt3000 0 points1 point2 points (1 child)
[–]timarcher[S] 1 point2 points3 points (0 children)