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

xhr-overwrite

v1.0.1

Published

A lib that offers interfaces to overwrite xhr.It can used as interceptor for ajax in the underlayer.

Downloads

10

Readme

#xhr-overwrite npm Build Status xhr-overwrite提供了一种重写XMLHttpRequest(ie ActiveXObject)的机制,可对常见的open、send等方法进行重写。大部分前端框架都有和jQuery beforeSend类似的拦截器机制,允许在请求发送前进行某些处理。xhr-overwrite则是在xhr底层做了包装,不依赖任何框架,对上层框架是透明的。

一个常见的应用场景是跨项目的前端http请求加密。不同项目使用了不同的前端框架,但请求加密的算法是一样的。此时可以通过xhr-orverwrite在xhr底层做统一的处理,否则就需要针对不同的框架编写不同的代码。

安装

####npm

npm i xhr-overwrite --save

####浏览器 直接引入xhr-overwrite.min.js。

注意:xhr-overwrite的引入一定要在其他前端框架之前,否则将不能有效拦截。

使用

xhrOverwrite({
	open: function(method, url, async) {
		// do some before open
		this.xhr.open(method, url);
	},
	send: function(data) {
		// do some before send
		this.xhr.send(data);
	}
});

xhrOverwrite(options)为一全局方法,可在options中指定需要重写的方法。重写方法的this指向xhr的包装类型的实例,this.xhr字段指向真实的xhr。

浏览器兼容性

  1. chrome
  2. fireforx
  3. safari
  4. ie6+
  5. iphone safari
  6. android browser

License

MIT:http://vinnyguitar.mit-license.org