npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xdrgo

v0.0.5

Published

cross-site http requests in your browser script

Downloads

9

Readme

xdrgo

(c)Bumblehead, 2013 MIT-license

CORS is not supported by IE < 8.

xdrgo is beta and is not for production use

https://stripe.com/blog/stripejs-and-jsonp no need for iframes as well as jsonp

http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx xdr limitations:

  • only GET and POST may be used
  • no header customisation
  • only text/plain is supported as a Content-Type
  • no authentication or cookies may be sent with request

Simple/dumb xhr (xdr for IE) object for performing cross-domain requests, using CORS when available or xdr as a fallback.

Another way to make cross-domain requests is JSONP. JSONP exploits unintended browser functionality. You may want to use JSONP rather than CORS if you need to support older browsers (lt IE8).

CORS and xdr supports the full range of REST methods (GET, POST, DELETE, etc.). CORS provides complete error handling. It limits access a malicious page would have to remote server data. It does not expose clients to remote server vulnerabilities.

xdrgo is not a comprehensive solution for xhr/xdr usage. It's perfect for the most common type of request using non-chunked json, html and form-urlencoded data formats. It assumes there is one 'success' response, 200.

xdrgo uses the node.js callback convention.

  • xdrgo.JSON( type, url, data, token, fn, time )

    The first two parameters are required. Data is sent and received in the JSON format. Data is passed to and returned from the method in the form of an object.

    xdrgo.JSON('POST', '/hi', {hi:'b'}, null, function (err, res) {
      if (err) return fn(new Error(err));     
      fn(null, res);
    }, 1000);
  • xdrgo.JSONU( type, url, data, token, fn, time )

    Calls xdrgo.JSON after adding a unique parameter to the url. Used to avoid cached responses.

  • xdrgo.getTextHTML( url, fn, time )

    This method makes 'GET' requests with "Content-Type" "text/html". Useful for requesting static template and text files.

    xdrgo.getTextHTML(htmlUrl, function (err, template) {
      if (err) return fn(new Error('failed load html: ' + htmlUrl));        
      fn(null, template);
    });
  • xdrgo.getTextHTMLU( url, fn, time )

    Calls xdrgo.getTextHTML after adding a unique parameter to the url. Used to avoid cached responses.

  • xdrgo.newRequest( )

    Returns a browser-supported xhr object. For most browser's the value returned by this method is new XMLHttpRequest()

  • xdrgo.getUriAsUnique( url )

    Returns a new url with a unique parameter added.

    xdrgo.getUriAsUnique('/a.html'); // "/a.html?uid=1377988402490"
  • xdrgo.addKeyVal( url, k, v )

    Returns a new url with key/val parameters added.

    var url = '/resource';
    url = xdrgo.addKeyVal(url, 'a', '1'); // "/resource?a=1"
    url = xdrgo.addKeyVal(url, 'b', '2'); // "/resource?a=1&b=2"
  • xdrgo.getArgsObjAsUriStr( argsObj )

    Top-level properties of the object are returned as a key/value string. Each value is encoded. The keys are joined in alphabetical order.

    For more comprehensive object serialization use url-formencoded.

    xdrgo.getArgsObjAsUriStr({
      modified : 137798840249,
      currency : 'usd'
    }); 
    // "currency=usd&modifed=137798840249"
  • xdrgo.getUriStrAsArgsObj( uriStr )

    Retuns an object with properties named and defined with values from the url. vanillaUri and hash are always named properties on the object returned.

    xdrgo.getUriStrAsArgsObj(
      "/resource/currency=usd&time=137798840249#hashvalue"
    }); 
    // {
    //   vanillaUri : '/resource/currency=usd&time=137798840249#val',
    //   hash : 'val',
    //   lastmodified : 137798840249,
    //   currency : 'usd'
    // }

License:

scrounge

(The MIT License)

Copyright (c) 2012 Bumblehead [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.